ox 0.14.47 → 0.14.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,18 +23,18 @@ export type Arbitrary = {
23
23
  /** Arbitrary signatures have no signer metadata. */
24
24
  signer?: undefined;
25
25
  };
26
- /** A structured secp256k1 signature entry. */
26
+ /** A secp256k1 signature entry. */
27
27
  export type Secp256k1 = {
28
28
  /** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
29
29
  payload?: Hex.Hex | undefined;
30
30
  /** secp256k1 verification scheme. */
31
31
  scheme: 1 | 'secp256k1';
32
- /** Recovered signature. Omit for an unsigned entry. */
33
- signature?: Signature.Signature | undefined;
32
+ /** Recovered signature or `Signature.toHex` bytes. Omit for an unsigned entry. */
33
+ signature?: Hex.Hex | Signature.Signature | undefined;
34
34
  /** Signer address. Omit to use the transaction sender. */
35
35
  signer?: Address.Address | undefined;
36
36
  };
37
- /** A structured P-256 signature entry. */
37
+ /** A P-256 signature entry. */
38
38
  export type P256 = {
39
39
  /** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
40
40
  payload?: Hex.Hex | undefined;
@@ -45,8 +45,8 @@ export type P256 = {
45
45
  } & ({
46
46
  /** Uncompressed P-256 public key. */
47
47
  publicKey: PublicKey.PublicKey;
48
- /** P-256 signature. */
49
- signature: Signature.Signature<false>;
48
+ /** P-256 signature or `Signature.toHex` bytes. */
49
+ signature: Hex.Hex | Signature.Signature<false>;
50
50
  } | {
51
51
  /** Public key, if already known. Empty wire signatures do not retain it. */
52
52
  publicKey?: PublicKey.PublicKey | undefined;
@@ -58,11 +58,11 @@ export type FrameSignature = Arbitrary | Secp256k1 | P256;
58
58
  /** JSON-RPC representation of a frame signature. */
59
59
  export type Rpc = {
60
60
  /** Explicit digest, or empty bytes for the transaction signing hash. */
61
- msg: Hex.Hex;
61
+ msg?: Hex.Hex | undefined;
62
62
  /** Signature verification scheme. */
63
- scheme: 0 | 1 | 2;
63
+ scheme: '0x0' | '0x1' | '0x2';
64
64
  /** Encoded signature bytes. */
65
- signature: Hex.Hex;
65
+ signature?: Hex.Hex | undefined;
66
66
  /** Signer address; absent for the transaction sender. */
67
67
  signer?: Address.Address | null | undefined;
68
68
  };
@@ -126,12 +126,13 @@ export declare namespace assert {
126
126
  */
127
127
  signed?: boolean | undefined;
128
128
  };
129
- type ErrorType = InvalidError | Address.assert.ErrorType | Hex.assert.ErrorType | Hex.toBigInt.ErrorType | PublicKey.assert.ErrorType | Signature.assert.ErrorType | Errors.GlobalErrorType;
129
+ type ErrorType = InvalidError | Address.assert.ErrorType | Hex.assert.ErrorType | Hex.toBigInt.ErrorType | PublicKey.assert.ErrorType | Signature.assert.ErrorType | Signature.fromHex.ErrorType | Errors.GlobalErrorType;
130
130
  }
131
131
  /**
132
132
  * Coerces a value into a {@link ox#FrameSignature.FrameSignature}.
133
133
  *
134
- * Accepts arbitrary signature bytes or a structured signature entry. Omitted
134
+ * Accepts arbitrary signature bytes or a signature entry. Protocol signatures accept
135
+ * structured objects or `Signature.toHex` bytes. P-256 entries still require a public key. Omitted
135
136
  * `scheme` and `payload` default to `'arbitrary'` and `'0x'`, respectively.
136
137
  * An empty payload selects the canonical transaction signing hash; an explicit
137
138
  * payload must be a nonzero 32-byte digest.
@@ -230,7 +231,7 @@ export declare namespace from {
230
231
  *
231
232
  * const entry = FrameSignature.fromRpc({
232
233
  * msg: '0x',
233
- * scheme: 0,
234
+ * scheme: '0x0',
234
235
  * signature: '0xdeadbeef'
235
236
  * })
236
237
  * ```
@@ -240,7 +241,7 @@ export declare namespace from {
240
241
  */
