From 2f55a302d47d28af4ab84987bcdbb162bf5b0ad3 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Fri, 22 Dec 2023 16:47:33 +0100 Subject: [PATCH 1/6] update gnosis explorer and rpcs --- packages/app/src/data/chains.json | 52 +++++++++++++++++++----------- packages/app/src/utils/explorer.ts | 5 ++- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/packages/app/src/data/chains.json b/packages/app/src/data/chains.json index ff032f699..c355e2e9d 100644 --- a/packages/app/src/data/chains.json +++ b/packages/app/src/data/chains.json @@ -55,7 +55,9 @@ "symbol": "OETH", "decimals": 18 }, - "rpc": ["https://mainnet.optimism.io/"], + "rpc": [ + "https://mainnet.optimism.io/" + ], "explorers": [ { "name": "etherscan", @@ -74,7 +76,11 @@ "symbol": "BNB", "decimals": 18 }, - "rpc": ["https://bsc-dataseed1.binance.org", "https://bsc-dataseed2.binance.org", "wss://bsc-ws-node.nariox.org"], + "rpc": [ + "https://bsc-dataseed1.binance.org", + "https://bsc-dataseed2.binance.org", + "wss://bsc-ws-node.nariox.org" + ], "explorers": [ { "name": "bscscan", @@ -97,22 +103,18 @@ "decimals": 18 }, "rpc": [ - "https://rpc.xdaichain.com", - "https://xdai.poanetwork.dev", - "wss://rpc.xdaichain.com/wss", - "wss://xdai.poanetwork.dev/wss", - "http://xdai.poanetwork.dev", - "https://dai.poa.network", - "ws://xdai.poanetwork.dev:8546" + "https://rpc.gnosischain.com", + "https://rpc.gnosis.gateway.fm", + "wss://rpc.gnosischain.com/wss" ], "explorers": [ { - "name": "blockscout", - "url": "https://blockscout.com/xdai/mainnet", + "name": "gnosisscan", + "url": "https:/gnosisscan.io", "standard": "EIP3091" } ], - "infoURL": "https://forum.poa.network/c/xdai-chain" + "infoURL": "https://gnosis.io" }, "137": { "name": "Polygon Mainnet", @@ -149,7 +151,10 @@ "symbol": "EWT", "decimals": 18 }, - "rpc": ["https://rpc.energyweb.org", "wss://rpc.energyweb.org/ws"], + "rpc": [ + "https://rpc.energyweb.org", + "wss://rpc.energyweb.org/ws" + ], "explorers": [ { "name": "blockscout", @@ -168,7 +173,10 @@ "symbol": "xDAI", "decimals": 18 }, - "rpc": ["https://optimism.gnosischain.com", "wss://optimism.gnosischain.com/wss"], + "rpc": [ + "https://optimism.gnosischain.com", + "wss://optimism.gnosischain.com/wss" + ], "explorers": [ { "name": "blockscout", @@ -178,7 +186,6 @@ ], "infoURL": "https://www.gnosischain.com/" }, - "42161": { "name": "Arbitrum One", "chainId": 42161, @@ -217,7 +224,9 @@ "symbol": "AVAX", "decimals": 18 }, - "rpc": ["https://api.avax.network/ext/bc/C/rpc"], + "rpc": [ + "https://api.avax.network/ext/bc/C/rpc" + ], "explorers": [ { "name": "snowtrace", @@ -243,7 +252,10 @@ "standard": "none" } ], - "rpc": ["https://volta-rpc.energyweb.org", "wss://volta-rpc.energyweb.org/ws"], + "rpc": [ + "https://volta-rpc.energyweb.org", + "wss://volta-rpc.energyweb.org/ws" + ], "infoURL": "https://energyweb.org" }, "1313161554": { @@ -255,7 +267,9 @@ "symbol": "aETH", "decimals": 18 }, - "rpc": ["https://mainnet.aurora.dev"], + "rpc": [ + "https://mainnet.aurora.dev" + ], "explorers": [ { "name": "explorer.aurora.dev", @@ -265,4 +279,4 @@ ], "infoURL": "https://aurora.dev" } -} +} \ No newline at end of file diff --git a/packages/app/src/utils/explorer.ts b/packages/app/src/utils/explorer.ts index 73be4f0bb..ba4f623a8 100644 --- a/packages/app/src/utils/explorer.ts +++ b/packages/app/src/utils/explorer.ts @@ -4,6 +4,7 @@ import memoize from "lodash.memoize" import { ethers } from "ethers" const ETHERSCAN_KEY = process.env.REACT_APP_ETHERSCAN_KEY as string +const GNOSISSCAN_KEY = process.env.REACT_APP_GNOSISSCAN_KEY as string const POLYGONSCAN_KEY = process.env.REACT_APP_POLYGONSCAN_KEY as string const ARBISCAN_KEY = process.env.REACT_APP_ARBISCAN_KEY as string const BSCSCAN_KEY = process.env.REACT_APP_BSCSCAN_KEY as string @@ -11,6 +12,7 @@ const OPTIMISTICSCAN_KEY = process.env.REACT_APP_OPTIMISTICSCAN_KEY as string const SNOWTRACE_KEY = process.env.REACT_APP_SNOWTRACE_KEY as string if (!ETHERSCAN_KEY) throw new Error("ETHERSCAN_KEY env is not set") +if (!GNOSISSCAN_KEY) throw new Error("GNOSISSCAN_KEY env is not set") if (!POLYGONSCAN_KEY) throw new Error("POLYGONSCAN_KEY env is not set") if (!ARBISCAN_KEY) throw new Error("ARBISCAN_KEY env is not set") if (!BSCSCAN_KEY) throw new Error("BSCSCAN_KEY env is not set") @@ -38,7 +40,8 @@ const explorerConfig: Record = { apiKey: ARBISCAN_KEY, }, [Network.GNOSIS]: { - apiUrl: "https://blockscout.com/xdai/mainnet/api", + apiUrl: "https://api.gnosisscan.io/api", + apiKey: GNOSISSCAN_KEY, }, [Network.BINANCE]: { apiUrl: "https://api.bscscan.com/api", From d6ff5c8f53b1d45bbfa1501c0bcf02026d6adcff Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Fri, 22 Dec 2023 17:11:56 +0100 Subject: [PATCH 2/6] properly disable the function area if all targets are selected --- .../src/components/views/Role/targets/TargetFunctionList.tsx | 1 + packages/app/src/utils/conditions.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/app/src/components/views/Role/targets/TargetFunctionList.tsx b/packages/app/src/components/views/Role/targets/TargetFunctionList.tsx index 1edd5c6cf..7aa96a79a 100644 --- a/packages/app/src/components/views/Role/targets/TargetFunctionList.tsx +++ b/packages/app/src/components/views/Role/targets/TargetFunctionList.tsx @@ -30,6 +30,7 @@ const useStyles = makeStyles((theme) => ({ }, }, disabledArea: { + pointerEvents: "none", opacity: 0.5, "&::after": { content: "''", diff --git a/packages/app/src/utils/conditions.ts b/packages/app/src/utils/conditions.ts index 84e432c3b..7e688e2a4 100644 --- a/packages/app/src/utils/conditions.ts +++ b/packages/app/src/utils/conditions.ts @@ -27,7 +27,7 @@ export function getNativeType(param: ethers.utils.ParamType | null): ParamNative if (param.arrayChildren.baseType === "array") return ParamNativeType.UNSUPPORTED return ParamNativeType.ARRAY } - if(param.baseType.startsWith('bytes') && param.baseType !== 'bytes') { + if (param.baseType.startsWith("bytes") && param.baseType !== "bytes") { return ParamNativeType.BYTES_FIXED } return ParamNativeType.BYTES From 652b827a1deb97cd883f07b75619c7f34119130b Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Tue, 26 Dec 2023 19:09:27 +0100 Subject: [PATCH 3/6] fix bug #2 --- packages/app/src/components/views/Role/RoleContext.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/app/src/components/views/Role/RoleContext.tsx b/packages/app/src/components/views/Role/RoleContext.tsx index 9a1cd1fe0..7d879b16a 100644 --- a/packages/app/src/components/views/Role/RoleContext.tsx +++ b/packages/app/src/components/views/Role/RoleContext.tsx @@ -186,13 +186,10 @@ function handleTargetConditions(state: RoleContextState, payload: SetTargetCondi if (type !== ConditionType.WILDCARDED) { const hasWildcardedFunction = conditionTypes.some((condition) => condition === ConditionType.WILDCARDED) const hasScopedFunction = conditionTypes.some((condition) => condition === ConditionType.SCOPED) - const hasBlockedFunction = conditionTypes.some((condition) => condition === ConditionType.BLOCKED) type = ConditionType.SCOPED - if (hasBlockedFunction && !hasScopedFunction && !hasWildcardedFunction) { + if (!hasScopedFunction && !hasWildcardedFunction) { type = ConditionType.BLOCKED - } else if (!hasBlockedFunction && !hasScopedFunction && hasWildcardedFunction) { - type = ConditionType.WILDCARDED } } From 1496adb47a8db538336dccc751d578ead177f94a Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Tue, 26 Dec 2023 19:29:48 +0100 Subject: [PATCH 4/6] fix decoding of empty values + fix Int type conditions fixes #3 --- .../views/Role/targets/ParamConditionInputValue.tsx | 5 ++++- packages/app/src/typings/role.ts | 1 + packages/app/src/utils/conditions.ts | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/app/src/components/views/Role/targets/ParamConditionInputValue.tsx b/packages/app/src/components/views/Role/targets/ParamConditionInputValue.tsx index c7cb3a00a..f586e5f78 100644 --- a/packages/app/src/components/views/Role/targets/ParamConditionInputValue.tsx +++ b/packages/app/src/components/views/Role/targets/ParamConditionInputValue.tsx @@ -34,7 +34,8 @@ const PlaceholderPerType: Record = { [ParamNativeType.ARRAY]: "[value 1, value 2, ...]", [ParamNativeType.TUPLE]: "(1,2,3)", [ParamNativeType.BOOLEAN]: "true", - [ParamNativeType.INT]: "235000000", + [ParamNativeType.INT]: "-235000000", + [ParamNativeType.UINT]: "235000000", [ParamNativeType.ADDRESS]: "0xABF...123", [ParamNativeType.STRING]: "Enter a string", [ParamNativeType.BYTES]: "0x...", @@ -149,9 +150,11 @@ const tryAbiEncode = (param: ethers.utils.ParamType | null, value: string) => { } const tryAbiDecode = (param: string, value: string, onDecodingError?: (err: Error) => void) => { + if (!value) return value try { return ethers.utils.defaultAbiCoder.decode([param], value).toString() } catch (err) { + console.error("Error decoding value", err, { param, value }) if (onDecodingError) onDecodingError(err as Error) return value } diff --git a/packages/app/src/typings/role.ts b/packages/app/src/typings/role.ts index 5bcbb0d51..fe7ffbfd4 100644 --- a/packages/app/src/typings/role.ts +++ b/packages/app/src/typings/role.ts @@ -54,6 +54,7 @@ export enum ParameterType { export enum ParamNativeType { INT, + UINT, BOOLEAN, BYTES, BYTES_FIXED, diff --git a/packages/app/src/utils/conditions.ts b/packages/app/src/utils/conditions.ts index 7e688e2a4..72266e2bb 100644 --- a/packages/app/src/utils/conditions.ts +++ b/packages/app/src/utils/conditions.ts @@ -22,7 +22,8 @@ export function getNativeType(param: ethers.utils.ParamType | null): ParamNative if (param.baseType === "string") return ParamNativeType.STRING if (param.baseType === "bool") return ParamNativeType.BOOLEAN if (param.baseType === "tuple") return ParamNativeType.TUPLE - if (param.baseType.startsWith("uint") || param.baseType.startsWith("int")) return ParamNativeType.INT + if (param.baseType.startsWith("uint")) return ParamNativeType.UINT + if (param.baseType.startsWith("int")) return ParamNativeType.INT if (param.baseType === "array") { if (param.arrayChildren.baseType === "array") return ParamNativeType.UNSUPPORTED return ParamNativeType.ARRAY @@ -35,7 +36,7 @@ export function getNativeType(param: ethers.utils.ParamType | null): ParamNative export function getConditionsPerType(type: ParamNativeType): ParamComparison[] { switch (type) { - case ParamNativeType.INT: + case ParamNativeType.UINT: return [ParamComparison.EQUAL_TO, ParamComparison.ONE_OF, ParamComparison.LESS_THAN, ParamComparison.GREATER_THAN] case ParamNativeType.BOOLEAN: From 84fac8258684888f5cb32e927e4101631267dd5e Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Wed, 3 Jan 2024 13:00:03 +0100 Subject: [PATCH 5/6] add "experimental" badge to header --- .vscode/settings.json | 2 +- .../app/src/components/views/Header/Header.tsx | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9ef657f44..3562c0ac5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,6 @@ "typescript.tsdk": "node_modules/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" } } diff --git a/packages/app/src/components/views/Header/Header.tsx b/packages/app/src/components/views/Header/Header.tsx index 6b95d255f..3d8b60eff 100644 --- a/packages/app/src/components/views/Header/Header.tsx +++ b/packages/app/src/components/views/Header/Header.tsx @@ -25,6 +25,13 @@ const useStyles = makeStyles((theme) => ({ grow: { flexGrow: 1, }, + badge: { + marginLeft: theme.spacing(2), + }, + warning: { + color: theme.palette.warning.main, + textTransform: "uppercase", + }, })) export const Header = () => { @@ -40,7 +47,14 @@ export const Header = () => { Roles - + +
+ Experimental + + Use this app with caution and carefully review all applied permissions + +
+
From 010dc2c7916f3818efaaccaa03bafc3fe164a402 Mon Sep 17 00:00:00 2001 From: Asgeir Date: Wed, 3 Jan 2024 21:16:00 +0100 Subject: [PATCH 6/6] Add REACT_APP_GNOSISSCAN_KEY to .env.sample --- packages/app/.env.sample | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/app/.env.sample b/packages/app/.env.sample index 7a9bf78c8..d0c3afac9 100644 --- a/packages/app/.env.sample +++ b/packages/app/.env.sample @@ -6,6 +6,7 @@ REACT_APP_ETHERSCAN_KEY= REACT_APP_POLYGONSCAN_KEY= REACT_APP_ARBISCAN_KEY= REACT_APP_BSCSCAN_KEY= +REACT_APP_GNOSISSCAN_KEY= REACT_APP_OPTIMISTICSCAN_KEY= REACT_APP_SNOWTRACE_KEY=