From a20a3bf410a6af82479c33e68cb5716f7900b807 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Tue, 22 Oct 2024 17:52:24 +0200 Subject: [PATCH 1/6] upgrade safe protocol-kit and fix tooling --- extension/.vscode/settings.json | 3 ++- extension/{esbuild.js => esbuild.mjs} | 0 extension/package.json | 9 ++++----- extension/pnpm-lock.yaml | 4 ++-- extension/src/panel/providers/ForkProvider.ts | 6 +++--- extension/tsconfig.json | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) rename extension/{esbuild.js => esbuild.mjs} (100%) diff --git a/extension/.vscode/settings.json b/extension/.vscode/settings.json index e1a6da18..11fd8a93 100644 --- a/extension/.vscode/settings.json +++ b/extension/.vscode/settings.json @@ -6,5 +6,6 @@ "typescript.enablePromptUseWorkspaceTsdk": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" - } + }, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/extension/esbuild.js b/extension/esbuild.mjs similarity index 100% rename from extension/esbuild.js rename to extension/esbuild.mjs diff --git a/extension/package.json b/extension/package.json index 0c11514f..3879f392 100644 --- a/extension/package.json +++ b/extension/package.json @@ -1,7 +1,6 @@ { "name": "zodiac-pilot", "version": "0.0.0", - "type": "module", "description": "Chrome extension to simulate dApp interactions and record transactions", "main": "index.js", "repository": "https://github.com/gnosisguild/zodiac-pilot.git", @@ -10,9 +9,9 @@ "private": true, "scripts": { "prebuild": "rimraf public/build", - "build": "NODE_ENV=production node esbuild.js", + "build": "NODE_ENV=production node esbuild.mjs", "zip": "mv public zodiac-pilot && zip -vr zodiac-pilot.zip zodiac-pilot/ -x \"*.DS_Store\" && mv zodiac-pilot public", - "dev": "NODE_ENV=development node esbuild.js", + "dev": "NODE_ENV=development node esbuild.mjs", "test:unit": "vitest", "test:e2e": "playwright test --headed", "check": "pnpm check:ts && pnpm check:format && pnpm check:lint && pnpm check:spelling", @@ -33,7 +32,7 @@ "@noble/hashes": "^1.4.0", "@playwright/test": "^1.48.1", "@safe-global/api-kit": "^2.4.2", - "@safe-global/protocol-kit": "^4.0.2", + "@safe-global/protocol-kit": "^5.0.1", "@safe-global/safe-apps-sdk": "^9.1.0", "@safe-global/safe-core-sdk-types": "^5.0.2", "@safe-global/safe-gateway-typescript-sdk": "^3.21.10", @@ -111,4 +110,4 @@ "vitest-chrome": "patches/vitest-chrome.patch" } } -} +} \ No newline at end of file diff --git a/extension/pnpm-lock.yaml b/extension/pnpm-lock.yaml index af284f05..ec3fec0b 100644 --- a/extension/pnpm-lock.yaml +++ b/extension/pnpm-lock.yaml @@ -48,8 +48,8 @@ importers: specifier: ^2.4.2 version: 2.5.2(typescript@5.6.3) '@safe-global/protocol-kit': - specifier: ^4.0.2 - version: 4.1.1(typescript@5.6.3) + specifier: ^5.0.1 + version: 5.0.2(typescript@5.6.3) '@safe-global/safe-apps-sdk': specifier: ^9.1.0 version: 9.1.0(typescript@5.6.3) diff --git a/extension/src/panel/providers/ForkProvider.ts b/extension/src/panel/providers/ForkProvider.ts index 43c096b0..e6323045 100644 --- a/extension/src/panel/providers/ForkProvider.ts +++ b/extension/src/panel/providers/ForkProvider.ts @@ -399,8 +399,8 @@ async function prepareSafeForSimulation( let from = moduleAddress || ownerAddress || DUMMY_MODULE_ADDRESS if (from === ZeroAddress) from = DUMMY_MODULE_ADDRESS - const iface = safe.getContractManager().safeContract?.contract.interface - if (!iface) { + const {safeContract} = safe.getContractManager() + if (!safeContract) { throw new Error('Safe contract not found') } @@ -410,7 +410,7 @@ async function prepareSafeForSimulation( params: [ { to: avatarAddress, - data: iface.encodeFunctionData('enableModule', [from]), + data: safeContract.encode('enableModule', [from]), from: avatarAddress, }, ], diff --git a/extension/tsconfig.json b/extension/tsconfig.json index 18c09642..ccf542ee 100644 --- a/extension/tsconfig.json +++ b/extension/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2020", + "target": "ES2023", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, @@ -9,8 +9,8 @@ "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, - "module": "esnext", - "moduleResolution": "node", + "module": "ESNext", + "moduleResolution": "Node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, From ca92aac0102d2e35b90df9bd97887a22c5880bb3 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Tue, 22 Oct 2024 18:07:42 +0200 Subject: [PATCH 2/6] fix format --- extension/src/panel/providers/ForkProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/src/panel/providers/ForkProvider.ts b/extension/src/panel/providers/ForkProvider.ts index e6323045..58a8ad36 100644 --- a/extension/src/panel/providers/ForkProvider.ts +++ b/extension/src/panel/providers/ForkProvider.ts @@ -399,7 +399,7 @@ async function prepareSafeForSimulation( let from = moduleAddress || ownerAddress || DUMMY_MODULE_ADDRESS if (from === ZeroAddress) from = DUMMY_MODULE_ADDRESS - const {safeContract} = safe.getContractManager() + const { safeContract } = safe.getContractManager() if (!safeContract) { throw new Error('Safe contract not found') } From c6ea196fcb1e7037f02013b69e6206b766de19a5 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Wed, 23 Oct 2024 09:38:15 +0200 Subject: [PATCH 3/6] ignore ts error --- extension/src/panel/providers/ForkProvider.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/extension/src/panel/providers/ForkProvider.ts b/extension/src/panel/providers/ForkProvider.ts index 58a8ad36..76c1c084 100644 --- a/extension/src/panel/providers/ForkProvider.ts +++ b/extension/src/panel/providers/ForkProvider.ts @@ -410,6 +410,7 @@ async function prepareSafeForSimulation( params: [ { to: avatarAddress, + // @ts-expect-error TODO: needs a fix in protocol-kit -> https://github.com/safe-global/safe-core-sdk/issues/1021 data: safeContract.encode('enableModule', [from]), from: avatarAddress, }, From ddc8bccbd70a94cb62bbbcf04245e3c8da9fd915 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Wed, 23 Oct 2024 10:00:34 +0200 Subject: [PATCH 4/6] fix eslint issue --- extension/eslint.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/eslint.config.mjs b/extension/eslint.config.mjs index 5fe73f91..73483379 100644 --- a/extension/eslint.config.mjs +++ b/extension/eslint.config.mjs @@ -44,7 +44,7 @@ export default tsEslint.config( ignores: ['public/build', 'playwright-report'], }, { - files: ['esbuild.js', 'manifest-util.js'], + files: ['esbuild.mjs', 'manifest-util.js'], languageOptions: { globals: { process: true } }, } ) From 282017bd1e0aa2e69c091e4cf24dcdc1b3ec96f2 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Wed, 23 Oct 2024 10:03:49 +0200 Subject: [PATCH 5/6] fix cspell --- extension/.cspell.json | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/extension/.cspell.json b/extension/.cspell.json index 7dd4e950..8f58c810 100644 --- a/extension/.cspell.json +++ b/extension/.cspell.json @@ -21,6 +21,7 @@ "cowswap", "Delegatecall", "delegatecalls", + "depay", "esbuild", "ethersproject", "foundance", @@ -51,15 +52,22 @@ "refork", "rpcs", "Samczun", + "sandboxed", "sepolia", + "servedir", + "serviceworker", "shazow", + "sidepanel", "sighash", "Sindre", "Sorhus", "Sourcify", + "speculationrules", "staderlabs", "Stakewise", "Sushiswap", + "tailwindcss", + "textbox", "toastify", "Uids", "UNWRAPPER", @@ -67,14 +75,7 @@ "walletconnect", "whatsabi", "xdai", - "xmlhttprequest", - "serviceworker", - "textbox", - "servedir", - "sidepanel", - "sandboxed", - "speculationrules", - "depay" + "xmlhttprequest" ], "flagWords": [], "ignorePaths": [ From dbfd6d58b6ae57be1389c8c9c660d44419da4e7e Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 23 Oct 2024 10:48:13 +0200 Subject: [PATCH 6/6] moah esm --- extension/esbuild.mjs | 1 + extension/package.json | 1 + extension/public/sidepanel.html | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extension/esbuild.mjs b/extension/esbuild.mjs index 734f8a45..6f9cbd35 100644 --- a/extension/esbuild.mjs +++ b/extension/esbuild.mjs @@ -29,6 +29,7 @@ esbuild './src/panel/app.tsx', ], bundle: true, + format: 'esm', minify: process.env.NODE_ENV === 'production', sourcemap: process.env.NODE_ENV !== 'production' ? 'inline' : 'linked', loader: { diff --git a/extension/package.json b/extension/package.json index 3879f392..afd3badb 100644 --- a/extension/package.json +++ b/extension/package.json @@ -2,6 +2,7 @@ "name": "zodiac-pilot", "version": "0.0.0", "description": "Chrome extension to simulate dApp interactions and record transactions", + "type": "module", "main": "index.js", "repository": "https://github.com/gnosisguild/zodiac-pilot.git", "author": "Jan-Felix ", diff --git a/extension/public/sidepanel.html b/extension/public/sidepanel.html index 2b834c69..25e05ada 100644 --- a/extension/public/sidepanel.html +++ b/extension/public/sidepanel.html @@ -11,7 +11,7 @@ /> Zodiac Pilot - +