-
-
Notifications
You must be signed in to change notification settings - Fork 65
feat: add keyed frame nonces #489
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| "ox": patch | ||
| --- | ||
|
|
||
| Added EIP-8250 keyed frame nonces with shared `nonce` sequences while preserving the original EIP-8141 encoding when `nonceKeys` is omitted. | ||
|
|
||
| ```ts | ||
| import { TxEnvelopeEip8141 } from 'ox' | ||
|
|
||
| const envelope = TxEnvelopeEip8141.from({ | ||
| chainId: 1, | ||
| sender: '0x1111111111111111111111111111111111111111', | ||
| frames: [{ mode: 'sender', executionGas: 50_000n }], | ||
| nonceKeys: [1n, 2n], | ||
| nonce: 0n, | ||
| }) | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -412,7 +412,10 @@ export function getType<const envelope extends Typeable>( | |
| return type as never | ||
| } | ||
|
|
||
| if ('frames' in envelope && envelope.frames !== undefined) | ||
| if ( | ||
| ('frames' in envelope && envelope.frames !== undefined) || | ||
| ('nonceKeys' in envelope && envelope.nonceKeys !== undefined) | ||
| ) | ||
| return 'eip8141' as never | ||
| if ( | ||
| 'authorizationList' in envelope && | ||
|
|
@@ -446,7 +449,9 @@ export declare namespace getType { | |
| type: infer type extends string | ||
| } | ||
| ? type | ||
| : HasDefined<envelope, 'frames'> extends true | ||
| : true extends | ||
| | HasDefined<envelope, 'frames'> | ||
| | HasDefined<envelope, 'nonceKeys'> | ||
|
Comment on lines
+452
to
+454
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a caller has an optional discriminator such as AGENTS.md reference: AGENTS.md:L45-L45 Useful? React with 👍 / 👎. |
||
| ? TxEnvelopeEip8141.Type | ||
| : HasDefined<envelope, 'authorizationList'> extends true | ||
| ? TxEnvelopeEip7702.Type | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an incomplete request supplies
nonceKeysbut omits bothtypeandframes,TransactionRequest.toEnvelopedelegates toTxEnvelope.getType, which only recognizesframesas the EIP-8141 discriminator. It therefore defaults to EIP-1559, interprets the shared sequence as a legacy nonce, and silently drops the keys instead of selecting EIP-8250 and reporting the missing required frames. AddnonceKeysto both the runtime and type-levelgetTypeinference so this input follows the EIP-8141 validation path.AGENTS.md reference: AGENTS.md:L150-L150
Useful? React with 👍 / 👎.