ox 0.14.55 → 0.14.56
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 +29 -0
- package/_cjs/tempo/{MultisigConfig.js → AccountConfig.js} +16 -4
- package/_cjs/tempo/AccountConfig.js.map +1 -0
- package/_cjs/tempo/{MultisigOperation.js → AccountOperation.js} +29 -29
- package/_cjs/tempo/AccountOperation.js.map +1 -0
- package/_cjs/tempo/{MultisigSimulation.js → AccountSimulation.js} +9 -9
- package/_cjs/tempo/AccountSimulation.js.map +1 -0
- package/_cjs/tempo/KeyAuthorization.js +12 -11
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +64 -64
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +12 -9
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/index.js +4 -4
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/{MultisigConfig.js → AccountConfig.js} +103 -55
- package/_esm/tempo/AccountConfig.js.map +1 -0
- package/_esm/tempo/{MultisigOperation.js → AccountOperation.js} +64 -64
- package/_esm/tempo/AccountOperation.js.map +1 -0
- package/_esm/tempo/{MultisigSimulation.js → AccountSimulation.js} +20 -20
- package/_esm/tempo/AccountSimulation.js.map +1 -0
- package/_esm/tempo/KeyAuthorization.js +13 -12
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +71 -71
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +12 -9
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/index.js +50 -48
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +110 -63
- package/_types/tempo/AccountConfig.d.ts.map +1 -0
- package/_types/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +62 -62
- package/_types/tempo/AccountOperation.d.ts.map +1 -0
- package/_types/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +21 -21
- package/_types/tempo/AccountSimulation.d.ts.map +1 -0
- package/_types/tempo/KeyAuthorization.d.ts +14 -14
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/RpcSchemaTempo.d.ts +13 -13
- package/_types/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +36 -33
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +11 -9
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +50 -48
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +31 -31
- package/tempo/AccountConfig/package.json +6 -0
- package/tempo/AccountConfig.test-d/package.json +6 -0
- package/tempo/{MultisigConfig.test-d.ts → AccountConfig.test-d.ts} +22 -12
- package/tempo/{MultisigConfig.test.ts → AccountConfig.test.ts} +155 -37
- package/tempo/{MultisigConfig.ts → AccountConfig.ts} +132 -66
- package/tempo/AccountOperation/package.json +6 -0
- package/tempo/AccountOperation.test-d/package.json +6 -0
- package/tempo/AccountOperation.test-d.ts +71 -0
- package/tempo/{MultisigOperation.test.ts → AccountOperation.test.ts} +97 -97
- package/tempo/{MultisigOperation.ts → AccountOperation.ts} +95 -97
- package/tempo/AccountSimulation/package.json +6 -0
- package/tempo/AccountSimulation.test-d/package.json +6 -0
- package/tempo/{MultisigSimulation.test-d.ts → AccountSimulation.test-d.ts} +7 -9
- package/tempo/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +29 -29
- package/tempo/{MultisigSimulation.ts → AccountSimulation.ts} +28 -30
- package/tempo/KeyAuthorization.test-d.ts +14 -14
- package/tempo/KeyAuthorization.test.ts +70 -49
- package/tempo/KeyAuthorization.ts +29 -27
- package/tempo/RpcSchemaTempo.test-d.ts +19 -19
- package/tempo/RpcSchemaTempo.ts +13 -13
- package/tempo/SignatureEnvelope.test-d.ts +7 -7
- package/tempo/SignatureEnvelope.test.ts +34 -34
- package/tempo/SignatureEnvelope.ts +107 -103
- package/tempo/Transaction.test.ts +4 -4
- package/tempo/TransactionRequest.test-d.ts +16 -7
- package/tempo/TransactionRequest.test.ts +25 -17
- package/tempo/TransactionRequest.ts +25 -18
- package/tempo/{multisig.e2e.test.ts → configurableAccounts.e2e.test.ts} +16 -16
- package/tempo/index.ts +50 -48
- package/version.ts +1 -1
- package/_cjs/tempo/MultisigConfig.js.map +0 -1
- package/_cjs/tempo/MultisigOperation.js.map +0 -1
- package/_cjs/tempo/MultisigSimulation.js.map +0 -1
- package/_esm/tempo/MultisigConfig.js.map +0 -1
- package/_esm/tempo/MultisigOperation.js.map +0 -1
- package/_esm/tempo/MultisigSimulation.js.map +0 -1
- package/_types/tempo/MultisigConfig.d.ts.map +0 -1
- package/_types/tempo/MultisigOperation.d.ts.map +0 -1
- package/_types/tempo/MultisigSimulation.d.ts.map +0 -1
- package/tempo/MultisigConfig/package.json +0 -6
- package/tempo/MultisigConfig.test-d/package.json +0 -6
- package/tempo/MultisigOperation/package.json +0 -6
- package/tempo/MultisigOperation.test-d/package.json +0 -6
- package/tempo/MultisigOperation.test-d.ts +0 -71
- package/tempo/MultisigSimulation/package.json +0 -6
- package/tempo/MultisigSimulation.test-d/package.json +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AccountConfig, AccountSimulation } from 'ox/tempo'
|
|
2
2
|
import { describe, expect, test } from 'vitest'
|
|
3
3
|
|
|
4
4
|
const config =
|
|
@@ -12,11 +12,11 @@ const rpc = {
|
|
|
12
12
|
},
|
|
13
13
|
],
|
|
14
14
|
config,
|
|
15
|
-
} as const satisfies
|
|
15
|
+
} as const satisfies AccountSimulation.Rpc
|
|
16
16
|
|
|
17
17
|
describe('fromRpc', () => {
|
|
18
18
|
test('behavior: decodes the configuration', () => {
|
|
19
|
-
expect(
|
|
19
|
+
expect(AccountSimulation.fromRpc(rpc)).toMatchInlineSnapshot(`
|
|
20
20
|
{
|
|
21
21
|
"approvals": [
|
|
22
22
|
{
|
|
@@ -49,43 +49,43 @@ describe('fromRpc', () => {
|
|
|
49
49
|
'0xf843a0000000000000000000000000000000000000000000000000000000000000000088ffffffffffffffff01d7d694111111111111111111111111111111111111111101' as const
|
|
50
50
|
|
|
51
51
|
expect(
|
|
52
|
-
|
|
52
|
+
AccountSimulation.fromRpc({ ...rpc, approvals: [], config }).config
|
|
53
53
|
.version,
|
|
54
54
|
).toMatchInlineSnapshot(`18446744073709551615n`)
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
test('error: rejects excess root approvals', () => {
|
|
58
58
|
expect(() =>
|
|
59
|
-
|
|
59
|
+
AccountSimulation.fromRpc({
|
|
60
60
|
...rpc,
|
|
61
61
|
approvals: Array.from({ length: 9 }, () => rpc.approvals[0]),
|
|
62
62
|
}),
|
|
63
63
|
).toThrowErrorMatchingInlineSnapshot(
|
|
64
|
-
`[
|
|
64
|
+
`[AccountSimulation.InvalidSimulationError: Invalid account simulation: approval count exceeds 8.]`,
|
|
65
65
|
)
|
|
66
66
|
})
|
|
67
67
|
test('error: rejects nested approvals', () => {
|
|
68
68
|
expect(() =>
|
|
69
|
-
|
|
69
|
+
AccountSimulation.fromRpc({
|
|
70
70
|
...rpc,
|
|
71
|
-
approvals: [{ type: '
|
|
71
|
+
approvals: [{ type: 'configurable', spec: rpc }],
|
|
72
72
|
} as never),
|
|
73
73
|
).toThrowErrorMatchingInlineSnapshot(
|
|
74
|
-
`[
|
|
74
|
+
`[AccountSimulation.InvalidSimulationError: Invalid account simulation: only untagged primitive owner approvals are allowed.]`,
|
|
75
75
|
)
|
|
76
76
|
})
|
|
77
77
|
|
|
78
78
|
test('error: rejects trailing configuration bytes', () => {
|
|
79
79
|
expect(() =>
|
|
80
|
-
|
|
80
|
+
AccountSimulation.fromRpc({ ...rpc, config: `${config}00` }),
|
|
81
81
|
).toThrowErrorMatchingInlineSnapshot(
|
|
82
|
-
`[
|
|
82
|
+
`[AccountSimulation.InvalidSimulationError: Invalid account simulation: noncanonical config encoding.]`,
|
|
83
83
|
)
|
|
84
84
|
})
|
|
85
85
|
|
|
86
86
|
test('error: rejects malformed configuration RLP', () => {
|
|
87
87
|
expect(() =>
|
|
88
|
-
|
|
88
|
+
AccountSimulation.fromRpc({ ...rpc, config: '0xf8' }),
|
|
89
89
|
).toThrowErrorMatchingInlineSnapshot(
|
|
90
90
|
`[Cursor.PositionOutOfBoundsError: Position \`1\` is out of bounds (\`0 < position < 1\`).]`,
|
|
91
91
|
)
|
|
@@ -93,9 +93,9 @@ describe('fromRpc', () => {
|
|
|
93
93
|
|
|
94
94
|
test('error: rejects a non-list configuration', () => {
|
|
95
95
|
expect(() =>
|
|
96
|
-
|
|
96
|
+
AccountSimulation.fromRpc({ ...rpc, config: '0x01' }),
|
|
97
97
|
).toThrowErrorMatchingInlineSnapshot(
|
|
98
|
-
`[
|
|
98
|
+
`[AccountSimulation.InvalidSimulationError: Invalid account simulation: invalid config encoding.]`,
|
|
99
99
|
)
|
|
100
100
|
})
|
|
101
101
|
|
|
@@ -105,9 +105,9 @@ describe('fromRpc', () => {
|
|
|
105
105
|
.replace('118002', '11810002') as `0x${string}`
|
|
106
106
|
|
|
107
107
|
expect(() =>
|
|
108
|
-
|
|
108
|
+
AccountSimulation.fromRpc({ ...rpc, config: noncanonical }),
|
|
109
109
|
).toThrowErrorMatchingInlineSnapshot(
|
|
110
|
-
`[
|
|
110
|
+
`[AccountSimulation.InvalidSimulationError: Invalid account simulation: invalid config encoding.]`,
|
|
111
111
|
)
|
|
112
112
|
})
|
|
113
113
|
})
|
|
@@ -115,7 +115,7 @@ describe('fromRpc', () => {
|
|
|
115
115
|
describe('toRpc', () => {
|
|
116
116
|
test('behavior: encodes configurations and shims long key data', () => {
|
|
117
117
|
expect(
|
|
118
|
-
|
|
118
|
+
AccountSimulation.toRpc(AccountSimulation.fromRpc(rpc)),
|
|
119
119
|
).toMatchInlineSnapshot(`
|
|
120
120
|
{
|
|
121
121
|
"approvals": [
|
|
@@ -131,12 +131,12 @@ describe('toRpc', () => {
|
|
|
131
131
|
})
|
|
132
132
|
|
|
133
133
|
test('behavior: preserves short key data', () => {
|
|
134
|
-
const spec =
|
|
134
|
+
const spec = AccountSimulation.fromRpc({
|
|
135
135
|
...rpc,
|
|
136
136
|
approvals: [{ ...rpc.approvals[0], keyData: '0x0102' }],
|
|
137
137
|
})
|
|
138
138
|
|
|
139
|
-
expect(
|
|
139
|
+
expect(AccountSimulation.toRpc(spec).approvals).toMatchInlineSnapshot(`
|
|
140
140
|
[
|
|
141
141
|
{
|
|
142
142
|
"keyData": "0x0102",
|
|
@@ -148,13 +148,13 @@ describe('toRpc', () => {
|
|
|
148
148
|
})
|
|
149
149
|
|
|
150
150
|
test('behavior: encodes the maximum uint64 configuration version', () => {
|
|
151
|
-
const spec =
|
|
151
|
+
const spec = AccountSimulation.fromRpc(rpc)
|
|
152
152
|
|
|
153
153
|
expect(
|
|
154
|
-
|
|
154
|
+
AccountSimulation.toRpc({
|
|
155
155
|
...spec,
|
|
156
156
|
approvals: [],
|
|
157
|
-
config:
|
|
157
|
+
config: AccountConfig.from({
|
|
158
158
|
owners: [
|
|
159
159
|
{
|
|
160
160
|
owner: '0x1111111111111111111111111111111111111111',
|
|
@@ -162,7 +162,7 @@ describe('toRpc', () => {
|
|
|
162
162
|
},
|
|
163
163
|
],
|
|
164
164
|
threshold: 1,
|
|
165
|
-
version:
|
|
165
|
+
version: AccountConfig.maxVersion,
|
|
166
166
|
}),
|
|
167
167
|
}).config,
|
|
168
168
|
).toMatchInlineSnapshot(
|
|
@@ -171,25 +171,25 @@ describe('toRpc', () => {
|
|
|
171
171
|
})
|
|
172
172
|
|
|
173
173
|
test('error: rejects excess root approvals', () => {
|
|
174
|
-
const spec =
|
|
174
|
+
const spec = AccountSimulation.fromRpc(rpc)
|
|
175
175
|
|
|
176
176
|
expect(() =>
|
|
177
|
-
|
|
177
|
+
AccountSimulation.toRpc({
|
|
178
178
|
...spec,
|
|
179
179
|
approvals: Array.from({ length: 9 }, () => spec.approvals[0]!),
|
|
180
180
|
}),
|
|
181
181
|
).toThrowErrorMatchingInlineSnapshot(
|
|
182
|
-
`[
|
|
182
|
+
`[AccountSimulation.InvalidSimulationError: Invalid account simulation: approval count exceeds 8.]`,
|
|
183
183
|
)
|
|
184
184
|
})
|
|
185
185
|
test('error: rejects nested approvals', () => {
|
|
186
186
|
expect(() =>
|
|
187
|
-
|
|
187
|
+
AccountSimulation.toRpc({
|
|
188
188
|
...rpc,
|
|
189
|
-
approvals: [{ type: '
|
|
189
|
+
approvals: [{ type: 'configurable', spec: rpc }],
|
|
190
190
|
} as never),
|
|
191
191
|
).toThrowErrorMatchingInlineSnapshot(
|
|
192
|
-
`[
|
|
192
|
+
`[AccountSimulation.InvalidSimulationError: Invalid account simulation: only untagged primitive owner approvals are allowed.]`,
|
|
193
193
|
)
|
|
194
194
|
})
|
|
195
195
|
})
|
|
@@ -3,13 +3,13 @@ import * as Errors from '../core/Errors.js'
|
|
|
3
3
|
import * as Hex from '../core/Hex.js'
|
|
4
4
|
import type { Compute } from '../core/internal/types.js'
|
|
5
5
|
import * as Rlp from '../core/Rlp.js'
|
|
6
|
-
import * as
|
|
6
|
+
import * as AccountConfig from './AccountConfig.js'
|
|
7
7
|
import type * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/** Configurable account owner approval used for RPC simulation. */
|
|
10
10
|
export type Approval = PrimitiveApproval
|
|
11
11
|
|
|
12
|
-
/** JSON-RPC
|
|
12
|
+
/** JSON-RPC configurable account owner approval used for RPC simulation. */
|
|
13
13
|
export type ApprovalRpc = PrimitiveApproval
|
|
14
14
|
|
|
15
15
|
/** Primitive owner approval used for RPC simulation. */
|
|
@@ -22,7 +22,7 @@ export type PrimitiveApproval = {
|
|
|
22
22
|
owner: Address.Address
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/** JSON-RPC representation of
|
|
25
|
+
/** JSON-RPC representation of an account simulation spec. */
|
|
26
26
|
export type Rpc = Compute<{
|
|
27
27
|
/** Owner approvals to model. */
|
|
28
28
|
approvals: readonly ApprovalRpc[]
|
|
@@ -30,27 +30,27 @@ export type Rpc = Compute<{
|
|
|
30
30
|
config: Hex.Hex
|
|
31
31
|
}>
|
|
32
32
|
|
|
33
|
-
/**
|
|
33
|
+
/** Account simulation spec used to construct an RPC simulation signature. */
|
|
34
34
|
export type Spec = Compute<{
|
|
35
35
|
/** Owner approvals to model. */
|
|
36
36
|
approvals: readonly Approval[]
|
|
37
37
|
/** Complete applicable configuration. */
|
|
38
|
-
config:
|
|
38
|
+
config: AccountConfig.Config
|
|
39
39
|
}>
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Converts a JSON-RPC
|
|
42
|
+
* Converts a JSON-RPC account simulation spec to its domain representation.
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts twoslash
|
|
46
46
|
* // @noErrors
|
|
47
|
-
* import {
|
|
47
|
+
* import { AccountSimulation } from 'ox/tempo'
|
|
48
48
|
*
|
|
49
|
-
* const spec =
|
|
49
|
+
* const spec = AccountSimulation.fromRpc(specRpc)
|
|
50
50
|
* ```
|
|
51
51
|
*
|
|
52
|
-
* @param spec - JSON-RPC
|
|
53
|
-
* @returns The
|
|
52
|
+
* @param spec - JSON-RPC account simulation spec.
|
|
53
|
+
* @returns The account simulation spec with decoded configurations.
|
|
54
54
|
*/
|
|
55
55
|
export function fromRpc(spec: Rpc): Spec {
|
|
56
56
|
const { approvals, config } = spec
|
|
@@ -63,25 +63,25 @@ export declare namespace fromRpc {
|
|
|
63
63
|
export type ErrorType =
|
|
64
64
|
| Hex.isEqual.ErrorType
|
|
65
65
|
| InvalidSimulationError
|
|
66
|
-
|
|
|
66
|
+
| AccountConfig.assert.ErrorType
|
|
67
67
|
| Rlp.fromHex.ErrorType
|
|
68
68
|
| Rlp.toHex.ErrorType
|
|
69
69
|
| Errors.GlobalErrorType
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Converts
|
|
73
|
+
* Converts an account simulation spec to its JSON-RPC representation.
|
|
74
74
|
*
|
|
75
75
|
* @example
|
|
76
76
|
* ```ts twoslash
|
|
77
77
|
* // @noErrors
|
|
78
|
-
* import {
|
|
78
|
+
* import { AccountSimulation } from 'ox/tempo'
|
|
79
79
|
*
|
|
80
|
-
* const specRpc =
|
|
80
|
+
* const specRpc = AccountSimulation.toRpc(spec)
|
|
81
81
|
* ```
|
|
82
82
|
*
|
|
83
|
-
* @param spec -
|
|
84
|
-
* @returns The JSON-RPC
|
|
83
|
+
* @param spec - Account simulation spec.
|
|
84
|
+
* @returns The JSON-RPC account simulation spec with encoded configurations.
|
|
85
85
|
*/
|
|
86
86
|
export function toRpc(spec: Spec): Rpc {
|
|
87
87
|
const { approvals, config } = spec
|
|
@@ -101,7 +101,7 @@ export declare namespace toRpc {
|
|
|
101
101
|
export type ErrorType =
|
|
102
102
|
| Hex.fromNumber.ErrorType
|
|
103
103
|
| InvalidSimulationError
|
|
104
|
-
|
|
|
104
|
+
| AccountConfig.assert.ErrorType
|
|
105
105
|
| Rlp.fromHex.ErrorType
|
|
106
106
|
| Errors.GlobalErrorType
|
|
107
107
|
}
|
|
@@ -120,14 +120,14 @@ function assertApprovals(approvals: readonly unknown[]) {
|
|
|
120
120
|
throw new InvalidSimulationError({
|
|
121
121
|
reason: 'only untagged primitive owner approvals are allowed',
|
|
122
122
|
})
|
|
123
|
-
if (approvals.length >
|
|
123
|
+
if (approvals.length > AccountConfig.maxSignatures)
|
|
124
124
|
throw new InvalidSimulationError({
|
|
125
|
-
reason: `approval count exceeds ${
|
|
125
|
+
reason: `approval count exceeds ${AccountConfig.maxSignatures}`,
|
|
126
126
|
})
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/** @internal */
|
|
130
|
-
function deserializeConfig(config: Hex.Hex):
|
|
130
|
+
function deserializeConfig(config: Hex.Hex): AccountConfig.Config {
|
|
131
131
|
const tuple = Rlp.toHex(config)
|
|
132
132
|
if (!Array.isArray(tuple) || tuple.length !== 4)
|
|
133
133
|
throw new InvalidSimulationError({ reason: 'invalid config encoding' })
|
|
@@ -151,18 +151,16 @@ function deserializeConfig(config: Hex.Hex): MultisigConfig.Config {
|
|
|
151
151
|
)
|
|
152
152
|
)
|
|
153
153
|
throw new InvalidSimulationError({ reason: 'invalid config encoding' })
|
|
154
|
-
const value =
|
|
155
|
-
|
|
156
|
-
)
|
|
157
|
-
MultisigConfig.assert(value)
|
|
154
|
+
const value = AccountConfig.fromTuple(tuple as unknown as AccountConfig.Tuple)
|
|
155
|
+
AccountConfig.assert(value)
|
|
158
156
|
if (!Hex.isEqual(config, serializeConfig(value)))
|
|
159
157
|
throw new InvalidSimulationError({ reason: 'noncanonical config encoding' })
|
|
160
158
|
return value
|
|
161
159
|
}
|
|
162
160
|
|
|
163
161
|
/** @internal */
|
|
164
|
-
function serializeConfig(config:
|
|
165
|
-
return Rlp.fromHex(
|
|
162
|
+
function serializeConfig(config: AccountConfig.Input): Hex.Hex {
|
|
163
|
+
return Rlp.fromHex(AccountConfig.toTuple(config))
|
|
166
164
|
}
|
|
167
165
|
|
|
168
166
|
/**
|
|
@@ -175,11 +173,11 @@ function shimKeyData(data: Hex.Hex): Hex.Hex {
|
|
|
175
173
|
return Hex.fromNumber(size, { size: 2 })
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
/** Thrown when
|
|
176
|
+
/** Thrown when an account simulation spec is invalid. */
|
|
179
177
|
export class InvalidSimulationError extends Errors.BaseError {
|
|
180
|
-
override readonly name = '
|
|
178
|
+
override readonly name = 'AccountSimulation.InvalidSimulationError'
|
|
181
179
|
constructor(options: InvalidSimulationError.Options) {
|
|
182
|
-
super(`Invalid
|
|
180
|
+
super(`Invalid account simulation: ${options.reason}.`)
|
|
183
181
|
}
|
|
184
182
|
}
|
|
185
183
|
|
|
@@ -18,7 +18,7 @@ const signature = {
|
|
|
18
18
|
type: 'secp256k1',
|
|
19
19
|
} as const satisfies SignatureEnvelope.Secp256k1
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const configurable = {
|
|
22
22
|
account: '0x2222222222222222222222222222222222222222',
|
|
23
23
|
config: {
|
|
24
24
|
salt: `0x${'00'.repeat(32)}`,
|
|
@@ -29,8 +29,8 @@ const multisig = {
|
|
|
29
29
|
],
|
|
30
30
|
},
|
|
31
31
|
signatures: [signature],
|
|
32
|
-
type: '
|
|
33
|
-
} as const satisfies SignatureEnvelope.
|
|
32
|
+
type: 'configurable',
|
|
33
|
+
} as const satisfies SignatureEnvelope.Configurable
|
|
34
34
|
|
|
35
35
|
test('accepts primitive signatures', () => {
|
|
36
36
|
const signed = KeyAuthorization.from(authorization, { signature })
|
|
@@ -40,10 +40,10 @@ test('accepts primitive signatures', () => {
|
|
|
40
40
|
>()
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
-
test('accepts
|
|
43
|
+
test('accepts configurable signatures and account-bound grants', () => {
|
|
44
44
|
const signed = KeyAuthorization.from(
|
|
45
|
-
{ ...authorization, account:
|
|
46
|
-
{ signature:
|
|
45
|
+
{ ...authorization, account: configurable.account, type: 'configurable' },
|
|
46
|
+
{ signature: configurable },
|
|
47
47
|
)
|
|
48
48
|
expectTypeOf(signed).toMatchTypeOf<KeyAuthorization.Signed>()
|
|
49
49
|
expectTypeOf(
|
|
@@ -51,11 +51,11 @@ test('accepts multisig signatures and account-bound grants', () => {
|
|
|
51
51
|
).toMatchTypeOf<KeyAuthorization.Rpc>()
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
-
test('requires an account for
|
|
55
|
-
type
|
|
56
|
-
expectTypeOf<
|
|
54
|
+
test('requires an account for configurable grants', () => {
|
|
55
|
+
type Configurable = Extract<KeyAuthorization.Input, { type: 'configurable' }>
|
|
56
|
+
expectTypeOf<Configurable['account']>().toEqualTypeOf<TempoAddress.Address>()
|
|
57
57
|
expectTypeOf<
|
|
58
|
-
Extract<KeyAuthorization.Signed, { type: '
|
|
58
|
+
Extract<KeyAuthorization.Signed, { type: 'configurable' }>['account']
|
|
59
59
|
>().toEqualTypeOf<`0x${string}`>()
|
|
60
60
|
expectTypeOf<
|
|
61
61
|
Omit<Extract<KeyAuthorization.Rpc, { keyType: 'multisig' }>, 'account'>
|
|
@@ -63,13 +63,13 @@ test('requires an account for multisig grants', () => {
|
|
|
63
63
|
expectTypeOf<{
|
|
64
64
|
address: `0x${string}`
|
|
65
65
|
chainId: bigint
|
|
66
|
-
type: '
|
|
66
|
+
type: 'configurable'
|
|
67
67
|
}>().not.toExtend<KeyAuthorization.Input>()
|
|
68
68
|
expectTypeOf<{
|
|
69
69
|
account: undefined
|
|
70
70
|
address: `0x${string}`
|
|
71
71
|
chainId: bigint
|
|
72
|
-
type: '
|
|
72
|
+
type: 'configurable'
|
|
73
73
|
}>().not.toExtend<KeyAuthorization.Input>()
|
|
74
74
|
expectTypeOf<{
|
|
75
75
|
account: null
|
|
@@ -118,13 +118,13 @@ test('rejects keychain signatures', () => {
|
|
|
118
118
|
expectTypeOf(rpc).toMatchTypeOf<KeyAuthorization.Rpc>()
|
|
119
119
|
})
|
|
120
120
|
|
|
121
|
-
test('resolves Tempo address bindings for
|
|
121
|
+
test('resolves Tempo address bindings for configurable grants', () => {
|
|
122
122
|
const signed = KeyAuthorization.from(
|
|
123
123
|
{
|
|
124
124
|
account: TempoAddress.format(authorization.address),
|
|
125
125
|
address: TempoAddress.format(authorization.address),
|
|
126
126
|
chainId: 1n,
|
|
127
|
-
type: '
|
|
127
|
+
type: 'configurable',
|
|
128
128
|
},
|
|
129
129
|
{ signature },
|
|
130
130
|
)
|