Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade safe protocol-kit and fix tooling #180

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions extension/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"cowswap",
"Delegatecall",
"delegatecalls",
"depay",
"esbuild",
"ethersproject",
"foundance",
Expand Down Expand Up @@ -51,30 +52,30 @@
"refork",
"rpcs",
"Samczun",
"sandboxed",
"sepolia",
"servedir",
"serviceworker",
"shazow",
"sidepanel",
"sighash",
"Sindre",
"Sorhus",
"Sourcify",
"speculationrules",
"staderlabs",
"Stakewise",
"Sushiswap",
"tailwindcss",
"textbox",
"toastify",
"Uids",
"UNWRAPPER",
"vnet",
"walletconnect",
"whatsabi",
"xdai",
"xmlhttprequest",
"serviceworker",
"textbox",
"servedir",
"sidepanel",
"sandboxed",
"speculationrules",
"depay"
"xmlhttprequest"
],
"flagWords": [],
"ignorePaths": [
Expand Down
3 changes: 2 additions & 1 deletion extension/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
},
"typescript.tsdk": "node_modules/typescript/lib"
}
1 change: 1 addition & 0 deletions extension/esbuild.js → extension/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion extension/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
}
)
10 changes: 5 additions & 5 deletions extension/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "zodiac-pilot",
"version": "0.0.0",
"type": "module",
"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 <jan@gnosisguild.org>",
"license": "LGPLv3",
"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",
Expand All @@ -33,7 +33,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",
Expand Down Expand Up @@ -113,4 +113,4 @@
"vitest-chrome": "patches/vitest-chrome.patch"
}
}
}
}
4 changes: 2 additions & 2 deletions extension/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extension/public/sidepanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/>
<title>Zodiac Pilot</title>
<link rel="stylesheet" href="/build/panel/app.css" />
<script src="/build/panel/app.js" defer></script>
<script type="module" src="/build/panel/app.js" defer></script>
</head>
<body class="h-full">
<div class="flex h-full flex-col" id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion extension/src/panel/integrations/safe/kits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const initSafeApiKit = (chainId: ChainId): SafeApiKit => {
export const initSafeProtocolKit = async (
chainId: ChainId,
safeAddress: string
) => {
): Promise<Safe> => {
// @ts-expect-error protocol-kit is only available as a CJS module. That doesn't play super nice with us being ESM.
if (Safe.default) {
// @ts-expect-error protocol-kit is only available as a CJS module. That doesn't play super nice with us being ESM.
Expand Down
7 changes: 4 additions & 3 deletions extension/src/panel/providers/ForkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,18 @@ async function prepareSafeForSimulation(
let from = moduleAddress || ownerAddress || DUMMY_MODULE_ADDRESS
if (from === ZeroAddress) from = DUMMY_MODULE_ADDRESS

const iface = safe.getContractManager().safeContract?.contract.interface
const { safeContract } = safe.getContractManager()

invariant(iface, 'Safe contract not found')
invariant(safeContract != null, 'Safe contract not found')

try {
await provider.request({
method: 'eth_sendTransaction',
params: [
{
to: avatarAddress,
data: iface.encodeFunctionData('enableModule', [from]),
// @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,
},
],
Expand Down
6 changes: 3 additions & 3 deletions extension/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ES2023",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand All @@ -9,8 +9,8 @@
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
Expand Down
Loading