Skip to content
Closed
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
18 changes: 18 additions & 0 deletions src/hooks/useWeb3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ export function Web3ContextProvider({ children }: { children: ReactNode | ReactN
params[0] = { ...params[0], ...gasSettingsForChain }
}
}
if (
method === 'eth_getCode' &&
address &&
typeof params?.[0] === 'string' &&
params[0].toLowerCase() === address.toLowerCase()
) {
const code = await webprovider.jsonRpcFetchFunc(method, params)
// EIP-7702 delegated EOAs (e.g. MetaMask Smart Accounts on Celo) return a 23-byte
// delegation designator (`0xef0100` + 20-byte target address). Per EIP-3541, deployed
// smart contracts (such as Gnosis Safe) cannot have bytecode starting with `0xef`.
// Returning `'0x'` prevents `@usedapp/core` from misclassifying EIP-7702 EOAs as
// Gnosis Safe contracts and calling `nonce()` on them before transaction signing.
if (typeof code === 'string' && /^0xef0100[0-9a-fA-F]{40}$/.test(code)) {
return '0x'
}
return code
}
return webprovider.jsonRpcFetchFunc(method, params)
}
}
Expand Down Expand Up @@ -271,3 +288,4 @@ export function Web3ContextProvider({ children }: { children: ReactNode | ReactN
</GdSdkContext.Provider>
)
}