Skip to content

Conversation

@leovigna
Copy link

What it solves

Resolves #505

How this PR fixes it

We check the topics.length to determine which encoding to use and then decode the args directly using ethers.

@github-actions
Copy link

github-actions bot commented Aug 20, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@leovigna
Copy link
Author

leovigna commented Aug 20, 2023

Link to CLA is broken
Edit: I think found it https://github.com/gnosis/CLA

@leovigna
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@leovigna
Copy link
Author

leovigna commented Aug 20, 2023

Also here is a simple util function to abstract this decoding logic

/**
 * Take an arbitrary event log and parse out if it is ProxyCreation(address proxy, address singleton) or ProxyCreation(address indexed proxy, address singleton)
 * @param event
 * @returns address/singleton kv or undefined
 */
export function parseProxyCreationEvent(event: Event): { proxy: string; singleton: string } | undefined {
    if (event.topics[0] != "0x4f51faf6c4561ff95f067657e43439f0f856d97c04d9ec9070a6199ad418e235") return undefined;

    if (event.topics.length == 1) {
        const ifaceNonIndexedProxyAddress = new ethers.utils.Interface([
            "event ProxyCreation(address proxy, address singleton)",
        ]);
        return ifaceNonIndexedProxyAddress.decodeEventLog("ProxyCreation", event.data, event.topics) as any;
    } else if (event.topics.length == 2) {
        const ifaceIndexedProxyAddress = new ethers.utils.Interface([
            "event ProxyCreation(address indexed proxy, address singleton)",
        ]);
        return ifaceIndexedProxyAddress.decodeEventLog("ProxyCreation", event.data, event.topics) as any;
    }
}

@leovigna
Copy link
Author

leovigna commented Aug 24, 2023

Anyone willing to review this? 😄
Open to any suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Protocol-kit): H3Error: SafeProxy was not deployed correctly

2 participants