ox 0.13.2 → 0.14.0

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 (61) hide show
  1. package/Bech32m/package.json +6 -0
  2. package/CHANGELOG.md +19 -0
  3. package/_cjs/core/Bech32m.js +205 -0
  4. package/_cjs/core/Bech32m.js.map +1 -0
  5. package/_cjs/index.js +3 -2
  6. package/_cjs/index.js.map +1 -1
  7. package/_cjs/tempo/KeyAuthorization.js +4 -4
  8. package/_cjs/tempo/KeyAuthorization.js.map +1 -1
  9. package/_cjs/tempo/SignatureEnvelope.js +18 -3
  10. package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
  11. package/_cjs/tempo/TempoAddress.js +40 -39
  12. package/_cjs/tempo/TempoAddress.js.map +1 -1
  13. package/_cjs/tempo/TxEnvelopeTempo.js +5 -2
  14. package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
  15. package/_cjs/tempo/index.js.map +1 -1
  16. package/_cjs/version.js +1 -1
  17. package/_esm/core/Bech32m.js +238 -0
  18. package/_esm/core/Bech32m.js.map +1 -0
  19. package/_esm/index.js +24 -0
  20. package/_esm/index.js.map +1 -1
  21. package/_esm/tempo/KeyAuthorization.js +19 -9
  22. package/_esm/tempo/KeyAuthorization.js.map +1 -1
  23. package/_esm/tempo/SignatureEnvelope.js +22 -5
  24. package/_esm/tempo/SignatureEnvelope.js.map +1 -1
  25. package/_esm/tempo/TempoAddress.js +47 -46
  26. package/_esm/tempo/TempoAddress.js.map +1 -1
  27. package/_esm/tempo/TxEnvelopeTempo.js +42 -2
  28. package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
  29. package/_esm/tempo/index.js +2 -2
  30. package/_esm/tempo/index.js.map +1 -1
  31. package/_esm/version.js +1 -1
  32. package/_types/core/Bech32m.d.ts +93 -0
  33. package/_types/core/Bech32m.d.ts.map +1 -0
  34. package/_types/index.d.ts +24 -0
  35. package/_types/index.d.ts.map +1 -1
  36. package/_types/tempo/KeyAuthorization.d.ts +17 -7
  37. package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
  38. package/_types/tempo/SignatureEnvelope.d.ts +19 -5
  39. package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
  40. package/_types/tempo/TempoAddress.d.ts +19 -11
  41. package/_types/tempo/TempoAddress.d.ts.map +1 -1
  42. package/_types/tempo/TxEnvelopeTempo.d.ts +47 -1
  43. package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
  44. package/_types/tempo/index.d.ts +2 -2
  45. package/_types/tempo/index.d.ts.map +1 -1
  46. package/_types/version.d.ts +1 -1
  47. package/core/Bech32m.ts +263 -0
  48. package/index.ts +24 -2
  49. package/package.json +6 -1
  50. package/tempo/KeyAuthorization.test.ts +70 -23
  51. package/tempo/KeyAuthorization.ts +21 -18
  52. package/tempo/SignatureEnvelope.test.ts +15 -8
  53. package/tempo/SignatureEnvelope.ts +43 -8
  54. package/tempo/TempoAddress.test.ts +49 -14
  55. package/tempo/TempoAddress.ts +56 -59
  56. package/tempo/Transaction.test.ts +4 -2
  57. package/tempo/TxEnvelopeTempo.test.ts +7 -3
  58. package/tempo/TxEnvelopeTempo.ts +52 -1
  59. package/tempo/e2e.test.ts +45 -10
  60. package/tempo/index.ts +6 -2
  61. package/version.ts +1 -1
