diff --git a/extension/.cspell.json b/extension/.cspell.json index d18282a7..bdfb4719 100644 --- a/extension/.cspell.json +++ b/extension/.cspell.json @@ -10,6 +10,7 @@ "arbitrum", "barnbridge", "bitshift", + "Bitmask", "Blockhash", "blockie", "blockies", diff --git a/extension/.pnp.cjs b/extension/.pnp.cjs index ca8b7d37..8806c083 100755 --- a/extension/.pnp.cjs +++ b/extension/.pnp.cjs @@ -31,6 +31,7 @@ const RAW_RUNTIME_STATE = ["@eslint/eslintrc", "npm:3.1.0"],\ ["@eslint/js", "npm:9.7.0"],\ ["@gnosis.pm/zodiac", "npm:4.0.3"],\ + ["@noble/hashes", "npm:1.4.0"],\ ["@safe-global/api-kit", "npm:2.4.2"],\ ["@safe-global/protocol-kit", "npm:4.0.2"],\ ["@safe-global/safe-apps-sdk", "npm:9.1.0"],\ @@ -84,7 +85,7 @@ const RAW_RUNTIME_STATE = ["react-select", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:5.8.0"],\ ["react-toastify", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:9.1.3"],\ ["rimraf", "npm:3.0.2"],\ - ["ser-kit", "npm:0.3.9"],\ + ["ser-kit", "npm:0.3.10"],\ ["typescript", "patch:typescript@npm%3A5.5.3#optional!builtin::version=5.5.3&hash=379a07"],\ ["typescript-eslint", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:7.16.0"],\ ["typescript-plugin-css-modules", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:5.1.0"],\ @@ -2363,7 +2364,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["@shazow/whatsabi", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:0.13.2"],\ ["@ethersproject/web", "npm:5.7.1"],\ - ["@noble/hashes", null],\ + ["@noble/hashes", "npm:1.4.0"],\ ["@types/noble__hashes", null],\ ["ethers", "npm:6.13.1"]\ ],\ @@ -10310,14 +10311,14 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["ser-kit", [\ - ["npm:0.3.9", {\ - "packageLocation": "./.yarn/cache/ser-kit-npm-0.3.9-d875db81cc-2dbbf79d74.zip/node_modules/ser-kit/",\ + ["npm:0.3.10", {\ + "packageLocation": "./.yarn/cache/ser-kit-npm-0.3.10-5f1f4f21e9-cf9788b578.zip/node_modules/ser-kit/",\ "packageDependencies": [\ - ["ser-kit", "npm:0.3.9"],\ + ["ser-kit", "npm:0.3.10"],\ ["@safe-global/api-kit", "npm:2.4.2"],\ ["@safe-global/protocol-kit", "npm:4.0.2"],\ ["@safe-global/safe-core-sdk-types", "npm:5.0.2"],\ - ["viem", "virtual:d875db81ccd1ab3dd71e93216c426643ffe88c19e5be35c28e05da34f5b2fbcbd5b6a42d1efe982056b4cd263ee6982550ef3cb2fee79adfef823c99d09fa16d#npm:2.17.3"]\ + ["viem", "virtual:5f1f4f21e904c90b3afba041433c4e1dd386ad92931991fbce4f874793959addefff8f2299e7d5b5f6906c08647bf50514c48e57deec7178ea8c2b7cec3afa65#npm:2.17.3"]\ ],\ "linkType": "HARD"\ }]\ @@ -11622,10 +11623,10 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:a2bcc550e4d5802f678fa6d1e27abcc996a71a1ab2fe3a437c1030dc4da4b9057d3b8af7003de16109440a98c44997cd8511fc59222d359bac8968ec19ade518#npm:2.17.4", {\ - "packageLocation": "./.yarn/__virtual__/viem-virtual-cc0d0158cc/0/cache/viem-npm-2.17.4-2e783c28b4-29e2b7d903.zip/node_modules/viem/",\ + ["virtual:5f1f4f21e904c90b3afba041433c4e1dd386ad92931991fbce4f874793959addefff8f2299e7d5b5f6906c08647bf50514c48e57deec7178ea8c2b7cec3afa65#npm:2.17.3", {\ + "packageLocation": "./.yarn/__virtual__/viem-virtual-ef0860dbab/0/cache/viem-npm-2.17.3-e88baaa01f-803b49f793.zip/node_modules/viem/",\ "packageDependencies": [\ - ["viem", "virtual:a2bcc550e4d5802f678fa6d1e27abcc996a71a1ab2fe3a437c1030dc4da4b9057d3b8af7003de16109440a98c44997cd8511fc59222d359bac8968ec19ade518#npm:2.17.4"],\ + ["viem", "virtual:5f1f4f21e904c90b3afba041433c4e1dd386ad92931991fbce4f874793959addefff8f2299e7d5b5f6906c08647bf50514c48e57deec7178ea8c2b7cec3afa65#npm:2.17.3"],\ ["@adraffy/ens-normalize", "npm:1.10.0"],\ ["@noble/curves", "npm:1.4.0"],\ ["@noble/hashes", "npm:1.4.0"],\ @@ -11643,10 +11644,10 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:d875db81ccd1ab3dd71e93216c426643ffe88c19e5be35c28e05da34f5b2fbcbd5b6a42d1efe982056b4cd263ee6982550ef3cb2fee79adfef823c99d09fa16d#npm:2.17.3", {\ - "packageLocation": "./.yarn/__virtual__/viem-virtual-beb1a85c96/0/cache/viem-npm-2.17.3-e88baaa01f-803b49f793.zip/node_modules/viem/",\ + ["virtual:a2bcc550e4d5802f678fa6d1e27abcc996a71a1ab2fe3a437c1030dc4da4b9057d3b8af7003de16109440a98c44997cd8511fc59222d359bac8968ec19ade518#npm:2.17.4", {\ + "packageLocation": "./.yarn/__virtual__/viem-virtual-cc0d0158cc/0/cache/viem-npm-2.17.4-2e783c28b4-29e2b7d903.zip/node_modules/viem/",\ "packageDependencies": [\ - ["viem", "virtual:d875db81ccd1ab3dd71e93216c426643ffe88c19e5be35c28e05da34f5b2fbcbd5b6a42d1efe982056b4cd263ee6982550ef3cb2fee79adfef823c99d09fa16d#npm:2.17.3"],\ + ["viem", "virtual:a2bcc550e4d5802f678fa6d1e27abcc996a71a1ab2fe3a437c1030dc4da4b9057d3b8af7003de16109440a98c44997cd8511fc59222d359bac8968ec19ade518#npm:2.17.4"],\ ["@adraffy/ens-normalize", "npm:1.10.0"],\ ["@noble/curves", "npm:1.4.0"],\ ["@noble/hashes", "npm:1.4.0"],\ @@ -12488,6 +12489,7 @@ const RAW_RUNTIME_STATE = ["@eslint/eslintrc", "npm:3.1.0"],\ ["@eslint/js", "npm:9.7.0"],\ ["@gnosis.pm/zodiac", "npm:4.0.3"],\ + ["@noble/hashes", "npm:1.4.0"],\ ["@safe-global/api-kit", "npm:2.4.2"],\ ["@safe-global/protocol-kit", "npm:4.0.2"],\ ["@safe-global/safe-apps-sdk", "npm:9.1.0"],\ @@ -12541,7 +12543,7 @@ const RAW_RUNTIME_STATE = ["react-select", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:5.8.0"],\ ["react-toastify", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:9.1.3"],\ ["rimraf", "npm:3.0.2"],\ - ["ser-kit", "npm:0.3.9"],\ + ["ser-kit", "npm:0.3.10"],\ ["typescript", "patch:typescript@npm%3A5.5.3#optional!builtin::version=5.5.3&hash=379a07"],\ ["typescript-eslint", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:7.16.0"],\ ["typescript-plugin-css-modules", "virtual:919984625f908c00f58e56a3a023a4bcc5a02977fb9ef0230392d1979706b2cc874abc287345e6561886da69e547c4d1330a8c5645be8f7e62b06d5144141c21#npm:5.1.0"],\ diff --git a/extension/.yarn/cache/ser-kit-npm-0.3.10-5f1f4f21e9-cf9788b578.zip b/extension/.yarn/cache/ser-kit-npm-0.3.10-5f1f4f21e9-cf9788b578.zip new file mode 100644 index 00000000..9085140c Binary files /dev/null and b/extension/.yarn/cache/ser-kit-npm-0.3.10-5f1f4f21e9-cf9788b578.zip differ diff --git a/extension/.yarn/cache/ser-kit-npm-0.3.9-d875db81cc-2dbbf79d74.zip b/extension/.yarn/cache/ser-kit-npm-0.3.9-d875db81cc-2dbbf79d74.zip deleted file mode 100644 index 59862ccc..00000000 Binary files a/extension/.yarn/cache/ser-kit-npm-0.3.9-d875db81cc-2dbbf79d74.zip and /dev/null differ diff --git a/extension/package.json b/extension/package.json index cdfd13be..40af64ff 100644 --- a/extension/package.json +++ b/extension/package.json @@ -26,6 +26,7 @@ "@eslint/eslintrc": "^3.1.0", "@eslint/js": "^9.7.0", "@gnosis.pm/zodiac": "^4.0.3", + "@noble/hashes": "^1.4.0", "@safe-global/api-kit": "^2.4.2", "@safe-global/protocol-kit": "^4.0.2", "@safe-global/safe-apps-sdk": "^9.1.0", @@ -79,7 +80,7 @@ "react-select": "^5.2.1", "react-toastify": "^9.0.8", "rimraf": "^3.0.2", - "ser-kit": "^0.3.9", + "ser-kit": "^0.3.10", "typescript": "^5.5.3", "typescript-eslint": "^7.16.0", "typescript-plugin-css-modules": "^5.1.0", diff --git a/extension/src/browser/Drawer/RolePermissionCheck.tsx b/extension/src/browser/Drawer/RolePermissionCheck.tsx index 3e1e9830..e91153b8 100644 --- a/extension/src/browser/Drawer/RolePermissionCheck.tsx +++ b/extension/src/browser/Drawer/RolePermissionCheck.tsx @@ -16,7 +16,7 @@ import { useTenderlyProvider } from '../../providers' import { TenderlyProvider } from '../../providers/ProvideTenderly' import { TransactionState } from '../../state' import { MetaTransactionData } from '@safe-global/safe-core-sdk-types' -import { ZeroAddress } from 'ethers' +import { toQuantity, ZeroAddress } from 'ethers' import { ExecutionActionType, parsePrefixedAddress, @@ -43,7 +43,11 @@ const simulateRolesTransaction = async ( } const [, from] = parsePrefixedAddress(plan[0].from) - const tx = { ...plan[0].transaction, from } + const tx = { + ...plan[0].transaction, + from, + value: toQuantity(BigInt(plan[0].transaction.value || 0)), + } try { await tenderlyProvider.request({ @@ -56,6 +60,9 @@ const simulateRolesTransaction = async ( decodeRolesV2Error(e as JsonRpcError) if (decodedError) { + if (decodedError.name === 'ConditionViolation') { + return RolesV2Status[decodedError.args.status] + } return decodedError.name } else { const genericError = decodeGenericError(e as JsonRpcError) @@ -149,3 +156,41 @@ const RolePermissionCheck: React.FC<{ } export default RolePermissionCheck + +enum RolesV2Status { + Ok, + /** Role not allowed to delegate call to target address */ + DelegateCallNotAllowed, + /** Role not allowed to call target address */ + TargetAddressNotAllowed, + /** Role not allowed to call this function on target address */ + FunctionNotAllowed, + /** Role not allowed to send to target address */ + SendNotAllowed, + /** Or condition not met */ + OrViolation, + /** Nor condition not met */ + NorViolation, + /** Parameter value is not equal to allowed */ + ParameterNotAllowed, + /** Parameter value less than allowed */ + ParameterLessThanAllowed, + /** Parameter value greater than maximum allowed by role */ + ParameterGreaterThanAllowed, + /** Parameter value does not match */ + ParameterNotAMatch, + /** Array elements do not meet allowed criteria for every element */ + NotEveryArrayElementPasses, + /** Array elements do not meet allowed criteria for at least one element */ + NoArrayElementPasses, + /** Parameter value not a subset of allowed */ + ParameterNotSubsetOfAllowed, + /** Bitmask exceeded value length */ + BitmaskOverflow, + /** Bitmask not an allowed value */ + BitmaskNotAllowed, + CustomConditionViolation, + AllowanceExceeded, + CallAllowanceExceeded, + EtherAllowanceExceeded, +} diff --git a/extension/yarn.lock b/extension/yarn.lock index d37dfc14..e9860961 100644 --- a/extension/yarn.lock +++ b/extension/yarn.lock @@ -1456,7 +1456,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:~1.4.0": +"@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0, @noble/hashes@npm:~1.4.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" checksum: 10/e156e65794c473794c52fa9d06baf1eb20903d0d96719530f523cc4450f6c721a957c544796e6efd0197b2296e7cd70efeb312f861465e17940a3e3c7e0febc6 @@ -8826,15 +8826,15 @@ __metadata: languageName: node linkType: hard -"ser-kit@npm:^0.3.9": - version: 0.3.9 - resolution: "ser-kit@npm:0.3.9" +"ser-kit@npm:^0.3.10": + version: 0.3.10 + resolution: "ser-kit@npm:0.3.10" dependencies: "@safe-global/api-kit": "npm:^2.4.2" "@safe-global/protocol-kit": "npm:^4.0.2" "@safe-global/safe-core-sdk-types": "npm:^5.0.2" viem: "npm:^2.13.8" - checksum: 10/2dbbf79d74d8d6d52db0fbf0421aef8dc80fdc537a135017947c7b37ff1ba686c920245ecf21854edb88de371e0a388d1ad0b4c27675d61379f5289881b5807f + checksum: 10/cf9788b578a2b8c38748028cee29d99ce201effdc564690dc9bc6c14411ca16a8d95cb5099314ec186fbc8188a6bb2bc04ba8f638fe1a00a997966ea26232518 languageName: node linkType: hard @@ -10670,6 +10670,7 @@ __metadata: "@eslint/eslintrc": "npm:^3.1.0" "@eslint/js": "npm:^9.7.0" "@gnosis.pm/zodiac": "npm:^4.0.3" + "@noble/hashes": "npm:^1.4.0" "@safe-global/api-kit": "npm:^2.4.2" "@safe-global/protocol-kit": "npm:^4.0.2" "@safe-global/safe-apps-sdk": "npm:^9.1.0" @@ -10723,7 +10724,7 @@ __metadata: react-select: "npm:^5.2.1" react-toastify: "npm:^9.0.8" rimraf: "npm:^3.0.2" - ser-kit: "npm:^0.3.9" + ser-kit: "npm:^0.3.10" typescript: "npm:^5.5.3" typescript-eslint: "npm:^7.16.0" typescript-plugin-css-modules: "npm:^5.1.0"