feat: add EIP-7702 self-sponsored and sponsored Type 4 transaction scripts#2533
Open
kyzooghost wants to merge 8 commits intomainfrom
Open
feat: add EIP-7702 self-sponsored and sponsored Type 4 transaction scripts#2533kyzooghost wants to merge 8 commits intomainfrom
kyzooghost wants to merge 8 commits intomainfrom
Conversation
- Rename sendType4Tx.ts to sendSelfSponsoredType4Tx.ts to clarify intent - Fix undefined method call (createAuthorization -> createAuthorization properly defined on class, consolidated from createAuthorizationForSelf) - Remove unused createAuthorizationForPrivateKey (not relevant for self-sponsored scenario) - Rename class and method to reflect self-sponsored semantics
Move reusable functions from self-sponsored script into contracts/scripts/utils.ts: requireEnv, checkDelegation, getAccountInfo, createAuthorization, estimateGasFees. Simplify sendSelfSponsoredType4Tx.ts from class-based to flat functions using the shared utilities.
New script where a separate sponsor wallet sends and pays for the transaction while the authority wallet signs the authorization. Env vars: SPONSOR_PRIVATE_KEY, AUTHORITY_PRIVATE_KEY, TARGET_ADDRESS (required), TO_ADDRESS and CALLDATA (optional, default to authority address and 0x respectively).
Destructure only maxFeePerGas and maxPriorityFeePerGas from estimateGasFees instead of spreading all fields. The Linea gas estimate returns a gasLimit (e.g. 21000) that was overwriting our explicit 500000n, causing "Intrinsic gas exceeds gas limit" for Type 4 transactions with authorization lists.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2533 +/- ##
============================================
- Coverage 56.94% 56.94% -0.01%
Complexity 1480 1480
============================================
Files 444 445 +1
Lines 17807 17809 +2
Branches 1949 1949
============================================
Hits 10141 10141
- Misses 7049 7051 +2
Partials 617 617
*This pull request uses carry forward flags. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
This file contains hidden or 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
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.
Summary
sendType4Tx.tstosendSelfSponsoredType4Tx.tswith explicit self-sponsored semanticssendSponsoredType4Tx.tsscript where a separate sponsor sends and pays while a different authority signs the authorizationrequireEnv,checkDelegation,getAccountInfo,createAuthorization,estimateGasFees) intocontracts/scripts/utils.tsgasLimitreturn value was overriding the explicit 500000n needed for Type 4 transactionsProblem
The original
sendType4Tx.tswas broken (called an undefined method) and only supported self-sponsored transactions. There was no script to test sponsored EIP-7702 transactions where the authority signer and the transaction sender are different wallets.Solution
Split into two explicit scripts with shared utilities:
sendSelfSponsoredType4Tx.ts): same wallet signs authorization and sends txsendSponsoredType4Tx.ts): configurable viaSPONSOR_PRIVATE_KEY,AUTHORITY_PRIVATE_KEY,TARGET_ADDRESS, optionalTO_ADDRESSandCALLDATARelated
None
Test Plan
tsc --noEmit)Note
Low Risk
Changes are limited to developer scripts and shared script utilities; main risk is breaking existing workflows that referenced the removed
sendType4Tx.tsor subtle fee-estimation behavior changes on Linea.Overview
Adds two explicit EIP-7702 Type 4 transaction scripts:
sendSelfSponsoredType4Tx.ts(same wallet authorizes and sends, using a +1 auth nonce offset) andsendSponsoredType4Tx.ts(separate authority signs authorization while a sponsor sends/pays, configurableTO_ADDRESS/CALLDATA).Replaces the old
sendType4Tx.tsimplementation and extracts common helpers intocontracts/scripts/utils.ts(requireEnv,checkDelegation,getAccountInfo,createAuthorization,estimateGasFees), including a Linea-aware fee estimator that drops the returnedgasLimitso it can’t override the scripts’ explicit500000ngas limit.Written by Cursor Bugbot for commit ae32bb1. This will update automatically on new commits. Configure here.