ox 1.8.1 → 1.8.3

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.
Files changed (134) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/core/Frame.d.ts +23 -20
  3. package/dist/core/Frame.d.ts.map +1 -1
  4. package/dist/core/Frame.js +28 -23
  5. package/dist/core/Frame.js.map +1 -1
  6. package/dist/core/FrameReceipt.d.ts +23 -14
  7. package/dist/core/FrameReceipt.d.ts.map +1 -1
  8. package/dist/core/FrameReceipt.js +15 -11
  9. package/dist/core/FrameReceipt.js.map +1 -1
  10. package/dist/core/FrameRequest.d.ts +50 -0
  11. package/dist/core/FrameRequest.d.ts.map +1 -0
  12. package/dist/core/FrameRequest.js +59 -0
  13. package/dist/core/FrameRequest.js.map +1 -0
  14. package/dist/core/FrameSignature.d.ts +17 -16
  15. package/dist/core/FrameSignature.d.ts.map +1 -1
  16. package/dist/core/FrameSignature.js +38 -21
  17. package/dist/core/FrameSignature.js.map +1 -1
  18. package/dist/core/Siwe.d.ts.map +1 -1
  19. package/dist/core/Siwe.js +3 -3
  20. package/dist/core/Siwe.js.map +1 -1
  21. package/dist/core/Transaction.d.ts +2 -2
  22. package/dist/core/Transaction.d.ts.map +1 -1
  23. package/dist/core/Transaction.js.map +1 -1
  24. package/dist/core/TransactionRequest.d.ts +5 -5
  25. package/dist/core/TransactionRequest.d.ts.map +1 -1
  26. package/dist/core/TransactionRequest.js +3 -3
  27. package/dist/core/TransactionRequest.js.map +1 -1
  28. package/dist/core/TxEnvelope.d.ts +3 -1
  29. package/dist/core/TxEnvelope.d.ts.map +1 -1
  30. package/dist/core/TxEnvelope.js +9 -1
  31. package/dist/core/TxEnvelope.js.map +1 -1
  32. package/dist/core/TxEnvelopeEip8141.d.ts +4 -4
  33. package/dist/core/TxEnvelopeEip8141.js +8 -8
  34. package/dist/core/TxEnvelopeEip8141.js.map +1 -1
  35. package/dist/core/internal/rpcSchemas/eth.d.ts +16 -4
  36. package/dist/core/internal/rpcSchemas/eth.d.ts.map +1 -1
  37. package/dist/index.d.ts +21 -5
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +21 -5
  40. package/dist/index.js.map +1 -1
  41. package/dist/zod/Block.d.ts +49 -37
  42. package/dist/zod/Block.d.ts.map +1 -1
  43. package/dist/zod/Frame.d.ts +14 -14
  44. package/dist/zod/Frame.js +5 -5
  45. package/dist/zod/Frame.js.map +1 -1
  46. package/dist/zod/FrameReceipt.d.ts +42 -2
  47. package/dist/zod/FrameReceipt.d.ts.map +1 -1
  48. package/dist/zod/FrameReceipt.js +11 -1
  49. package/dist/zod/FrameReceipt.js.map +1 -1
  50. package/dist/zod/FrameRequest.d.ts +40 -0
  51. package/dist/zod/FrameRequest.d.ts.map +1 -0
  52. package/dist/zod/FrameRequest.js +37 -0
  53. package/dist/zod/FrameRequest.js.map +1 -0
  54. package/dist/zod/FrameSignature.d.ts +21 -13
  55. package/dist/zod/FrameSignature.d.ts.map +1 -1
  56. package/dist/zod/FrameSignature.js +10 -7
  57. package/dist/zod/FrameSignature.js.map +1 -1
  58. package/dist/zod/RpcSchema.d.ts +447 -265
  59. package/dist/zod/RpcSchema.d.ts.map +1 -1
  60. package/dist/zod/Transaction.d.ts +98 -74
  61. package/dist/zod/Transaction.d.ts.map +1 -1
  62. package/dist/zod/Transaction.js +4 -4
  63. package/dist/zod/Transaction.js.map +1 -1
  64. package/dist/zod/TransactionEnvelope.d.ts +50 -34
  65. package/dist/zod/TransactionEnvelope.d.ts.map +1 -1
  66. package/dist/zod/TransactionReceipt.d.ts +42 -2
  67. package/dist/zod/TransactionReceipt.d.ts.map +1 -1
  68. package/dist/zod/TransactionRequest.d.ts +29 -21
  69. package/dist/zod/TransactionRequest.d.ts.map +1 -1
  70. package/dist/zod/TransactionRequest.js +3 -3
  71. package/dist/zod/TransactionRequest.js.map +1 -1
  72. package/dist/zod/TxEnvelopeEip8141.d.ts +37 -25
  73. package/dist/zod/TxEnvelopeEip8141.d.ts.map +1 -1
  74. package/dist/zod/internal/rpcSchemas/Eth.d.ts +449 -267
  75. package/dist/zod/internal/rpcSchemas/Eth.d.ts.map +1 -1
  76. package/dist/zod/internal/rpcSchemas/Eth.js +9 -0
  77. package/dist/zod/internal/rpcSchemas/Eth.js.map +1 -1
  78. package/dist/zod/internal/rpcSchemas/Wallet.d.ts +49 -21
  79. package/dist/zod/internal/rpcSchemas/Wallet.d.ts.map +1 -1
  80. package/dist/zod/tempo/RpcSchemaTempo.d.ts +64 -48
  81. package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
  82. package/dist/zod/tempo/Transaction.d.ts +49 -37
  83. package/dist/zod/tempo/Transaction.d.ts.map +1 -1
  84. package/dist/zod/z.d.ts +1 -0
  85. package/dist/zod/z.d.ts.map +1 -1
  86. package/dist/zod/z.js +1 -0
  87. package/dist/zod/z.js.map +1 -1
  88. package/package.json +11 -1
  89. package/src/core/Frame.ts +41 -33
  90. package/src/core/FrameReceipt.ts +30 -16
  91. package/src/core/FrameRequest.ts +78 -0
  92. package/src/core/FrameSignature.ts +64 -34
  93. package/src/core/Siwe.ts +21 -13
  94. package/src/core/Transaction.ts +35 -24
  95. package/src/core/TransactionRequest.ts +9 -7
  96. package/src/core/TxEnvelope.ts +9 -1
  97. package/src/core/TxEnvelopeEip8141.ts +8 -8
  98. package/src/core/_test/AbiConstructor.test.ts +2 -0
  99. package/src/core/_test/Frame.test-d.ts +16 -7
  100. package/src/core/_test/Frame.test.ts +52 -24
  101. package/src/core/_test/FrameReceipt.test.ts +15 -9
  102. package/src/core/_test/FrameRequest.test-d.ts +16 -0
  103. package/src/core/_test/FrameRequest.test.ts +41 -0
  104. package/src/core/_test/FrameRpc.test.ts +131 -0
  105. package/src/core/_test/FrameSignature.test-d.ts +20 -0
  106. package/src/core/_test/FrameSignature.test.ts +132 -11
  107. package/src/core/_test/RpcSchema.test-d.ts +45 -0
  108. package/src/core/_test/Siwe.test.ts +147 -0
  109. package/src/core/_test/TransactionEnvelope.test.ts +1 -1
  110. package/src/core/_test/TransactionReceipt.test.ts +32 -6
  111. package/src/core/_test/TransactionRequest.test-d.ts +10 -1
  112. package/src/core/_test/TransactionRequest.test.ts +3 -2
  113. package/src/core/_test/TxEnvelopeEip8141.test-d.ts +2 -2
  114. package/src/core/_test/TxEnvelopeEip8141.test.ts +92 -53
  115. package/src/core/_test/index.test.ts +1 -0
  116. package/src/core/internal/rpcSchemas/eth.ts +13 -4
  117. package/src/index.ts +22 -5
  118. package/src/version.ts +1 -1
  119. package/src/zod/Frame.ts +5 -5
  120. package/src/zod/FrameReceipt.ts +11 -1
  121. package/src/zod/FrameRequest.ts +46 -0
  122. package/src/zod/FrameSignature.ts +10 -7
  123. package/src/zod/Transaction.ts +4 -4
  124. package/src/zod/TransactionRequest.ts +3 -3
  125. package/src/zod/_test/Frame.test.ts +13 -11
  126. package/src/zod/_test/FrameReceipt.test.ts +11 -4
  127. package/src/zod/_test/FrameRequest.test-d.ts +15 -0
  128. package/src/zod/_test/FrameRequest.test.ts +44 -0
  129. package/src/zod/_test/FrameSignature.test.ts +73 -9
  130. package/src/zod/_test/RpcSchema.test.ts +106 -0
  131. package/src/zod/_test/TransactionRequest.test.ts +61 -0
  132. package/src/zod/_test/TxEnvelopeEip8141.test.ts +3 -3
  133. package/src/zod/internal/rpcSchemas/Eth.ts +20 -0
  134. package/src/zod/z.ts +1 -0