241
242
  export declare function fromRpc(entry: Rpc): FrameSignature;
242
243
  export declare namespace fromRpc {
243
- type ErrorType = fromTuple.ErrorType | Hex.fromNumber.ErrorType;
244
+ type ErrorType = fromTuple.ErrorType | Hex.fromNumber.ErrorType | Hex.toNumber.ErrorType;
244
245
  }
245
246
  /**
246
247
  * Converts a structured frame signature to its RPC representation.
@@ -1 +1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M,CAAC,SAAS,CAAA;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,cAAc,EACrB,OAAO,GAAE,MAAM,CAAC,OAAY,GAC3B,OAAO,CAOT;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC;AAED,mEAAmE;AACnE,qBAAa,YAAa,SAAQ,MAAM,CAAC,SAAS;IAChD,SAAkB,IAAI,iCAAgC;gBAC1C,OAAO,EAAE,MAAM;CAG5B"}
@@ -82,7 +82,7 @@ export type Type = typeof type;
82
82
  *
83
83
  * TxEnvelopeEip8141.assert({
84
84
  * chainId: 1,
85
- * frames: [{ gas: 50_000n, mode: 'verify' }],
85
+ * frames: [{ executionGas: 50_000n, mode: 'verify' }],
86
86
  * sender: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
87
87
  * })
88
88
  * ```
@@ -132,8 +132,8 @@ export declare namespace deserialize {
132
132
  * chainId: 1,
133
133
  * frames: [
134
134
  * {
135
+ * executionGas: 50_000n,
135
136
  * flags: 'approveExecutionAndPayment',
136
- * gas: 50_000n,
137
137
  * mode: 'verify'
138
138
  * }
139
139
  * ],
@@ -235,8 +235,8 @@ export declare namespace toRpc {
235
235
  * chainId: 1,
236
236
  * frames: [
237
237
  * {
238
+ * executionGas: 50_000n,
238
239
  * flags: 'approveExecutionAndPayment',
239
- * gas: 50_000n,
240
240
  * mode: 'verify'
241
241
  * }
242
242
  * ],
@@ -300,7 +300,7 @@ export declare namespace hash {
300
300
  *
301
301
  * const envelope = TxEnvelopeEip8141.from({
302
302
  * chainId: 1,
303
- * frames: [{ gas: 50_000n, mode: 'sender' }],
303
+ * frames: [{ executionGas: 50_000n, mode: 'sender' }],
304
304
  * sender: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
305
305
  * })
306
306
  * const serialized = TxEnvelopeEip8141.serialize(envelope)
package/_types/index.d.ts CHANGED
@@ -1533,13 +1533,13 @@ export * as Filter from './core/Filter.js';
1533
1533
  * import { Frame } from 'ox'
1534
1534
  *
1535
1535
  * const frame = Frame.from({
1536
+ * executionGas: 50_000n,
1536
1537
  * flags: 'approveExecutionAndPayment',
1537
- * gas: 50_000n,
1538
1538
  * mode: 'verify'
1539
1539
  * })
1540
1540
  * ```
1541
1541
  *
1542
- * @category Transaction Envelopes
1542
+ * @category Frames (EIP-8141)
1543
1543
  */
1544
1544
  export * as Frame from './core/Frame.js';
1545
1545
  /**
@@ -1547,7 +1547,7 @@ export * as Frame from './core/Frame.js';
1547
1547
  *
1548
1548
  * Frame receipts include execution gas, state gas, logs, and execution status.
1549
1549
  *
1550
- * @category Execution Spec
1550
+ * @category Frames (EIP-8141)
1551
1551
  */
1552
1552
  export * as FrameReceipt from './core/FrameReceipt.js';
