-
Notifications
You must be signed in to change notification settings - Fork 217
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
fix ethers event decoding #512
Open
leovigna
wants to merge
1
commit into
safe-global:main
Choose a base branch
from
leovigna:fix/ethers-proxycreation-decode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix ethers event decoding #512
leovigna
wants to merge
1
commit into
safe-global:main
from
leovigna:fix/ethers-proxycreation-decode
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Link to CLA is broken |
I have read the CLA Document and I hereby sign the CLA |
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;
}
} |
franvf
approved these changes
Aug 22, 2023
Anyone willing to review this? 😄 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.