Merge branch 'master' of https://github.com/ethereum/remix-project into parserfix

pull/5370/head
filip mertens 2 years ago
commit 941c91d820
  1. 20
      libs/remix-lib/src/execution/txHelper.ts
  2. 15
      libs/remix-lib/test/txHelper.ts
  3. 2
      libs/remix-ui/app/src/lib/remix-app/style/remix-app.css
  4. 5
      libs/remix-ui/vertical-icons-panel/src/lib/components/IconList.tsx
  5. 13
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -102,17 +102,25 @@ export function extractSize (type) {
return size ? size[2] : '' return size ? size[2] : ''
} }
export function getFunction (abi, fnName) { export function getFunctionLiner (fn, detailTuple: boolean = true) {
for (let i = 0; i < abi.length; i++) { /*
const fn = abi[i] if detailsTuple is True, this will return something like fnName((uint, string))
if (fn.type === 'function' && fnName === fn.name + '(' + fn.inputs.map((value) => { if detailsTuple is False, this will return something like fnName(tuple)
if (value.components) { */
return fn.name + '(' + fn.inputs.map((value) => {
if (detailTuple && value.components) {
const fullType = makeFullTypeDefinition(value) const fullType = makeFullTypeDefinition(value)
return fullType.replace(/tuple/g, '') // return of makeFullTypeDefinition might contain `tuple`, need to remove it cause `methodIdentifier` (fnName) does not include `tuple` keyword return fullType.replace(/tuple/g, '') // return of makeFullTypeDefinition might contain `tuple`, need to remove it cause `methodIdentifier` (fnName) does not include `tuple` keyword
} else { } else {
return value.type return value.type
} }
}).join(',') + ')') { }).join(',') + ')'
}
export function getFunction (abi, fnName) {
for (let i = 0; i < abi.length; i++) {
const fn = abi[i]
if (fn.type === 'function' && (fnName === getFunctionLiner(fn, true) || fnName === getFunctionLiner(fn, false))) {
return fn return fn
} }
} }