1553
1553
  /**
@@ -1569,7 +1569,7 @@ export * as FrameReceipt from './core/FrameReceipt.js';
1569
1569
  * // @log: { payload: '0x', scheme: 'arbitrary', signature: '0xaabb' }
1570
1570
  * ```
1571
1571
  *
1572
- * @category Transaction Envelopes
1572
+ * @category Frames (EIP-8141)
1573
1573
  */
1574
1574
  export * as FrameSignature from './core/FrameSignature.js';
1575
1575
  /**
@@ -3299,7 +3299,7 @@ export * as TxEnvelopeEip7702 from './core/TxEnvelopeEip7702.js';
3299
3299
  *
3300
3300
  * const envelope = TxEnvelopeEip8141.from({
3301
3301
  * chainId: 1,
3302
- * frames: [{ gas: 50_000n, mode: 'sender' }],
3302
+ * frames: [{ executionGas: 50_000n, mode: 'sender' }],
3303
3303
  * sender: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
3304
3304
  * })
3305
3305
  * ```
@@ -1,3 +1,3 @@
1
1
  /** @internal */
2
- export declare const version = "0.14.47";
2
+ export declare const version = "0.14.49";
3
3
  //# sourceMappingURL=version.d.ts.map
package/core/Frame.ts CHANGED
@@ -11,16 +11,16 @@ export type Frame<bigintType = bigint> = {
11
11
  * @default '0x'
12
12
  */
13
13
  data?: Hex.Hex | undefined
14
+ /**
15
+ * Execution gas budget.
16
+ * @default 0n
17
+ */
18
+ executionGas?: bigintType | undefined
14
19
  /**
15
20
  * Approval scope and atomic batching bits.
16
21
  * @default 0
17
22
  */
18
23
  flags?: Flags | undefined
19
- /**
20
- * Execution gas budget.
21
- * @default 0n
22
- */
23
- gas?: bigintType | undefined
24
24
  /**
25
25
  * Execution context: default, verify, or sender.
26
26
  * @default 0
@@ -45,13 +45,13 @@ export type Rpc = {
45
45
  /** Frame calldata. */
46
46
  data: Hex.Hex
47
47
  /** Execution gas budget. */
48
- executionGasLimit: Hex.Hex
48
+ executionGas: Hex.Hex
49
49
  /** Approval scope and batching bits. */
50
- flags: number
50
+ flags: Hex.Hex
51
51
  /** Execution mode. */
52
- mode: number
52
+ mode: Hex.Hex
53
53
  /** State gas budget. */
54
- stateGasLimit: Hex.Hex
54
+ stateGas: Hex.Hex
55
55
  /** Target address; absent for the transaction sender. */
56
56
  target?: Address.Address | null | undefined
57
57
  /** Value transferred in wei. */
@@ -101,8 +101,8 @@ export type Tuple = readonly [
101
101
  * import { Frame } from 'ox'
102
102
  *
103
103
  * Frame.assert({
104
+ * executionGas: 50_000n,
104
105
  * flags: 'approveExecutionAndPayment',
105
- * gas: 50_000n,
106
106
  * mode: 'verify'
107
107
  * })
108
108
  * ```
@@ -112,8 +112,8 @@ export type Tuple = readonly [
112
112
  export function assert(frame: Frame): void {
113
113
  const {
114
114
  data = '0x',
115
+ executionGas = 0n,
115
116
  flags: flagsValue = 0,
116
- gas = 0n,
117
117
  mode: modeValue = 0,
118
118
  stateGas = 0n,
119
119
  value = 0n,
@@ -136,12 +136,12 @@ export function assert(frame: Frame): void {
136
136
  }
137
137
  if (frame.to !== undefined) Address.assert(frame.to, { strict: false })
138
138
  for (const [field, limit] of [
139
- ['gas', gas],
139
+ ['executionGas', executionGas],
140
140
  ['stateGas', stateGas],
141
141
  ] as const)
142
142
  if (typeof limit !== 'bigint' || limit < 0n || limit >= 2n ** 64n)
143
143
  throw new InvalidError(`${field} must be an unsigned 64-bit integer.`)
144
- if (gas + stateGas >= 2n ** 64n)
144
+ if (executionGas + stateGas >= 2n ** 64n)
145
145
  throw new InvalidError('Combined frame gas must be less than 2^64.')
146
146
  if (typeof value !== 'bigint' || value < 0n || value >= 2n ** 256n)
147
147
  throw new InvalidError('value must be an unsigned 256-bit integer.')
@@ -176,8 +176,8 @@ export declare namespace assert {
176
176
  * import { Frame } from 'ox'
177
177
  *
178
178
  * const frame = Frame.from({
179
+ * executionGas: 50_000n,
179
180
  * flags: 'approveExecutionAndPayment',
180
- * gas: 50_000n,
181
181
  * mode: 'verify'
182
182
  * })
183
183
  * ```
@@ -205,10 +205,10 @@ export declare namespace from {
205
205
  *
206
206
  * const frame = Frame.fromRpc({
207
207
  * data: '0x',
208
- * executionGasLimit: '0xc350',
209
- * flags: 3,
210
- * mode: 1,
211
- * stateGasLimit: '0x0',
208
+ * executionGas: '0xc350',
209
+ * flags: '0x3',
210
+ * mode: '0x1',
211
+ * stateGas: '0x0',
212
212
  * value: '0x0'
213
213
  * })
214
214
  * ```
@@ -219,17 +219,20 @@ export declare namespace from {
219
219
  export function fromRpc(frame: Rpc): Frame {
220
220
  return from({
221
221
  data: frame.data,
222
- flags: frame.flags,
223
- gas: Hex.toBigInt(frame.executionGasLimit),
224
- mode: frame.mode,
225
- stateGas: Hex.toBigInt(frame.stateGasLimit),
222
+ executionGas: Hex.toBigInt(frame.executionGas),
223
+ flags: Hex.toNumber(frame.flags),
224
+ mode: Hex.toNumber(frame.mode),
225
+ stateGas: Hex.toBigInt(frame.stateGas),
226
226
  ...(frame.target == null ? {} : { to: frame.target }),
227
227
  value: Hex.toBigInt(frame.value),
228
228
  })
229
229
  }
230
230
 
231
231
  export declare namespace fromRpc {
232
- type ErrorType = from.ErrorType | Hex.toBigInt.ErrorType
232
+ type ErrorType =
233
+ | from.ErrorType
234
+ | Hex.toBigInt.ErrorType
235
+ | Hex.toNumber.ErrorType
233
236
  }
234
237
 
235
238
  /**
@@ -241,7 +244,7 @@ export declare namespace fromRpc {
241
244
  * ```ts twoslash
242
245
  * import { Frame } from 'ox'
243
246
  *
244
- * const frame = Frame.from({ gas: 50_000n, mode: 'verify' })
247
+ * const frame = Frame.from({ executionGas: 50_000n, mode: 'verify' })
245
248
  * const rpc = Frame.toRpc(frame)
246
249
  * ```
247
250
  *
@@ -252,10 +255,10 @@ export function toRpc(frame: toRpc.Input): Rpc {
252
255
  const { flags: flags_ = 0, mode = 0 } = frame
253
256
  return {
254
257
  data: frame.data ?? '0x',
255
- executionGasLimit: Quantity.fromNumberish(frame.gas ?? 0n),
256
- flags: typeof flags_ === 'string' ? flags[flags_] : flags_,
257
- mode: typeof mode === 'string' ? modes[mode] : mode,
258
- stateGasLimit: Quantity.fromNumberish(frame.stateGas ?? 0n),
258
+ executionGas: Quantity.fromNumberish(frame.executionGas ?? 0n),
259
+ flags: Hex.fromNumber(typeof flags_ === 'string' ? flags[flags_] : flags_),
260
+ mode: Hex.fromNumber(typeof mode === 'string' ? modes[mode] : mode),
261
+ stateGas: Quantity.fromNumberish(frame.stateGas ?? 0n),
259
262
  ...(frame.to === undefined ? {} : { target: frame.to }),
260
263
  value: Quantity.fromNumberish(frame.value ?? 0n),
261
264
  }
@@ -290,8 +293,8 @@ export declare namespace toRpc {
290
293
  * ])
291
294
  * // @log: {
292
295
  * // @log: data: '0x',
296
+ * // @log: executionGas: 50000n,
293
297
  * // @log: flags: 3,
294
- * // @log: gas: 50000n,
295
298
  * // @log: mode: 1,
296
299
  * // @log: stateGas: 0n,
297
300
  * // @log: value: 0n
@@ -325,8 +328,8 @@ export function fromTuple(tuple: Tuple): Frame {
325
328
  const frame = {
326
329
  ...(target === '0x' ? {} : { to: target }),
327
330
  data,
331
+ executionGas: execution === '0x' ? 0n : Hex.toBigInt(execution),
328
332
  flags: flags === '0x' ? 0 : Hex.toNumber(flags),
329
- gas: execution === '0x' ? 0n : Hex.toBigInt(execution),
330
333
  mode: mode === '0x' ? 0 : Hex.toNumber(mode),
331
334
  stateGas: state === '0x' ? 0n : Hex.toBigInt(state),
332
335
  value: value === '0x' ? 0n : Hex.toBigInt(value),
@@ -358,8 +361,8 @@ export declare namespace fromTuple {
358
361
  * import { Frame } from 'ox'
359
362
  *
360
363
  * const tuple = Frame.toTuple({
364
+ * executionGas: 50_000n,
361
365
  * flags: 'approveExecutionAndPayment',
362
- * gas: 50_000n,
363
366
  * mode: 'verify'
364
367
  * })
365
368
  * // @log: ['0x01', '0x03', '0x', ['0xc350', '0x'], '0x', '0x']
@@ -379,7 +382,9 @@ export function toTuple(frame: Frame): Tuple {
379
382
  flags_ ? Hex.fromBytes(Bytes.fromNumber(flags_)) : '0x',
380
383
  frame.to ?? '0x',
381
384
  [
382
- frame.gas ? Hex.fromBytes(Bytes.fromNumber(frame.gas)) : '0x',
385
+ frame.executionGas
386
+ ? Hex.fromBytes(Bytes.fromNumber(frame.executionGas))
387
+ : '0x',
383
388
  frame.stateGas ? Hex.fromBytes(Bytes.fromNumber(frame.stateGas)) : '0x',
384
389
  ],
385
390
  frame.value ? Hex.fromBytes(Bytes.fromNumber(frame.value)) : '0x',
@@ -409,8 +414,8 @@ export declare namespace toTuple {
409
414
  * import { Frame } from 'ox'
410
415
  *
411
416
  * const valid = Frame.validate({
417
+ * executionGas: 50_000n,
412
418
  * flags: 'approveExecutionAndPayment',
413
- * gas: 50_000n,
414
419
  * mode: 'verify'
415
420
  * })
416
421
  * // @log: true
@@ -6,6 +6,8 @@ import type * as Log from './Log.js'
6
6
  /** Receipt for one frame. Frame logs contain only address, data, and topics. */
7
7
  export type FrameReceipt<bigintType = bigint> = {
8
8
  /** Execution gas used before transaction-level refunds. */
9
+ executionGasUsed: bigintType
10
+ /** Total execution and state gas used. */
9
11
  gasUsed: bigintType
10
12
  /** Logs emitted by this frame. */
11
13
  logs: readonly Pick<Log.Log, 'address' | 'data' | 'topics'>[]
@@ -17,6 +19,8 @@ export type FrameReceipt<bigintType = bigint> = {
17
19
 
18
20
  /** JSON-RPC receipt for one frame. */
19
21
  export type Rpc = {
22
+ /** Total execution and state gas used. */
23
+ gasUsed: Hex.Hex
20
24
  /** Execution gas used. */
21
25
  executionGasUsed: Hex.Hex
22
26
  /** Logs emitted by this frame. */
@@ -30,21 +34,21 @@ export type Rpc = {
30
34
  /** Frame execution status. */
31
35
  export type Status = 'reverted' | 'skipped' | 'success'
32
36
 
33
- /** Numeric JSON-RPC frame execution status. */
34
- export type RpcStatus = 0 | 1 | 2
37
+ /** Hex JSON-RPC frame execution status. */
38
+ export type RpcStatus = '0x0' | '0x1' | '0x2'
35
39
 
36
40
  /** RPC status to status mapping. */
37
41
  export const fromRpcStatus = {
38
- 0: 'reverted',
39
- 1: 'success',
40
- 2: 'skipped',
42
+ '0x0': 'reverted',
43
+ '0x1': 'success',
44
+ '0x2': 'skipped',
41
45
  } as const
42
46
 
43
47
  /** Status to RPC status mapping. */
44
48
  export const toRpcStatus = {
45
- reverted: 0,
46
- skipped: 2,
47
- success: 1,
49
+ reverted: '0x0',
50
+ skipped: '0x2',
51
+ success: '0x1',
48
52
  } as const
49
53
 
50
54
  /**
@@ -58,9 +62,10 @@ export const toRpcStatus = {
58
62
  *
59
63
  * const receipt = FrameReceipt.fromRpc({
60
64
  * executionGasUsed: '0x5208',
65
+ * gasUsed: '0x5208',
61
66
  * logs: [],
62
67
  * stateGasUsed: '0x0',
63
- * status: 1
68
+ * status: '0x1'
64
69
  * })
65
70
  * ```
66
71
  *
@@ -69,7 +74,8 @@ export const toRpcStatus = {
69
74
  */
70
75
  export function fromRpc(receipt: Rpc): FrameReceipt {
71
76
  return {
72
- gasUsed: Hex.toBigInt(receipt.executionGasUsed),
77
+ executionGasUsed: Hex.toBigInt(receipt.executionGasUsed),
78
+ gasUsed: Hex.toBigInt(receipt.gasUsed),
73
79
  logs: receipt.logs,
74
80
  stateGasUsed: Hex.toBigInt(receipt.stateGasUsed),
75
81
  status: fromRpcStatus[receipt.status],
@@ -91,19 +97,21 @@ export declare namespace fromRpc {
91
97
  *
92
98
  * const receipt = FrameReceipt.fromRpc({
93
99
  * executionGasUsed: '0x5208',
100
+ * gasUsed: '0x5208',
94
101
  * logs: [],
95
102
  * stateGasUsed: '0x0',
96
- * status: 1
103
+ * status: '0x1'
97
104
  * })
98
105
  * const rpc = FrameReceipt.toRpc(receipt)
99
106
  * ```
100
107
  *
101
108
  * @param receipt - The frame receipt. Gas accepts hex, bigint, or number values.
102
- * @returns The RPC frame receipt with hex gas and a numeric status.
109
+ * @returns The RPC frame receipt with hex gas and a hex status.
103
110
  */
104
111
  export function toRpc(receipt: toRpc.Input): Rpc {
105
112
  return {
106
- executionGasUsed: Quantity.fromNumberish(receipt.gasUsed),
113
+ executionGasUsed: Quantity.fromNumberish(receipt.executionGasUsed),
114
+ gasUsed: Quantity.fromNumberish(receipt.gasUsed),
107
115
  logs: receipt.logs,
108
116
  stateGasUsed: Quantity.fromNumberish(receipt.stateGasUsed),
109
117
  status: toRpcStatus[receipt.status],
@@ -26,19 +26,19 @@ export type Arbitrary = {
26
26
  signer?: undefined
27
27
  }
28
28
 
29
- /** A structured secp256k1 signature entry. */
29
+ /** A secp256k1 signature entry. */
30
30
  export type Secp256k1 = {
31
31
  /** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
32
32
  payload?: Hex.Hex | undefined
33
33
  /** secp256k1 verification scheme. */
34
34
  scheme: 1 | 'secp256k1'
35
- /** Recovered signature. Omit for an unsigned entry. */
36
- signature?: Signature.Signature | undefined
35
+ /** Recovered signature or `Signature.toHex` bytes. Omit for an unsigned entry. */
36
+ signature?: Hex.Hex | Signature.Signature | undefined
37
37
  /** Signer address. Omit to use the transaction sender. */
38
38
  signer?: Address.Address | undefined
39
39
  }
40
40
 
41
- /** A structured P-256 signature entry. */
41
+ /** A P-256 signature entry. */
42
42
  export type P256 = {
43
43
  /** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
44
44
  payload?: Hex.Hex | undefined
@@ -50,8 +50,8 @@ export type P256 = {
50
50
  | {
51
51
  /** Uncompressed P-256 public key. */
52
52
  publicKey: PublicKey.PublicKey
53
- /** P-256 signature. */
54
- signature: Signature.Signature<false>
53
+ /** P-256 signature or `Signature.toHex` bytes. */
54
+ signature: Hex.Hex | Signature.Signature<false>
55
55
  }
56
56
  | {
57
57
  /** Public key, if already known. Empty wire signatures do not retain it. */
@@ -67,11 +67,11 @@ export type FrameSignature = Arbitrary | Secp256k1 | P256
67
67
  /** JSON-RPC representation of a frame signature. */
68
68
  export type Rpc = {
69
69
  /** Explicit digest, or empty bytes for the transaction signing hash. */
70
- msg: Hex.Hex
70
+ msg?: Hex.Hex | undefined
71
71
  /** Signature verification scheme. */
72
- scheme: 0 | 1 | 2
72
+ scheme: '0x0' | '0x1' | '0x2'
73
73
  /** Encoded signature bytes. */
74
- signature: Hex.Hex
74
+ signature?: Hex.Hex | undefined
75
75
  /** Signer address; absent for the transaction sender. */
76
76
  signer?: Address.Address | null | undefined
77
77
  }
@@ -174,20 +174,23 @@ export function assert(
174
174
  if (options.signed) throw new InvalidError('Signature is required.')
175
175
  return
176
176
  }
177
- if (
178
- typeof entry.signature.r !== 'bigint' ||
179
- typeof entry.signature.s !== 'bigint'
180
- )
177
+ if (typeof entry.signature === 'string')
178
+ Hex.assert(entry.signature, { strict: true })
179
+ const signature =
180
+ typeof entry.signature === 'string'
181
+ ? Signature.fromHex(entry.signature)
182
+ : entry.signature
183
+ if (typeof signature.r !== 'bigint' || typeof signature.s !== 'bigint')
181
184
  throw new InvalidError('Signature scalars must be bigint.')
182
185
  if (
183
- (scheme === 1 || entry.signature.yParity !== undefined) &&
184
- entry.signature.yParity !== 0 &&
185
- entry.signature.yParity !== 1
186
+ (scheme === 1 || signature.yParity !== undefined) &&
187
+ signature.yParity !== 0 &&
188
+ signature.yParity !== 1
186
189
  )
187
190
  throw new InvalidError('Signature parity must be 0 or 1.')
188
- Signature.assert(entry.signature, { recovered: scheme === 1 })
189
- const r = entry.signature.r
190
- const s = entry.signature.s
191
+ Signature.assert(signature, { recovered: scheme === 1 })
192
+ const r = signature.r
193
+ const s = signature.s
191
194
  const order = scheme === 1 ? secp256k1N : p256N
192
195
  if (
193
196
  r === 0n ||
@@ -216,13 +219,15 @@ export declare namespace assert {
216
219
  | Hex.toBigInt.ErrorType
217
220
  | PublicKey.assert.ErrorType
218
221
  | Signature.assert.ErrorType
222
+ | Signature.fromHex.ErrorType
219
223
  | Errors.GlobalErrorType
220
224
  }
221
225
 
222
226
  /**
223
227
  * Coerces a value into a {@link ox#FrameSignature.FrameSignature}.
224
228
  *
225
- * Accepts arbitrary signature bytes or a structured signature entry. Omitted
229
+ * Accepts arbitrary signature bytes or a signature entry. Protocol signatures accept
230
+ * structured objects or `Signature.toHex` bytes. P-256 entries still require a public key. Omitted
226
231
  * `scheme` and `payload` default to `'arbitrary'` and `'0x'`, respectively.
227
232
  * An empty payload selects the canonical transaction signing hash; an explicit
228
233
  * payload must be a nonzero 32-byte digest.
@@ -346,7 +351,7 @@ export declare namespace from {
346
351
  *
347
352
  * const entry = FrameSignature.fromRpc({
348
353
  * msg: '0x',
349
- * scheme: 0,
354
+ * scheme: '0x0',
350
355
  * signature: '0xdeadbeef'
351
356
  * })
352
357
  * ```
@@ -356,15 +361,20 @@ export declare namespace from {
356
361
  */
357
362
  export function fromRpc(entry: Rpc): FrameSignature {
358
363
  return fromTuple([
359
- entry.scheme === 0 ? '0x' : Hex.fromNumber(entry.scheme, { size: 1 }),
364
+ entry.scheme === '0x0'
365
+ ? '0x'
366
+ : Hex.fromNumber(Hex.toNumber(entry.scheme), { size: 1 }),
360
367
  entry.signer ?? '0x',
361
- entry.msg,
362
- entry.signature,
368
+ entry.msg ?? '0x',
369
+ entry.signature ?? '0x',
363
370
  ])
364
371
  }
365
372
 
366
373
  export declare namespace fromRpc {
367
- type ErrorType = fromTuple.ErrorType | Hex.fromNumber.ErrorType
374
+ type ErrorType =
375
+ | fromTuple.ErrorType
376
+ | Hex.fromNumber.ErrorType
377
+ | Hex.toNumber.ErrorType
368
378
  }
369
379
 
370
380
  /**
@@ -387,8 +397,10 @@ export function toRpc(entry: FrameSignature): Rpc {
387
397
  const [scheme, signer, msg, signature] = toTuple(entry)
388
398
  return {
389
399
  msg,
390
- scheme: (scheme === '0x' ? 0 : Hex.toNumber(scheme)) as Rpc['scheme'],
391
- signature,
400
+ scheme: (scheme === '0x'
401
+ ? '0x0'
402
+ : Hex.fromNumber(Hex.toNumber(scheme))) as Rpc['scheme'],
403
+ ...(signature === '0x' && scheme !== '0x' ? {} : { signature }),
392
404
  ...(signer === '0x' ? {} : { signer }),
393
405
  }
394
406
  }
@@ -518,18 +530,26 @@ export function toTuple(entry: FrameSignature): Tuple {
518
530
  case 'arbitrary':
519
531
  return entry.signature
520
532
  case 1:
521
- case 'secp256k1':
522
- return entry.signature === undefined
523
- ? '0x'
524
- : Hex.concat(
525
- Hex.fromNumber(entry.signature.yParity, { size: 1 }),
526
- Hex.fromNumber(entry.signature.r, { size: 32 }),
527
- Hex.fromNumber(entry.signature.s, { size: 32 }),
528
- )
533
+ case 'secp256k1': {
534
+ if (entry.signature === undefined) return '0x'
535
+ const signature =
536
+ typeof entry.signature === 'string'
537
+ ? Signature.fromHex(entry.signature)
538
+ : entry.signature
539
+ return Hex.concat(
540
+ Hex.fromNumber(signature.yParity, { size: 1 }),
541
+ Hex.fromNumber(signature.r, { size: 32 }),
542
+ Hex.fromNumber(signature.s, { size: 32 }),
543
+ )
544
+ }
529
545
  case 2:
530
546
  case 'p256': {
531
547
  if (entry.signature === undefined) return '0x'
532
- const { publicKey, signature } = entry
548
+ const { publicKey } = entry
549
+ const signature =
550
+ typeof entry.signature === 'string'
551
+ ? Signature.fromHex(entry.signature)
552
+ : entry.signature
533
553
  const s = signature.s
534
554
  return Hex.concat(
535
555
  Hex.fromNumber(signature.r, { size: 32 }),