ox 1.8.10 → 1.8.12
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 +14 -0
- package/dist/core/Authorization.d.ts.map +1 -1
- package/dist/core/Authorization.js +44 -6
- package/dist/core/Authorization.js.map +1 -1
- package/dist/core/Siwe.d.ts.map +1 -1
- package/dist/core/Siwe.js +1 -1
- package/dist/core/Siwe.js.map +1 -1
- package/dist/tempo/AccountConfig.d.ts +7 -17
- package/dist/tempo/AccountConfig.d.ts.map +1 -1
- package/dist/tempo/AccountConfig.js +8 -26
- package/dist/tempo/AccountConfig.js.map +1 -1
- package/dist/tempo/AccountOperation.d.ts +1 -1
- package/dist/tempo/AccountOperation.js +1 -1
- package/dist/tempo/index.d.ts +1 -3
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +1 -3
- package/dist/tempo/index.js.map +1 -1
- package/dist/zod/Authorization.d.ts.map +1 -1
- package/dist/zod/Authorization.js +6 -9
- package/dist/zod/Authorization.js.map +1 -1
- package/package.json +1 -1
- package/src/core/Authorization.ts +43 -6
- package/src/core/Siwe.ts +1 -1
- package/src/core/_test/Authorization.test.ts +166 -0
- package/src/core/_test/Siwe.test.ts +53 -0
- package/src/core/_test/TransactionEnvelopeEip7702.test.ts +66 -0
- package/src/tempo/AccountConfig.test.ts +34 -47
- package/src/tempo/AccountConfig.ts +9 -37
- package/src/tempo/AccountOperation.test.ts +36 -37
- package/src/tempo/AccountOperation.ts +1 -1
- package/src/tempo/SignatureEnvelope.test.ts +1 -3
- package/src/tempo/configurableAccounts.e2e.test.ts +1 -2
- package/src/tempo/index.ts +1 -3
- package/src/version.ts +1 -1
- package/src/zod/Authorization.ts +6 -24
- package/src/zod/_test/Authorization.test.ts +35 -2
- package/src/zod/_test/TransactionRequest.test.ts +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Address from '../core/Address.js'
|
|
2
2
|
import type * as Bytes from '../core/Bytes.js'
|
|
3
|
-
import * as ContractAddress from '../core/ContractAddress.js'
|
|
4
3
|
import * as Errors from '../core/Errors.js'
|
|
5
4
|
import * as Hash from '../core/Hash.js'
|
|
6
5
|
import * as Hex from '../core/Hex.js'
|
|
@@ -38,15 +37,6 @@ const accountDomain = 'tempo:configurable-account:account'
|
|
|
38
37
|
/** Domain prefix for account configuration commitments. */
|
|
39
38
|
const configDomain = 'tempo:configurable-account:config'
|
|
40
39
|
|
|
41
|
-
/**
|
|
42
|
-
* Keccak-256 of the account proxy creation code.
|
|
43
|
-
*
|
|
44
|
-
* Placeholder until [TIP-1110](https://tips.sh/1110) fixes the canonical
|
|
45
|
-
* account proxy, which will change every derived address.
|
|
46
|
-
*/
|
|
47
|
-
const accountProxyInitCodeHash =
|
|
48
|
-
'0x583cc63a2e37f645b43eac911b1a6d6de08b83abdc308c61364edda8cfc3bd37'
|
|
49
|
-
|
|
50
40
|
/** Domain prefix for configurable account owner approvals. */
|
|
51
41
|
const signatureDomain = 'tempo:configurable-account:signature'
|
|
52
42
|
|
|
@@ -421,9 +411,9 @@ export declare namespace fromUpgrade {
|
|
|
421
411
|
/**
|
|
422
412
|
* Derives the stable configurable account address.
|
|
423
413
|
*
|
|
424
|
-
* The
|
|
425
|
-
* big-endian fields, not RLP
|
|
426
|
-
*
|
|
414
|
+
* The address is the last 20 bytes of the keccak256 hash of the initial
|
|
415
|
+
* config, encoded with fixed-width big-endian fields, not RLP:
|
|
416
|
+
* `keccak256("tempo:configurable-account:account" || salt || uint8(threshold) || uint8(owners.length) || owners)`.
|
|
427
417
|
*
|
|
428
418
|
* The address is derived once from the initial version-0 config. Config
|
|
429
419
|
* updates do not change it.
|
|
@@ -442,26 +432,19 @@ export declare namespace fromUpgrade {
|
|
|
442
432
|
* threshold: 1
|
|
443
433
|
* })
|
|
444
434
|
*
|
|
445
|
-
* const address = AccountConfig.getAddress(initialConfig
|
|
446
|
-
* factory: '0x7171717171717171717171717171717171717171'
|
|
447
|
-
* })
|
|
435
|
+
* const address = AccountConfig.getAddress(initialConfig)
|
|
448
436
|
* ```
|
|
449
437
|
*
|
|
450
438
|
* @param config - The initial account config.
|
|
451
|
-
* @param options - The recovery factory configured by the chain.
|
|
452
439
|
* @returns The configurable account address.
|
|
453
440
|
*/
|
|
454
|
-
export function getAddress(
|
|
455
|
-
config: Input,
|
|
456
|
-
options: getAddress.Options,
|
|
457
|
-
): Address.Address {
|
|
458
|
-
Address.assert(options.factory)
|
|
441
|
+
export function getAddress(config: Input): Address.Address {
|
|
459
442
|
assert(config)
|
|
460
443
|
if (BigInt(config.version ?? 0) !== 0n)
|
|
461
444
|
throw new InvalidConfigError({
|
|
462
445
|
reason: 'account address requires version zero',
|
|
463
446
|
})
|
|
464
|
-
const
|
|
447
|
+
const hash = Hash.keccak256(
|
|
465
448
|
Hex.concat(
|
|
466
449
|
Hex.fromString(accountDomain),
|
|
467
450
|
Hex.padLeft(config.salt ?? zeroSalt, 32),
|
|
@@ -473,11 +456,7 @@ export function getAddress(
|
|
|
473
456
|
]),
|
|
474
457
|
),
|
|
475
458
|
)
|
|
476
|
-
const account =
|
|
477
|
-
bytecodeHash: accountProxyInitCodeHash,
|
|
478
|
-
from: options.factory,
|
|
479
|
-
salt: accountSalt,
|
|
480
|
-
})
|
|
459
|
+
const account = Hex.slice(hash, 12)
|
|
481
460
|
if (Hex.toBigInt(account) === 0n)
|
|
482
461
|
throw new InvalidConfigError({ reason: 'derived account cannot be zero' })
|
|
483
462
|
if (config.owners.some((owner) => Address.isEqual(owner.owner, account)))
|
|
@@ -488,18 +467,13 @@ export function getAddress(
|
|
|
488
467
|
}
|
|
489
468
|
|
|
490
469
|
export declare namespace getAddress {
|
|
491
|
-
type Options = {
|
|
492
|
-
/** Recovery factory configured by the chain. */
|
|
493
|
-
factory: Address.Address
|
|
494
|
-
}
|
|
495
|
-
|
|
496
470
|
type ErrorType =
|
|
497
471
|
| assert.ErrorType
|
|
498
|
-
| ContractAddress.fromCreate2.ErrorType
|
|
499
472
|
| Hash.keccak256.ErrorType
|
|
500
473
|
| Hex.concat.ErrorType
|
|
501
474
|
| Hex.fromNumber.ErrorType
|
|
502
475
|
| Hex.fromString.ErrorType
|
|
476
|
+
| Hex.slice.ErrorType
|
|
503
477
|
| Errors.GlobalErrorType
|
|
504
478
|
}
|
|
505
479
|
|
|
@@ -586,9 +560,7 @@ export declare namespace getCommitment {
|
|
|
586
560
|
* })
|
|
587
561
|
*
|
|
588
562
|
* const digest = AccountConfig.getSignPayload({
|
|
589
|
-
* account: AccountConfig.getAddress(config,
|
|
590
|
-
* factory: '0x7171717171717171717171717171717171717171'
|
|
591
|
-
* }),
|
|
563
|
+
* account: AccountConfig.getAddress(config),
|
|
592
564
|
* config,
|
|
593
565
|
* payload: TxEnvelopeTempo.getSignPayload(envelope)
|
|
594
566
|
* })
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { factory } from '../../test/tempo/configurableAccounts.js'
|
|
2
1
|
import { Address, Hash, Hex, P256 } from 'ox'
|
|
3
2
|
import {
|
|
4
3
|
AccountConfig,
|
|
@@ -41,7 +40,7 @@ const config = AccountConfig.from({
|
|
|
41
40
|
threshold: 2,
|
|
42
41
|
})
|
|
43
42
|
const currentConfig = AccountConfig.from({ ...config, version: 1n })
|
|
44
|
-
const account = AccountConfig.getAddress(config
|
|
43
|
+
const account = AccountConfig.getAddress(config)
|
|
45
44
|
const ownerSignature_1 = owners[0]!.signature
|
|
46
45
|
const approval_1 = SignatureEnvelope.serialize(ownerSignature_1)
|
|
47
46
|
const approval_2 = SignatureEnvelope.serialize(owners[1]!.signature)
|
|
@@ -153,8 +152,8 @@ describe('getHash', () => {
|
|
|
153
152
|
}),
|
|
154
153
|
}).toMatchInlineSnapshot(`
|
|
155
154
|
{
|
|
156
|
-
"keyAuthorization": "
|
|
157
|
-
"transaction": "
|
|
155
|
+
"keyAuthorization": "0x5e8fa6d31c6e604cdac971bdd0a10b825cbb039c76ee399a6d6f619957032de4",
|
|
156
|
+
"transaction": "0x4f312a4616f3f96375e6bd4c20f992694408a8c804429140068aee31bd0b0eaf",
|
|
158
157
|
}
|
|
159
158
|
`)
|
|
160
159
|
})
|
|
@@ -170,7 +169,7 @@ describe('selectApprovals', () => {
|
|
|
170
169
|
],
|
|
171
170
|
threshold: 3,
|
|
172
171
|
})
|
|
173
|
-
const account = AccountConfig.getAddress(config
|
|
172
|
+
const account = AccountConfig.getAddress(config)
|
|
174
173
|
const hash = AccountOperation.getHash({
|
|
175
174
|
account,
|
|
176
175
|
config: { ...config, version: 1n },
|
|
@@ -226,7 +225,7 @@ describe('selectApprovals', () => {
|
|
|
226
225
|
}
|
|
227
226
|
`)
|
|
228
227
|
})
|
|
229
|
-
test('accepts an explicit account
|
|
228
|
+
test('accepts an explicit derived account', async () => {
|
|
230
229
|
const selected = await AccountOperation.selectApprovals({
|
|
231
230
|
account,
|
|
232
231
|
approvals: [],
|
|
@@ -345,14 +344,14 @@ describe('serializeKeyAuthorization', () => {
|
|
|
345
344
|
expect(results).toMatchInlineSnapshot(`
|
|
346
345
|
[
|
|
347
346
|
{
|
|
348
|
-
"account": "
|
|
349
|
-
"hash": "
|
|
347
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
348
|
+
"hash": "0xa12b482453a90d0be6ec0c85e9871d47c322278e2e623191196a974aef52cafd",
|
|
350
349
|
"signatureCount": 2,
|
|
351
350
|
"version": 1n,
|
|
352
351
|
},
|
|
353
352
|
{
|
|
354
|
-
"account": "
|
|
355
|
-
"hash": "
|
|
353
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
354
|
+
"hash": "0x65666f84fa858423447d9eb84e4ad8e36ea483b358cfb935103f14912db0de93",
|
|
356
355
|
"signatureCount": 2,
|
|
357
356
|
"version": 0n,
|
|
358
357
|
},
|
|
@@ -446,15 +445,15 @@ describe('serializeTransaction', () => {
|
|
|
446
445
|
expect(results).toMatchInlineSnapshot(`
|
|
447
446
|
[
|
|
448
447
|
{
|
|
449
|
-
"account": "
|
|
450
|
-
"hash": "
|
|
448
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
449
|
+
"hash": "0x58d5d2655982d69e28c791189c23056344a2b7a166a893988a4b9be228b73469",
|
|
451
450
|
"signatureCount": 2,
|
|
452
451
|
"type": "0x76",
|
|
453
452
|
"version": 1n,
|
|
454
453
|
},
|
|
455
454
|
{
|
|
456
|
-
"account": "
|
|
457
|
-
"hash": "
|
|
455
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
456
|
+
"hash": "0xb3e7bcc63f69d80a954c2e4a5ba186903012686ea31bd049465f6c1e2308c046",
|
|
458
457
|
"signatureCount": 2,
|
|
459
458
|
"type": "0x76",
|
|
460
459
|
"version": 0n,
|
|
@@ -535,7 +534,7 @@ describe('serializeTransaction', () => {
|
|
|
535
534
|
[
|
|
536
535
|
{
|
|
537
536
|
"feePayerSignature": null,
|
|
538
|
-
"from": "
|
|
537
|
+
"from": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
539
538
|
"signatureCount": 2,
|
|
540
539
|
"type": "0x78",
|
|
541
540
|
},
|
|
@@ -545,7 +544,7 @@ describe('serializeTransaction', () => {
|
|
|
545
544
|
"s": "0x0000000000000000000000000000000000000000000000000000000000000006",
|
|
546
545
|
"yParity": 0,
|
|
547
546
|
},
|
|
548
|
-
"from": "
|
|
547
|
+
"from": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
549
548
|
"signatureCount": 2,
|
|
550
549
|
"type": "0x78",
|
|
551
550
|
},
|
|
@@ -617,7 +616,7 @@ describe('from', () => {
|
|
|
617
616
|
expect({ pending, submitting, success }).toMatchInlineSnapshot(`
|
|
618
617
|
{
|
|
619
618
|
"pending": {
|
|
620
|
-
"account": "
|
|
619
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
621
620
|
"approvals": [
|
|
622
621
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
623
622
|
],
|
|
@@ -637,7 +636,7 @@ describe('from', () => {
|
|
|
637
636
|
"version": 1n,
|
|
638
637
|
},
|
|
639
638
|
"createdAt": 1,
|
|
640
|
-
"hash": "
|
|
639
|
+
"hash": "0x4f312a4616f3f96375e6bd4c20f992694408a8c804429140068aee31bd0b0eaf",
|
|
641
640
|
"signatureCount": 1,
|
|
642
641
|
"status": "pending",
|
|
643
642
|
"threshold": 2,
|
|
@@ -647,7 +646,7 @@ describe('from', () => {
|
|
|
647
646
|
"weight": 1,
|
|
648
647
|
},
|
|
649
648
|
"submitting": {
|
|
650
|
-
"account": "
|
|
649
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
651
650
|
"approvals": [
|
|
652
651
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
653
652
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -669,7 +668,7 @@ describe('from', () => {
|
|
|
669
668
|
},
|
|
670
669
|
"createdAt": 1,
|
|
671
670
|
"expiresAt": 10,
|
|
672
|
-
"hash": "
|
|
671
|
+
"hash": "0x4f312a4616f3f96375e6bd4c20f992694408a8c804429140068aee31bd0b0eaf",
|
|
673
672
|
"signatureCount": 2,
|
|
674
673
|
"status": "submitting",
|
|
675
674
|
"submissionId": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
@@ -680,7 +679,7 @@ describe('from', () => {
|
|
|
680
679
|
"weight": 2,
|
|
681
680
|
},
|
|
682
681
|
"success": {
|
|
683
|
-
"account": "
|
|
682
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
684
683
|
"approvals": [
|
|
685
684
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
686
685
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -701,7 +700,7 @@ describe('from', () => {
|
|
|
701
700
|
"version": 1n,
|
|
702
701
|
},
|
|
703
702
|
"createdAt": 1,
|
|
704
|
-
"hash": "
|
|
703
|
+
"hash": "0x4f312a4616f3f96375e6bd4c20f992694408a8c804429140068aee31bd0b0eaf",
|
|
705
704
|
"signatureCount": 2,
|
|
706
705
|
"status": "success",
|
|
707
706
|
"threshold": 2,
|
|
@@ -747,7 +746,7 @@ describe('from', () => {
|
|
|
747
746
|
},
|
|
748
747
|
`
|
|
749
748
|
{
|
|
750
|
-
"account": "
|
|
749
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
751
750
|
"approvals": [
|
|
752
751
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
753
752
|
],
|
|
@@ -833,7 +832,7 @@ describe('from', () => {
|
|
|
833
832
|
},
|
|
834
833
|
`
|
|
835
834
|
{
|
|
836
|
-
"account": "
|
|
835
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
837
836
|
"approvals": [
|
|
838
837
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
839
838
|
],
|
|
@@ -890,7 +889,7 @@ describe('from', () => {
|
|
|
890
889
|
expect({ pending, success }).toMatchInlineSnapshot(`
|
|
891
890
|
{
|
|
892
891
|
"pending": {
|
|
893
|
-
"account": "
|
|
892
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
894
893
|
"approvals": [
|
|
895
894
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
896
895
|
],
|
|
@@ -910,8 +909,8 @@ describe('from', () => {
|
|
|
910
909
|
"version": 1n,
|
|
911
910
|
},
|
|
912
911
|
"createdAt": 1,
|
|
913
|
-
"hash": "
|
|
914
|
-
"keyAuthorization": "
|
|
912
|
+
"hash": "0x5e8fa6d31c6e604cdac971bdd0a10b825cbb039c76ee399a6d6f619957032de4",
|
|
913
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d2008080808094b3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
915
914
|
"signatureCount": 1,
|
|
916
915
|
"status": "pending",
|
|
917
916
|
"threshold": 2,
|
|
@@ -920,7 +919,7 @@ describe('from', () => {
|
|
|
920
919
|
"weight": 1,
|
|
921
920
|
},
|
|
922
921
|
"success": {
|
|
923
|
-
"account": "
|
|
922
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
924
923
|
"approvals": [
|
|
925
924
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
926
925
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -941,8 +940,8 @@ describe('from', () => {
|
|
|
941
940
|
"version": 1n,
|
|
942
941
|
},
|
|
943
942
|
"createdAt": 1,
|
|
944
|
-
"hash": "
|
|
945
|
-
"keyAuthorization": "
|
|
943
|
+
"hash": "0x5e8fa6d31c6e604cdac971bdd0a10b825cbb039c76ee399a6d6f619957032de4",
|
|
944
|
+
"keyAuthorization": "0xf901b3f782107980943333333333333333333333333333333333333333846b49d2008080808094b3cc0b31026c7a54a9c45e468c674722c3c5b3b5b9017805f9017494b3cc0b31026c7a54a9c45e468c674722c3c5b3b5f852a000000000000000000000000000000000000000000000000000000000000000000102eed69407e1ed8ea0e9601e5546b0a03aed683df360140701d694288f0cd85005f34168f731a468aef268c2f9456f01f90108b88201000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200b88201000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
946
945
|
"signatureCount": 2,
|
|
947
946
|
"status": "success",
|
|
948
947
|
"threshold": 2,
|
|
@@ -988,7 +987,7 @@ describe('from', () => {
|
|
|
988
987
|
},
|
|
989
988
|
`
|
|
990
989
|
{
|
|
991
|
-
"account": "
|
|
990
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
992
991
|
"approvals": [
|
|
993
992
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
994
993
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1034,7 +1033,7 @@ describe('RPC conversion', () => {
|
|
|
1034
1033
|
expect({ keyAuthorizationRpc, transactionRpc }).toMatchInlineSnapshot(`
|
|
1035
1034
|
{
|
|
1036
1035
|
"keyAuthorizationRpc": {
|
|
1037
|
-
"account": "
|
|
1036
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
1038
1037
|
"approvals": [
|
|
1039
1038
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1040
1039
|
],
|
|
@@ -1054,8 +1053,8 @@ describe('RPC conversion', () => {
|
|
|
1054
1053
|
"version": "0x1",
|
|
1055
1054
|
},
|
|
1056
1055
|
"createdAt": 1,
|
|
1057
|
-
"hash": "
|
|
1058
|
-
"keyAuthorization": "
|
|
1056
|
+
"hash": "0x5e8fa6d31c6e604cdac971bdd0a10b825cbb039c76ee399a6d6f619957032de4",
|
|
1057
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d2008080808094b3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
1059
1058
|
"signatureCount": 1,
|
|
1060
1059
|
"status": "pending",
|
|
1061
1060
|
"threshold": 2,
|
|
@@ -1064,7 +1063,7 @@ describe('RPC conversion', () => {
|
|
|
1064
1063
|
"weight": 1,
|
|
1065
1064
|
},
|
|
1066
1065
|
"transactionRpc": {
|
|
1067
|
-
"account": "
|
|
1066
|
+
"account": "0xb3cc0b31026c7a54a9c45e468c674722c3c5b3b5",
|
|
1068
1067
|
"approvals": [
|
|
1069
1068
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1070
1069
|
],
|
|
@@ -1084,7 +1083,7 @@ describe('RPC conversion', () => {
|
|
|
1084
1083
|
"version": "0x1",
|
|
1085
1084
|
},
|
|
1086
1085
|
"createdAt": 1,
|
|
1087
|
-
"hash": "
|
|
1086
|
+
"hash": "0x4f312a4616f3f96375e6bd4c20f992694408a8c804429140068aee31bd0b0eaf",
|
|
1088
1087
|
"signatureCount": 1,
|
|
1089
1088
|
"status": "pending",
|
|
1090
1089
|
"threshold": 2,
|
|
@@ -1427,7 +1426,7 @@ describe('validation', () => {
|
|
|
1427
1426
|
salt: `0x${'AB'.repeat(32)}`,
|
|
1428
1427
|
threshold: 2,
|
|
1429
1428
|
})
|
|
1430
|
-
const account = AccountConfig.getAddress(config
|
|
1429
|
+
const account = AccountConfig.getAddress(config)
|
|
1431
1430
|
const authorization = KeyAuthorization.from({
|
|
1432
1431
|
account,
|
|
1433
1432
|
address: '0x3333333333333333333333333333333333333333',
|
|
@@ -143,7 +143,7 @@ export declare namespace getHash {
|
|
|
143
143
|
* The function retains one canonical approval per owner. It selects the
|
|
144
144
|
* smallest deterministic quorum by owner weight, then orders the selected
|
|
145
145
|
* approvals by owner address for serialization. The caller supplies the
|
|
146
|
-
* account and config; the chain validates their
|
|
146
|
+
* account and config; the chain validates their derived identity.
|
|
147
147
|
*
|
|
148
148
|
* @example
|
|
149
149
|
* ```ts twoslash
|
|
@@ -1769,9 +1769,7 @@ describe('sortApprovals', () => {
|
|
|
1769
1769
|
owners: ascendingOwners.map((o) => ({ owner: o.address, weight: 1 })),
|
|
1770
1770
|
})
|
|
1771
1771
|
const payload = `0x${'42'.repeat(32)}` as const
|
|
1772
|
-
const account = AccountConfig.getAddress(genesisConfig
|
|
1773
|
-
factory: '0x7171717171717171717171717171717171717171',
|
|
1774
|
-
})
|
|
1772
|
+
const account = AccountConfig.getAddress(genesisConfig)
|
|
1775
1773
|
const version = 3n
|
|
1776
1774
|
const digest = AccountConfig.getSignPayload({
|
|
1777
1775
|
payload,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AbiFunction, Address, Hex, Secp256k1, Value } from 'ox'
|
|
2
2
|
import { describe, expect, test } from 'vp/test'
|
|
3
3
|
import { chain, client, fundAddress } from '../../test/tempo/config.js'
|
|
4
|
-
import { factory } from '../../test/tempo/configurableAccounts.js'
|
|
5
4
|
import {
|
|
6
5
|
AccountConfig,
|
|
7
6
|
KeyAuthorization,
|
|
@@ -31,7 +30,7 @@ async function setup() {
|
|
|
31
30
|
threshold: 2,
|
|
32
31
|
owners: keys.map((key) => ({ owner: key.address, weight: 1 })),
|
|
33
32
|
})
|
|
34
|
-
const account = AccountConfig.getAddress(config
|
|
33
|
+
const account = AccountConfig.getAddress(config)
|
|
35
34
|
await fundAddress(client, { address: account })
|
|
36
35
|
return { account, config, keys }
|
|
37
36
|
}
|
package/src/tempo/index.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '1.8.
|
|
2
|
+
export const version = '1.8.12'
|
package/src/zod/Authorization.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/* eslint-disable jsdoc-js/require-jsdoc, jsdoc-js/require-description, jsdoc-js/require-example */
|
|
2
2
|
import * as z_Address from './Address.js'
|
|
3
3
|
import * as z_Hex from './Hex.js'
|
|
4
|
+
import { quantityHex } from './internal/Integer.js'
|
|
4
5
|
import * as z_Number from './Number.js'
|
|
5
6
|
import * as z_Uint from './Uint.js'
|
|
6
7
|
import * as z from 'zod/mini'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'expected yParity hex',
|
|
12
|
-
),
|
|
13
|
-
)
|
|
9
|
+
// EIP-7702 permits any `y_parity` below 2**8 in an authorization tuple, so
|
|
10
|
+
// every authorization schema accepts an 8-bit `yParity`.
|
|
11
|
+
const yParityHex = quantityHex(8)
|
|
14
12
|
|
|
15
13
|
/** Unsigned EIP-7702 authorization schema. */
|
|
16
14
|
export const Unsigned = z.object(unsignedFields(z_Number.Number, z_Uint.Uint))
|
|
@@ -22,12 +20,12 @@ export const UnsignedToRpc = z.object(
|
|
|
22
20
|
|
|
23
21
|
/** Signed EIP-7702 authorization schema. */
|
|
24
22
|
export const Signed = z.object(
|
|
25
|
-
signedFields(z_Number.Number, z_Uint.Uint,
|
|
23
|
+
signedFields(z_Number.Number, z_Uint.Uint, z_Uint.Uint8),
|
|
26
24
|
)
|
|
27
25
|
|
|
28
26
|
/** Encode-only signed EIP-7702 authorization schema accepting numberish `toRpc` inputs. */
|
|
29
27
|
export const SignedToRpc = z.object(
|
|
30
|
-
signedFields(z_Number.NumberToRpc, z_Uint.UintToRpc,
|
|
28
|
+
signedFields(z_Number.NumberToRpc, z_Uint.UintToRpc, z_Uint.Uint8ToRpc),
|
|
31
29
|
)
|
|
32
30
|
|
|
33
31
|
/** EIP-7702 authorization schema. */
|
|
@@ -71,22 +69,6 @@ export const TupleList = z.readonly(z.array(Tuple))
|
|
|
71
69
|
/** Signed EIP-7702 authorization tuple list schema. */
|
|
72
70
|
export const TupleListSigned = z.readonly(z.array(TupleSigned))
|
|
73
71
|
|
|
74
|
-
function yParityUint() {
|
|
75
|
-
return z_Uint.Uint8.check(
|
|
76
|
-
z.refine((value) => value === 0 || value === 1, 'expected yParity'),
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function yParityUintToRpc() {
|
|
81
|
-
return z_Uint.Uint8ToRpc.check(
|
|
82
|
-
z.refine(
|
|
83
|
-
(value) =>
|
|
84
|
-
value === 0 || value === 1 || value === '0x0' || value === '0x1',
|
|
85
|
-
'expected yParity',
|
|
86
|
-
),
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
72
|
function unsignedFields<num extends z.ZodMiniType, uint extends z.ZodMiniType>(
|
|
91
73
|
num: num,
|
|
92
74
|
uint: uint,
|
|
@@ -165,6 +165,39 @@ describe('Authorization', () => {
|
|
|
165
165
|
`)
|
|
166
166
|
})
|
|
167
167
|
|
|
168
|
+
test('accepts yParity above 1', () => {
|
|
169
|
+
expect(
|
|
170
|
+
z.decode(z_Authorization.Signed, {
|
|
171
|
+
address,
|
|
172
|
+
chainId: '0x1',
|
|
173
|
+
nonce: '0x2',
|
|
174
|
+
r,
|
|
175
|
+
s,
|
|
176
|
+
yParity: '0x1c',
|
|
177
|
+
}).yParity,
|
|
178
|
+
).toMatchInlineSnapshot(`28`)
|
|
179
|
+
expect(
|
|
180
|
+
z.encode(z_Authorization.SignedToRpc, {
|
|
181
|
+
address,
|
|
182
|
+
chainId: 1,
|
|
183
|
+
nonce: 2n,
|
|
184
|
+
r,
|
|
185
|
+
s,
|
|
186
|
+
yParity: 28,
|
|
187
|
+
}).yParity,
|
|
188
|
+
).toMatchInlineSnapshot(`"0x1c"`)
|
|
189
|
+
expect(
|
|
190
|
+
z.decode(z_Authorization.TupleSigned, [
|
|
191
|
+
'0x1',
|
|
192
|
+
address,
|
|
193
|
+
'0x2',
|
|
194
|
+
'0x1c',
|
|
195
|
+
r,
|
|
196
|
+
s,
|
|
197
|
+
])[3],
|
|
198
|
+
).toMatchInlineSnapshot(`"0x1c"`)
|
|
199
|
+
})
|
|
200
|
+
|
|
168
201
|
test('rejects invalid signatures', () => {
|
|
169
202
|
expect(
|
|
170
203
|
z.safeDecode(z_Authorization.Signed, {
|
|
@@ -173,7 +206,7 @@ describe('Authorization', () => {
|
|
|
173
206
|
nonce: '0x2',
|
|
174
207
|
r,
|
|
175
208
|
s,
|
|
176
|
-
yParity: '
|
|
209
|
+
yParity: '0x100',
|
|
177
210
|
}).success,
|
|
178
211
|
).toBe(false)
|
|
179
212
|
expect(
|
|
@@ -181,7 +214,7 @@ describe('Authorization', () => {
|
|
|
181
214
|
'0x1',
|
|
182
215
|
address,
|
|
183
216
|
'0x2',
|
|
184
|
-
'
|
|
217
|
+
'0x100',
|
|
185
218
|
r,
|
|
186
219
|
s,
|
|
187
220
|
]).success,
|
|
@@ -214,7 +214,7 @@ describe('TransactionRequest', () => {
|
|
|
214
214
|
expect(
|
|
215
215
|
z.safeDecode(z_TransactionRequest.TransactionRequest, {
|
|
216
216
|
authorizationList: [
|
|
217
|
-
{ address, chainId: '0x1', nonce: '0x2', r, s, yParity: '
|
|
217
|
+
{ address, chainId: '0x1', nonce: '0x2', r, s, yParity: '0x100' },
|
|
218
218
|
],
|
|
219
219
|
}).success,
|
|
220
220
|
).toBe(false)
|