From ce371f8a47a7c18e1bd76405f388b67813a554b3 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 12 Sep 2022 10:38:23 +0200 Subject: [PATCH 1/5] fix resolving function abi with tuple --- libs/remix-lib/src/execution/txHelper.ts | 24 ++++++++++++++++-------- libs/remix-lib/test/txHelper.ts | 13 +++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/libs/remix-lib/src/execution/txHelper.ts b/libs/remix-lib/src/execution/txHelper.ts index 0b50d96463..f3c78930b1 100644 --- a/libs/remix-lib/src/execution/txHelper.ts +++ b/libs/remix-lib/src/execution/txHelper.ts @@ -102,17 +102,25 @@ export function extractSize (type) { return size ? size[2] : '' } +export function getFunctionLiner (fn, detailTuple: boolean = true) { + /* + if detailsTuple is True, this will return something like fnName((uint, string)) + if detailsTuple is False, this will return something like fnName(tuple) + */ + return fn.name + '(' + fn.inputs.map((value) => { + if (detailTuple && value.components) { + 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 + } else { + return value.type + } + }).join(',') + ')' +} + export function getFunction (abi, fnName) { for (let i = 0; i < abi.length; i++) { const fn = abi[i] - if (fn.type === 'function' && fnName === fn.name + '(' + fn.inputs.map((value) => { - if (value.components) { - 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 - } else { - return value.type - } - }).join(',') + ')') { + if (fn.type === 'function' && (fnName === getFunctionLiner(fn, true) || fnName === getFunctionLiner(fn, false))) { return fn } } diff --git a/libs/remix-lib/test/txHelper.ts b/libs/remix-lib/test/txHelper.ts index 2532bcd34d..9ddd23788e 100644 --- a/libs/remix-lib/test/txHelper.ts +++ b/libs/remix-lib/test/txHelper.ts @@ -21,6 +21,17 @@ tape('getFunction', function (st) { fn = txHelper.getReceiveInterface(JSON.parse(abi)) 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 = `[ @@ -153,3 +164,5 @@ const abi = `[ "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"}] \ No newline at end of file From e53f11cda361f763b0739f91d6fa95890459972a Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 12 Sep 2022 10:57:19 +0200 Subject: [PATCH 2/5] update test count --- libs/remix-lib/test/txHelper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-lib/test/txHelper.ts b/libs/remix-lib/test/txHelper.ts index 9ddd23788e..4d9a46426f 100644 --- a/libs/remix-lib/test/txHelper.ts +++ b/libs/remix-lib/test/txHelper.ts @@ -3,7 +3,7 @@ import tape from 'tape' import * as txHelper from '../src/execution/txHelper' tape('getFunction', function (st) { - st.plan(6) + st.plan(11) let fn = txHelper.getFunction(JSON.parse(abi), 'o((address,uint256))') st.equal(fn.name, 'o') @@ -165,4 +165,4 @@ const abi = `[ } ]` -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"}] \ No newline at end of file +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"}] From d5a758e07c81e97668c6db36fbc9f674cf74a81e Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 13 Sep 2022 09:34:18 +0200 Subject: [PATCH 3/5] move dropdown item --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 91aa2c63ff..0977cee871 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -280,6 +280,7 @@ export function Workspace () { - create a new workspace - } + { switchWorkspace(LOCALHOST) }}>{currentWorkspace === LOCALHOST ? ✓ localhost : { LOCALHOST } } { global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => ( )) } - { switchWorkspace(LOCALHOST) }}>{currentWorkspace === LOCALHOST ? ✓ localhost : { LOCALHOST } } { ((global.fs.browser.workspaces.length <= 0) || currentWorkspace === NO_WORKSPACE) && { switchWorkspace(NO_WORKSPACE) }}>{ NO_WORKSPACE } } From 5c672782d55f4ce977ef90a7f54263a9ae82272a Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 6 Sep 2022 15:52:57 +0200 Subject: [PATCH 4/5] do not show localhost explorer if it is not required --- .../workspace/src/lib/remix-ui-workspace.tsx | 151 +++++++++--------- 1 file changed, 74 insertions(+), 77 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 0977cee871..de157c1feb 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -309,83 +309,80 @@ export function Workspace () {
{ toggleDropdown(false) }}>
{ (global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) &&
} - { !(global.fs.browser.isRequestingWorkspace || - global.fs.browser.isRequestingCloning) && - (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && -
- -
- } - { - global.fs.localhost.isRequestingLocalhost ?
- :
- { global.fs.mode === 'localhost' && global.fs.localhost.isSuccessfulLocalhost && - - } -
- } + { !(global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) && + (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && +
+ +
+ } + { global.fs.localhost.isRequestingLocalhost &&
} + { (global.fs.mode === 'localhost' && global.fs.localhost.isSuccessfulLocalhost) && +
+ +
+ }
From 500ce64b5459fa2962c0489d4f96c86d7d5a31b0 Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 6 Sep 2022 16:23:13 +0200 Subject: [PATCH 5/5] fixing scroll issue --- libs/remix-ui/app/src/lib/remix-app/style/remix-app.css | 2 +- .../vertical-icons-panel/src/lib/components/IconList.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/app/src/lib/remix-app/style/remix-app.css b/libs/remix-ui/app/src/lib/remix-app/style/remix-app.css index 8c321b9145..d177ce8bcf 100644 --- a/libs/remix-ui/app/src/lib/remix-app/style/remix-app.css +++ b/libs/remix-ui/app/src/lib/remix-app/style/remix-app.css @@ -8,7 +8,7 @@ pre { overflow-x: auto; } .remixIDE { - width : 100vw; + width : 100%; height : 100vh; overflow : hidden; flex-direction : row; diff --git a/libs/remix-ui/vertical-icons-panel/src/lib/components/IconList.tsx b/libs/remix-ui/vertical-icons-panel/src/lib/components/IconList.tsx index b41a417ddd..4716ac47f9 100644 --- a/libs/remix-ui/vertical-icons-panel/src/lib/components/IconList.tsx +++ b/libs/remix-ui/vertical-icons-panel/src/lib/components/IconList.tsx @@ -12,7 +12,7 @@ interface OtherIconsProps { function IconList ({ verticalIconsPlugin, itemContextAction, icons, theme }: OtherIconsProps) { return ( -
+
{ icons .map(p => ( @@ -25,7 +25,8 @@ function IconList ({ verticalIconsPlugin, itemContextAction, icons, theme }: Oth p.profile.name } /> - ))} + )) + }
) }