-
-
Notifications
You must be signed in to change notification settings - Fork 65
feat: align frame rpc definitions #476
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,5 @@ | ||
| --- | ||
| "ox": patch | ||
| --- | ||
|
|
||
| Aligned frame RPC quantities, signature placeholders, and receipt gas totals with the execution API definitions. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,13 +45,13 @@ export type Rpc = { | |
| /** Frame calldata. */ | ||
| data: Hex.Hex | ||
| /** Execution gas budget. */ | ||
| executionGasLimit: Hex.Hex | ||
| executionGas: Hex.Hex | ||
|
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.
After this rename, Useful? React with 👍 / 👎. |
||
| /** Approval scope and batching bits. */ | ||
| flags: number | ||
| flags: Hex.Hex | ||
| /** Execution mode. */ | ||
| mode: number | ||
| mode: Hex.Hex | ||
| /** State gas budget. */ | ||
| stateGasLimit: Hex.Hex | ||
| stateGas: Hex.Hex | ||
| /** Target address; absent for the transaction sender. */ | ||
| target?: Address.Address | null | undefined | ||
| /** Value transferred in wei. */ | ||
|
|
@@ -205,10 +205,10 @@ export declare namespace from { | |
| * | ||
| * const frame = Frame.fromRpc({ | ||
| * data: '0x', | ||
| * executionGasLimit: '0xc350', | ||
| * flags: 3, | ||
| * mode: 1, | ||
| * stateGasLimit: '0x0', | ||
| * executionGas: '0xc350', | ||
| * flags: '0x3', | ||
| * mode: '0x1', | ||
| * stateGas: '0x0', | ||
| * value: '0x0' | ||
| * }) | ||
| * ``` | ||
|
|
@@ -219,17 +219,20 @@ export declare namespace from { | |
| export function fromRpc(frame: Rpc): Frame { | ||
| return from({ | ||
| data: frame.data, | ||
| executionGas: Hex.toBigInt(frame.executionGasLimit), | ||
| flags: frame.flags, | ||
| mode: frame.mode, | ||
| stateGas: Hex.toBigInt(frame.stateGasLimit), | ||
| executionGas: Hex.toBigInt(frame.executionGas), | ||
| flags: Hex.toNumber(frame.flags), | ||
| mode: Hex.toNumber(frame.mode), | ||
| stateGas: Hex.toBigInt(frame.stateGas), | ||
| ...(frame.target == null ? {} : { to: frame.target }), | ||
| value: Hex.toBigInt(frame.value), | ||
| }) | ||
| } | ||
|
|
||
| export declare namespace fromRpc { | ||
| type ErrorType = from.ErrorType | Hex.toBigInt.ErrorType | ||
| type ErrorType = | ||
| | from.ErrorType | ||
| | Hex.toBigInt.ErrorType | ||
| | Hex.toNumber.ErrorType | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -255,10 +258,10 @@ export function toRpc(frame: toRpc.Input): Rpc { | |
| const { flags: flags_ = 0, mode = 0 } = frame | ||
| return { | ||
| data: frame.data ?? '0x', | ||
| executionGasLimit: Quantity.fromNumberish(frame.executionGas ?? 0n), | ||
| flags: typeof flags_ === 'string' ? flags[flags_] : flags_, | ||
| mode: typeof mode === 'string' ? modes[mode] : mode, | ||
| stateGasLimit: Quantity.fromNumberish(frame.stateGas ?? 0n), | ||
| executionGas: Quantity.fromNumberish(frame.executionGas ?? 0n), | ||
| flags: Hex.fromNumber(typeof flags_ === 'string' ? flags[flags_] : flags_), | ||
| mode: Hex.fromNumber(typeof mode === 'string' ? modes[mode] : mode), | ||
| stateGas: Quantity.fromNumberish(frame.stateGas ?? 0n), | ||
| ...(frame.to === undefined ? {} : { target: frame.to }), | ||
| value: Quantity.fromNumberish(frame.value ?? 0n), | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,21 @@ import type * as Errors from './Errors.js' | |
| import * as Hex from './Hex.js' | ||
| import * as Quantity from './internal/quantity.js' | ||
| import type * as Log from './Log.js' | ||
| import type { Compute, ExactPartial } from './internal/types.js' | ||
|
|
||
| /** Receipt for one frame. Frame logs contain only address, data, and topics. */ | ||
| type FrameLog = Compute< | ||
| Pick<Log.Rpc, 'address' | 'data' | 'topics'> & | ||
| ExactPartial<Omit<Log.Rpc, 'address' | 'data' | 'topics'>> | ||
|
Comment on lines
+8
to
+9
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 frame log includes the metadata newly admitted here, Useful? React with 👍 / 👎. |
||
| > | ||
|
|
||
| /** Receipt for one frame. */ | ||
| export type FrameReceipt<bigintType = bigint> = { | ||
| /** Execution gas used before transaction-level refunds. */ | ||
| executionGasUsed: bigintType | ||
| /** Total execution and state gas used. */ | ||
| gasUsed: bigintType | ||
| /** Logs emitted by this frame. */ | ||
| logs: readonly Pick<Log.Log, 'address' | 'data' | 'topics'>[] | ||
| logs: readonly FrameLog[] | ||
| /** Final state gas after refills and rollbacks. */ | ||
| stateGasUsed: bigintType | ||
| /** Frame execution result. */ | ||
|
|
@@ -19,8 +27,10 @@ export type FrameReceipt<bigintType = bigint> = { | |
| export type Rpc = { | ||
| /** Execution gas used. */ | ||
| executionGasUsed: Hex.Hex | ||
| /** Total execution and state gas used. */ | ||
| gasUsed: Hex.Hex | ||
| /** Logs emitted by this frame. */ | ||
| logs: readonly Pick<Log.Log, 'address' | 'data' | 'topics'>[] | ||
| logs: readonly FrameLog[] | ||
| /** Final state gas used. */ | ||
| stateGasUsed: Hex.Hex | ||
| /** Zero for failure, one for success, or two for a skipped frame. */ | ||
|
|
@@ -30,21 +40,21 @@ export type Rpc = { | |
| /** Frame execution status. */ | ||
| export type Status = 'reverted' | 'skipped' | 'success' | ||
|
|
||
| /** Numeric JSON-RPC frame execution status. */ | ||
| export type RpcStatus = 0 | 1 | 2 | ||
| /** Hex JSON-RPC frame execution status. */ | ||
| export type RpcStatus = '0x0' | '0x1' | '0x2' | ||
|
|
||
| /** RPC status to status mapping. */ | ||
| export const fromRpcStatus = { | ||
| 0: 'reverted', | ||
| 1: 'success', | ||
| 2: 'skipped', | ||
| '0x0': 'reverted', | ||
| '0x1': 'success', | ||
| '0x2': 'skipped', | ||
| } as const | ||
|
|
||
| /** Status to RPC status mapping. */ | ||
| export const toRpcStatus = { | ||
| reverted: 0, | ||
| skipped: 2, | ||
| success: 1, | ||
| reverted: '0x0', | ||
| skipped: '0x2', | ||
| success: '0x1', | ||
| } as const | ||
|
|
||
| /** | ||
|
|
@@ -58,9 +68,10 @@ export const toRpcStatus = { | |
| * | ||
| * const receipt = FrameReceipt.fromRpc({ | ||
| * executionGasUsed: '0x5208', | ||
| * gasUsed: '0x5208', | ||
| * logs: [], | ||
| * stateGasUsed: '0x0', | ||
| * status: 1 | ||
| * status: '0x1' | ||
| * }) | ||
| * ``` | ||
| * | ||
|
|
@@ -69,7 +80,8 @@ export const toRpcStatus = { | |
| */ | ||
| export function fromRpc(receipt: Rpc): FrameReceipt { | ||
| return { | ||
| gasUsed: Hex.toBigInt(receipt.executionGasUsed), | ||
| executionGasUsed: Hex.toBigInt(receipt.executionGasUsed), | ||
| gasUsed: Hex.toBigInt(receipt.gasUsed), | ||
| logs: receipt.logs, | ||
| stateGasUsed: Hex.toBigInt(receipt.stateGasUsed), | ||
| status: fromRpcStatus[receipt.status], | ||
|
|
@@ -91,19 +103,21 @@ export declare namespace fromRpc { | |
| * | ||
| * const receipt = FrameReceipt.fromRpc({ | ||
| * executionGasUsed: '0x5208', | ||
| * gasUsed: '0x5208', | ||
| * logs: [], | ||
| * stateGasUsed: '0x0', | ||
| * status: 1 | ||
| * status: '0x1' | ||
| * }) | ||
| * const rpc = FrameReceipt.toRpc(receipt) | ||
| * ``` | ||
| * | ||
| * @param receipt - The frame receipt. Gas accepts hex, bigint, or number values. | ||
| * @returns The RPC frame receipt with hex gas and a numeric status. | ||
| * @returns The RPC frame receipt with hex gas and a hex status. | ||
| */ | ||
| export function toRpc(receipt: toRpc.Input): Rpc { | ||
| return { | ||
| executionGasUsed: Quantity.fromNumberish(receipt.gasUsed), | ||
| executionGasUsed: Quantity.fromNumberish(receipt.executionGasUsed), | ||
| gasUsed: Quantity.fromNumberish(receipt.gasUsed), | ||
| logs: receipt.logs, | ||
| stateGasUsed: Quantity.fromNumberish(receipt.stateGasUsed), | ||
| status: toRpcStatus[receipt.status], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,12 @@ import * as Frame from './Frame.js' | |
| import * as FrameSignature from './FrameSignature.js' | ||
| import * as Hex from './Hex.js' | ||
| import * as Quantity from './internal/quantity.js' | ||
| import type { Compute, OneOf, UnionCompute } from './internal/types.js' | ||
| import type { | ||
| Compute, | ||
| ExactPartial, | ||
| OneOf, | ||
| UnionCompute, | ||
| } from './internal/types.js' | ||
| import * as Signature from './Signature.js' | ||
|
|
||
| /** | ||
|
|
@@ -197,29 +202,35 @@ export type Eip8141< | |
| > = Compute< | ||
| Omit< | ||
| Base<type, pending, bigintType, numberType>, | ||
| 'chainId' | 'r' | 's' | 'v' | 'yParity' | ||
| > & { | ||
| /** Versioned blob hashes. */ | ||
| blobVersionedHashes: readonly Hex.Hex[] | ||
| /** Chain ID, retaining bigint precision when needed. */ | ||
| chainId: numberType | bigintType | ||
| /** Frames in execution order. */ | ||
| frames: readonly ([bigintType] extends [Hex.Hex] | ||
| ? Frame.Rpc | ||
| : Frame.Frame<bigintType>)[] | ||
| /** Effective gas price. */ | ||
| gasPrice?: bigintType | undefined | ||
| /** Maximum fee per blob gas. */ | ||
| maxFeePerBlobGas: bigintType | ||
| /** Maximum fee per gas. */ | ||
| maxFeePerGas: bigintType | ||
| /** Maximum priority fee per gas. */ | ||
| maxPriorityFeePerGas: bigintType | ||
| /** Frame signature entries. */ | ||
| signatures: readonly ([bigintType] extends [Hex.Hex] | ||
| ? FrameSignature.Rpc | ||
| : FrameSignature.FrameSignature)[] | ||
| } | ||
| 'chainId' | 'gas' | 'input' | 'to' | 'value' | 'r' | 's' | 'v' | 'yParity' | ||
| > & | ||
| ExactPartial< | ||
| Pick< | ||
| Base<type, pending, bigintType, numberType>, | ||
| 'gas' | 'input' | 'to' | 'value' | ||
|
Comment on lines
+205
to
+210
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 an EIP-8141 RPC response omits the newly optional Useful? React with 👍 / 👎. |
||
| > | ||
| > & { | ||
| /** Versioned blob hashes. */ | ||
| blobVersionedHashes: readonly Hex.Hex[] | ||
| /** Chain ID, retaining bigint precision when needed. */ | ||
| chainId: numberType | bigintType | ||
| /** Frames in execution order. */ | ||
| frames: readonly ([bigintType] extends [Hex.Hex] | ||
| ? Frame.Rpc | ||
| : Frame.Frame<bigintType>)[] | ||
| /** Effective gas price. */ | ||
| gasPrice?: bigintType | undefined | ||
| /** Maximum fee per blob gas. */ | ||
| maxFeePerBlobGas: bigintType | ||
| /** Maximum fee per gas. */ | ||
| maxFeePerGas: bigintType | ||
| /** Maximum priority fee per gas. */ | ||
| maxPriorityFeePerGas: bigintType | ||
| /** Frame signature entries. */ | ||
| signatures: readonly ([bigintType] extends [Hex.Hex] | ||
| ? FrameSignature.Rpc | ||
| : FrameSignature.FrameSignature)[] | ||
| } | ||
| > | ||
|
|
||
| /** An EIP-8141 RPC transaction. */ | ||
|
|
||
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.
This commit removes or changes several public RPC fields and types—such as
executionGasLimit, numeric frame modes, and the previousFrameReceiptshape—yet the changeset declares only a patch release. Consumers accepting a patch update can therefore encounter compile failures or incompatible RPC payloads; mark this as a major change and include the required before/after migration shape.AGENTS.md reference: AGENTS.md:L121-L124
Useful? React with 👍 / 👎.