@ -3,7 +3,7 @@ import tape from 'tape'
import * as txHelper from '../src/execution/txHelper' import * as txHelper from '../src/execution/txHelper'
tape('getFunction', function (st) { tape('getFunction', function (st) {
st.plan(6) st.plan(11)
let fn = txHelper.getFunction(JSON.parse(abi), 'o((address,uint256))') let fn = txHelper.getFunction(JSON.parse(abi), 'o((address,uint256))')
st.equal(fn.name, 'o') st.equal(fn.name, 'o')
@ -21,6 +21,17 @@ tape('getFunction', function (st) {
fn = txHelper.getReceiveInterface(JSON.parse(abi)) fn = txHelper.getReceiveInterface(JSON.parse(abi))
st.equal(fn.type, 'receive') st.equal(fn.type, 'receive')
fn = txHelper.getFunction(testTupleAbi, 'setUser(tuple)') // some compiler version might resolve to tuple.
st.equal(fn.name, 'setUser')
st.equal(fn.inputs[0].type, 'tuple')
st.equal(fn.inputs[0].name, 'user')
fn = txHelper.getFunctionLiner(testTupleAbi[0], true)
st.equal(fn, 'setUser((string,uint256))')
fn = txHelper.getFunctionLiner(testTupleAbi[0], false)
st.equal(fn, 'setUser(tuple)')
}) })
const abi = `[ const abi = `[
@ -153,3 +164,5 @@ const abi = `[
"type": "receive" "type": "receive"
} }
]` ]`
const testTupleAbi = [{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"age","type":"uint256"}],"internalType":"struct Example.User","name":"user","type":"tuple"}],"name":"setUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userByAddress","outputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"age","type":"uint256"}],"stateMutability":"view","type":"function"}]

@ -8,7 +8,7 @@ pre {
overflow-x: auto; overflow-x: auto;
} }
.remixIDE { .remixIDE {
width : 100vw; width : 100%;
height : 100vh; height : 100vh;
overflow : hidden; overflow : hidden;
flex-direction : row; flex-direction : row;

@ -12,7 +12,7 @@ interface OtherIconsProps {
function IconList ({ verticalIconsPlugin, itemContextAction, icons, theme }: OtherIconsProps) { function IconList ({ verticalIconsPlugin, itemContextAction, icons, theme }: OtherIconsProps) {
return ( return (
<div id="otherIcons"> <div id="otherIcons" className="position-relative">
{ {
icons icons
.map(p => ( .map(p => (
@ -25,7 +25,8 @@ function IconList ({ verticalIconsPlugin, itemContextAction, icons, theme }: Oth
p.profile.name p.profile.name
} }
/> />
))} ))
}
</div> </div>
) )
} }

@ -280,6 +280,7 @@ export function Workspace () {
<span className="pl-3"> - create a new workspace - </span> <span className="pl-3"> - create a new workspace - </span>
} }
</Dropdown.Item> </Dropdown.Item>
<Dropdown.Item onClick={() => { switchWorkspace(LOCALHOST) }}>{currentWorkspace === LOCALHOST ? <span>&#10003; localhost </span> : <span className="pl-3"> { LOCALHOST } </span>}</Dropdown.Item>
{ {
global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => ( global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => (
<Dropdown.Item <Dropdown.Item
@ -299,7 +300,6 @@ export function Workspace () {
</Dropdown.Item> </Dropdown.Item>
)) ))
} }
<Dropdown.Item onClick={() => { switchWorkspace(LOCALHOST) }}>{currentWorkspace === LOCALHOST ? <span>&#10003; localhost </span> : <span className="pl-3"> { LOCALHOST } </span>}</Dropdown.Item>
{ ((global.fs.browser.workspaces.length <= 0) || currentWorkspace === NO_WORKSPACE) && <Dropdown.Item onClick={() => { switchWorkspace(NO_WORKSPACE) }}>{ <span className="pl-3">NO_WORKSPACE</span> }</Dropdown.Item> } { ((global.fs.browser.workspaces.length <= 0) || currentWorkspace === NO_WORKSPACE) && <Dropdown.Item onClick={() => { switchWorkspace(NO_WORKSPACE) }}>{ <span className="pl-3">NO_WORKSPACE</span> }</Dropdown.Item> }
</Dropdown.Menu> </Dropdown.Menu>
</Dropdown> </Dropdown>
@ -309,8 +309,7 @@ export function Workspace () {
<div className='h-100 remixui_fileExplorerTree' onFocus={() => { toggleDropdown(false) }}> <div className='h-100 remixui_fileExplorerTree' onFocus={() => { toggleDropdown(false) }}>
<div className='h-100'> <div className='h-100'>
{ (global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) && <div className="text-center py-5"><i className="fas fa-spinner fa-pulse fa-2x"></i></div>} { (global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) && <div className="text-center py-5"><i className="fas fa-spinner fa-pulse fa-2x"></i></div>}
{ !(global.fs.browser.isRequestingWorkspace || { !(global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) &&
global.fs.browser.isRequestingCloning) &&
(global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) &&
<div className='h-100 remixui_treeview' data-id='filePanelFileExplorerTree'> <div className='h-100 remixui_treeview' data-id='filePanelFileExplorerTree'>
<FileExplorer <FileExplorer
@ -347,10 +346,9 @@ export function Workspace () {
/> />
</div> </div>
} }
{ { global.fs.localhost.isRequestingLocalhost && <div className="text-center py-5"><i className="fas fa-spinner fa-pulse fa-2x"></i></div> }
global.fs.localhost.isRequestingLocalhost ? <div className="text-center py-5"><i className="fas fa-spinner fa-pulse fa-2x"></i></div> { (global.fs.mode === 'localhost' && global.fs.localhost.isSuccessfulLocalhost) &&
: <div className='h-100 filesystemexplorer remixui_treeview'> <div className='h-100 filesystemexplorer remixui_treeview'>
{ global.fs.mode === 'localhost' && global.fs.localhost.isSuccessfulLocalhost &&
<FileExplorer <FileExplorer
name='localhost' name='localhost'
menuItems={['createNewFile', 'createNewFolder']} menuItems={['createNewFile', 'createNewFolder']}
@ -383,7 +381,6 @@ export function Workspace () {
dispatchMoveFile={global.dispatchMoveFile} dispatchMoveFile={global.dispatchMoveFile}
dispatchMoveFolder={global.dispatchMoveFolder} dispatchMoveFolder={global.dispatchMoveFolder}
/> />
}
</div> </div>
} }
</div> </div>

Loading…
Cancel
Save