-
Notifications
You must be signed in to change notification settings - Fork 211
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
feat(Protocol-kit): H3Error: SafeProxy was not deployed correctly #505
Comments
I have had the same error following the official ProtocolKit tutorial and debugged the root issue by manually deploying the Safe. // src/adapters/ethers/contracts/SafeProxyFactoryEthersContract.ts
async createProxy({
safeMasterCopyAddress,
initializer,
saltNonce,
options,
callback
}: CreateProxyProps): Promise<string> {
//...
const proxyAddress = this.contract
.createProxyWithNonce(safeMasterCopyAddress, initializer, saltNonce, options)
.then(async (txResponse) => {
if (callback) {
callback(txResponse.hash)
}
const txReceipt = await txResponse.wait()
//BUG: Event is emitted but is hash no "ProxyCreation" name, however event signatures match!
const proxyCreationEvent = txReceipt?.events?.find(
({ event }: Event) => event === 'ProxyCreation'
)
if (!proxyCreationEvent || !proxyCreationEvent.args) {
throw new Error('SafeProxy was not deployed correctly')
}
const proxyAddress: string = proxyCreationEvent.args[0]
return proxyAddress
})
return proxyAddress
} The safe is properly deployed, and the factory emits the correct event with the event signature. However it has a different encoding. is not decoded by ethers, and is left in it's raw format. This is because I assume old versions of the proxy factory used the same event signature # The following two events have the same signature but different encoding
# old version, or at least what is expected by ethers
event ProxyCreation(address proxy, address singleton); # topics: [signature], data: [proxy, singleton]
# v1.3.0
event ProxyCreation(address indexed proxy, address singleton); # topics: [signature, proxy], data: [singleton] I discovered this by creating my own interfaces for the contracts in solidity and then deploying manually however a simpler patch can be made to fix this issue at the SDK level using ethers to decode the raw log. I will make a suggested PR with this. const proxyCreationLog = txReceipt?.events?.find(
({ topics }: Event) =>
topics[0] === '0x4f51faf6c4561ff95f067657e43439f0f856d97c04d9ec9070a6199ad418e235'
) as Event | undefined
let proxyCreationEventArgs: { 0: string; 1: string; proxy: string; singleton: string }
| undefined
if (proxyCreationLog) {
if (proxyCreationLog.topics.length == 1) {
const ifaceNonIndexedProxyAddress = new ethers.utils.Interface([
'event ProxyCreation(address proxy, address singleton)'
])
proxyCreationEventArgs = ifaceNonIndexedProxyAddress.decodeEventLog(
'ProxyCreation',
proxyCreationLog.data,
proxyCreationLog.topics
) as unknown as typeof proxyCreationEventArgs
} else if (proxyCreationLog.topics.length == 2) {
const ifaceIndexedProxyAddress = new ethers.utils.Interface([
'event ProxyCreation(address indexed proxy, address singleton)'
])
proxyCreationEventArgs = ifaceIndexedProxyAddress.decodeEventLog(
'ProxyCreation',
proxyCreationLog.data,
proxyCreationLog.topics
) as unknown as typeof proxyCreationEventArgs
}
} |
Note while this patch (see #512) fixes the decoding, the core underlying issue is the contract object stored by the SDK does not seem to match the deployed contract's interface. |
Decoding the return value also works 👍 |
Hi @leovigna, you propose a very clean solution. Thank you! |
Thanks. I would also recommend the actual interface used by the SDK (as mentioned in comment above) as this could cause other issues if parts of the code rely on events that aren't properly decoded. |
Was using v1.2.0. I see v1.3.0 was recently released, was the issue fixed there? |
It seems this file was not changed https://github.com/safe-global/safe-core-sdk/blob/main/packages/protocol-kit/src/adapters/ethers/contracts/SafeProxyFactory/SafeProxyFactoryEthersContract.ts as can also be seen by my PR https://github.com/safe-global/safe-core-sdk/pull/512/files I would assume the error persists due to the above described issue with ethers being unable to decode the event. Did you test with web3.js or ethers? |
I suppose the issue might have also been fixed itself if the proper ethers contract abi is being instantiated relative to the version. |
Description
I'm trying to deploy a safe wallet, but the function
deploySafe()
returns the error: SafeProxy was not deployed correctly. But, if I check the tx hash, the SafeProxy is deployed successfully.I have solved this locally modifying the
@safe-global/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryWeb3Contract.js
fileWhat I have modified in this file is:
Original file (not works)
My modified file (work)
Environment
@safe-global/protocol-kit version: "^1.2.0",
@safe-global/safe-core-sdk-types version: "^2.2.0",
Steps to reproduce
My Code
Expected result
The error should not be thrown.
The text was updated successfully, but these errors were encountered: