ox 0.14.56 → 0.14.58
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/CHANGELOG.md +35 -0
- package/_cjs/core/AbiEvent.js +16 -4
- package/_cjs/core/AbiEvent.js.map +1 -1
- package/_cjs/core/Hex.js +5 -3
- package/_cjs/core/Hex.js.map +1 -1
- package/_cjs/core/RpcTransport.js +32 -19
- package/_cjs/core/RpcTransport.js.map +1 -1
- package/_cjs/core/TypedData.js +1 -1
- package/_cjs/core/TypedData.js.map +1 -1
- package/_cjs/core/internal/abiItem.js +46 -14
- package/_cjs/core/internal/abiItem.js.map +1 -1
- package/_cjs/tempo/AccountConfig.js +16 -5
- package/_cjs/tempo/AccountConfig.js.map +1 -1
- package/_cjs/tempo/AccountSimulation.js +13 -4
- package/_cjs/tempo/AccountSimulation.js.map +1 -1
- package/_cjs/tempo/KeyAuthorization.js +2 -11
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +7 -5
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/AbiEvent.js +19 -4
- package/_esm/core/AbiEvent.js.map +1 -1
- package/_esm/core/Hex.js +5 -3
- package/_esm/core/Hex.js.map +1 -1
- package/_esm/core/RpcTransport.js +38 -19
- package/_esm/core/RpcTransport.js.map +1 -1
- package/_esm/core/TypedData.js +1 -1
- package/_esm/core/TypedData.js.map +1 -1
- package/_esm/core/internal/abiItem.js +51 -17
- package/_esm/core/internal/abiItem.js.map +1 -1
- package/_esm/tempo/AccountConfig.js +58 -9
- package/_esm/tempo/AccountConfig.js.map +1 -1
- package/_esm/tempo/AccountSimulation.js +15 -5
- package/_esm/tempo/AccountSimulation.js.map +1 -1
- package/_esm/tempo/KeyAuthorization.js +8 -12
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +7 -5
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/AbiEvent.d.ts.map +1 -1
- package/_types/core/Hex.d.ts +13 -1
- package/_types/core/Hex.d.ts.map +1 -1
- package/_types/core/RpcTransport.d.ts.map +1 -1
- package/_types/core/internal/abiItem.d.ts.map +1 -1
- package/_types/tempo/AccountConfig.d.ts +46 -3
- package/_types/tempo/AccountConfig.d.ts.map +1 -1
- package/_types/tempo/AccountSimulation.d.ts +6 -2
- package/_types/tempo/AccountSimulation.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorization.d.ts +18 -13
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +3 -3
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/AbiEvent.ts +24 -3
- package/core/Hex.ts +17 -3
- package/core/RpcTransport.ts +40 -22
- package/core/TypedData.ts +1 -1
- package/core/internal/abiItem.ts +70 -21
- package/package.json +1 -1
- package/tempo/AccountConfig.test-d.ts +10 -0
- package/tempo/AccountConfig.test.ts +143 -10
- package/tempo/AccountConfig.ts +80 -9
- package/tempo/AccountOperation.test.ts +32 -32
- package/tempo/AccountSimulation.test.ts +44 -0
- package/tempo/AccountSimulation.ts +19 -5
- package/tempo/KeyAuthorization.test-d.ts +8 -18
- package/tempo/KeyAuthorization.test.ts +95 -39
- package/tempo/KeyAuthorization.ts +20 -43
- package/tempo/RpcSchemaTempo.test-d.ts +2 -2
- package/tempo/TransactionRequest.test-d.ts +3 -3
- package/tempo/TransactionRequest.test.ts +10 -8
- package/tempo/TransactionRequest.ts +10 -8
- package/version.ts +1 -1
|
@@ -150,8 +150,8 @@ describe('getHash', () => {
|
|
|
150
150
|
}),
|
|
151
151
|
}).toMatchInlineSnapshot(`
|
|
152
152
|
{
|
|
153
|
-
"keyAuthorization": "
|
|
154
|
-
"transaction": "
|
|
153
|
+
"keyAuthorization": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
154
|
+
"transaction": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
155
155
|
}
|
|
156
156
|
`)
|
|
157
157
|
})
|
|
@@ -342,14 +342,14 @@ describe('serializeKeyAuthorization', () => {
|
|
|
342
342
|
expect(results).toMatchInlineSnapshot(`
|
|
343
343
|
[
|
|
344
344
|
{
|
|
345
|
-
"account": "
|
|
346
|
-
"hash": "
|
|
345
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
346
|
+
"hash": "0x8d72c92f8aca5cf651ff914a928a32b1717e51b70fce97e305aaab02617474f5",
|
|
347
347
|
"signatureCount": 2,
|
|
348
348
|
"version": 1n,
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
|
-
"account": "
|
|
352
|
-
"hash": "
|
|
351
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
352
|
+
"hash": "0x1dce79ae000bb60526cbe3b18be29d517319ee0958b01e5e3e89608e19c13459",
|
|
353
353
|
"signatureCount": 2,
|
|
354
354
|
"version": 0n,
|
|
355
355
|
},
|
|
@@ -443,15 +443,15 @@ describe('serializeTransaction', () => {
|
|
|
443
443
|
expect(results).toMatchInlineSnapshot(`
|
|
444
444
|
[
|
|
445
445
|
{
|
|
446
|
-
"account": "
|
|
447
|
-
"hash": "
|
|
446
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
447
|
+
"hash": "0x75106153400c34efbeb7380828e3fef939340eb0a3a42dda6a22f798f94665d0",
|
|
448
448
|
"signatureCount": 2,
|
|
449
449
|
"type": "0x76",
|
|
450
450
|
"version": 1n,
|
|
451
451
|
},
|
|
452
452
|
{
|
|
453
|
-
"account": "
|
|
454
|
-
"hash": "
|
|
453
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
454
|
+
"hash": "0x2718b956492b1f8ff4e25165ac425e9e7064580b76eb087ce764e263723152bc",
|
|
455
455
|
"signatureCount": 2,
|
|
456
456
|
"type": "0x76",
|
|
457
457
|
"version": 0n,
|
|
@@ -528,7 +528,7 @@ describe('serializeTransaction', () => {
|
|
|
528
528
|
[
|
|
529
529
|
{
|
|
530
530
|
"feePayerSignature": null,
|
|
531
|
-
"from": "
|
|
531
|
+
"from": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
532
532
|
"signatureCount": 2,
|
|
533
533
|
"type": "0x78",
|
|
534
534
|
},
|
|
@@ -538,7 +538,7 @@ describe('serializeTransaction', () => {
|
|
|
538
538
|
"s": 6n,
|
|
539
539
|
"yParity": 0,
|
|
540
540
|
},
|
|
541
|
-
"from": "
|
|
541
|
+
"from": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
542
542
|
"signatureCount": 2,
|
|
543
543
|
"type": "0x78",
|
|
544
544
|
},
|
|
@@ -610,7 +610,7 @@ describe('from', () => {
|
|
|
610
610
|
expect({ pending, submitting, success }).toMatchInlineSnapshot(`
|
|
611
611
|
{
|
|
612
612
|
"pending": {
|
|
613
|
-
"account": "
|
|
613
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
614
614
|
"approvals": [
|
|
615
615
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
616
616
|
],
|
|
@@ -630,7 +630,7 @@ describe('from', () => {
|
|
|
630
630
|
"version": 1n,
|
|
631
631
|
},
|
|
632
632
|
"createdAt": 1,
|
|
633
|
-
"hash": "
|
|
633
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
634
634
|
"signatureCount": 1,
|
|
635
635
|
"status": "pending",
|
|
636
636
|
"threshold": 2,
|
|
@@ -640,7 +640,7 @@ describe('from', () => {
|
|
|
640
640
|
"weight": 1,
|
|
641
641
|
},
|
|
642
642
|
"submitting": {
|
|
643
|
-
"account": "
|
|
643
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
644
644
|
"approvals": [
|
|
645
645
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
646
646
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -662,7 +662,7 @@ describe('from', () => {
|
|
|
662
662
|
},
|
|
663
663
|
"createdAt": 1,
|
|
664
664
|
"expiresAt": 10,
|
|
665
|
-
"hash": "
|
|
665
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
666
666
|
"signatureCount": 2,
|
|
667
667
|
"status": "submitting",
|
|
668
668
|
"submissionId": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
@@ -673,7 +673,7 @@ describe('from', () => {
|
|
|
673
673
|
"weight": 2,
|
|
674
674
|
},
|
|
675
675
|
"success": {
|
|
676
|
-
"account": "
|
|
676
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
677
677
|
"approvals": [
|
|
678
678
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
679
679
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -694,7 +694,7 @@ describe('from', () => {
|
|
|
694
694
|
"version": 1n,
|
|
695
695
|
},
|
|
696
696
|
"createdAt": 1,
|
|
697
|
-
"hash": "
|
|
697
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
698
698
|
"signatureCount": 2,
|
|
699
699
|
"status": "success",
|
|
700
700
|
"threshold": 2,
|
|
@@ -735,7 +735,7 @@ describe('from', () => {
|
|
|
735
735
|
},
|
|
736
736
|
`
|
|
737
737
|
{
|
|
738
|
-
"account": "
|
|
738
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
739
739
|
"approvals": [
|
|
740
740
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
741
741
|
],
|
|
@@ -812,7 +812,7 @@ describe('from', () => {
|
|
|
812
812
|
},
|
|
813
813
|
`
|
|
814
814
|
{
|
|
815
|
-
"account": "
|
|
815
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
816
816
|
"approvals": [
|
|
817
817
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
818
818
|
],
|
|
@@ -869,7 +869,7 @@ describe('from', () => {
|
|
|
869
869
|
expect({ pending, success }).toMatchInlineSnapshot(`
|
|
870
870
|
{
|
|
871
871
|
"pending": {
|
|
872
|
-
"account": "
|
|
872
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
873
873
|
"approvals": [
|
|
874
874
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
875
875
|
],
|
|
@@ -889,8 +889,8 @@ describe('from', () => {
|
|
|
889
889
|
"version": 1n,
|
|
890
890
|
},
|
|
891
891
|
"createdAt": 1,
|
|
892
|
-
"hash": "
|
|
893
|
-
"keyAuthorization": "
|
|
892
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
893
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
894
894
|
"signatureCount": 1,
|
|
895
895
|
"status": "pending",
|
|
896
896
|
"threshold": 2,
|
|
@@ -899,7 +899,7 @@ describe('from', () => {
|
|
|
899
899
|
"weight": 1,
|
|
900
900
|
},
|
|
901
901
|
"success": {
|
|
902
|
-
"account": "
|
|
902
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
903
903
|
"approvals": [
|
|
904
904
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
905
905
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -920,8 +920,8 @@ describe('from', () => {
|
|
|
920
920
|
"version": 1n,
|
|
921
921
|
},
|
|
922
922
|
"createdAt": 1,
|
|
923
|
-
"hash": "
|
|
924
|
-
"keyAuthorization": "
|
|
923
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
924
|
+
"keyAuthorization": "0xf901b3f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13b9017805f90174940f8659dd87410f00a1668211ecda7ac7f9c9fd13f852a000000000000000000000000000000000000000000000000000000000000000000102eed69407e1ed8ea0e9601e5546b0a03aed683df360140701d694288f0cd85005f34168f731a468aef268c2f9456f01f90108b88201000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200b88201000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
925
925
|
"signatureCount": 2,
|
|
926
926
|
"status": "success",
|
|
927
927
|
"threshold": 2,
|
|
@@ -967,7 +967,7 @@ describe('from', () => {
|
|
|
967
967
|
},
|
|
968
968
|
`
|
|
969
969
|
{
|
|
970
|
-
"account": "
|
|
970
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
971
971
|
"approvals": [
|
|
972
972
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
973
973
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1013,7 +1013,7 @@ describe('RPC conversion', () => {
|
|
|
1013
1013
|
expect({ keyAuthorizationRpc, transactionRpc }).toMatchInlineSnapshot(`
|
|
1014
1014
|
{
|
|
1015
1015
|
"keyAuthorizationRpc": {
|
|
1016
|
-
"account": "
|
|
1016
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1017
1017
|
"approvals": [
|
|
1018
1018
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1019
1019
|
],
|
|
@@ -1033,8 +1033,8 @@ describe('RPC conversion', () => {
|
|
|
1033
1033
|
"version": "0x1",
|
|
1034
1034
|
},
|
|
1035
1035
|
"createdAt": 1,
|
|
1036
|
-
"hash": "
|
|
1037
|
-
"keyAuthorization": "
|
|
1036
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
1037
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1038
1038
|
"signatureCount": 1,
|
|
1039
1039
|
"status": "pending",
|
|
1040
1040
|
"threshold": 2,
|
|
@@ -1043,7 +1043,7 @@ describe('RPC conversion', () => {
|
|
|
1043
1043
|
"weight": 1,
|
|
1044
1044
|
},
|
|
1045
1045
|
"transactionRpc": {
|
|
1046
|
-
"account": "
|
|
1046
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1047
1047
|
"approvals": [
|
|
1048
1048
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1049
1049
|
],
|
|
@@ -1063,7 +1063,7 @@ describe('RPC conversion', () => {
|
|
|
1063
1063
|
"version": "0x1",
|
|
1064
1064
|
},
|
|
1065
1065
|
"createdAt": 1,
|
|
1066
|
-
"hash": "
|
|
1066
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
1067
1067
|
"signatureCount": 1,
|
|
1068
1068
|
"status": "pending",
|
|
1069
1069
|
"threshold": 2,
|
|
@@ -113,6 +113,26 @@ describe('fromRpc', () => {
|
|
|
113
113
|
})
|
|
114
114
|
|
|
115
115
|
describe('toRpc', () => {
|
|
116
|
+
test('behavior: round-trips the grant signer', () => {
|
|
117
|
+
const signer = '0x2222222222222222222222222222222222222222'
|
|
118
|
+
const spec = AccountSimulation.fromRpc({ ...rpc, signer })
|
|
119
|
+
expect(spec.signer).toBe(signer)
|
|
120
|
+
expect(AccountSimulation.toRpc(spec).signer).toBe(signer)
|
|
121
|
+
expect(
|
|
122
|
+
'signer' in AccountSimulation.toRpc(AccountSimulation.fromRpc(rpc)),
|
|
123
|
+
).toBe(false)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
test('error: rejects an invalid grant signer', () => {
|
|
127
|
+
expect(() =>
|
|
128
|
+
AccountSimulation.fromRpc({ ...rpc, signer: '0x1234' }),
|
|
129
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
130
|
+
[Address.InvalidAddressError: Address "0x1234" is invalid.
|
|
131
|
+
|
|
132
|
+
Details: Address is not a 20 byte (40 hexadecimal character) value.]
|
|
133
|
+
`)
|
|
134
|
+
})
|
|
135
|
+
|
|
116
136
|
test('behavior: encodes configurations and shims long key data', () => {
|
|
117
137
|
expect(
|
|
118
138
|
AccountSimulation.toRpc(AccountSimulation.fromRpc(rpc)),
|
|
@@ -147,6 +167,30 @@ describe('toRpc', () => {
|
|
|
147
167
|
`)
|
|
148
168
|
})
|
|
149
169
|
|
|
170
|
+
test('behavior: shims key data that is not a valid length hint', () => {
|
|
171
|
+
const keyData = (keyData: `0x${string}`) =>
|
|
172
|
+
AccountSimulation.toRpc(
|
|
173
|
+
AccountSimulation.fromRpc({
|
|
174
|
+
...rpc,
|
|
175
|
+
approvals: [{ ...rpc.approvals[0], keyData }],
|
|
176
|
+
}),
|
|
177
|
+
).approvals[0]?.keyData
|
|
178
|
+
|
|
179
|
+
expect({
|
|
180
|
+
empty: keyData('0x'),
|
|
181
|
+
four: keyData('0x01020304'),
|
|
182
|
+
one: keyData('0x01'),
|
|
183
|
+
three: keyData('0x010203'),
|
|
184
|
+
}).toMatchInlineSnapshot(`
|
|
185
|
+
{
|
|
186
|
+
"empty": "0x0000",
|
|
187
|
+
"four": "0x01020304",
|
|
188
|
+
"one": "0x01",
|
|
189
|
+
"three": "0x0003",
|
|
190
|
+
}
|
|
191
|
+
`)
|
|
192
|
+
})
|
|
193
|
+
|
|
150
194
|
test('behavior: encodes the maximum uint64 configuration version', () => {
|
|
151
195
|
const spec = AccountSimulation.fromRpc(rpc)
|
|
152
196
|
|
|
@@ -28,6 +28,8 @@ export type Rpc = Compute<{
|
|
|
28
28
|
approvals: readonly ApprovalRpc[]
|
|
29
29
|
/** Canonical RLP-encoded applicable configuration. */
|
|
30
30
|
config: Hex.Hex
|
|
31
|
+
/** Account that signs the modeled key authorization. Omitted for a direct signature. */
|
|
32
|
+
signer?: Address.Address | undefined
|
|
31
33
|
}>
|
|
32
34
|
|
|
33
35
|
/** Account simulation spec used to construct an RPC simulation signature. */
|
|
@@ -36,6 +38,8 @@ export type Spec = Compute<{
|
|
|
36
38
|
approvals: readonly Approval[]
|
|
37
39
|
/** Complete applicable configuration. */
|
|
38
40
|
config: AccountConfig.Config
|
|
41
|
+
/** Account that signs the modeled key authorization. Omitted for a direct signature. */
|
|
42
|
+
signer?: Address.Address | undefined
|
|
39
43
|
}>
|
|
40
44
|
|
|
41
45
|
/**
|
|
@@ -53,14 +57,20 @@ export type Spec = Compute<{
|
|
|
53
57
|
* @returns The account simulation spec with decoded configurations.
|
|
54
58
|
*/
|
|
55
59
|
export function fromRpc(spec: Rpc): Spec {
|
|
56
|
-
const { approvals, config } = spec
|
|
60
|
+
const { approvals, config, signer } = spec
|
|
57
61
|
assertApprovals(approvals)
|
|
58
|
-
|
|
62
|
+
if (signer !== undefined) Address.assert(signer)
|
|
63
|
+
return {
|
|
64
|
+
approvals,
|
|
65
|
+
config: deserializeConfig(config),
|
|
66
|
+
...(signer !== undefined ? { signer } : {}),
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
|
|
61
70
|
export declare namespace fromRpc {
|
|
62
71
|
/** Error type for `fromRpc`. */
|
|
63
72
|
export type ErrorType =
|
|
73
|
+
| Address.assert.ErrorType
|
|
64
74
|
| Hex.isEqual.ErrorType
|
|
65
75
|
| InvalidSimulationError
|
|
66
76
|
| AccountConfig.assert.ErrorType
|
|
@@ -84,8 +94,9 @@ export declare namespace fromRpc {
|
|
|
84
94
|
* @returns The JSON-RPC account simulation spec with encoded configurations.
|
|
85
95
|
*/
|
|
86
96
|
export function toRpc(spec: Spec): Rpc {
|
|
87
|
-
const { approvals, config } = spec
|
|
97
|
+
const { approvals, config, signer } = spec
|
|
88
98
|
assertApprovals(approvals)
|
|
99
|
+
if (signer !== undefined) Address.assert(signer)
|
|
89
100
|
return {
|
|
90
101
|
approvals: approvals.map(({ keyData, keyType, owner }) => ({
|
|
91
102
|
...(keyData !== undefined ? { keyData: shimKeyData(keyData) } : {}),
|
|
@@ -93,12 +104,14 @@ export function toRpc(spec: Spec): Rpc {
|
|
|
93
104
|
owner,
|
|
94
105
|
})),
|
|
95
106
|
config: serializeConfig(config),
|
|
107
|
+
...(signer !== undefined ? { signer } : {}),
|
|
96
108
|
}
|
|
97
109
|
}
|
|
98
110
|
|
|
99
111
|
export declare namespace toRpc {
|
|
100
112
|
/** Error type for `toRpc`. */
|
|
101
113
|
export type ErrorType =
|
|
114
|
+
| Address.assert.ErrorType
|
|
102
115
|
| Hex.fromNumber.ErrorType
|
|
103
116
|
| InvalidSimulationError
|
|
104
117
|
| AccountConfig.assert.ErrorType
|
|
@@ -164,12 +177,13 @@ function serializeConfig(config: AccountConfig.Input): Hex.Hex {
|
|
|
164
177
|
}
|
|
165
178
|
|
|
166
179
|
/**
|
|
167
|
-
* Shims
|
|
180
|
+
* Shims key data into the 1-, 2-, or 4-byte length hint accepted by Tempo's
|
|
181
|
+
* gas estimator. Other sizes are replaced by a 2-byte hint of their length.
|
|
168
182
|
* @internal
|
|
169
183
|
*/
|
|
170
184
|
function shimKeyData(data: Hex.Hex): Hex.Hex {
|
|
171
185
|
const size = Hex.size(data)
|
|
172
|
-
if (size
|
|
186
|
+
if (size === 1 || size === 2 || size === 4) return data
|
|
173
187
|
return Hex.fromNumber(size, { size: 2 })
|
|
174
188
|
}
|
|
175
189
|
|
|
@@ -51,37 +51,27 @@ test('accepts configurable signatures and account-bound grants', () => {
|
|
|
51
51
|
).toMatchTypeOf<KeyAuthorization.Rpc>()
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
-
test('
|
|
54
|
+
test('allows configurable grants without an account', () => {
|
|
55
55
|
type Configurable = Extract<KeyAuthorization.Input, { type: 'configurable' }>
|
|
56
|
-
expectTypeOf<Configurable['account']>().toEqualTypeOf<
|
|
56
|
+
expectTypeOf<Configurable['account']>().toEqualTypeOf<
|
|
57
|
+
TempoAddress.Address | undefined
|
|
58
|
+
>()
|
|
57
59
|
expectTypeOf<
|
|
58
60
|
Extract<KeyAuthorization.Signed, { type: 'configurable' }>['account']
|
|
59
|
-
>().toEqualTypeOf<`0x${string}
|
|
60
|
-
expectTypeOf<
|
|
61
|
-
Omit<Extract<KeyAuthorization.Rpc, { keyType: 'multisig' }>, 'account'>
|
|
62
|
-
>().not.toExtend<KeyAuthorization.Rpc>()
|
|
61
|
+
>().toEqualTypeOf<`0x${string}` | undefined>()
|
|
63
62
|
expectTypeOf<{
|
|
64
63
|
address: `0x${string}`
|
|
65
64
|
chainId: bigint
|
|
66
65
|
type: 'configurable'
|
|
67
|
-
}>().
|
|
68
|
-
expectTypeOf<{
|
|
69
|
-
account: undefined
|
|
70
|
-
address: `0x${string}`
|
|
71
|
-
chainId: bigint
|
|
72
|
-
type: 'configurable'
|
|
73
|
-
}>().not.toExtend<KeyAuthorization.Input>()
|
|
66
|
+
}>().toExtend<KeyAuthorization.Input>()
|
|
74
67
|
expectTypeOf<{
|
|
75
68
|
account: null
|
|
76
69
|
chainId: '0x1'
|
|
77
70
|
expiry: null
|
|
78
71
|
keyId: `0x${string}`
|
|
79
|
-
keyType: '
|
|
72
|
+
keyType: 'configurableAccount'
|
|
80
73
|
signature: KeyAuthorization.SignatureRpc
|
|
81
|
-
}>().
|
|
82
|
-
expectTypeOf<
|
|
83
|
-
Extract<KeyAuthorization.Rpc, { keyType: 'multisig' }>['account']
|
|
84
|
-
>().toEqualTypeOf<`0x${string}`>()
|
|
74
|
+
}>().toExtend<KeyAuthorization.Rpc>()
|
|
85
75
|
})
|
|
86
76
|
|
|
87
77
|
test('rejects keychain signatures', () => {
|
|
@@ -117,49 +117,84 @@ describe('configurable account binding', () => {
|
|
|
117
117
|
).toMatchInlineSnapshot(`"0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c"`)
|
|
118
118
|
})
|
|
119
119
|
|
|
120
|
-
test('
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
type: 'configurable',
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
120
|
+
test('behavior: accepts unbound configurable grants', () => {
|
|
121
|
+
// The node binds a root-signed grant to its signer, so only admin-signed
|
|
122
|
+
// grants need `account` (TIP-1049).
|
|
123
|
+
const signed = KeyAuthorization.from(
|
|
124
|
+
{ address, chainId: 1n, type: 'configurable' },
|
|
125
|
+
{ signature: signature_secp256k1 },
|
|
126
|
+
)
|
|
127
|
+
const rpc = KeyAuthorization.toRpc(signed)
|
|
128
|
+
expect({
|
|
129
|
+
deserialized: KeyAuthorization.deserialize(
|
|
130
|
+
KeyAuthorization.serialize(signed),
|
|
131
|
+
),
|
|
132
|
+
fromRpc: KeyAuthorization.fromRpc(rpc),
|
|
133
|
+
fromTuple: KeyAuthorization.fromTuple([['0x01', '0x03', address]]),
|
|
134
|
+
rpc,
|
|
135
|
+
}).toMatchInlineSnapshot(`
|
|
136
|
+
{
|
|
137
|
+
"deserialized": {
|
|
138
|
+
"account": undefined,
|
|
139
|
+
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
140
|
+
"chainId": 1n,
|
|
141
|
+
"signature": {
|
|
142
|
+
"signature": {
|
|
143
|
+
"r": 113291597329930009559670063131885256927775966057121513567941051428123344285399n,
|
|
144
|
+
"s": 54293712598725100598138577281441749550405991478212695085505730636505228583888n,
|
|
145
|
+
"yParity": 1,
|
|
146
|
+
},
|
|
147
|
+
"type": "secp256k1",
|
|
148
|
+
},
|
|
149
|
+
"type": "configurable",
|
|
150
|
+
},
|
|
151
|
+
"fromRpc": {
|
|
152
|
+
"account": undefined,
|
|
153
|
+
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
154
|
+
"chainId": 1n,
|
|
155
|
+
"limits": undefined,
|
|
156
|
+
"signature": {
|
|
157
|
+
"signature": {
|
|
158
|
+
"r": 113291597329930009559670063131885256927775966057121513567941051428123344285399n,
|
|
159
|
+
"s": 54293712598725100598138577281441749550405991478212695085505730636505228583888n,
|
|
160
|
+
"yParity": 1,
|
|
161
|
+
},
|
|
162
|
+
"type": "secp256k1",
|
|
163
|
+
},
|
|
164
|
+
"type": "configurable",
|
|
165
|
+
},
|
|
166
|
+
"fromTuple": {
|
|
167
|
+
"account": undefined,
|
|
168
|
+
"address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
169
|
+
"chainId": 1n,
|
|
170
|
+
"type": "configurable",
|
|
171
|
+
},
|
|
172
|
+
"rpc": {
|
|
173
|
+
"account": undefined,
|
|
174
|
+
"chainId": "0x1",
|
|
175
|
+
"expiry": null,
|
|
176
|
+
"keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
177
|
+
"keyType": "configurableAccount",
|
|
178
|
+
"limits": undefined,
|
|
179
|
+
"signature": {
|
|
180
|
+
"r": "0xfa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7",
|
|
181
|
+
"s": "0x780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d0",
|
|
182
|
+
"type": "secp256k1",
|
|
183
|
+
"yParity": "0x1",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
}
|
|
187
|
+
`)
|
|
145
188
|
})
|
|
146
189
|
|
|
147
|
-
test('
|
|
190
|
+
test('behavior: preserves a bound account', () => {
|
|
148
191
|
const signed = KeyAuthorization.from(
|
|
149
192
|
{ account: address, address, chainId: 1n, type: 'configurable' },
|
|
150
193
|
{ signature: signature_secp256k1 },
|
|
151
194
|
)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
expect(() => KeyAuthorization.fromRpc({ ...rpc, account })).toThrowError(
|
|
156
|
-
KeyAuthorization.MissingAccountError,
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
expect(() =>
|
|
160
|
-
KeyAuthorization.fromTuple([['0x01', '0x03', address]]),
|
|
161
|
-
).toThrowError(KeyAuthorization.MissingAccountError)
|
|
162
|
-
expect(KeyAuthorization.fromRpc(rpc).account).toBe(address)
|
|
195
|
+
expect(
|
|
196
|
+
KeyAuthorization.fromRpc(KeyAuthorization.toRpc(signed)).account,
|
|
197
|
+
).toBe(address)
|
|
163
198
|
expect(
|
|
164
199
|
KeyAuthorization.deserialize(KeyAuthorization.serialize(signed)).account,
|
|
165
200
|
).toBe(address)
|
|
@@ -1512,13 +1547,13 @@ describe('serialize', () => {
|
|
|
1512
1547
|
})
|
|
1513
1548
|
|
|
1514
1549
|
describe('toRpc', () => {
|
|
1515
|
-
test('behavior: configurable key type uses the RPC
|
|
1550
|
+
test('behavior: configurable key type uses the RPC configurableAccount key type', () => {
|
|
1516
1551
|
const authorization = KeyAuthorization.from(
|
|
1517
1552
|
{ account: address, address, chainId: 1n, type: 'configurable' },
|
|
1518
1553
|
{ signature: signature_secp256k1 },
|
|
1519
1554
|
)
|
|
1520
1555
|
const rpc = KeyAuthorization.toRpc(authorization)
|
|
1521
|
-
expect(rpc.keyType).toMatchInlineSnapshot(`"
|
|
1556
|
+
expect(rpc.keyType).toMatchInlineSnapshot(`"configurableAccount"`)
|
|
1522
1557
|
expect(KeyAuthorization.fromRpc(rpc).type).toMatchInlineSnapshot(
|
|
1523
1558
|
`"configurable"`,
|
|
1524
1559
|
)
|
|
@@ -2891,4 +2926,25 @@ describe('admin keys (TIP-1049)', () => {
|
|
|
2891
2926
|
})
|
|
2892
2927
|
expect(KeyAuthorization.hash(a)).not.toBe(KeyAuthorization.hash(b))
|
|
2893
2928
|
})
|
|
2929
|
+
|
|
2930
|
+
describe('configurable admin keys', () => {
|
|
2931
|
+
test('behavior: a configurable account may sign or be granted an admin key', () => {
|
|
2932
|
+
const signed = KeyAuthorization.from(
|
|
2933
|
+
{
|
|
2934
|
+
account: signature_configurable.account,
|
|
2935
|
+
address,
|
|
2936
|
+
chainId: 1n,
|
|
2937
|
+
isAdmin: true,
|
|
2938
|
+
type: 'configurable',
|
|
2939
|
+
},
|
|
2940
|
+
{ signature: signature_configurable },
|
|
2941
|
+
)
|
|
2942
|
+
expect(
|
|
2943
|
+
KeyAuthorization.deserialize(KeyAuthorization.serialize(signed)),
|
|
2944
|
+
).toEqual(signed)
|
|
2945
|
+
expect(
|
|
2946
|
+
KeyAuthorization.fromRpc(KeyAuthorization.toRpc(signed)),
|
|
2947
|
+
).toMatchObject({ isAdmin: true, type: 'configurable' })
|
|
2948
|
+
})
|
|
2949
|
+
})
|
|
2894
2950
|
})
|