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

fix: correctly trim implementation address #1261

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

adamegyed
Copy link
Collaborator

@adamegyed adamegyed commented Jan 4, 2025

There's a bug in the logic of getImplementationAddress, where we call viem's trim over the ERC-1967 storage slot's value. This results in two issues:

  • Before a contract is deployed, it returns 0x00 instead of address(0).
  • After deployment, if the address has leading or trailing zeros, these will incorrectly be trimmed.

Both of these could cause issues if the caller wants to use them as a viem Address type, because they will not be of the full length.

To fix this, we can manually trim out the first 12 bytes of the response, because if the response exists, it should always be 32 bytes in total.

Also updates package.json to not have verbose logging on by default, just for warnings. The number of files linted by prettier would fill up the entire scrollback buffer in my builtin terminal.

Pull Request Checklist


PR-Codex overview

This PR focuses on improving the linting command in package.json, refining the toSmartContractAccount function in smartContractAccount.ts, and adding a new test case in client.test.ts to validate the implementation address retrieval process.

Detailed summary

  • Updated lint:write command in package.json to use --loglevel warn.
  • Modified toSmartContractAccount function to return the last 20 bytes of storage prefixed with 0x.
  • Added a test case in client.test.ts to verify the correct retrieval of the implementation address before and after deployment.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Jan 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aa-sdk-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 4:32pm
aa-sdk-ui-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 4:32pm

Copy link

graphite-app bot commented Jan 4, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

howydev
howydev previously approved these changes Jan 4, 2025
rthomare
rthomare previously approved these changes Jan 4, 2025
@adamegyed adamegyed force-pushed the adam/fix-implementation-address-getter branch from ca0f8cb to 4ce1f87 Compare January 6, 2025 16:19
@adamegyed adamegyed merged commit 5dae940 into main Jan 6, 2025
6 checks passed
@adamegyed adamegyed deleted the adam/fix-implementation-address-getter branch January 6, 2025 16:40
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.

4 participants