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

[SDK] Feature: Basic EIP7702 Support #5801

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented Dec 19, 2024

PR-Codex overview

This PR introduces beta support for EIP-7702 authorization lists, enhancing transaction capabilities and authorization signing within the thirdweb ecosystem.

Detailed summary

  • Added style configuration in biome.json.
  • Introduced sleep in smart-wallet-integration.test.ts.
  • Updated nonce handling to convert to Number in ethers5.ts.
  • Added types and functions for EIP-7702 in thirdweb.ts and transaction.ts.
  • Implemented signAuthorization for EIP-7702 in authorization.ts.
  • Enhanced prepareTransaction to accept authorizationList.
  • Introduced tests for signAuthorization and prepareTransaction with authorization.
  • Updated gas estimation to handle authorization lists in estimate-gas.ts.
  • Added serialization support for EIP-7702 transactions in serialize-transaction.ts.
  • Created a new wagmiTokenContractConfig in wagmiToken.ts.

The following files were skipped due to too many changes: pnpm-lock.yaml

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

@gregfromstl gregfromstl requested review from a team as code owners December 19, 2024 01:46
Copy link

linear bot commented Dec 19, 2024

Copy link

changeset-bot bot commented Dec 19, 2024

🦋 Changeset detected

Latest commit: 4413b3a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
thirdweb Minor
@thirdweb-dev/wagmi-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 19, 2024

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

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 5:48am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 5:48am
thirdweb-www ❌ Failed (Inspect) Jan 6, 2025 5:48am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 5:48am

Copy link

graphite-app bot commented Dec 19, 2024

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

Copy link
Contributor

github-actions bot commented Dec 19, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 45.31 KB (+0.49% 🔺) 907 ms (+0.49% 🔺) 429 ms (+29.01% 🔺) 1.4 s
thirdweb (cjs) 111.52 KB (+0.61% 🔺) 2.3 s (+0.61% 🔺) 1.2 s (+7.66% 🔺) 3.4 s
thirdweb (minimal + tree-shaking) 5.58 KB (0%) 112 ms (0%) 201 ms (+394.38% 🔺) 313 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 47 ms (+405.23% 🔺) 57 ms
thirdweb/react (minimal + tree-shaking) 19.12 KB (0%) 383 ms (0%) 184 ms (+62.91% 🔺) 566 ms

from: options.from ? getAddress(options.from) : undefined,
from:
typeof options.from === "string" // Is this just an address?
? checksumAddress(options.from)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getaddress is nice because it throws if invalid input, not sure if checksum does that

}): Promise<SignedAuthorization[]> {
const { authorizations, account } = options;

return Promise.all(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way to sign multiple authorizations with one signature? Assume this will prompt multiple signatures right

resolvePromisedValue(options.transaction.to),
resolvePromisedValue(options.transaction.accessList),
resolvePromisedValue(options.transaction.value),
resolvePromisedValue(options.transaction.authorizations),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this right? Weird to have this and the one below

@@ -112,5 +128,50 @@ export async function toSerializableTransaction(
accessList,
value,
...feeData,
// For some reason authorizationList is not getting properly typed when returned from resolveAndSignAuthorizations?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prob because of the comment above

async function resolveAndSignAuthorizations(
options: ToSerializableTransactionOptions,
): Promise<SignedAuthorization[] | undefined> {
if (typeof options.transaction.authorizations === "undefined") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to resolvePromise this first?

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 88.99083% with 12 lines in your changes missing coverage. Please review.

Project coverage is 53.28%. Comparing base (3683c11) to head (6f4ad21).

Files with missing lines Patch % Lines
...transaction/actions/to-serializable-transaction.ts 86.11% 10 Missing ⚠️
packages/thirdweb/src/adapters/ethers5.ts 0.00% 1 Missing ⚠️
.../thirdweb/src/transaction/serialize-transaction.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5801      +/-   ##
==========================================
+ Coverage   53.20%   53.28%   +0.07%     
==========================================
  Files        1101     1102       +1     
  Lines       59095    59174      +79     
  Branches     4816     4837      +21     
==========================================
+ Hits        31444    31528      +84     
+ Misses      26934    26928       -6     
- Partials      717      718       +1     
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from 3683c11
packages 50.48% <88.99%> (+0.09%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
packages/thirdweb/src/gas/estimate-l1-fee.ts 100.00% <100.00%> (ø)
.../transaction/actions/eip7702/sign-authorization.ts 100.00% <100.00%> (ø)
...irdweb/src/transaction/actions/send-transaction.ts 46.80% <100.00%> (ø)
...es/thirdweb/src/transaction/prepare-transaction.ts 100.00% <ø> (ø)
packages/thirdweb/src/adapters/ethers5.ts 53.28% <0.00%> (ø)
.../thirdweb/src/transaction/serialize-transaction.ts 88.78% <90.90%> (+1.28%) ⬆️
...transaction/actions/to-serializable-transaction.ts 77.98% <86.11%> (+1.79%) ⬆️

... and 5 files with indirect coverage changes

Copy link
Member

@0xFirekeeper 0xFirekeeper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful

fix
@gregfromstl gregfromstl force-pushed the greg/tool-2477-basic-7702-support-in-ts-sdk branch from 55bb597 to d59413e Compare December 19, 2024 07:13
@github-actions github-actions bot added the Stale label Dec 27, 2024
@github-actions github-actions bot closed this Dec 29, 2024
@gregfromstl
Copy link
Member Author

Revive

client: TEST_CLIENT,
value: 100n,
to: TEST_WALLET_B,
authorizationList: authorization,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be an array right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes

@gregfromstl gregfromstl force-pushed the greg/tool-2477-basic-7702-support-in-ts-sdk branch from cf3ad5e to ae8bee2 Compare January 2, 2025 09:09
* const transaction = prepareTransaction({
* chain: sepolia,
* client: client,
* authorizations: [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authorizationList or authorizations? i think it should be the former right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants