ox 1.8.5 → 1.8.7
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 +37 -0
- package/dist/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +116 -63
- package/dist/tempo/AccountConfig.d.ts.map +1 -0
- package/dist/tempo/{MultisigConfig.js → AccountConfig.js} +109 -55
- package/dist/tempo/AccountConfig.js.map +1 -0
- package/dist/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +62 -62
- package/dist/tempo/AccountOperation.d.ts.map +1 -0
- package/dist/tempo/{MultisigOperation.js → AccountOperation.js} +64 -64
- package/dist/tempo/AccountOperation.js.map +1 -0
- package/dist/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +21 -21
- package/dist/tempo/AccountSimulation.d.ts.map +1 -0
- package/dist/tempo/{MultisigSimulation.js → AccountSimulation.js} +20 -20
- package/dist/tempo/AccountSimulation.js.map +1 -0
- package/dist/tempo/KeyAuthorization.d.ts +37 -27
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +17 -19
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/RpcSchemaTempo.d.ts +13 -13
- package/dist/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +36 -33
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +77 -77
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/TokenRole.d.ts +4 -2
- package/dist/tempo/TokenRole.d.ts.map +1 -1
- package/dist/tempo/TokenRole.js +4 -1
- package/dist/tempo/TokenRole.js.map +1 -1
- package/dist/tempo/TransactionRequest.d.ts +11 -9
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +14 -10
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/tempo/index.d.ts +56 -54
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +56 -54
- package/dist/tempo/index.js.map +1 -1
- package/dist/zod/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +6 -6
- package/dist/zod/tempo/AccountConfig.d.ts.map +1 -0
- package/dist/zod/tempo/{MultisigConfig.js → AccountConfig.js} +12 -12
- package/dist/zod/tempo/AccountConfig.js.map +1 -0
- package/dist/zod/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +5 -5
- package/dist/zod/tempo/AccountOperation.d.ts.map +1 -0
- package/dist/zod/tempo/{MultisigOperation.js → AccountOperation.js} +10 -10
- package/dist/zod/tempo/AccountOperation.js.map +1 -0
- package/dist/zod/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +5 -5
- package/dist/zod/tempo/AccountSimulation.d.ts.map +1 -0
- package/dist/zod/tempo/AccountSimulation.js +44 -0
- package/dist/zod/tempo/AccountSimulation.js.map +1 -0
- package/dist/zod/tempo/AuthorizationTempo.d.ts +10 -10
- package/dist/zod/tempo/KeyAuthorization.d.ts +12 -12
- package/dist/zod/tempo/KeyAuthorization.js +6 -6
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +59 -59
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.js +28 -28
- package/dist/zod/tempo/RpcSchemaTempo.js.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts +7 -7
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +22 -16
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/TokenRole.d.ts +1 -1
- package/dist/zod/tempo/TokenRole.d.ts.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +24 -24
- package/dist/zod/tempo/TransactionRequest.d.ts +84 -84
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.js +26 -17
- package/dist/zod/tempo/TransactionRequest.js.map +1 -1
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts +12 -12
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts +3 -3
- package/dist/zod/tempo/z.d.ts +3 -3
- package/dist/zod/tempo/z.d.ts.map +1 -1
- package/dist/zod/tempo/z.js +3 -3
- package/dist/zod/tempo/z.js.map +1 -1
- package/package.json +31 -31
- package/src/tempo/{MultisigConfig.test-d.ts → AccountConfig.test-d.ts} +22 -12
- package/src/tempo/{MultisigConfig.test.ts → AccountConfig.test.ts} +155 -37
- package/src/tempo/{MultisigConfig.ts → AccountConfig.ts} +138 -66
- package/src/tempo/AccountOperation.test-d.ts +79 -0
- package/src/tempo/{MultisigOperation.test.ts → AccountOperation.test.ts} +97 -97
- package/src/tempo/{MultisigOperation.ts → AccountOperation.ts} +95 -97
- package/src/tempo/{MultisigSimulation.test-d.ts → AccountSimulation.test-d.ts} +7 -9
- package/src/tempo/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +28 -28
- package/src/tempo/{MultisigSimulation.ts → AccountSimulation.ts} +28 -30
- package/src/tempo/KeyAuthorization.test-d.ts +15 -6
- package/src/tempo/KeyAuthorization.test.ts +117 -37
- package/src/tempo/KeyAuthorization.ts +68 -59
- package/src/tempo/RpcSchemaTempo.test-d.ts +19 -19
- package/src/tempo/RpcSchemaTempo.ts +13 -13
- package/src/tempo/SignatureEnvelope.test-d.ts +7 -7
- package/src/tempo/SignatureEnvelope.test.ts +34 -34
- package/src/tempo/SignatureEnvelope.ts +112 -108
- package/src/tempo/TokenRole.ts +4 -1
- package/src/tempo/Transaction.test.ts +4 -4
- package/src/tempo/TransactionRequest.test-d.ts +17 -6
- package/src/tempo/TransactionRequest.test.ts +32 -17
- package/src/tempo/TransactionRequest.ts +27 -19
- package/src/tempo/{multisig.e2e.test.ts → configurableAccounts.e2e.test.ts} +16 -16
- package/src/tempo/e2e.test.ts +32 -20
- package/src/tempo/index.ts +56 -54
- package/src/version.ts +1 -1
- package/src/zod/tempo/{MultisigConfig.ts → AccountConfig.ts} +12 -12
- package/src/zod/tempo/{MultisigOperation.ts → AccountOperation.ts} +9 -9
- package/src/zod/tempo/AccountSimulation.ts +53 -0
- package/src/zod/tempo/KeyAuthorization.ts +8 -8
- package/src/zod/tempo/RpcSchemaTempo.ts +28 -28
- package/src/zod/tempo/SignatureEnvelope.ts +23 -17
- package/src/zod/tempo/TransactionRequest.ts +29 -18
- package/src/zod/tempo/_test/AccountConfig.test-d.ts +13 -0
- package/src/zod/tempo/_test/{MultisigConfig.test.ts → AccountConfig.test.ts} +7 -7
- package/src/zod/tempo/_test/AccountOperation.test-d.ts +27 -0
- package/src/zod/tempo/_test/{MultisigOperation.test.ts → AccountOperation.test.ts} +9 -9
- package/src/zod/tempo/_test/AccountSimulation.test-d.ts +13 -0
- package/src/zod/tempo/_test/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +13 -13
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +9 -9
- package/src/zod/tempo/_test/RpcSchemaTempo.test-d.ts +27 -27
- package/src/zod/tempo/_test/RpcSchemaTempo.test.ts +16 -18
- package/src/zod/tempo/_test/SignatureEnvelope.test-d.ts +5 -5
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +12 -9
- package/src/zod/tempo/_test/TransactionRequest.test.ts +28 -8
- package/src/zod/tempo/z.ts +3 -3
- package/dist/tempo/MultisigConfig.d.ts.map +0 -1
- package/dist/tempo/MultisigConfig.js.map +0 -1
- package/dist/tempo/MultisigOperation.d.ts.map +0 -1
- package/dist/tempo/MultisigOperation.js.map +0 -1
- package/dist/tempo/MultisigSimulation.d.ts.map +0 -1
- package/dist/tempo/MultisigSimulation.js.map +0 -1
- package/dist/zod/tempo/MultisigConfig.d.ts.map +0 -1
- package/dist/zod/tempo/MultisigConfig.js.map +0 -1
- package/dist/zod/tempo/MultisigOperation.d.ts.map +0 -1
- package/dist/zod/tempo/MultisigOperation.js.map +0 -1
- package/dist/zod/tempo/MultisigSimulation.d.ts.map +0 -1
- package/dist/zod/tempo/MultisigSimulation.js +0 -44
- package/dist/zod/tempo/MultisigSimulation.js.map +0 -1
- package/src/tempo/MultisigOperation.test-d.ts +0 -79
- package/src/zod/tempo/MultisigSimulation.ts +0 -53
- package/src/zod/tempo/_test/MultisigConfig.test-d.ts +0 -13
- package/src/zod/tempo/_test/MultisigOperation.test-d.ts +0 -27
- package/src/zod/tempo/_test/MultisigSimulation.test-d.ts +0 -13
|
@@ -1,76 +1,76 @@
|
|
|
1
1
|
import type { Provider } from 'ox'
|
|
2
2
|
import type {
|
|
3
|
+
AccountConfig,
|
|
4
|
+
AccountSimulation,
|
|
3
5
|
KeyAuthorization,
|
|
4
|
-
|
|
5
|
-
MultisigOperation,
|
|
6
|
-
MultisigSimulation,
|
|
6
|
+
AccountOperation,
|
|
7
7
|
RpcSchemaTempo,
|
|
8
8
|
} from 'ox/tempo'
|
|
9
9
|
import { expectTypeOf, test } from 'vp/test'
|
|
10
10
|
import type * as Address from '../core/Address.js'
|
|
11
11
|
import type * as Hex from '../core/Hex.js'
|
|
12
12
|
|
|
13
|
-
declare const provider: Provider.Provider<{ schema: RpcSchemaTempo.
|
|
13
|
+
declare const provider: Provider.Provider<{ schema: RpcSchemaTempo.Account }>
|
|
14
14
|
declare const tempoProvider: Provider.Provider<{
|
|
15
15
|
schema: RpcSchemaTempo.Tempo
|
|
16
16
|
}>
|
|
17
17
|
declare const address: Address.Address
|
|
18
18
|
declare const hash: Hex.Hex
|
|
19
19
|
declare const keyAuthorization: KeyAuthorization.Rpc
|
|
20
|
-
declare const multisigSimulation:
|
|
20
|
+
declare const multisigSimulation: AccountSimulation.Rpc
|
|
21
21
|
declare const serializedTransaction: Hex.Hex
|
|
22
22
|
declare const signature: Hex.Hex
|
|
23
23
|
|
|
24
|
-
test('
|
|
24
|
+
test('account provider methods', () => {
|
|
25
25
|
expectTypeOf(
|
|
26
26
|
provider.request({
|
|
27
|
-
method: '
|
|
27
|
+
method: 'account_approveKeyAuthorization',
|
|
28
28
|
params: [{ keyAuthorization }],
|
|
29
29
|
}),
|
|
30
|
-
).resolves.toEqualTypeOf<
|
|
30
|
+
).resolves.toEqualTypeOf<AccountOperation.KeyAuthorizationRpc>()
|
|
31
31
|
|
|
32
32
|
expectTypeOf(
|
|
33
33
|
provider.request({
|
|
34
|
-
method: '
|
|
34
|
+
method: 'account_approveKeyAuthorization',
|
|
35
35
|
params: [{ hash, signature }],
|
|
36
36
|
}),
|
|
37
|
-
).resolves.toEqualTypeOf<
|
|
37
|
+
).resolves.toEqualTypeOf<AccountOperation.KeyAuthorizationRpc>()
|
|
38
38
|
|
|
39
39
|
expectTypeOf(
|
|
40
40
|
provider.request({
|
|
41
|
-
method: '
|
|
41
|
+
method: 'account_approveRawTransaction',
|
|
42
42
|
params: [serializedTransaction],
|
|
43
43
|
}),
|
|
44
44
|
).resolves.toEqualTypeOf<Hex.Hex>()
|
|
45
45
|
|
|
46
46
|
expectTypeOf(
|
|
47
47
|
provider.request({
|
|
48
|
-
method: '
|
|
48
|
+
method: 'account_approveRawTransactionSync',
|
|
49
49
|
params: [serializedTransaction],
|
|
50
50
|
}),
|
|
51
|
-
).resolves.toEqualTypeOf<
|
|
51
|
+
).resolves.toEqualTypeOf<AccountOperation.TransactionRpc>()
|
|
52
52
|
|
|
53
53
|
void provider.request({
|
|
54
|
-
method: '
|
|
54
|
+
method: 'account_approveRawTransactionSync',
|
|
55
55
|
params: [serializedTransaction, 30_000],
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
expectTypeOf(
|
|
59
59
|
provider.request({
|
|
60
|
-
method: '
|
|
60
|
+
method: 'account_getConfig',
|
|
61
61
|
params: [{ address }],
|
|
62
62
|
}),
|
|
63
|
-
).resolves.toEqualTypeOf<
|
|
63
|
+
).resolves.toEqualTypeOf<AccountConfig.Rpc | null>()
|
|
64
64
|
|
|
65
65
|
expectTypeOf(
|
|
66
66
|
provider.request({
|
|
67
|
-
method: '
|
|
67
|
+
method: 'account_getOperation',
|
|
68
68
|
params: [hash],
|
|
69
69
|
}),
|
|
70
|
-
).resolves.toEqualTypeOf<
|
|
70
|
+
).resolves.toEqualTypeOf<AccountOperation.Rpc | null>()
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
-
test('tempo simulation accepts
|
|
73
|
+
test('tempo simulation accepts account simulation specs', () => {
|
|
74
74
|
void tempoProvider.request({
|
|
75
75
|
method: 'tempo_simulateV1',
|
|
76
76
|
params: [
|
|
@@ -5,9 +5,9 @@ import type * as Hex from '../core/Hex.js'
|
|
|
5
5
|
import type * as Log from '../core/Log.js'
|
|
6
6
|
import type * as RpcSchema from '../core/RpcSchema.js'
|
|
7
7
|
import type * as StateOverrides from '../core/StateOverrides.js'
|
|
8
|
+
import type * as AccountConfig from './AccountConfig.js'
|
|
8
9
|
import type * as KeyAuthorization from './KeyAuthorization.js'
|
|
9
|
-
import type * as
|
|
10
|
-
import type * as MultisigOperation from './MultisigOperation.js'
|
|
10
|
+
import type * as AccountOperation from './AccountOperation.js'
|
|
11
11
|
import type * as TransactionRequest from './TransactionRequest.js'
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -58,44 +58,44 @@ export type Tempo = RpcSchema.From<{
|
|
|
58
58
|
}
|
|
59
59
|
}>
|
|
60
60
|
|
|
61
|
-
/** Union of all JSON-RPC methods for the `
|
|
62
|
-
export type
|
|
61
|
+
/** Union of all JSON-RPC methods for the `account_` namespace. */
|
|
62
|
+
export type Account = RpcSchema.From<
|
|
63
63
|
| {
|
|
64
64
|
Request: {
|
|
65
|
-
method: '
|
|
65
|
+
method: 'account_approveKeyAuthorization'
|
|
66
66
|
params: [
|
|
67
67
|
| { keyAuthorization: KeyAuthorization.Rpc }
|
|
68
68
|
| { hash: Hex.Hex; signature: Hex.Hex },
|
|
69
69
|
]
|
|
70
70
|
}
|
|
71
|
-
ReturnType:
|
|
71
|
+
ReturnType: AccountOperation.KeyAuthorizationRpc
|
|
72
72
|
}
|
|
73
73
|
| {
|
|
74
74
|
Request: {
|
|
75
|
-
method: '
|
|
75
|
+
method: 'account_approveRawTransaction'
|
|
76
76
|
params: [serializedTransaction: Hex.Hex]
|
|
77
77
|
}
|
|
78
78
|
ReturnType: Hex.Hex
|
|
79
79
|
}
|
|
80
80
|
| {
|
|
81
81
|
Request: {
|
|
82
|
-
method: '
|
|
82
|
+
method: 'account_approveRawTransactionSync'
|
|
83
83
|
params: [serializedTransaction: Hex.Hex, timeout?: number]
|
|
84
84
|
}
|
|
85
|
-
ReturnType:
|
|
85
|
+
ReturnType: AccountOperation.TransactionRpc
|
|
86
86
|
}
|
|
87
87
|
| {
|
|
88
88
|
Request: {
|
|
89
|
-
method: '
|
|
89
|
+
method: 'account_getConfig'
|
|
90
90
|
params: [{ address: Address.Address }]
|
|
91
91
|
}
|
|
92
|
-
ReturnType:
|
|
92
|
+
ReturnType: AccountConfig.Rpc | null
|
|
93
93
|
}
|
|
94
94
|
| {
|
|
95
95
|
Request: {
|
|
96
|
-
method: '
|
|
96
|
+
method: 'account_getOperation'
|
|
97
97
|
params: [hash: Hex.Hex]
|
|
98
98
|
}
|
|
99
|
-
ReturnType:
|
|
99
|
+
ReturnType: AccountOperation.Rpc | null
|
|
100
100
|
}
|
|
101
101
|
>
|
|
@@ -15,24 +15,24 @@ const envelope = SignatureEnvelope.from({
|
|
|
15
15
|
signatures: [primitive],
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
test('preserves primitive and
|
|
18
|
+
test('preserves primitive and configurable RPC types', () => {
|
|
19
19
|
expectTypeOf(
|
|
20
20
|
SignatureEnvelope.toRpc(primitive),
|
|
21
21
|
).toEqualTypeOf<SignatureEnvelope.Secp256k1Rpc>()
|
|
22
22
|
expectTypeOf(SignatureEnvelope.toRpc(envelope)).toEqualTypeOf<Hex.Hex>()
|
|
23
23
|
expectTypeOf<
|
|
24
24
|
SignatureEnvelope.GetType<typeof envelope>
|
|
25
|
-
>().toEqualTypeOf<'
|
|
26
|
-
expectTypeOf(envelope).toMatchTypeOf<SignatureEnvelope.
|
|
25
|
+
>().toEqualTypeOf<'configurable'>()
|
|
26
|
+
expectTypeOf(envelope).toMatchTypeOf<SignatureEnvelope.Configurable>()
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
test('requires config and primitive approvals', () => {
|
|
30
|
-
// @ts-expect-error Every
|
|
30
|
+
// @ts-expect-error Every configurable signature carries its current config.
|
|
31
31
|
SignatureEnvelope.from({ account: envelope.account, signatures: [primitive] })
|
|
32
|
-
// @ts-expect-error
|
|
32
|
+
// @ts-expect-error Configurable owners cannot recursively approve with configurable signatures.
|
|
33
33
|
SignatureEnvelope.from({ ...envelope, signatures: [envelope] })
|
|
34
|
-
// @ts-expect-error
|
|
35
|
-
const rpc: SignatureEnvelope.
|
|
34
|
+
// @ts-expect-error Configurable RPC signatures are hex-encoded RLP.
|
|
35
|
+
const rpc: SignatureEnvelope.ConfigurableRpc = {
|
|
36
36
|
account: envelope.account,
|
|
37
37
|
signatures: [],
|
|
38
38
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
WebCryptoP256,
|
|
11
11
|
} from 'ox'
|
|
12
12
|
import { describe, expect, test } from 'vp/test'
|
|
13
|
-
import * as
|
|
13
|
+
import * as AccountConfig from './AccountConfig.js'
|
|
14
14
|
import * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
15
15
|
|
|
16
16
|
const publicKey = PublicKey.from({
|
|
@@ -530,7 +530,7 @@ describe('deserialize', () => {
|
|
|
530
530
|
SignatureEnvelope.deserialize('0xdeadbeef'),
|
|
531
531
|
).toThrowErrorMatchingInlineSnapshot(
|
|
532
532
|
`
|
|
533
|
-
[SignatureEnvelope.InvalidSerializedError: Unable to deserialize signature envelope: Unknown signature type identifier: 0xde. Expected 0x01 (P256), 0x02 (WebAuthn), 0x03 (Keychain V1), 0x04 (Keychain V2), or 0x05 (
|
|
533
|
+
[SignatureEnvelope.InvalidSerializedError: Unable to deserialize signature envelope: Unknown signature type identifier: 0xde. Expected 0x01 (P256), 0x02 (WebAuthn), 0x03 (Keychain V1), 0x04 (Keychain V2), or 0x05 (Configurable)
|
|
534
534
|
|
|
535
535
|
Serialized: 0xdeadbeef]
|
|
536
536
|
`,
|
|
@@ -690,7 +690,7 @@ describe('deserialize', () => {
|
|
|
690
690
|
SignatureEnvelope.deserialize(unknownType),
|
|
691
691
|
).toThrowErrorMatchingInlineSnapshot(
|
|
692
692
|
`
|
|
693
|
-
[SignatureEnvelope.InvalidSerializedError: Unable to deserialize signature envelope: Unknown signature type identifier: 0xff. Expected 0x01 (P256), 0x02 (WebAuthn), 0x03 (Keychain V1), 0x04 (Keychain V2), or 0x05 (
|
|
693
|
+
[SignatureEnvelope.InvalidSerializedError: Unable to deserialize signature envelope: Unknown signature type identifier: 0xff. Expected 0x01 (P256), 0x02 (WebAuthn), 0x03 (Keychain V1), 0x04 (Keychain V2), or 0x05 (Configurable)
|
|
694
694
|
|
|
695
695
|
Serialized: 0xff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
|
|
696
696
|
`,
|
|
@@ -1115,7 +1115,7 @@ describe('from', () => {
|
|
|
1115
1115
|
})
|
|
1116
1116
|
})
|
|
1117
1117
|
|
|
1118
|
-
describe('
|
|
1118
|
+
describe('configurable', () => {
|
|
1119
1119
|
test('normalizes the current config', () => {
|
|
1120
1120
|
const envelope = SignatureEnvelope.from({
|
|
1121
1121
|
account: '0x2222222222222222222222222222222222222222',
|
|
@@ -1750,7 +1750,7 @@ describe('serialize', () => {
|
|
|
1750
1750
|
})
|
|
1751
1751
|
})
|
|
1752
1752
|
|
|
1753
|
-
describe('
|
|
1753
|
+
describe('sortApprovals', () => {
|
|
1754
1754
|
// Build owner key pairs first so we can construct a real genesis config
|
|
1755
1755
|
// whose owner set matches the keys that produce the approvals below.
|
|
1756
1756
|
const ownerKeys = Array.from({ length: 3 }, () => {
|
|
@@ -1764,16 +1764,16 @@ describe('sortMultisigApprovals', () => {
|
|
|
1764
1764
|
Hex.toBigInt(a.address) < Hex.toBigInt(b.address) ? -1 : 1,
|
|
1765
1765
|
)
|
|
1766
1766
|
|
|
1767
|
-
const genesisConfig =
|
|
1767
|
+
const genesisConfig = AccountConfig.from({
|
|
1768
1768
|
threshold: 2,
|
|
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 =
|
|
1772
|
+
const account = AccountConfig.getAddress(genesisConfig, {
|
|
1773
1773
|
factory: '0x7171717171717171717171717171717171717171',
|
|
1774
1774
|
})
|
|
1775
1775
|
const version = 3n
|
|
1776
|
-
const digest =
|
|
1776
|
+
const digest = AccountConfig.getSignPayload({
|
|
1777
1777
|
payload,
|
|
1778
1778
|
account,
|
|
1779
1779
|
config: { version },
|
|
@@ -1791,7 +1791,7 @@ describe('sortMultisigApprovals', () => {
|
|
|
1791
1791
|
}))
|
|
1792
1792
|
|
|
1793
1793
|
test('behavior: orders approvals ascending by recovered owner address', () => {
|
|
1794
|
-
const ordered = SignatureEnvelope.
|
|
1794
|
+
const ordered = SignatureEnvelope.sortApprovals({
|
|
1795
1795
|
account,
|
|
1796
1796
|
config: { version },
|
|
1797
1797
|
payload,
|
|
@@ -1804,7 +1804,7 @@ describe('sortMultisigApprovals', () => {
|
|
|
1804
1804
|
test('behavior: already-sorted input is unchanged', () => {
|
|
1805
1805
|
const signatures = ascending.map((owner) => owner.signature)
|
|
1806
1806
|
expect(
|
|
1807
|
-
SignatureEnvelope.
|
|
1807
|
+
SignatureEnvelope.sortApprovals({
|
|
1808
1808
|
account,
|
|
1809
1809
|
config: { version },
|
|
1810
1810
|
payload,
|
|
@@ -1814,7 +1814,7 @@ describe('sortMultisigApprovals', () => {
|
|
|
1814
1814
|
})
|
|
1815
1815
|
|
|
1816
1816
|
test('behavior: recovered order matches the config owner order', () => {
|
|
1817
|
-
const ordered = SignatureEnvelope.
|
|
1817
|
+
const ordered = SignatureEnvelope.sortApprovals({
|
|
1818
1818
|
account,
|
|
1819
1819
|
config: { version },
|
|
1820
1820
|
payload,
|
|
@@ -2832,9 +2832,9 @@ describe('CoercionError', () => {
|
|
|
2832
2832
|
})
|
|
2833
2833
|
})
|
|
2834
2834
|
|
|
2835
|
-
describe('
|
|
2835
|
+
describe('configurable', () => {
|
|
2836
2836
|
const account = '0x2222222222222222222222222222222222222222'
|
|
2837
|
-
const config =
|
|
2837
|
+
const config = AccountConfig.from({
|
|
2838
2838
|
threshold: 1,
|
|
2839
2839
|
owners: [
|
|
2840
2840
|
{ owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
@@ -2853,7 +2853,7 @@ describe('multisig', () => {
|
|
|
2853
2853
|
expect(Rlp.toHex(Hex.slice(serialized, 1))).toEqual([
|
|
2854
2854
|
account,
|
|
2855
2855
|
[
|
|
2856
|
-
|
|
2856
|
+
AccountConfig.zeroSalt,
|
|
2857
2857
|
'0x',
|
|
2858
2858
|
'0x01',
|
|
2859
2859
|
[['0x1111111111111111111111111111111111111111', '0x01']],
|
|
@@ -2894,7 +2894,7 @@ describe('multisig', () => {
|
|
|
2894
2894
|
})
|
|
2895
2895
|
|
|
2896
2896
|
test('rejects old wire and RPC shapes', () => {
|
|
2897
|
-
for (const first of [account,
|
|
2897
|
+
for (const first of [account, AccountConfig.toTuple(config)] as const)
|
|
2898
2898
|
expect(() =>
|
|
2899
2899
|
SignatureEnvelope.deserialize(
|
|
2900
2900
|
Hex.concat(
|
|
@@ -2909,7 +2909,7 @@ describe('multisig', () => {
|
|
|
2909
2909
|
})
|
|
2910
2910
|
|
|
2911
2911
|
test('rejects malformed configs', () => {
|
|
2912
|
-
const valid =
|
|
2912
|
+
const valid = AccountConfig.toTuple(config)
|
|
2913
2913
|
for (const tuple of [
|
|
2914
2914
|
['0x00', ...valid.slice(1)],
|
|
2915
2915
|
[valid[0], '0x00', valid[2], valid[3]],
|
|
@@ -2929,7 +2929,7 @@ describe('multisig', () => {
|
|
|
2929
2929
|
]),
|
|
2930
2930
|
),
|
|
2931
2931
|
),
|
|
2932
|
-
).toThrowError(
|
|
2932
|
+
).toThrowError(AccountConfig.InvalidConfigError)
|
|
2933
2933
|
})
|
|
2934
2934
|
|
|
2935
2935
|
test('rejects invalid accounts, missing configs, and invalid approval counts', () => {
|
|
@@ -2955,7 +2955,7 @@ describe('multisig', () => {
|
|
|
2955
2955
|
config: { ...config, owners: [{ owner: account, weight: 1 }] },
|
|
2956
2956
|
} as const
|
|
2957
2957
|
expect(() => SignatureEnvelope.assert(self)).toThrowError(
|
|
2958
|
-
SignatureEnvelope.
|
|
2958
|
+
SignatureEnvelope.InvalidApprovalError,
|
|
2959
2959
|
)
|
|
2960
2960
|
expect(() =>
|
|
2961
2961
|
SignatureEnvelope.assert({
|
|
@@ -2972,12 +2972,12 @@ describe('multisig', () => {
|
|
|
2972
2972
|
...envelope,
|
|
2973
2973
|
signatures: [signature],
|
|
2974
2974
|
} as never),
|
|
2975
|
-
).toThrowError(SignatureEnvelope.
|
|
2975
|
+
).toThrowError(SignatureEnvelope.InvalidApprovalError)
|
|
2976
2976
|
const wire = Hex.concat(
|
|
2977
2977
|
'0x05',
|
|
2978
2978
|
Rlp.fromHex([
|
|
2979
2979
|
account,
|
|
2980
|
-
|
|
2980
|
+
AccountConfig.toTuple(config),
|
|
2981
2981
|
[SignatureEnvelope.serialize(signature)],
|
|
2982
2982
|
]),
|
|
2983
2983
|
)
|
|
@@ -2997,9 +2997,9 @@ describe('multisig', () => {
|
|
|
2997
2997
|
}
|
|
2998
2998
|
expect(() =>
|
|
2999
2999
|
SignatureEnvelope.assert({ ...envelope, signatures: [oversized] }),
|
|
3000
|
-
).toThrowError(SignatureEnvelope.
|
|
3000
|
+
).toThrowError(SignatureEnvelope.InvalidApprovalError)
|
|
3001
3001
|
})
|
|
3002
|
-
test('requires keychain V2 for
|
|
3002
|
+
test('requires keychain V2 for configurable delegates', () => {
|
|
3003
3003
|
const keychain = SignatureEnvelope.from({
|
|
3004
3004
|
userAddress: account,
|
|
3005
3005
|
version: 'v2',
|
|
@@ -3009,12 +3009,12 @@ describe('multisig', () => {
|
|
|
3009
3009
|
expect(SignatureEnvelope.deserialize(serialized)).toEqual(keychain)
|
|
3010
3010
|
expect(() =>
|
|
3011
3011
|
SignatureEnvelope.serialize({ ...keychain, version: 'v1' }),
|
|
3012
|
-
).toThrowError(SignatureEnvelope.
|
|
3012
|
+
).toThrowError(SignatureEnvelope.InvalidApprovalError)
|
|
3013
3013
|
expect(() =>
|
|
3014
3014
|
SignatureEnvelope.deserialize(
|
|
3015
3015
|
Hex.concat('0x03', Hex.slice(serialized, 1)),
|
|
3016
3016
|
),
|
|
3017
|
-
).toThrowError(SignatureEnvelope.
|
|
3017
|
+
).toThrowError(SignatureEnvelope.InvalidApprovalError)
|
|
3018
3018
|
expect(() =>
|
|
3019
3019
|
SignatureEnvelope.fromRpc({
|
|
3020
3020
|
type: 'keychain',
|
|
@@ -3022,9 +3022,9 @@ describe('multisig', () => {
|
|
|
3022
3022
|
version: 'v1',
|
|
3023
3023
|
signature: SignatureEnvelope.toRpc(envelope),
|
|
3024
3024
|
}),
|
|
3025
|
-
).toThrowError(SignatureEnvelope.
|
|
3025
|
+
).toThrowError(SignatureEnvelope.InvalidApprovalError)
|
|
3026
3026
|
})
|
|
3027
|
-
test('rejects V1 wrappers around recursively nested
|
|
3027
|
+
test('rejects V1 wrappers around recursively nested configurable delegates', () => {
|
|
3028
3028
|
let inner: SignatureEnvelope.SignatureEnvelope = envelope
|
|
3029
3029
|
for (let depth = 0; depth < 3; depth++) {
|
|
3030
3030
|
inner = { inner, type: 'keychain', userAddress: account, version: 'v2' }
|
|
@@ -3038,10 +3038,10 @@ describe('multisig', () => {
|
|
|
3038
3038
|
expect(SignatureEnvelope.validate(valid)).toBe(true)
|
|
3039
3039
|
expect(SignatureEnvelope.validate(invalid)).toBe(false)
|
|
3040
3040
|
expect(() => SignatureEnvelope.serialize(invalid)).toThrowError(
|
|
3041
|
-
SignatureEnvelope.
|
|
3041
|
+
SignatureEnvelope.InvalidApprovalError,
|
|
3042
3042
|
)
|
|
3043
3043
|
expect(() => SignatureEnvelope.toRpc(invalid)).toThrowError(
|
|
3044
|
-
SignatureEnvelope.
|
|
3044
|
+
SignatureEnvelope.InvalidApprovalError,
|
|
3045
3045
|
)
|
|
3046
3046
|
expect(() =>
|
|
3047
3047
|
SignatureEnvelope.fromRpc({
|
|
@@ -3050,15 +3050,15 @@ describe('multisig', () => {
|
|
|
3050
3050
|
version: 'v1',
|
|
3051
3051
|
signature: SignatureEnvelope.toRpc(inner),
|
|
3052
3052
|
}),
|
|
3053
|
-
).toThrowError(SignatureEnvelope.
|
|
3053
|
+
).toThrowError(SignatureEnvelope.InvalidApprovalError)
|
|
3054
3054
|
expect(() =>
|
|
3055
3055
|
SignatureEnvelope.deserialize(
|
|
3056
3056
|
Hex.concat('0x03', account, SignatureEnvelope.serialize(inner)),
|
|
3057
3057
|
),
|
|
3058
|
-
).toThrowError(SignatureEnvelope.
|
|
3058
|
+
).toThrowError(SignatureEnvelope.InvalidApprovalError)
|
|
3059
3059
|
expect(() =>
|
|
3060
3060
|
SignatureEnvelope.serialize({ ...valid, inner: invalid }),
|
|
3061
|
-
).toThrowError(SignatureEnvelope.
|
|
3061
|
+
).toThrowError(SignatureEnvelope.InvalidApprovalError)
|
|
3062
3062
|
}
|
|
3063
3063
|
expect(
|
|
3064
3064
|
SignatureEnvelope.validate({
|
|
@@ -3123,7 +3123,7 @@ describe('multisig', () => {
|
|
|
3123
3123
|
})
|
|
3124
3124
|
})
|
|
3125
3125
|
|
|
3126
|
-
describe('
|
|
3126
|
+
describe('configurable vectors', () => {
|
|
3127
3127
|
const initial =
|
|
3128
3128
|
'0x05f89794c4a590afa7337e5cd5eb3aa60cacf91c5400044bf83ba000000000000000000000000000000000000000000000000000000000000000008001d7d6947e5f4552091a69125d5dfcb7b8c2659029395bdf01f843b841869437e01f64bebeb78a8a6b30bfd3a993819c8cad82c807515d9b9e9b36f98535dfaa5eebc597715d05f6ce4927747f14fa4cd2acc717fdcd3877146437f8f41b' as const
|
|
3129
3129
|
const current =
|
|
@@ -3156,7 +3156,7 @@ describe('multisig vectors', () => {
|
|
|
3156
3156
|
"type": "secp256k1",
|
|
3157
3157
|
},
|
|
3158
3158
|
],
|
|
3159
|
-
"type": "
|
|
3159
|
+
"type": "configurable",
|
|
3160
3160
|
}
|
|
3161
3161
|
`)
|
|
3162
3162
|
expect(SignatureEnvelope.serialize(envelope)).toBe(initial)
|
|
@@ -3189,7 +3189,7 @@ describe('multisig vectors', () => {
|
|
|
3189
3189
|
"type": "secp256k1",
|
|
3190
3190
|
},
|
|
3191
3191
|
],
|
|
3192
|
-
"type": "
|
|
3192
|
+
"type": "configurable",
|
|
3193
3193
|
}
|
|
3194
3194
|
`)
|
|
3195
3195
|
expect(SignatureEnvelope.serialize(envelope)).toBe(current)
|