@@ -56,6 +56,7 @@ describe('from', () => {
56
56
  test('default', () => {
57
57
  const authorization = KeyAuthorization.from({
58
58
  address,
59
+ chainId: 1n,
59
60
  expiry,
60
61
  type: 'secp256k1',
61
62
  limits: [
@@ -69,6 +70,7 @@ describe('from', () => {
69
70
  expect(authorization).toMatchInlineSnapshot(`
70
71
  {
71
72
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
73
+ "chainId": 1n,
72
74
  "expiry": 1234567890,
73
75
  "limits": [
74
76
  {
@@ -85,6 +87,7 @@ describe('from', () => {
85
87
  const authorization = KeyAuthorization.from(
86
88
  {
87
89
  address,
90
+ chainId: 1n,
88
91
  expiry,
89
92
  type: 'secp256k1',
90
93
  limits: [
@@ -102,6 +105,7 @@ describe('from', () => {
102
105
  expect(authorization).toMatchInlineSnapshot(`
103
106
  {
104
107
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
108
+ "chainId": 1n,
105
109
  "expiry": 1234567890,
106
110
  "limits": [
107
111
  {
@@ -126,6 +130,7 @@ describe('from', () => {
126
130
  const authorization = KeyAuthorization.from(
127
131
  {
128
132
  address,
133
+ chainId: 1n,
129
134
  expiry,
130
135
  type: 'secp256k1',
131
136
  limits: [
@@ -143,6 +148,7 @@ describe('from', () => {
143
148
  expect(authorization).toMatchInlineSnapshot(`
144
149
  {
145
150
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
151
+ "chainId": 1n,
146
152
  "expiry": 1234567890,
147
153
  "limits": [
148
154
  {
@@ -167,6 +173,7 @@ describe('from', () => {
167
173
  const authorization = KeyAuthorization.from(
168
174
  {
169
175
  address,
176
+ chainId: 1n,
170
177
  expiry,
171
178
  type: 'p256',
172
179
  limits: [
@@ -184,6 +191,7 @@ describe('from', () => {
184
191
  expect(authorization).toMatchInlineSnapshot(`
185
192
  {
186
193
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
194
+ "chainId": 1n,
187
195
  "expiry": 1234567890,
188
196
  "limits": [
189
197
  {
@@ -214,6 +222,7 @@ describe('from', () => {
214
222
  const authorization = KeyAuthorization.from(
215
223
  {
216
224
  address,
225
+ chainId: 1n,
217
226
  expiry,
218
227
  type: 'webAuthn',
219
228
  limits: [
@@ -231,6 +240,7 @@ describe('from', () => {
231
240
  expect(authorization).toMatchInlineSnapshot(`
232
241
  {
233
242
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
243
+ "chainId": 1n,
234
244
  "expiry": 1234567890,
235
245
  "limits": [
236
246
  {
@@ -263,6 +273,7 @@ describe('from', () => {
263
273
  test('with inline signature (secp256k1)', () => {
264
274
  const authorization = KeyAuthorization.from({
265
275
  address,
276
+ chainId: 1n,
266
277
  expiry,
267
278
  type: 'secp256k1',
268
279
  limits: [
@@ -277,6 +288,7 @@ describe('from', () => {
277
288
  expect(authorization).toMatchInlineSnapshot(`
278
289
  {
279
290
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
291
+ "chainId": 1n,
280
292
  "expiry": 1234567890,
281
293
  "limits": [
282
294
  {
@@ -301,6 +313,7 @@ describe('from', () => {
301
313
  const authorization = KeyAuthorization.from({
302
314
  expiry: Hex.fromNumber(expiry),
303
315
  keyId: address,
316
+ chainId: '0x1',
304
317
  keyType: 'secp256k1',
305
318
  limits: [{ token, limit: '0x989680' }],
306
319
  signature: {
@@ -314,7 +327,7 @@ describe('from', () => {
314
327
  expect(authorization).toMatchInlineSnapshot(`
315
328
  {
316
329
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
317
- "chainId": 0n,
330
+ "chainId": 1n,
318
331
  "expiry": 1234567890,
319
332
  "limits": [
320
333
  {
@@ -338,6 +351,7 @@ describe('from', () => {
338
351
  test('multiple limits', () => {
339
352
  const authorization = KeyAuthorization.from({
340
353
  address,
354
+ chainId: 1n,
341
355
  expiry,
342
356
  type: 'secp256k1',
343
357
  limits: [
@@ -355,6 +369,7 @@ describe('from', () => {
355
369
  expect(authorization).toMatchInlineSnapshot(`
356
370
  {
357
371
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
372
+ "chainId": 1n,
358
373
  "expiry": 1234567890,
359
374
  "limits": [
360
375
  {
@@ -374,6 +389,7 @@ describe('from', () => {
374
389
  test('zero expiry (never expires)', () => {
375
390
  const authorization = KeyAuthorization.from({
376
391
  address,
392
+ chainId: 1n,
377
393
  expiry: 0,
378
394
  type: 'secp256k1',
379
395
  limits: [
@@ -387,6 +403,7 @@ describe('from', () => {
387
403
  expect(authorization).toMatchInlineSnapshot(`
388
404
  {
389
405
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
406
+ "chainId": 1n,
390
407
  "expiry": 0,
391
408
  "limits": [
392
409
  {
@@ -403,6 +420,7 @@ describe('from', () => {
403
420
  describe('fromRpc', () => {
404
421
  test('secp256k1', () => {
405
422
  const authorization = KeyAuthorization.fromRpc({
423
+ chainId: '0x1',
406
424
  expiry: Hex.fromNumber(expiry),
407
425
  keyId: address,
408
426
  keyType: 'secp256k1',
@@ -418,7 +436,7 @@ describe('fromRpc', () => {
418
436
  expect(authorization).toMatchInlineSnapshot(`
419
437
  {
420
438
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
421
- "chainId": 0n,
439
+ "chainId": 1n,
422
440
  "expiry": 1234567890,
423
441
  "limits": [
424
442
  {
@@ -441,6 +459,7 @@ describe('fromRpc', () => {
441
459
 
442
460
  test('p256', () => {
443
461
  const authorization = KeyAuthorization.fromRpc({
462
+ chainId: '0x1',
444
463
  expiry: Hex.fromNumber(expiry),
445
464
  keyId: address,
446
465
  keyType: 'p256',
@@ -458,7 +477,7 @@ describe('fromRpc', () => {
458
477
  expect(authorization).toMatchInlineSnapshot(`
459
478
  {
460
479
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
461
- "chainId": 0n,
480
+ "chainId": 1n,
462
481
  "expiry": 1234567890,
463
482
  "limits": [
464
483
  {
@@ -486,6 +505,7 @@ describe('fromRpc', () => {
486
505
 
487
506
  test('webAuthn', () => {
488
507
  const authorization = KeyAuthorization.fromRpc({
508
+ chainId: '0x1',
489
509
  expiry: Hex.fromNumber(expiry),
490
510
  keyId: address,
491
511
  keyType: 'webAuthn',
@@ -496,7 +516,7 @@ describe('fromRpc', () => {
496
516
  expect(authorization).toMatchInlineSnapshot(`
497
517
  {
498
518
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
499
- "chainId": 0n,
519
+ "chainId": 1n,
500
520
  "expiry": 1234567890,
501
521
  "limits": [
502
522
  {
@@ -527,6 +547,7 @@ describe('fromRpc', () => {
527
547
 
528
548
  test('multiple limits', () => {
529
549
  const authorization = KeyAuthorization.fromRpc({
550
+ chainId: '0x1',
530
551
  expiry: Hex.fromNumber(expiry),
531
552
  keyId: address,
532
553
  keyType: 'secp256k1',
@@ -551,7 +572,7 @@ describe('fromRpc', () => {
551
572
  expect(authorization).toMatchInlineSnapshot(`
552
573
  {
553
574
  "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
554
- "chainId": 0n,
575
+ "chainId": 1n,
555
576
  "expiry": 1234567890,
556
577
  "limits": [
557
578
  {
@@ -845,6 +866,7 @@ describe('getSignPayload', () => {
845
866
  test('default', () => {
846
867
  const authorization = KeyAuthorization.from({
847
868
  address,
869
+ chainId: 1n,
848
870
  expiry,
849
871
  type: 'secp256k1',
850
872
  limits: [
@@ -858,13 +880,14 @@ describe('getSignPayload', () => {
858
880
  const payload = KeyAuthorization.getSignPayload(authorization)
859
881
 
860
882
  expect(payload).toMatchInlineSnapshot(
861
- `"0x6d56b62bb5e94ca0206340e4bc1ece5a35e7ad31c30c6b98074d146d5c5de993"`,
883
+ `"0x5a3a9a67cc6b68eafd00fe3ffb1ea8755ef29cfa1d1c2f655efa61966ef248f7"`,
862
884
  )
863
885
  })
864
886
 
865
887
  test('with signature (signature should be ignored)', () => {
866
888
  const authorization = KeyAuthorization.from({
867
889
  address,
890
+ chainId: 1n,
868
891
  expiry,
869
892
  type: 'secp256k1',
870
893
  limits: [
@@ -880,13 +903,14 @@ describe('getSignPayload', () => {
880
903
 
881
904
  // Should be same as without signature
882
905
  expect(payload).toMatchInlineSnapshot(
883
- `"0x6d56b62bb5e94ca0206340e4bc1ece5a35e7ad31c30c6b98074d146d5c5de993"`,
906
+ `"0x5a3a9a67cc6b68eafd00fe3ffb1ea8755ef29cfa1d1c2f655efa61966ef248f7"`,
884
907
  )
885
908
  })
886
909
 
887
910
  test('different key types', () => {
888
911
  const auth_secp256k1 = KeyAuthorization.from({
889
912
  address,
913
+ chainId: 1n,
890
914
  expiry,
891
915
  type: 'secp256k1',
892
916
  limits: [{ token, limit: Value.from('10', 6) }],
@@ -894,6 +918,7 @@ describe('getSignPayload', () => {
894
918
 
895
919
  const auth_p256 = KeyAuthorization.from({
896
920
  address,
921
+ chainId: 1n,
897
922
  expiry,
898
923
  type: 'p256',
899
924
  limits: [{ token, limit: Value.from('10', 6) }],
@@ -901,6 +926,7 @@ describe('getSignPayload', () => {
901
926
 
902
927
  const auth_webauthn = KeyAuthorization.from({
903
928
  address,
929
+ chainId: 1n,
904
930
  expiry,
905
931
  type: 'webAuthn',
906
932
  limits: [{ token, limit: Value.from('10', 6) }],
@@ -916,13 +942,13 @@ describe('getSignPayload', () => {
916
942
  expect(payload_p256).not.toBe(payload_webauthn)
917
943
 
918
944
  expect(payload_secp256k1).toMatchInlineSnapshot(
919
- `"0x6d56b62bb5e94ca0206340e4bc1ece5a35e7ad31c30c6b98074d146d5c5de993"`,
945
+ `"0x5a3a9a67cc6b68eafd00fe3ffb1ea8755ef29cfa1d1c2f655efa61966ef248f7"`,
920
946
  )
921
947
  expect(payload_p256).toMatchInlineSnapshot(
922
- `"0x70f1d02570bd5ec14701306f7c3fadf405911fcd585136d1d60f2e4eb689f602"`,
948
+ `"0x6807f3a5597cdc334568094bb2a884fd97cfa21ecb7a8034e7fabef32680e5fe"`,
923
949
  )
924
950
  expect(payload_webauthn).toMatchInlineSnapshot(
925
- `"0xb69543e8899a3d0a0186e347df6589f47ea194b6bc3ac935225411b1ef2d4627"`,
951
+ `"0x576f0b2608ac4630b7f40f2b8571828e2e1e6f13ad9aca8c7ce53773407e9ce5"`,
926
952
  )
927
953
  })
928
954
  })
@@ -931,6 +957,7 @@ describe('deserialize', () => {
931
957
  test('default', () => {
932
958
  const authorization = KeyAuthorization.from({
933
959
  address,
960
+ chainId: 1n,
934
961
  expiry,
935
962
  type: 'secp256k1',
936
963
  limits: [
@@ -951,6 +978,7 @@ describe('deserialize', () => {
951
978
  const authorization = KeyAuthorization.from(
952
979
  {
953
980
  address,
981
+ chainId: 1n,
954
982
  expiry,
955
983
  type: 'secp256k1',
956
984
  limits: [
@@ -972,6 +1000,7 @@ describe('deserialize', () => {
972
1000
  test('no limits', () => {
973
1001
  const authorization = KeyAuthorization.from({
974
1002
  address,
1003
+ chainId: 1n,
975
1004
  expiry,
976
1005
  type: 'secp256k1',
977
1006
  })
@@ -985,6 +1014,7 @@ describe('deserialize', () => {
985
1014
  test('no expiry', () => {
986
1015
  const authorization = KeyAuthorization.from({
987
1016
  address,
1017
+ chainId: 1n,
988
1018
  type: 'secp256k1',
989
1019
  })
990
1020
 
@@ -999,6 +1029,7 @@ describe('hash', () => {
999
1029
  test('default', () => {
1000
1030
  const authorization = KeyAuthorization.from({
1001
1031
  address,
1032
+ chainId: 1n,
1002
1033
  expiry,
1003
1034
  type: 'secp256k1',
1004
1035
  limits: [
@@ -1012,7 +1043,7 @@ describe('hash', () => {
1012
1043
  const hash = KeyAuthorization.hash(authorization)
1013
1044
 
1014
1045
  expect(hash).toMatchInlineSnapshot(
1015
- `"0x6d56b62bb5e94ca0206340e4bc1ece5a35e7ad31c30c6b98074d146d5c5de993"`,
1046
+ `"0x5a3a9a67cc6b68eafd00fe3ffb1ea8755ef29cfa1d1c2f655efa61966ef248f7"`,
1016
1047
  )
1017
1048
  })
1018
1049
  })
@@ -1021,6 +1052,7 @@ describe('serialize', () => {
1021
1052
  test('default', () => {
1022
1053
  const authorization = KeyAuthorization.from({
1023
1054
  address,
1055
+ chainId: 1n,
1024
1056
  expiry,
1025
1057
  type: 'secp256k1',
1026
1058
  limits: [
@@ -1034,7 +1066,7 @@ describe('serialize', () => {
1034
1066
  const serialized = KeyAuthorization.serialize(authorization)
1035
1067
 
1036
1068
  expect(serialized).toMatchInlineSnapshot(
1037
- `"0xf838f7808094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680"`,
1069
+ `"0xf838f7018094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680"`,
1038
1070
  )
1039
1071
  })
1040
1072
 
@@ -1042,6 +1074,7 @@ describe('serialize', () => {
1042
1074
  const authorization = KeyAuthorization.from(
1043
1075
  {
1044
1076
  address,
1077
+ chainId: 1n,
1045
1078
  expiry,
1046
1079
  type: 'secp256k1',
1047
1080
  limits: [
@@ -1063,6 +1096,7 @@ describe('serialize', () => {
1063
1096
  test('no limits', () => {
1064
1097
  const authorization = KeyAuthorization.from({
1065
1098
  address,
1099
+ chainId: 1n,
1066
1100
  expiry,
1067
1101
  type: 'secp256k1',
1068
1102
  })
@@ -1070,20 +1104,21 @@ describe('serialize', () => {
1070
1104
  const serialized = KeyAuthorization.serialize(authorization)
1071
1105
 
1072
1106
  expect(serialized).toMatchInlineSnapshot(
1073
- `"0xdddc808094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2"`,
1107
+ `"0xdddc018094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2"`,
1074
1108
  )
1075
1109
  })
1076
1110
 
1077
1111
  test('no expiry', () => {
1078
1112
  const authorization = KeyAuthorization.from({
1079
1113
  address,
1114
+ chainId: 1n,
1080
1115
  type: 'secp256k1',
1081
1116
  })
1082
1117
 
1083
1118
  const serialized = KeyAuthorization.serialize(authorization)
1084
1119
 
1085
1120
  expect(serialized).toMatchInlineSnapshot(
1086
- `"0xd8d7808094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c"`,
1121
+ `"0xd8d7018094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c"`,
1087
1122
  )
1088
1123
  })
1089
1124
  })
@@ -1092,6 +1127,7 @@ describe('toRpc', () => {
1092
1127
  test('secp256k1', () => {
1093
1128
  const authorization = KeyAuthorization.from({
1094
1129
  address,
1130
+ chainId: 1n,
1095
1131
  expiry,
1096
1132
  type: 'secp256k1',
1097
1133
  limits: [
@@ -1111,7 +1147,7 @@ describe('toRpc', () => {
1111
1147
 
1112
1148
  expect(rpc).toMatchInlineSnapshot(`
1113
1149
  {
1114
- "chainId": "0x",
1150
+ "chainId": "0x1",
1115
1151
  "expiry": "0x499602d2",
1116
1152
  "keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1117
1153
  "keyType": "secp256k1",
@@ -1134,6 +1170,7 @@ describe('toRpc', () => {
1134
1170
  test('p256', () => {
1135
1171
  const authorization = KeyAuthorization.from({
1136
1172
  address,
1173
+ chainId: 1n,
1137
1174
  expiry,
1138
1175
  type: 'p256',
1139
1176
  limits: [
@@ -1149,7 +1186,7 @@ describe('toRpc', () => {
1149
1186
 
1150
1187
  expect(rpc).toMatchInlineSnapshot(`
1151
1188
  {
1152
- "chainId": "0x",
1189
+ "chainId": "0x1",
1153
1190
  "expiry": "0x499602d2",
1154
1191
  "keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1155
1192
  "keyType": "p256",
@@ -1174,6 +1211,7 @@ describe('toRpc', () => {
1174
1211
  test('webAuthn', () => {
1175
1212
  const authorization = KeyAuthorization.from({
1176
1213
  address,
1214
+ chainId: 1n,
1177
1215
  expiry,
1178
1216
  type: 'webAuthn',
1179
1217
  limits: [
@@ -1189,7 +1227,7 @@ describe('toRpc', () => {
1189
1227
 
1190
1228
  expect(rpc).toMatchInlineSnapshot(`
1191
1229
  {
1192
- "chainId": "0x",
1230
+ "chainId": "0x1",
1193
1231
  "expiry": "0x499602d2",
1194
1232
  "keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1195
1233
  "keyType": "webAuthn",
@@ -1214,6 +1252,7 @@ describe('toRpc', () => {
1214
1252
  test('multiple limits', () => {
1215
1253
  const authorization = KeyAuthorization.from({
1216
1254
  address,
1255
+ chainId: 1n,
1217
1256
  expiry,
1218
1257
  type: 'secp256k1',
1219
1258
  limits: [
@@ -1233,7 +1272,7 @@ describe('toRpc', () => {
1233
1272
 
1234
1273
  expect(rpc).toMatchInlineSnapshot(`
1235
1274
  {
1236
- "chainId": "0x",
1275
+ "chainId": "0x1",
1237
1276
  "expiry": "0x499602d2",
1238
1277
  "keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1239
1278
  "keyType": "secp256k1",
@@ -1322,6 +1361,7 @@ describe('toTuple', () => {
1322
1361
  test('default', () => {
1323
1362
  const authorization = KeyAuthorization.from({
1324
1363
  address,
1364
+ chainId: 1n,
1325
1365
  type: 'secp256k1',
1326
1366
  })
1327
1367
 
@@ -1330,7 +1370,7 @@ describe('toTuple', () => {
1330
1370
  expect(tuple).toMatchInlineSnapshot(`
1331
1371
  [
1332
1372
  [
1333
- "0x",
1373
+ "0x1",
1334
1374
  "0x",
1335
1375
  "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1336
1376
  ],
@@ -1341,6 +1381,7 @@ describe('toTuple', () => {
1341
1381
  test('with signature (secp256k1)', () => {
1342
1382
  const authorization = KeyAuthorization.from({
1343
1383
  address,
1384
+ chainId: 1n,
1344
1385
  expiry,
1345
1386
  type: 'secp256k1',
1346
1387
  limits: [
@@ -1357,7 +1398,7 @@ describe('toTuple', () => {
1357
1398
  expect(tuple).toMatchInlineSnapshot(`
1358
1399
  [
1359
1400
  [
1360
- "0x",
1401
+ "0x1",
1361
1402
  "0x",
1362
1403
  "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1363
1404
  "0x499602d2",
@@ -1376,6 +1417,7 @@ describe('toTuple', () => {
1376
1417
  test('with signature (p256)', () => {
1377
1418
  const authorization = KeyAuthorization.from({
1378
1419
  address,
1420
+ chainId: 1n,
1379
1421
  expiry,
1380
1422
  type: 'p256',
1381
1423
  limits: [
@@ -1392,7 +1434,7 @@ describe('toTuple', () => {
1392
1434
  expect(tuple).toMatchInlineSnapshot(`
1393
1435
  [
1394
1436
  [
1395
- "0x",
1437
+ "0x1",
1396
1438
  "0x01",
1397
1439
  "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1398
1440
  "0x499602d2",
@@ -1411,6 +1453,7 @@ describe('toTuple', () => {
1411
1453
  test('with signature (webAuthn)', () => {
1412
1454
  const authorization = KeyAuthorization.from({
1413
1455
  address,
1456
+ chainId: 1n,
1414
1457
  expiry,
1415
1458
  type: 'webAuthn',
1416
1459
  limits: [
@@ -1427,7 +1470,7 @@ describe('toTuple', () => {
1427
1470
  expect(tuple).toMatchInlineSnapshot(`
1428
1471
  [
1429
1472
  [
1430
- "0x",
1473
+ "0x1",
1431
1474
  "0x02",
1432
1475
  "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1433
1476
  "0x499602d2",
@@ -1446,6 +1489,7 @@ describe('toTuple', () => {
1446
1489
  test('multiple limits', () => {
1447
1490
  const authorization = KeyAuthorization.from({
1448
1491
  address,
1492
+ chainId: 1n,
1449
1493
  expiry,
1450
1494
  type: 'secp256k1',
1451
1495
  limits: [
@@ -1465,7 +1509,7 @@ describe('toTuple', () => {
1465
1509
  expect(tuple).toMatchInlineSnapshot(`
1466
1510
  [
1467
1511
  [
1468
- "0x",
1512
+ "0x1",
1469
1513
  "0x",
1470
1514
  "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
1471
1515
  "0x499602d2",
@@ -1521,6 +1565,7 @@ describe('toTuple', () => {
1521
1565
  test('zero spending limit roundtrips through RLP', () => {
1522
1566
  const authorization = KeyAuthorization.from({
1523
1567
  address,
1568
+ chainId: 0n,
1524
1569
  expiry,
1525
1570
  type: 'secp256k1',
1526
1571
  limits: [
@@ -1562,6 +1607,7 @@ describe('toTuple', () => {
1562
1607
  test('zero expiry roundtrips through RLP', () => {
1563
1608
  const authorization = KeyAuthorization.from({
1564
1609
  address,
1610
+ chainId: 0n,
1565
1611
  expiry: 0,
1566
1612
  type: 'secp256k1',
1567
1613
  limits: [
@@ -1603,6 +1649,7 @@ describe('toTuple', () => {
1603
1649
  test('hash works with zero spending limit', () => {
1604
1650
  const authorization = KeyAuthorization.from({
1605
1651
  address,
1652
+ chainId: 1n,
1606
1653
  expiry,
1607
1654
  type: 'secp256k1',
1608
1655
  limits: [
@@ -34,8 +34,8 @@ export type KeyAuthorization<
34
34
  > = {
35
35
  /** Address derived from the public key of the key type. */
36
36
  address: Address.Address
37
- /** Chain ID for replay protection (0 = valid on any chain). */
38
- chainId?: bigintType | undefined
37
+ /** Chain ID for replay protection. */
38
+ chainId: bigintType
39
39
  /** Unix timestamp when key expires (0 = never expires). */
40
40
  expiry?: numberType | null | undefined
41
41
  /** TIP20 spending limits for this key. */
@@ -136,6 +136,7 @@ export type TokenLimit<bigintType = bigint> = {
136
136
  *
137
137
  * const authorization = KeyAuthorization.from({
138
138
  * address,
139
+ * chainId: 4217n,
139
140
  * expiry: 1234567890,
140
141
  * type: 'secp256k1',
141
142
  * limits: [{
@@ -157,6 +158,7 @@ export type TokenLimit<bigintType = bigint> = {
157
158
  *
158
159
  * const authorization = KeyAuthorization.from({
159
160
  * address,
161
+ * chainId: 4217n,
160
162
  * expiry: 1234567890,
161
163
  * type: 'p256',
162
164
  * limits: [{
@@ -181,6 +183,7 @@ export type TokenLimit<bigintType = bigint> = {
181
183
  *
182
184
  * const authorization = KeyAuthorization.from({
183
185
  * address,
186
+ * chainId: 4217n,
184
187
  * expiry: 1234567890,
185
188
  * type: 'secp256k1',
186
189
  * limits: [{
@@ -214,6 +217,7 @@ export type TokenLimit<bigintType = bigint> = {
214
217
  *
215
218
  * const authorization = KeyAuthorization.from({
216
219
  * address,
220
+ * chainId: 4217n,
217
221
  * expiry: 1234567890,
218
222
  * type: 'p256',
219
223
  * limits: [{
@@ -313,7 +317,7 @@ export declare namespace from {
313
317
  * @returns A signed {@link ox#AuthorizationTempo.AuthorizationTempo}.
314
318
  */
315
319
  export function fromRpc(authorization: Rpc): Signed {
316
- const { chainId = '0x0', keyId, expiry = 0, limits, keyType } = authorization
320
+ const { chainId, keyId, expiry = 0, limits, keyType } = authorization
317
321
  const signature = SignatureEnvelope.fromRpc(authorization.signature)
318
322
  return {
319
323
  address: keyId,
@@ -393,7 +397,7 @@ export function fromTuple<const tuple extends Tuple>(
393
397
  address: keyId,
394
398
  expiry: typeof expiry !== 'undefined' ? hexToNumber(expiry) : undefined,
395
399
  type: keyType,
396
- ...(chainId !== '0x' ? { chainId: Hex.toBigInt(chainId) } : {}),
400
+ chainId: chainId === '0x' ? 0n : Hex.toBigInt(chainId),
397
401
  ...(typeof expiry !== 'undefined' ? { expiry: hexToNumber(expiry) } : {}),
398
402
  ...(typeof limits !== 'undefined'
399
403
  ? {
@@ -436,6 +440,7 @@ export declare namespace fromTuple {
436
440
  *
437
441
  * const authorization = KeyAuthorization.from({
438
442
  * address,
443
+ * chainId: 4217n,
439
444
  * expiry: 1234567890,
440
445
  * type: 'secp256k1',
441
446
  * limits: [{
@@ -467,8 +472,9 @@ export declare namespace getSignPayload {
467
472
  * import { Value } from 'ox'
468
473
  *
469
474
  * const authorization = KeyAuthorization.from({
470
- * expiry: 1234567890,
471
475
  * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
476
+ * chainId: 4217n,
477
+ * expiry: 1234567890,
472
478
  * type: 'secp256k1',
473
479
  * limits: [{
474
480
  * token: '0x20c0000000000000000000000000000000000001',
@@ -504,8 +510,9 @@ export declare namespace deserialize {
504
510
  * import { Value } from 'ox'
505
511
  *
506
512
  * const authorization = KeyAuthorization.from({
507
- * expiry: 1234567890,
508
513
  * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
514
+ * chainId: 4217n,
515
+ * expiry: 1234567890,
509
516
  * type: 'secp256k1',
510
517
  * limits: [{
511
518
  * token: '0x20c0000000000000000000000000000000000001',
@@ -543,8 +550,9 @@ export declare namespace hash {
543
550
  * import { Value } from 'ox'
544
551
  *
545
552
  * const authorization = KeyAuthorization.from({
546
- * expiry: 1234567890,
547
553
  * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
554
+ * chainId: 4217n,
555
+ * expiry: 1234567890,
548
556
  * type: 'secp256k1',
549
557
  * limits: [{
550
558
  * token: '0x20c0000000000000000000000000000000000001',
@@ -579,8 +587,9 @@ export declare namespace serialize {
579
587
  * import { Value } from 'ox'
580
588
  *
581
589
  * const authorization = KeyAuthorization.toRpc({
582
- * expiry: 1234567890,
583
590
  * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
591
+ * chainId: 4217n,
592
+ * expiry: 1234567890,
584
593
  * type: 'secp256k1',
585
594
  * limits: [{
586
595
  * token: '0x20c0000000000000000000000000000000000001',
@@ -601,14 +610,7 @@ export declare namespace serialize {
601
610
  * @returns An RPC-formatted Key Authorization.
602
611
  */
603
612
  export function toRpc(authorization: Signed): Rpc {
604
- const {
605
- address,
606
- chainId = 0n,
607
- expiry,
608
- limits,
609
- type,
610
- signature,
611
- } = authorization
613
+ const { address, chainId, expiry, limits, type, signature } = authorization
612
614
 
613
615
  return {
614
616
  chainId: chainId === 0n ? '0x' : Hex.fromNumber(chainId),
@@ -636,8 +638,9 @@ export declare namespace toRpc {
636
638
  * import { Value } from 'ox'
637
639
  *
638
640
  * const authorization = KeyAuthorization.from({
639
- * expiry: 1234567890,
640
641
  * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
642
+ * chainId: 4217n,
643
+ * expiry: 1234567890,
641
644
  * type: 'secp256k1',
642
645
  * limits: [{
643
646
  * token: '0x20c0000000000000000000000000000000000001',
@@ -660,7 +663,7 @@ export declare namespace toRpc {
660
663
  export function toTuple<const authorization extends KeyAuthorization>(
661
664
  authorization: authorization,
662
665
  ): toTuple.ReturnType<authorization> {
663
- const { address, chainId = 0n, expiry, limits } = authorization
666
+ const { address, chainId, expiry, limits } = authorization
664
667
  const signature = authorization.signature
665
668
  ? SignatureEnvelope.serialize(authorization.signature)
666
669
  : undefined