@@ -214,3 +214,48 @@ test('eth_call accepts a 4-tuple with state + block overrides', () => {
214
214
  ]
215
215
  >().toExtend<Params>()
216
216
  })
217
+
218
+ test('frame fill responses do not require raw bytes or lookup metadata', () => {
219
+ type Filled = Extract<
220
+ RpcSchema.Eth,
221
+ { Request: { method: 'eth_fillTransaction' } }
222
+ >['ReturnType']
223
+ const filled = {
224
+ tx: {
225
+ type: '0x6',
226
+ chainId: '0x1',
227
+ nonce: '0x0',
228
+ from: '0x1111111111111111111111111111111111111111',
229
+ frames: [
230
+ {
231
+ mode: '0x2',
232
+ flags: '0x0',
233
+ executionGas: '0x10000',
234
+ stateGas: '0x0',
235
+ value: '0x0',
236
+ data: '0x',
237
+ },
238
+ ],
239
+ signatures: [{ scheme: '0x1' }],
240
+ maxFeePerGas: '0x2',
241
+ maxPriorityFeePerGas: '0x1',
242
+ maxFeePerBlobGas: '0x0',
243
+ blobVersionedHashes: [],
244
+ },
245
+ } as const satisfies Filled
246
+ expectTypeOf(filled).toExtend<Filled>()
247
+ })
248
+
249
+ test('frame simulation results expose payer and frame results', () => {
250
+ type Result = Extract<
251
+ RpcSchema.Eth,
252
+ { Request: { method: 'eth_simulateV1' } }
253
+ >['ReturnType'][number]
254
+ type Call = NonNullable<Result['calls']>[number]
255
+ expectTypeOf<Call['payer']>().toEqualTypeOf<`0x${string}` | undefined>()
256
+ type Frame = NonNullable<Call['frameResults']>[number]
257
+ expectTypeOf<Frame['status']>().toEqualTypeOf<'0x0' | '0x1' | '0x2'>()
258
+ expectTypeOf<Frame['executionGasUsed']>().toEqualTypeOf<`0x${string}`>()
259
+ expectTypeOf<Frame['stateGasUsed']>().toEqualTypeOf<`0x${string}`>()
260
+ expectTypeOf<Frame['returnData']>().toEqualTypeOf<`0x${string}`>()
261
+ })
@@ -773,6 +773,153 @@ Resources:
773
773
  `)
774
774
  })
775
775
 
776
+ test('behavior: "Resources:" in statement', () => {
777
+ const message = `example.com wants you to sign in with your Ethereum account:
778
+ 0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
779
+
780
+ See the Resources: list below.
781
+
782
+ URI: https://example.com/path
783
+ Version: 1
784
+ Chain ID: 1
785
+ Nonce: foobarbaz
786
+ Issued At: 2023-02-01T00:00:00.000Z
787
+ Resources:
788
+ - https://example.com/foo
789
+ - https://example.com/bar`
790
+ const parsed = Siwe.parseMessage(message)
791
+ expect(parsed).toMatchInlineSnapshot(`
792
+ {
793
+ "address": "0xA0Cf798816D4b9b9866b5330EEa46a18382f251e",
794
+ "chainId": 1,
795
+ "domain": "example.com",
796
+ "issuedAt": 2023-02-01T00:00:00.000Z,
797
+ "nonce": "foobarbaz",
798
+ "resources": [
799
+ "https://example.com/foo",
800
+ "https://example.com/bar",
801
+ ],
802
+ "statement": "See the Resources: list below.",
803
+ "uri": "https://example.com/path",
804
+ "version": "1",
805
+ }
806
+ `)
807
+ })
808
+
809
+ test('behavior: "Resources:" in statement without resources', () => {
810
+ const message = `example.com wants you to sign in with your Ethereum account:
811
+ 0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
812
+
813
+ See the Resources: page.
814
+
815
+ URI: https://example.com/path
816
+ Version: 1
817
+ Chain ID: 1
818
+ Nonce: foobarbaz
819
+ Issued At: 2023-02-01T00:00:00.000Z`
820
+ const parsed = Siwe.parseMessage(message)
821
+ expect(parsed.resources).toBeUndefined()
822
+ })
823
+
824
+ test('behavior: "Resources:" in uri', () => {
825
+ const message = `example.com wants you to sign in with your Ethereum account:
826
+ 0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
827
+
828
+
829
+ URI: https://example.com/Resources:path
830
+ Version: 1
831
+ Chain ID: 1
832
+ Nonce: foobarbaz
833
+ Issued At: 2023-02-01T00:00:00.000Z
834
+ Resources:
835
+ - https://example.com/foo`
836
+ const parsed = Siwe.parseMessage(message)
837
+ expect(parsed.resources).toMatchInlineSnapshot(`
838
+ [
839
+ "https://example.com/foo",
840
+ ]
841
+ `)
842
+ })
843
+
844
+ test('behavior: "Resources:" in requestId', () => {
845
+ const message = `example.com wants you to sign in with your Ethereum account:
846
+ 0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
847
+
848
+
849
+ URI: https://example.com/path
850
+ Version: 1
851
+ Chain ID: 1
852
+ Nonce: foobarbaz
853
+ Issued At: 2023-02-01T00:00:00.000Z
854
+ Request ID: Resources:123
855
+ Resources:
856
+ - https://example.com/foo`
857
+ const parsed = Siwe.parseMessage(message)
858
+ expect(parsed.resources).toMatchInlineSnapshot(`
859
+ [
860
+ "https://example.com/foo",
861
+ ]
862
+ `)
863
+ })
864
+
865
+ test('behavior: "Resources:" in a resource', () => {
866
+ const message = `example.com wants you to sign in with your Ethereum account:
867
+ 0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
868
+
869
+
870
+ URI: https://example.com/path
871
+ Version: 1
872
+ Chain ID: 1
873
+ Nonce: foobarbaz
874
+ Issued At: 2023-02-01T00:00:00.000Z
875
+ Resources:
876
+ - https://example.com/Resources:foo
877
+ - https://example.com/bar`
878
+ const parsed = Siwe.parseMessage(message)
879
+ expect(parsed.resources).toMatchInlineSnapshot(`
880
+ [
881
+ "https://example.com/Resources:foo",
882
+ "https://example.com/bar",
883
+ ]
884
+ `)
885
+ })
886
+
887
+ test('behavior: empty requestId with resources', () => {
888
+ // EIP-4361 allows an empty Request ID (`request-id = *pchar`).
889
+ const message = `example.com wants you to sign in with your Ethereum account:
890
+ 0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
891
+
892
+
893
+ URI: https://example.com/path
894
+ Version: 1
895
+ Chain ID: 1
896
+ Nonce: foobarbaz
897
+ Issued At: 2023-02-01T00:00:00.000Z
898
+ Request ID: \nResources:
899
+ - https://example.com/foo`
900
+ const parsed = Siwe.parseMessage(message)
901
+ expect(parsed.resources).toMatchInlineSnapshot(`
902
+ [
903
+ "https://example.com/foo",
904
+ ]
905
+ `)
906
+ })
907
+
908
+ test('behavior: empty resources', () => {
909
+ const message = Siwe.createMessage({
910
+ address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
911
+ chainId: 1,
912
+ domain: 'example.com',
913
+ issuedAt: new Date('2023-02-01T00:00:00.000Z'),
914
+ nonce: 'foobarbaz',
915
+ resources: [],
916
+ statement: 'Resources:',
917
+ uri: 'https://example.com/path',
918
+ version: '1',
919
+ })
920
+ expect(Siwe.parseMessage(message).resources).toMatchInlineSnapshot('[]')
921
+ })
922
+
776
923
  test('behavior: no suffix', () => {
777
924
  const message = `https://example.com wants you to sign in with your Ethereum account:
778
925
  0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
@@ -434,7 +434,7 @@ describe('toTransactionRequest', () => {
434
434
  test('maps frame sender to request from', () => {
435
435
  expect(TransactionEnvelope.toTransactionRequest(eip8141)).toEqual({
436
436
  chainId: 1,
437
- frames: [{}],
437
+ frames: [{ executionGas: 0n, stateGas: 0n }],
438
438
  from: '0x1111111111111111111111111111111111111111',
439
439
  type: 'eip8141',
440
440
  })
@@ -469,6 +469,7 @@ describe('frame receipts', () => {
469
469
  frameReceipts: [
470
470
  {
471
471
  executionGasUsed: '0x20000000000001',
472
+ gasUsed: '0x20000000000003',
472
473
  logs: [
473
474
  {
474
475
  address: '0x1111111111111111111111111111111111111111',
@@ -477,10 +478,22 @@ describe('frame receipts', () => {
477
478
  },
478
479
  ],
479
480
  stateGasUsed: '0x2',
480
- status: 1,
481
+ status: '0x1',
482
+ },
483
+ {
484
+ executionGasUsed: '0x3',
485
+ gasUsed: '0x3',
486
+ logs: [],
487
+ stateGasUsed: '0x0',
488
+ status: '0x0',
489
+ },
490
+ {
491
+ executionGasUsed: '0x0',
492
+ gasUsed: '0x0',
493
+ logs: [],
494
+ stateGasUsed: '0x0',
495
+ status: '0x2',
481
496
  },
482
- { executionGasUsed: '0x3', logs: [], stateGasUsed: '0x0', status: 0 },
483
- { executionGasUsed: '0x0', logs: [], stateGasUsed: '0x0', status: 2 },
484
497
  ],
485
498
  from: '0x1111111111111111111111111111111111111111',
486
499
  gasUsed: '0x20000000000001',
@@ -498,13 +511,26 @@ describe('frame receipts', () => {
498
511
  expect(receipt.payer).toBe(rpc.payer)
499
512
  expect(receipt.frameReceipts).toEqual([
500
513
  {
501
- gasUsed: 9007199254740993n,
514
+ executionGasUsed: 9007199254740993n,
515
+ gasUsed: 9007199254740995n,
502
516
  logs: rpc.frameReceipts[0]!.logs,
503
517
  stateGasUsed: 2n,
504
518
  status: 'success',
505
519
  },
506
- { gasUsed: 3n, logs: [], stateGasUsed: 0n, status: 'reverted' },
507
- { gasUsed: 0n, logs: [], stateGasUsed: 0n, status: 'skipped' },
520
+ {
521
+ executionGasUsed: 3n,
522
+ gasUsed: 3n,
523
+ logs: [],
524
+ stateGasUsed: 0n,
525
+ status: 'reverted',
526
+ },
527
+ {
528
+ executionGasUsed: 0n,
529
+ gasUsed: 0n,
530
+ logs: [],
531
+ stateGasUsed: 0n,
532
+ status: 'skipped',
533
+ },
508
534
  ])
509
535
  expect(TransactionReceipt.toRpc(receipt)).toMatchObject(rpc)
510
536
  expect(
@@ -139,7 +139,16 @@ describe('frame generics', () => {
139
139
 
140
140
  test('RPC types', () => {
141
141
  expectTypeOf<TransactionRequest.Rpc['frames']>().toEqualTypeOf<
142
- readonly Frame.Rpc[] | undefined
142
+ | readonly {
143
+ mode: `0x${string}`
144
+ flags?: `0x${string}` | undefined
145
+ data?: `0x${string}` | undefined
146
+ executionGas?: `0x${string}` | undefined
147
+ stateGas?: `0x${string}` | undefined
148
+ target?: `0x${string}` | null | undefined
149
+ value?: `0x${string}` | undefined
150
+ }[]
151
+ | undefined
143
152
  >()
144
153
  expectTypeOf<TransactionRequest.Rpc['signatures']>().toEqualTypeOf<
145
154
  readonly FrameSignature.Rpc[] | undefined
@@ -466,7 +466,7 @@ describe('frame transactions', () => {
466
466
  test('round-trips frame requests and envelopes', () => {
467
467
  const envelope = TxEnvelopeEip8141.from({
468
468
  chainId: 8141,
469
- frames: [Frame.from({ gas: 50_000n, mode: 'verify' })],
469
+ frames: [Frame.from({ executionGas: 50_000n, mode: 'verify' })],
470
470
  sender: '0x1111111111111111111111111111111111111111',
471
471
  signatures: [FrameSignature.from('0xaabb')],
472
472
  })
@@ -474,8 +474,9 @@ describe('frame transactions', () => {
474
474
  const rpc = TransactionRequest.toRpc(request)
475
475
  expect(rpc.chainId).toBe('0x1fcd')
476
476
  expect(rpc.type).toBe('0x6')
477
+ expect(rpc.frames?.[0]?.executionGas).toBe('0xc350')
477
478
  expect(rpc.signatures).toEqual([
478
- { msg: '0x', scheme: 0, signature: '0xaabb' },
479
+ { msg: '0x', scheme: '0x0', signature: '0xaabb' },
479
480
  ])
480
481
  const decoded = TransactionRequest.fromRpc(rpc)
481
482
  expect(decoded.chainId).toBe(8141)
@@ -4,12 +4,12 @@ import { expectTypeOf, test } from 'vp/test'
4
4
  test('default', () => {
5
5
  const envelope = TxEnvelopeEip8141.from({
6
6
  chainId: 1,
7
- frames: [{ gas: 50000n }],
7
+ frames: [{ executionGas: 50000n }],
8
8
  sender: '0x1111111111111111111111111111111111111111',
9
9
  })
10
10
  expectTypeOf(envelope).toEqualTypeOf<{
11
11
  readonly chainId: 1
12
- readonly frames: readonly [{ readonly gas: 50000n }]
12
+ readonly frames: readonly [{ readonly executionGas: 50000n }]
13
13
  readonly sender: '0x1111111111111111111111111111111111111111'
14
14
  readonly type: 'eip8141'
15
15
  }>()