ox 0.13.2 → 0.14.1
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.
- package/Bech32m/package.json +6 -0
- package/CHANGELOG.md +25 -0
- package/_cjs/core/Bech32m.js +205 -0
- package/_cjs/core/Bech32m.js.map +1 -0
- package/_cjs/index.js +3 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/AuthorizationTempo.js +7 -2
- package/_cjs/tempo/AuthorizationTempo.js.map +1 -1
- package/_cjs/tempo/KeyAuthorization.js +22 -8
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +39 -4
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TempoAddress.js +49 -41
- package/_cjs/tempo/TempoAddress.js.map +1 -1
- package/_cjs/tempo/TokenId.js +8 -5
- package/_cjs/tempo/TokenId.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +2 -1
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/TxEnvelopeTempo.js +17 -4
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/Bech32m.js +238 -0
- package/_esm/core/Bech32m.js.map +1 -0
- package/_esm/index.js +24 -0
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/AuthorizationTempo.js +24 -19
- package/_esm/tempo/AuthorizationTempo.js.map +1 -1
- package/_esm/tempo/KeyAuthorization.js +38 -13
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +43 -6
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TempoAddress.js +79 -48
- package/_esm/tempo/TempoAddress.js.map +1 -1
- package/_esm/tempo/TokenId.js +9 -6
- package/_esm/tempo/TokenId.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +2 -1
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js +66 -15
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_esm/tempo/index.js +11 -10
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/Bech32m.d.ts +93 -0
- package/_types/core/Bech32m.d.ts.map +1 -0
- package/_types/index.d.ts +24 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/tempo/AuthorizationTempo.d.ts +19 -19
- package/_types/tempo/AuthorizationTempo.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorization.d.ts +21 -9
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +30 -7
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/_types/tempo/TempoAddress.d.ts +51 -15
- package/_types/tempo/TempoAddress.d.ts.map +1 -1
- package/_types/tempo/TokenId.d.ts +6 -5
- package/_types/tempo/TokenId.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +2 -1
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/TxEnvelopeTempo.d.ts +64 -17
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +11 -10
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/Bech32m.ts +263 -0
- package/index.ts +24 -2
- package/package.json +6 -1
- package/tempo/AuthorizationTempo.test.ts +13 -0
- package/tempo/AuthorizationTempo.ts +27 -21
- package/tempo/KeyAuthorization.test.ts +95 -23
- package/tempo/KeyAuthorization.ts +44 -25
- package/tempo/PoolId.test.ts +9 -0
- package/tempo/SignatureEnvelope.test.ts +123 -8
- package/tempo/SignatureEnvelope.ts +82 -9
- package/tempo/TempoAddress.test.ts +70 -14
- package/tempo/TempoAddress.ts +95 -67
- package/tempo/TokenId.test.ts +14 -0
- package/tempo/TokenId.ts +13 -10
- package/tempo/Transaction.test.ts +4 -2
- package/tempo/TransactionRequest.ts +3 -2
- package/tempo/TxEnvelopeTempo.test.ts +79 -3
- package/tempo/TxEnvelopeTempo.ts +86 -19
- package/tempo/e2e.test.ts +33 -9
- package/tempo/index.ts +15 -10
- 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
|
{
|
|
@@ -81,10 +83,36 @@ describe('from', () => {
|
|
|
81
83
|
`)
|
|
82
84
|
})
|
|
83
85
|
|
|
86
|
+
test('tempo address input', () => {
|
|
87
|
+
const tempoAddr = 'tempo1qzlftsl42n5lep0v2xlxng7cq7sd2k709sxlwnsu'
|
|
88
|
+
const tempoToken = 'tempo1qqsvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqyr9xgnd'
|
|
89
|
+
|
|
90
|
+
const authorization = KeyAuthorization.from({
|
|
91
|
+
address: tempoAddr,
|
|
92
|
+
chainId: 1n,
|
|
93
|
+
expiry,
|
|
94
|
+
type: 'secp256k1',
|
|
95
|
+
limits: [
|
|
96
|
+
{
|
|
97
|
+
token: tempoToken,
|
|
98
|
+
limit: Value.from('10', 6),
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
expect(authorization.address).toBe(
|
|
104
|
+
'0xBE95c3f554e9Fc85ec51bE69a3D807A0D55BCF2C',
|
|
105
|
+
)
|
|
106
|
+
expect(authorization.limits?.[0]?.token).toBe(
|
|
107
|
+
'0x20C0000000000000000000000000000000000001',
|
|
108
|
+
)
|
|
109
|
+
})
|
|
110
|
+
|
|
84
111
|
test('with signature (secp256k1)', () => {
|
|
85
112
|
const authorization = KeyAuthorization.from(
|
|
86
113
|
{
|
|
87
114
|
address,
|
|
115
|
+
chainId: 1n,
|
|
88
116
|
expiry,
|
|
89
117
|
type: 'secp256k1',
|
|
90
118
|
limits: [
|
|
@@ -102,6 +130,7 @@ describe('from', () => {
|
|
|
102
130
|
expect(authorization).toMatchInlineSnapshot(`
|
|
103
131
|
{
|
|
104
132
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
133
|
+
"chainId": 1n,
|
|
105
134
|
"expiry": 1234567890,
|
|
106
135
|
"limits": [
|
|
107
136
|
{
|
|
@@ -126,6 +155,7 @@ describe('from', () => {
|
|
|
126
155
|
const authorization = KeyAuthorization.from(
|
|
127
156
|
{
|
|
128
157
|
address,
|
|
158
|
+
chainId: 1n,
|
|
129
159
|
expiry,
|
|
130
160
|
type: 'secp256k1',
|
|
131
161
|
limits: [
|
|
@@ -143,6 +173,7 @@ describe('from', () => {
|
|
|
143
173
|
expect(authorization).toMatchInlineSnapshot(`
|
|
144
174
|
{
|
|
145
175
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
176
|
+
"chainId": 1n,
|
|
146
177
|
"expiry": 1234567890,
|
|
147
178
|
"limits": [
|
|
148
179
|
{
|
|
@@ -167,6 +198,7 @@ describe('from', () => {
|
|
|
167
198
|
const authorization = KeyAuthorization.from(
|
|
168
199
|
{
|
|
169
200
|
address,
|
|
201
|
+
chainId: 1n,
|
|
170
202
|
expiry,
|
|
171
203
|
type: 'p256',
|
|
172
204
|
limits: [
|
|
@@ -184,6 +216,7 @@ describe('from', () => {
|
|
|
184
216
|
expect(authorization).toMatchInlineSnapshot(`
|
|
185
217
|
{
|
|
186
218
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
219
|
+
"chainId": 1n,
|
|
187
220
|
"expiry": 1234567890,
|
|
188
221
|
"limits": [
|
|
189
222
|
{
|
|
@@ -214,6 +247,7 @@ describe('from', () => {
|
|
|
214
247
|
const authorization = KeyAuthorization.from(
|
|
215
248
|
{
|
|
216
249
|
address,
|
|
250
|
+
chainId: 1n,
|
|
217
251
|
expiry,
|
|
218
252
|
type: 'webAuthn',
|
|
219
253
|
limits: [
|
|
@@ -231,6 +265,7 @@ describe('from', () => {
|
|
|
231
265
|
expect(authorization).toMatchInlineSnapshot(`
|
|
232
266
|
{
|
|
233
267
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
268
|
+
"chainId": 1n,
|
|
234
269
|
"expiry": 1234567890,
|
|
235
270
|
"limits": [
|
|
236
271
|
{
|
|
@@ -263,6 +298,7 @@ describe('from', () => {
|
|
|
263
298
|
test('with inline signature (secp256k1)', () => {
|
|
264
299
|
const authorization = KeyAuthorization.from({
|
|
265
300
|
address,
|
|
301
|
+
chainId: 1n,
|
|
266
302
|
expiry,
|
|
267
303
|
type: 'secp256k1',
|
|
268
304
|
limits: [
|
|
@@ -277,6 +313,7 @@ describe('from', () => {
|
|
|
277
313
|
expect(authorization).toMatchInlineSnapshot(`
|
|
278
314
|
{
|
|
279
315
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
316
|
+
"chainId": 1n,
|
|
280
317
|
"expiry": 1234567890,
|
|
281
318
|
"limits": [
|
|
282
319
|
{
|
|
@@ -301,6 +338,7 @@ describe('from', () => {
|
|
|
301
338
|
const authorization = KeyAuthorization.from({
|
|
302
339
|
expiry: Hex.fromNumber(expiry),
|
|
303
340
|
keyId: address,
|
|
341
|
+
chainId: '0x1',
|
|
304
342
|
keyType: 'secp256k1',
|
|
305
343
|
limits: [{ token, limit: '0x989680' }],
|
|
306
344
|
signature: {
|
|
@@ -314,7 +352,7 @@ describe('from', () => {
|
|
|
314
352
|
expect(authorization).toMatchInlineSnapshot(`
|
|
315
353
|
{
|
|
316
354
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
317
|
-
"chainId":
|
|
355
|
+
"chainId": 1n,
|
|
318
356
|
"expiry": 1234567890,
|
|
319
357
|
"limits": [
|
|
320
358
|
{
|
|
@@ -338,6 +376,7 @@ describe('from', () => {
|
|
|
338
376
|
test('multiple limits', () => {
|
|
339
377
|
const authorization = KeyAuthorization.from({
|
|
340
378
|
address,
|
|
379
|
+
chainId: 1n,
|
|
341
380
|
expiry,
|
|
342
381
|
type: 'secp256k1',
|
|
343
382
|
limits: [
|
|
@@ -355,6 +394,7 @@ describe('from', () => {
|
|
|
355
394
|
expect(authorization).toMatchInlineSnapshot(`
|
|
356
395
|
{
|
|
357
396
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
397
|
+
"chainId": 1n,
|
|
358
398
|
"expiry": 1234567890,
|
|
359
399
|
"limits": [
|
|
360
400
|
{
|
|
@@ -374,6 +414,7 @@ describe('from', () => {
|
|
|
374
414
|
test('zero expiry (never expires)', () => {
|
|
375
415
|
const authorization = KeyAuthorization.from({
|
|
376
416
|
address,
|
|
417
|
+
chainId: 1n,
|
|
377
418
|
expiry: 0,
|
|
378
419
|
type: 'secp256k1',
|
|
379
420
|
limits: [
|
|
@@ -387,6 +428,7 @@ describe('from', () => {
|
|
|
387
428
|
expect(authorization).toMatchInlineSnapshot(`
|
|
388
429
|
{
|
|
389
430
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
431
|
+
"chainId": 1n,
|
|
390
432
|
"expiry": 0,
|
|
391
433
|
"limits": [
|
|
392
434
|
{
|
|
@@ -403,6 +445,7 @@ describe('from', () => {
|
|
|
403
445
|
describe('fromRpc', () => {
|
|
404
446
|
test('secp256k1', () => {
|
|
405
447
|
const authorization = KeyAuthorization.fromRpc({
|
|
448
|
+
chainId: '0x1',
|
|
406
449
|
expiry: Hex.fromNumber(expiry),
|
|
407
450
|
keyId: address,
|
|
408
451
|
keyType: 'secp256k1',
|
|
@@ -418,7 +461,7 @@ describe('fromRpc', () => {
|
|
|
418
461
|
expect(authorization).toMatchInlineSnapshot(`
|
|
419
462
|
{
|
|
420
463
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
421
|
-
"chainId":
|
|
464
|
+
"chainId": 1n,
|
|
422
465
|
"expiry": 1234567890,
|
|
423
466
|
"limits": [
|
|
424
467
|
{
|
|
@@ -441,6 +484,7 @@ describe('fromRpc', () => {
|
|
|
441
484
|
|
|
442
485
|
test('p256', () => {
|
|
443
486
|
const authorization = KeyAuthorization.fromRpc({
|
|
487
|
+
chainId: '0x1',
|
|
444
488
|
expiry: Hex.fromNumber(expiry),
|
|
445
489
|
keyId: address,
|
|
446
490
|
keyType: 'p256',
|
|
@@ -458,7 +502,7 @@ describe('fromRpc', () => {
|
|
|
458
502
|
expect(authorization).toMatchInlineSnapshot(`
|
|
459
503
|
{
|
|
460
504
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
461
|
-
"chainId":
|
|
505
|
+
"chainId": 1n,
|
|
462
506
|
"expiry": 1234567890,
|
|
463
507
|
"limits": [
|
|
464
508
|
{
|
|
@@ -486,6 +530,7 @@ describe('fromRpc', () => {
|
|
|
486
530
|
|
|
487
531
|
test('webAuthn', () => {
|
|
488
532
|
const authorization = KeyAuthorization.fromRpc({
|
|
533
|
+
chainId: '0x1',
|
|
489
534
|
expiry: Hex.fromNumber(expiry),
|
|
490
535
|
keyId: address,
|
|
491
536
|
keyType: 'webAuthn',
|
|
@@ -496,7 +541,7 @@ describe('fromRpc', () => {
|
|
|
496
541
|
expect(authorization).toMatchInlineSnapshot(`
|
|
497
542
|
{
|
|
498
543
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
499
|
-
"chainId":
|
|
544
|
+
"chainId": 1n,
|
|
500
545
|
"expiry": 1234567890,
|
|
501
546
|
"limits": [
|
|
502
547
|
{
|
|
@@ -527,6 +572,7 @@ describe('fromRpc', () => {
|
|
|
527
572
|
|
|
528
573
|
test('multiple limits', () => {
|
|
529
574
|
const authorization = KeyAuthorization.fromRpc({
|
|
575
|
+
chainId: '0x1',
|
|
530
576
|
expiry: Hex.fromNumber(expiry),
|
|
531
577
|
keyId: address,
|
|
532
578
|
keyType: 'secp256k1',
|
|
@@ -551,7 +597,7 @@ describe('fromRpc', () => {
|
|
|
551
597
|
expect(authorization).toMatchInlineSnapshot(`
|
|
552
598
|
{
|
|
553
599
|
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
554
|
-
"chainId":
|
|
600
|
+
"chainId": 1n,
|
|
555
601
|
"expiry": 1234567890,
|
|
556
602
|
"limits": [
|
|
557
603
|
{
|
|
@@ -845,6 +891,7 @@ describe('getSignPayload', () => {
|
|
|
845
891
|
test('default', () => {
|
|
846
892
|
const authorization = KeyAuthorization.from({
|
|
847
893
|
address,
|
|
894
|
+
chainId: 1n,
|
|
848
895
|
expiry,
|
|
849
896
|
type: 'secp256k1',
|
|
850
897
|
limits: [
|
|
@@ -858,13 +905,14 @@ describe('getSignPayload', () => {
|
|
|
858
905
|
const payload = KeyAuthorization.getSignPayload(authorization)
|
|
859
906
|
|
|
860
907
|
expect(payload).toMatchInlineSnapshot(
|
|
861
|
-
`"
|
|
908
|
+
`"0x5a3a9a67cc6b68eafd00fe3ffb1ea8755ef29cfa1d1c2f655efa61966ef248f7"`,
|
|
862
909
|
)
|
|
863
910
|
})
|
|
864
911
|
|
|
865
912
|
test('with signature (signature should be ignored)', () => {
|
|
866
913
|
const authorization = KeyAuthorization.from({
|
|
867
914
|
address,
|
|
915
|
+
chainId: 1n,
|
|
868
916
|
expiry,
|
|
869
917
|
type: 'secp256k1',
|
|
870
918
|
limits: [
|
|
@@ -880,13 +928,14 @@ describe('getSignPayload', () => {
|
|
|
880
928
|
|
|
881
929
|
// Should be same as without signature
|
|
882
930
|
expect(payload).toMatchInlineSnapshot(
|
|
883
|
-
`"
|
|
931
|
+
`"0x5a3a9a67cc6b68eafd00fe3ffb1ea8755ef29cfa1d1c2f655efa61966ef248f7"`,
|
|
884
932
|
)
|
|
885
933
|
})
|
|
886
934
|
|
|
887
935
|
test('different key types', () => {
|
|
888
936
|
const auth_secp256k1 = KeyAuthorization.from({
|
|
889
937
|
address,
|
|
938
|
+
chainId: 1n,
|
|
890
939
|
expiry,
|
|
891
940
|
type: 'secp256k1',
|
|
892
941
|
limits: [{ token, limit: Value.from('10', 6) }],
|
|
@@ -894,6 +943,7 @@ describe('getSignPayload', () => {
|
|
|
894
943
|
|
|
895
944
|
const auth_p256 = KeyAuthorization.from({
|
|
896
945
|
address,
|
|
946
|
+
chainId: 1n,
|
|
897
947
|
expiry,
|
|
898
948
|
type: 'p256',
|
|
899
949
|
limits: [{ token, limit: Value.from('10', 6) }],
|
|
@@ -901,6 +951,7 @@ describe('getSignPayload', () => {
|
|
|
901
951
|
|
|
902
952
|
const auth_webauthn = KeyAuthorization.from({
|
|
903
953
|
address,
|
|
954
|
+
chainId: 1n,
|
|
904
955
|
expiry,
|
|
905
956
|
type: 'webAuthn',
|
|
906
957
|
limits: [{ token, limit: Value.from('10', 6) }],
|
|
@@ -916,13 +967,13 @@ describe('getSignPayload', () => {
|
|
|
916
967
|
expect(payload_p256).not.toBe(payload_webauthn)
|
|
917
968
|
|
|
918
969
|
expect(payload_secp256k1).toMatchInlineSnapshot(
|
|
919
|
-
`"
|
|
970
|
+
`"0x5a3a9a67cc6b68eafd00fe3ffb1ea8755ef29cfa1d1c2f655efa61966ef248f7"`,
|
|
920
971
|
)
|
|
921
972
|
expect(payload_p256).toMatchInlineSnapshot(
|
|
922
|
-
`"
|
|
973
|
+
`"0x6807f3a5597cdc334568094bb2a884fd97cfa21ecb7a8034e7fabef32680e5fe"`,
|
|
923
974
|
)
|
|
924
975
|
expect(payload_webauthn).toMatchInlineSnapshot(
|
|
925
|
-
`"
|
|
976
|
+
`"0x576f0b2608ac4630b7f40f2b8571828e2e1e6f13ad9aca8c7ce53773407e9ce5"`,
|
|
926
977
|
)
|
|
927
978
|
})
|
|
928
979
|
})
|
|
@@ -931,6 +982,7 @@ describe('deserialize', () => {
|
|
|
931
982
|
test('default', () => {
|
|
932
983
|
const authorization = KeyAuthorization.from({
|
|
933
984
|
address,
|
|
985
|
+
chainId: 1n,
|
|
934
986
|
expiry,
|
|
935
987
|
type: 'secp256k1',
|
|
936
988
|
limits: [
|
|
@@ -951,6 +1003,7 @@ describe('deserialize', () => {
|
|
|
951
1003
|
const authorization = KeyAuthorization.from(
|
|
952
1004
|
{
|
|
953
1005
|
address,
|
|
1006
|
+
chainId: 1n,
|
|
954
1007
|
expiry,
|
|
955
1008
|
type: 'secp256k1',
|
|
956
1009
|
limits: [
|
|
@@ -972,6 +1025,7 @@ describe('deserialize', () => {
|
|
|
972
1025
|
test('no limits', () => {
|
|
973
1026
|
const authorization = KeyAuthorization.from({
|
|
974
1027
|
address,
|
|
1028
|
+
chainId: 1n,
|
|
975
1029
|
expiry,
|
|
976
1030
|
type: 'secp256k1',
|
|
977
1031
|
})
|
|
@@ -985,6 +1039,7 @@ describe('deserialize', () => {
|
|
|
985
1039
|
test('no expiry', () => {
|
|
986
1040
|
const authorization = KeyAuthorization.from({
|
|
987
1041
|
address,
|
|
1042
|
+
chainId: 1n,
|
|
988
1043
|
type: 'secp256k1',
|
|
989
1044
|
})
|
|
990
1045
|
|
|
@@ -999,6 +1054,7 @@ describe('hash', () => {
|
|
|
999
1054
|
test('default', () => {
|
|
1000
1055
|
const authorization = KeyAuthorization.from({
|
|
1001
1056
|
address,
|
|
1057
|
+
chainId: 1n,
|
|
1002
1058
|
expiry,
|
|
1003
1059
|
type: 'secp256k1',
|
|
1004
1060
|
limits: [
|
|
@@ -1012,7 +1068,7 @@ describe('hash', () => {
|
|
|
1012
1068
|
const hash = KeyAuthorization.hash(authorization)
|
|
1013
1069
|
|
|
1014
1070
|
expect(hash).toMatchInlineSnapshot(
|
|
1015
|
-
`"
|
|
1071
|
+
`"0x5a3a9a67cc6b68eafd00fe3ffb1ea8755ef29cfa1d1c2f655efa61966ef248f7"`,
|
|
1016
1072
|
)
|
|
1017
1073
|
})
|
|
1018
1074
|
})
|
|
@@ -1021,6 +1077,7 @@ describe('serialize', () => {
|
|
|
1021
1077
|
test('default', () => {
|
|
1022
1078
|
const authorization = KeyAuthorization.from({
|
|
1023
1079
|
address,
|
|
1080
|
+
chainId: 1n,
|
|
1024
1081
|
expiry,
|
|
1025
1082
|
type: 'secp256k1',
|
|
1026
1083
|
limits: [
|
|
@@ -1034,7 +1091,7 @@ describe('serialize', () => {
|
|
|
1034
1091
|
const serialized = KeyAuthorization.serialize(authorization)
|
|
1035
1092
|
|
|
1036
1093
|
expect(serialized).toMatchInlineSnapshot(
|
|
1037
|
-
`"
|
|
1094
|
+
`"0xf838f7018094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2dad99420c000000000000000000000000000000000000183989680"`,
|
|
1038
1095
|
)
|
|
1039
1096
|
})
|
|
1040
1097
|
|
|
@@ -1042,6 +1099,7 @@ describe('serialize', () => {
|
|
|
1042
1099
|
const authorization = KeyAuthorization.from(
|
|
1043
1100
|
{
|
|
1044
1101
|
address,
|
|
1102
|
+
chainId: 1n,
|
|
1045
1103
|
expiry,
|
|
1046
1104
|
type: 'secp256k1',
|
|
1047
1105
|
limits: [
|
|
@@ -1063,6 +1121,7 @@ describe('serialize', () => {
|
|
|
1063
1121
|
test('no limits', () => {
|
|
1064
1122
|
const authorization = KeyAuthorization.from({
|
|
1065
1123
|
address,
|
|
1124
|
+
chainId: 1n,
|
|
1066
1125
|
expiry,
|
|
1067
1126
|
type: 'secp256k1',
|
|
1068
1127
|
})
|
|
@@ -1070,20 +1129,21 @@ describe('serialize', () => {
|
|
|
1070
1129
|
const serialized = KeyAuthorization.serialize(authorization)
|
|
1071
1130
|
|
|
1072
1131
|
expect(serialized).toMatchInlineSnapshot(
|
|
1073
|
-
`"
|
|
1132
|
+
`"0xdddc018094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c84499602d2"`,
|
|
1074
1133
|
)
|
|
1075
1134
|
})
|
|
1076
1135
|
|
|
1077
1136
|
test('no expiry', () => {
|
|
1078
1137
|
const authorization = KeyAuthorization.from({
|
|
1079
1138
|
address,
|
|
1139
|
+
chainId: 1n,
|
|
1080
1140
|
type: 'secp256k1',
|
|
1081
1141
|
})
|
|
1082
1142
|
|
|
1083
1143
|
const serialized = KeyAuthorization.serialize(authorization)
|
|
1084
1144
|
|
|
1085
1145
|
expect(serialized).toMatchInlineSnapshot(
|
|
1086
|
-
`"
|
|
1146
|
+
`"0xd8d7018094be95c3f554e9fc85ec51be69a3d807a0d55bcf2c"`,
|
|
1087
1147
|
)
|
|
1088
1148
|
})
|
|
1089
1149
|
})
|
|
@@ -1092,6 +1152,7 @@ describe('toRpc', () => {
|
|
|
1092
1152
|
test('secp256k1', () => {
|
|
1093
1153
|
const authorization = KeyAuthorization.from({
|
|
1094
1154
|
address,
|
|
1155
|
+
chainId: 1n,
|
|
1095
1156
|
expiry,
|
|
1096
1157
|
type: 'secp256k1',
|
|
1097
1158
|
limits: [
|
|
@@ -1111,7 +1172,7 @@ describe('toRpc', () => {
|
|
|
1111
1172
|
|
|
1112
1173
|
expect(rpc).toMatchInlineSnapshot(`
|
|
1113
1174
|
{
|
|
1114
|
-
"chainId": "
|
|
1175
|
+
"chainId": "0x1",
|
|
1115
1176
|
"expiry": "0x499602d2",
|
|
1116
1177
|
"keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1117
1178
|
"keyType": "secp256k1",
|
|
@@ -1134,6 +1195,7 @@ describe('toRpc', () => {
|
|
|
1134
1195
|
test('p256', () => {
|
|
1135
1196
|
const authorization = KeyAuthorization.from({
|
|
1136
1197
|
address,
|
|
1198
|
+
chainId: 1n,
|
|
1137
1199
|
expiry,
|
|
1138
1200
|
type: 'p256',
|
|
1139
1201
|
limits: [
|
|
@@ -1149,7 +1211,7 @@ describe('toRpc', () => {
|
|
|
1149
1211
|
|
|
1150
1212
|
expect(rpc).toMatchInlineSnapshot(`
|
|
1151
1213
|
{
|
|
1152
|
-
"chainId": "
|
|
1214
|
+
"chainId": "0x1",
|
|
1153
1215
|
"expiry": "0x499602d2",
|
|
1154
1216
|
"keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1155
1217
|
"keyType": "p256",
|
|
@@ -1174,6 +1236,7 @@ describe('toRpc', () => {
|
|
|
1174
1236
|
test('webAuthn', () => {
|
|
1175
1237
|
const authorization = KeyAuthorization.from({
|
|
1176
1238
|
address,
|
|
1239
|
+
chainId: 1n,
|
|
1177
1240
|
expiry,
|
|
1178
1241
|
type: 'webAuthn',
|
|
1179
1242
|
limits: [
|
|
@@ -1189,7 +1252,7 @@ describe('toRpc', () => {
|
|
|
1189
1252
|
|
|
1190
1253
|
expect(rpc).toMatchInlineSnapshot(`
|
|
1191
1254
|
{
|
|
1192
|
-
"chainId": "
|
|
1255
|
+
"chainId": "0x1",
|
|
1193
1256
|
"expiry": "0x499602d2",
|
|
1194
1257
|
"keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1195
1258
|
"keyType": "webAuthn",
|
|
@@ -1214,6 +1277,7 @@ describe('toRpc', () => {
|
|
|
1214
1277
|
test('multiple limits', () => {
|
|
1215
1278
|
const authorization = KeyAuthorization.from({
|
|
1216
1279
|
address,
|
|
1280
|
+
chainId: 1n,
|
|
1217
1281
|
expiry,
|
|
1218
1282
|
type: 'secp256k1',
|
|
1219
1283
|
limits: [
|
|
@@ -1233,7 +1297,7 @@ describe('toRpc', () => {
|
|
|
1233
1297
|
|
|
1234
1298
|
expect(rpc).toMatchInlineSnapshot(`
|
|
1235
1299
|
{
|
|
1236
|
-
"chainId": "
|
|
1300
|
+
"chainId": "0x1",
|
|
1237
1301
|
"expiry": "0x499602d2",
|
|
1238
1302
|
"keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1239
1303
|
"keyType": "secp256k1",
|
|
@@ -1322,6 +1386,7 @@ describe('toTuple', () => {
|
|
|
1322
1386
|
test('default', () => {
|
|
1323
1387
|
const authorization = KeyAuthorization.from({
|
|
1324
1388
|
address,
|
|
1389
|
+
chainId: 1n,
|
|
1325
1390
|
type: 'secp256k1',
|
|
1326
1391
|
})
|
|
1327
1392
|
|
|
@@ -1330,7 +1395,7 @@ describe('toTuple', () => {
|
|
|
1330
1395
|
expect(tuple).toMatchInlineSnapshot(`
|
|
1331
1396
|
[
|
|
1332
1397
|
[
|
|
1333
|
-
"
|
|
1398
|
+
"0x1",
|
|
1334
1399
|
"0x",
|
|
1335
1400
|
"0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1336
1401
|
],
|
|
@@ -1341,6 +1406,7 @@ describe('toTuple', () => {
|
|
|
1341
1406
|
test('with signature (secp256k1)', () => {
|
|
1342
1407
|
const authorization = KeyAuthorization.from({
|
|
1343
1408
|
address,
|
|
1409
|
+
chainId: 1n,
|
|
1344
1410
|
expiry,
|
|
1345
1411
|
type: 'secp256k1',
|
|
1346
1412
|
limits: [
|
|
@@ -1357,7 +1423,7 @@ describe('toTuple', () => {
|
|
|
1357
1423
|
expect(tuple).toMatchInlineSnapshot(`
|
|
1358
1424
|
[
|
|
1359
1425
|
[
|
|
1360
|
-
"
|
|
1426
|
+
"0x1",
|
|
1361
1427
|
"0x",
|
|
1362
1428
|
"0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1363
1429
|
"0x499602d2",
|
|
@@ -1376,6 +1442,7 @@ describe('toTuple', () => {
|
|
|
1376
1442
|
test('with signature (p256)', () => {
|
|
1377
1443
|
const authorization = KeyAuthorization.from({
|
|
1378
1444
|
address,
|
|
1445
|
+
chainId: 1n,
|
|
1379
1446
|
expiry,
|
|
1380
1447
|
type: 'p256',
|
|
1381
1448
|
limits: [
|
|
@@ -1392,7 +1459,7 @@ describe('toTuple', () => {
|
|
|
1392
1459
|
expect(tuple).toMatchInlineSnapshot(`
|
|
1393
1460
|
[
|
|
1394
1461
|
[
|
|
1395
|
-
"
|
|
1462
|
+
"0x1",
|
|
1396
1463
|
"0x01",
|
|
1397
1464
|
"0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1398
1465
|
"0x499602d2",
|
|
@@ -1411,6 +1478,7 @@ describe('toTuple', () => {
|
|
|
1411
1478
|
test('with signature (webAuthn)', () => {
|
|
1412
1479
|
const authorization = KeyAuthorization.from({
|
|
1413
1480
|
address,
|
|
1481
|
+
chainId: 1n,
|
|
1414
1482
|
expiry,
|
|
1415
1483
|
type: 'webAuthn',
|
|
1416
1484
|
limits: [
|
|
@@ -1427,7 +1495,7 @@ describe('toTuple', () => {
|
|
|
1427
1495
|
expect(tuple).toMatchInlineSnapshot(`
|
|
1428
1496
|
[
|
|
1429
1497
|
[
|
|
1430
|
-
"
|
|
1498
|
+
"0x1",
|
|
1431
1499
|
"0x02",
|
|
1432
1500
|
"0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1433
1501
|
"0x499602d2",
|
|
@@ -1446,6 +1514,7 @@ describe('toTuple', () => {
|
|
|
1446
1514
|
test('multiple limits', () => {
|
|
1447
1515
|
const authorization = KeyAuthorization.from({
|
|
1448
1516
|
address,
|
|
1517
|
+
chainId: 1n,
|
|
1449
1518
|
expiry,
|
|
1450
1519
|
type: 'secp256k1',
|
|
1451
1520
|
limits: [
|
|
@@ -1465,7 +1534,7 @@ describe('toTuple', () => {
|
|
|
1465
1534
|
expect(tuple).toMatchInlineSnapshot(`
|
|
1466
1535
|
[
|
|
1467
1536
|
[
|
|
1468
|
-
"
|
|
1537
|
+
"0x1",
|
|
1469
1538
|
"0x",
|
|
1470
1539
|
"0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
1471
1540
|
"0x499602d2",
|
|
@@ -1521,6 +1590,7 @@ describe('toTuple', () => {
|
|
|
1521
1590
|
test('zero spending limit roundtrips through RLP', () => {
|
|
1522
1591
|
const authorization = KeyAuthorization.from({
|
|
1523
1592
|
address,
|
|
1593
|
+
chainId: 0n,
|
|
1524
1594
|
expiry,
|
|
1525
1595
|
type: 'secp256k1',
|
|
1526
1596
|
limits: [
|
|
@@ -1562,6 +1632,7 @@ describe('toTuple', () => {
|
|
|
1562
1632
|
test('zero expiry roundtrips through RLP', () => {
|
|
1563
1633
|
const authorization = KeyAuthorization.from({
|
|
1564
1634
|
address,
|
|
1635
|
+
chainId: 0n,
|
|
1565
1636
|
expiry: 0,
|
|
1566
1637
|
type: 'secp256k1',
|
|
1567
1638
|
limits: [
|
|
@@ -1603,6 +1674,7 @@ describe('toTuple', () => {
|
|
|
1603
1674
|
test('hash works with zero spending limit', () => {
|
|
1604
1675
|
const authorization = KeyAuthorization.from({
|
|
1605
1676
|
address,
|
|
1677
|
+
chainId: 1n,
|
|
1606
1678
|
expiry,
|
|
1607
1679
|
type: 'secp256k1',
|
|
1608
1680
|
limits: [
|