ox 1.8.6 → 1.8.8
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/dist/core/internal/abiItem.d.ts.map +1 -1
- package/dist/core/internal/abiItem.js +3 -2
- package/dist/core/internal/abiItem.js.map +1 -1
- 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 +16 -16
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +10 -9
- 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/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/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/core/_test/AbiEvent.test.ts +7 -0
- package/src/core/_test/AbiFunction.test.ts +3 -0
- package/src/core/_test/AbiItem.test.ts +20 -0
- package/src/core/internal/abiItem.ts +3 -2
- 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 +6 -6
- package/src/tempo/KeyAuthorization.test.ts +52 -36
- package/src/tempo/KeyAuthorization.ts +29 -27
- 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/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/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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* eslint-disable jsdoc-js/require-jsdoc, jsdoc-js/require-description, jsdoc-js/require-example */
|
|
2
|
+
import * as core_AccountConfig from '../../tempo/AccountConfig.js'
|
|
3
|
+
import * as core_AccountSimulation from '../../tempo/AccountSimulation.js'
|
|
4
|
+
import * as z_Address from '../Address.js'
|
|
5
|
+
import * as z_Hex from '../Hex.js'
|
|
6
|
+
import * as z from 'zod/mini'
|
|
7
|
+
import * as z_AccountConfig from './AccountConfig.js'
|
|
8
|
+
import * as z_SignatureEnvelope from './SignatureEnvelope.js'
|
|
9
|
+
|
|
10
|
+
const PrimitiveApproval = z.strictObject({
|
|
11
|
+
keyData: z.optional(z_Hex.Hex),
|
|
12
|
+
keyType: z.optional(z_SignatureEnvelope.Type),
|
|
13
|
+
owner: z_Address.Address,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
/** Account simulation spec schema. */
|
|
17
|
+
export const Domain = z.object({
|
|
18
|
+
approvals: z.readonly(
|
|
19
|
+
z
|
|
20
|
+
.array(PrimitiveApproval)
|
|
21
|
+
.check(z.maxLength(core_AccountConfig.maxSignatures)),
|
|
22
|
+
),
|
|
23
|
+
config: z_AccountConfig.Config,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const Rpc_ = z
|
|
27
|
+
.object({
|
|
28
|
+
approvals: z.readonly(
|
|
29
|
+
z
|
|
30
|
+
.array(PrimitiveApproval)
|
|
31
|
+
.check(z.maxLength(core_AccountConfig.maxSignatures)),
|
|
32
|
+
),
|
|
33
|
+
config: z_Hex.Hex,
|
|
34
|
+
})
|
|
35
|
+
.check(
|
|
36
|
+
z.refine((value) => {
|
|
37
|
+
try {
|
|
38
|
+
core_AccountSimulation.fromRpc(value)
|
|
39
|
+
return true
|
|
40
|
+
} catch {
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
43
|
+
}, 'expected valid account simulation spec'),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
/** Codec decoding an RPC account simulation spec into its domain representation. */
|
|
47
|
+
export const AccountSimulation = z.codec(Rpc_, Domain, {
|
|
48
|
+
decode: (value) => core_AccountSimulation.fromRpc(value),
|
|
49
|
+
encode: (value) => core_AccountSimulation.toRpc(value),
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
/** RPC account simulation spec schema. */
|
|
53
|
+
export const Rpc = Rpc_
|
|
@@ -41,14 +41,14 @@ export const Rpc = z
|
|
|
41
41
|
limits: z.optional(z.nullable(z.readonly(z.array(RpcTokenLimit)))),
|
|
42
42
|
signature: z.union([
|
|
43
43
|
z_SignatureEnvelope.PrimitiveRpc,
|
|
44
|
-
z_SignatureEnvelope.
|
|
44
|
+
z_SignatureEnvelope.ConfigurableRpc,
|
|
45
45
|
]),
|
|
46
46
|
witness: z.optional(z.nullable(z_Hex.Hex)),
|
|
47
47
|
})
|
|
48
48
|
.check(
|
|
49
49
|
z.refine(
|
|
50
50
|
(value) => value.keyType !== 'multisig' || value.account != null,
|
|
51
|
-
'
|
|
51
|
+
'configurable account key grants require a parent account binding',
|
|
52
52
|
),
|
|
53
53
|
)
|
|
54
54
|
|
|
@@ -81,9 +81,9 @@ const domainShape = {
|
|
|
81
81
|
scopes: z.optional(z.readonly(z.array(Scope))),
|
|
82
82
|
signature: z.union([
|
|
83
83
|
z_SignatureEnvelope.Primitive,
|
|
84
|
-
z_SignatureEnvelope.
|
|
84
|
+
z_SignatureEnvelope.Configurable,
|
|
85
85
|
]),
|
|
86
|
-
type: z.union([z_SignatureEnvelope.Type, z.literal('
|
|
86
|
+
type: z.union([z_SignatureEnvelope.Type, z.literal('configurable')]),
|
|
87
87
|
witness: z.optional(z_Hex.Hex),
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -96,8 +96,8 @@ export const Domain = z
|
|
|
96
96
|
})
|
|
97
97
|
.check(
|
|
98
98
|
z.refine(
|
|
99
|
-
(value) => value.type !== '
|
|
100
|
-
'
|
|
99
|
+
(value) => value.type !== 'configurable' || value.account != null,
|
|
100
|
+
'configurable account key grants require a parent account binding',
|
|
101
101
|
),
|
|
102
102
|
)
|
|
103
103
|
|
|
@@ -117,8 +117,8 @@ export const DomainToRpc = z
|
|
|
117
117
|
})
|
|
118
118
|
.check(
|
|
119
119
|
z.refine(
|
|
120
|
-
(value) => value.type !== '
|
|
121
|
-
'
|
|
120
|
+
(value) => value.type !== 'configurable' || value.account != null,
|
|
121
|
+
'configurable account key grants require a parent account binding',
|
|
122
122
|
),
|
|
123
123
|
)
|
|
124
124
|
|
|
@@ -7,9 +7,9 @@ import * as z_Log from '../Log.js'
|
|
|
7
7
|
import * as z_StateOverrides from '../StateOverrides.js'
|
|
8
8
|
import { from } from '../internal/rpcSchemas/from.js'
|
|
9
9
|
import * as z from 'zod/mini'
|
|
10
|
+
import * as z_AccountConfig from './AccountConfig.js'
|
|
10
11
|
import * as z_KeyAuthorization from './KeyAuthorization.js'
|
|
11
|
-
import * as
|
|
12
|
-
import * as z_MultisigOperation from './MultisigOperation.js'
|
|
12
|
+
import * as z_AccountOperation from './AccountOperation.js'
|
|
13
13
|
import * as z_TransactionRequest from './TransactionRequest.js'
|
|
14
14
|
|
|
15
15
|
const BlockNumberOrTagOrIdentifier = z.union([
|
|
@@ -90,51 +90,51 @@ export const tempo_simulateV1 = from({
|
|
|
90
90
|
/** JSON-RPC method schemas for the `tempo_` namespace. */
|
|
91
91
|
export const Tempo = { tempo_simulateV1 }
|
|
92
92
|
|
|
93
|
-
/** Schema for the `
|
|
94
|
-
export const
|
|
95
|
-
method: '
|
|
93
|
+
/** Schema for the `account_approveKeyAuthorization` JSON-RPC method. */
|
|
94
|
+
export const account_approveKeyAuthorization = from({
|
|
95
|
+
method: 'account_approveKeyAuthorization',
|
|
96
96
|
params: z.tuple([
|
|
97
97
|
z.union([
|
|
98
98
|
z.object({ keyAuthorization: z_KeyAuthorization.Rpc }),
|
|
99
99
|
z.object({ hash: z_Hex.Hex, signature: z_Hex.Hex }),
|
|
100
100
|
]),
|
|
101
101
|
]),
|
|
102
|
-
returns:
|
|
102
|
+
returns: z_AccountOperation.KeyAuthorizationOperation,
|
|
103
103
|
})
|
|
104
104
|
|
|
105
|
-
/** Schema for the `
|
|
106
|
-
export const
|
|
107
|
-
method: '
|
|
105
|
+
/** Schema for the `account_approveRawTransaction` JSON-RPC method. */
|
|
106
|
+
export const account_approveRawTransaction = from({
|
|
107
|
+
method: 'account_approveRawTransaction',
|
|
108
108
|
params: z.tuple([z_Hex.Hex]),
|
|
109
109
|
returns: z_Hex.Hex,
|
|
110
110
|
})
|
|
111
111
|
|
|
112
|
-
/** Schema for the `
|
|
113
|
-
export const
|
|
114
|
-
method: '
|
|
112
|
+
/** Schema for the `account_approveRawTransactionSync` JSON-RPC method. */
|
|
113
|
+
export const account_approveRawTransactionSync = from({
|
|
114
|
+
method: 'account_approveRawTransactionSync',
|
|
115
115
|
params: z.tuple([z_Hex.Hex, z.optional(z.number())]),
|
|
116
|
-
returns:
|
|
116
|
+
returns: z_AccountOperation.TransactionOperation,
|
|
117
117
|
})
|
|
118
118
|
|
|
119
|
-
/** Schema for the `
|
|
120
|
-
export const
|
|
121
|
-
method: '
|
|
119
|
+
/** Schema for the `account_getConfig` JSON-RPC method. */
|
|
120
|
+
export const account_getConfig = from({
|
|
121
|
+
method: 'account_getConfig',
|
|
122
122
|
params: z.tuple([z.object({ address: z_Address.Address })]),
|
|
123
|
-
returns: z.nullable(
|
|
123
|
+
returns: z.nullable(z_AccountConfig.Rpc),
|
|
124
124
|
})
|
|
125
125
|
|
|
126
|
-
/** Schema for the `
|
|
127
|
-
export const
|
|
128
|
-
method: '
|
|
126
|
+
/** Schema for the `account_getOperation` JSON-RPC method. */
|
|
127
|
+
export const account_getOperation = from({
|
|
128
|
+
method: 'account_getOperation',
|
|
129
129
|
params: z.tuple([z_Hex.Hex]),
|
|
130
|
-
returns: z.nullable(
|
|
130
|
+
returns: z.nullable(z_AccountOperation.Operation),
|
|
131
131
|
})
|
|
132
132
|
|
|
133
|
-
/** JSON-RPC method schemas for the `
|
|
134
|
-
export const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
/** JSON-RPC method schemas for the `account_` namespace. */
|
|
134
|
+
export const Account = {
|
|
135
|
+
account_approveKeyAuthorization,
|
|
136
|
+
account_approveRawTransaction,
|
|
137
|
+
account_approveRawTransactionSync,
|
|
138
|
+
account_getConfig,
|
|
139
|
+
account_getOperation,
|
|
140
140
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable jsdoc-js/require-jsdoc, jsdoc-js/require-description, jsdoc-js/require-example */
|
|
2
2
|
import * as core_SignatureEnvelope from '../../tempo/SignatureEnvelope.js'
|
|
3
3
|
import * as core_Hex from '../../core/Hex.js'
|
|
4
|
-
import * as
|
|
4
|
+
import * as core_AccountConfig from '../../tempo/AccountConfig.js'
|
|
5
5
|
import * as z_Address from '../Address.js'
|
|
6
6
|
import * as z_Hex from '../Hex.js'
|
|
7
|
-
import * as
|
|
7
|
+
import * as z_AccountConfig from './AccountConfig.js'
|
|
8
8
|
import * as z from 'zod/mini'
|
|
9
9
|
|
|
10
10
|
/** Signature envelope key type schema. */
|
|
@@ -92,11 +92,11 @@ export const KeychainRpc = z
|
|
|
92
92
|
} catch {
|
|
93
93
|
return false
|
|
94
94
|
}
|
|
95
|
-
}, '
|
|
95
|
+
}, 'configurable access keys require keychain V2'),
|
|
96
96
|
)
|
|
97
97
|
|
|
98
|
-
/** RPC
|
|
99
|
-
export const
|
|
98
|
+
/** RPC configurable account signature envelope schema. */
|
|
99
|
+
export const ConfigurableRpc = z_Hex.Hex.check(
|
|
100
100
|
z.refine((value) => {
|
|
101
101
|
try {
|
|
102
102
|
core_SignatureEnvelope.fromRpc(value)
|
|
@@ -104,7 +104,7 @@ export const MultisigRpc = z_Hex.Hex.check(
|
|
|
104
104
|
} catch {
|
|
105
105
|
return false
|
|
106
106
|
}
|
|
107
|
-
}, 'expected valid
|
|
107
|
+
}, 'expected valid configurable account signature'),
|
|
108
108
|
)
|
|
109
109
|
|
|
110
110
|
/** RPC signature envelope schema. */
|
|
@@ -113,7 +113,7 @@ export const Rpc = z.union([
|
|
|
113
113
|
P256Rpc,
|
|
114
114
|
WebAuthnRpc,
|
|
115
115
|
KeychainRpc,
|
|
116
|
-
|
|
116
|
+
ConfigurableRpc,
|
|
117
117
|
])
|
|
118
118
|
|
|
119
119
|
/** secp256k1 signature envelope schema. */
|
|
@@ -160,32 +160,38 @@ export const Keychain = z
|
|
|
160
160
|
.check(
|
|
161
161
|
z.refine(
|
|
162
162
|
(value) => core_SignatureEnvelope.validate(value),
|
|
163
|
-
'
|
|
163
|
+
'configurable access keys require keychain V2',
|
|
164
164
|
),
|
|
165
165
|
)
|
|
166
166
|
|
|
167
|
-
/**
|
|
168
|
-
export const
|
|
167
|
+
/** Configurable account signature envelope schema. */
|
|
168
|
+
export const Configurable = z
|
|
169
169
|
.object({
|
|
170
170
|
account: z_Address.Address,
|
|
171
|
-
config:
|
|
171
|
+
config: z_AccountConfig.Config,
|
|
172
172
|
signatures: z.readonly(
|
|
173
173
|
z
|
|
174
174
|
.array(Primitive)
|
|
175
|
-
.check(z.minLength(1), z.maxLength(
|
|
175
|
+
.check(z.minLength(1), z.maxLength(core_AccountConfig.maxSignatures)),
|
|
176
176
|
),
|
|
177
|
-
type: z.literal('
|
|
177
|
+
type: z.literal('configurable'),
|
|
178
178
|
})
|
|
179
179
|
// Keep invalid recursive approvals inside Zod's issue path.
|
|
180
180
|
.check(
|
|
181
181
|
z.refine(
|
|
182
182
|
(value) => core_SignatureEnvelope.validate(value),
|
|
183
|
-
'expected valid
|
|
183
|
+
'expected valid configurable account signature',
|
|
184
184
|
),
|
|
185
185
|
)
|
|
186
186
|
|
|
187
187
|
/** Decoded signature envelope schema. */
|
|
188
|
-
export const Domain = z.union([
|
|
188
|
+
export const Domain = z.union([
|
|
189
|
+
Secp256k1,
|
|
190
|
+
P256,
|
|
191
|
+
WebAuthn,
|
|
192
|
+
Keychain,
|
|
193
|
+
Configurable,
|
|
194
|
+
])
|
|
189
195
|
|
|
190
196
|
/** Codec decoding an RPC signature envelope into a signature envelope. */
|
|
191
197
|
export const SignatureEnvelope = z.codec(Rpc, Domain, {
|
|
@@ -298,9 +304,9 @@ function toRpc(
|
|
|
298
304
|
}
|
|
299
305
|
}
|
|
300
306
|
|
|
301
|
-
if (value.type === '
|
|
307
|
+
if (value.type === 'configurable')
|
|
302
308
|
return core_SignatureEnvelope.toRpc(
|
|
303
|
-
value as core_SignatureEnvelope.
|
|
309
|
+
value as core_SignatureEnvelope.Configurable,
|
|
304
310
|
)
|
|
305
311
|
|
|
306
312
|
const keychain = value as core_SignatureEnvelope.Keychain
|
|
@@ -11,15 +11,23 @@ import {
|
|
|
11
11
|
uintNumberNumberish,
|
|
12
12
|
} from '../internal/Integer.js'
|
|
13
13
|
import * as z from 'zod/mini'
|
|
14
|
+
import * as z_AccountSimulation from './AccountSimulation.js'
|
|
14
15
|
import * as z_AuthorizationTempo from './AuthorizationTempo.js'
|
|
15
16
|
import * as z_KeyAuthorization from './KeyAuthorization.js'
|
|
16
|
-
import * as z_MultisigSimulation from './MultisigSimulation.js'
|
|
17
17
|
import * as z_SignatureEnvelope from './SignatureEnvelope.js'
|
|
18
18
|
|
|
19
19
|
const fromRpcType = { '0x76': 'tempo' } as const
|
|
20
20
|
const toRpcType = { tempo: '0x76' } as const
|
|
21
21
|
|
|
22
22
|
const KeyType = z.union([
|
|
23
|
+
z.literal('secp256k1'),
|
|
24
|
+
z.literal('p256'),
|
|
25
|
+
z.literal('webAuthn'),
|
|
26
|
+
z.literal('configurable'),
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
// The node's wire format names the configurable account key type `multisig`.
|
|
30
|
+
const KeyTypeRpc = z.union([
|
|
23
31
|
z.literal('secp256k1'),
|
|
24
32
|
z.literal('p256'),
|
|
25
33
|
z.literal('webAuthn'),
|
|
@@ -80,12 +88,12 @@ export const Rpc = z.object({
|
|
|
80
88
|
keyAuthorization: z.optional(z_KeyAuthorization.Rpc),
|
|
81
89
|
keyData: z.optional(z_Hex.Hex),
|
|
82
90
|
keyId: z.optional(z_Address.Address),
|
|
83
|
-
keyType: z.optional(
|
|
91
|
+
keyType: z.optional(KeyTypeRpc),
|
|
84
92
|
maxFeePerBlobGas: z.optional(z_Hex.Hex),
|
|
85
93
|
maxFeePerGas: z.optional(z_Hex.Hex),
|
|
86
94
|
maxPriorityFeePerGas: z.optional(z_Hex.Hex),
|
|
87
|
-
keyAuthorizationSimulation: z.optional(
|
|
88
|
-
multisigSimulation: z.optional(
|
|
95
|
+
keyAuthorizationSimulation: z.optional(z_AccountSimulation.Rpc),
|
|
96
|
+
multisigSimulation: z.optional(z_AccountSimulation.Rpc),
|
|
89
97
|
nonce: z.optional(z_Hex.Hex),
|
|
90
98
|
nonceKey: z.optional(z_Hex.Hex),
|
|
91
99
|
r: z.optional(z_Hex.Hex),
|
|
@@ -117,6 +125,7 @@ const AuthorizationSignedToRpc = z.object({
|
|
|
117
125
|
/** Decoded tempo transaction request schema. */
|
|
118
126
|
export const Domain = z.object({
|
|
119
127
|
accessList: z.optional(z_AccessList.AccessList),
|
|
128
|
+
accountSimulation: z.optional(z_AccountSimulation.Domain),
|
|
120
129
|
authorizationList: z.optional(z.readonly(z.array(AuthorizationSigned))),
|
|
121
130
|
blobVersionedHashes: z.optional(z.readonly(z.array(z_Hex.Hex))),
|
|
122
131
|
blobs: z.optional(z.readonly(z.array(z_Hex.Hex))),
|
|
@@ -138,8 +147,7 @@ export const Domain = z.object({
|
|
|
138
147
|
maxFeePerBlobGas: z.optional(z.bigint()),
|
|
139
148
|
maxFeePerGas: z.optional(z.bigint()),
|
|
140
149
|
maxPriorityFeePerGas: z.optional(z.bigint()),
|
|
141
|
-
keyAuthorizationSimulation: z.optional(
|
|
142
|
-
multisigSimulation: z.optional(z_MultisigSimulation.Domain),
|
|
150
|
+
keyAuthorizationSimulation: z.optional(z_AccountSimulation.Domain),
|
|
143
151
|
nonce: z.optional(z.bigint()),
|
|
144
152
|
nonceKey: z.optional(z.union([z.bigint(), z.literal('random')])),
|
|
145
153
|
r: z.optional(z_Hex.Hex),
|
|
@@ -157,6 +165,7 @@ export const Domain = z.object({
|
|
|
157
165
|
/** Encode-only decoded tempo transaction request schema accepting numberish `toRpc` inputs. */
|
|
158
166
|
export const DomainToRpc = z.object({
|
|
159
167
|
accessList: z.optional(z_AccessList.AccessList),
|
|
168
|
+
accountSimulation: z.optional(z_AccountSimulation.Domain),
|
|
160
169
|
authorizationList: z.optional(z.readonly(z.array(AuthorizationSignedToRpc))),
|
|
161
170
|
blobVersionedHashes: z.optional(z.readonly(z.array(z_Hex.Hex))),
|
|
162
171
|
blobs: z.optional(z.readonly(z.array(z_Hex.Hex))),
|
|
@@ -178,8 +187,7 @@ export const DomainToRpc = z.object({
|
|
|
178
187
|
maxFeePerBlobGas: z.optional(uintBigintNumberish()),
|
|
179
188
|
maxFeePerGas: z.optional(uintBigintNumberish()),
|
|
180
189
|
maxPriorityFeePerGas: z.optional(uintBigintNumberish()),
|
|
181
|
-
keyAuthorizationSimulation: z.optional(
|
|
182
|
-
multisigSimulation: z.optional(z_MultisigSimulation.Domain),
|
|
190
|
+
keyAuthorizationSimulation: z.optional(z_AccountSimulation.Domain),
|
|
183
191
|
nonce: z.optional(uintBigintNumberish()),
|
|
184
192
|
nonceKey: z.optional(z.union([uintBigintNumberish(), z.literal('random')])),
|
|
185
193
|
r: z.optional(z_Hex.Hex),
|
|
@@ -253,15 +261,17 @@ function fromRpc(
|
|
|
253
261
|
request_.feePayer = request.feePayer
|
|
254
262
|
if (typeof request.keyData !== 'undefined') request_.keyData = request.keyData
|
|
255
263
|
if (typeof request.keyId !== 'undefined') request_.keyId = request.keyId
|
|
256
|
-
if (typeof request.keyType !== 'undefined')
|
|
264
|
+
if (typeof request.keyType !== 'undefined')
|
|
265
|
+
request_.keyType =
|
|
266
|
+
request.keyType === 'multisig' ? 'configurable' : request.keyType
|
|
257
267
|
if (typeof request.keyAuthorizationSimulation !== 'undefined')
|
|
258
268
|
request_.keyAuthorizationSimulation = z.decode(
|
|
259
|
-
|
|
269
|
+
z_AccountSimulation.AccountSimulation,
|
|
260
270
|
request.keyAuthorizationSimulation,
|
|
261
271
|
)
|
|
262
272
|
if (typeof request.multisigSimulation !== 'undefined')
|
|
263
|
-
request_.
|
|
264
|
-
|
|
273
|
+
request_.accountSimulation = z.decode(
|
|
274
|
+
z_AccountSimulation.AccountSimulation,
|
|
265
275
|
request.multisigSimulation,
|
|
266
276
|
)
|
|
267
277
|
if (typeof request.validBefore !== 'undefined')
|
|
@@ -284,6 +294,7 @@ function toRpc(
|
|
|
284
294
|
} as never) as core_TransactionRequest.Rpc
|
|
285
295
|
|
|
286
296
|
const tempo =
|
|
297
|
+
typeof request.accountSimulation !== 'undefined' ||
|
|
287
298
|
typeof request.calls !== 'undefined' ||
|
|
288
299
|
typeof request.capabilities !== 'undefined' ||
|
|
289
300
|
typeof request.feePayer !== 'undefined' ||
|
|
@@ -292,7 +303,6 @@ function toRpc(
|
|
|
292
303
|
typeof request.keyData !== 'undefined' ||
|
|
293
304
|
typeof request.keyId !== 'undefined' ||
|
|
294
305
|
typeof request.keyType !== 'undefined' ||
|
|
295
|
-
typeof request.multisigSimulation !== 'undefined' ||
|
|
296
306
|
typeof request.nonceKey !== 'undefined' ||
|
|
297
307
|
typeof request.validBefore !== 'undefined' ||
|
|
298
308
|
typeof request.validAfter !== 'undefined' ||
|
|
@@ -346,16 +356,17 @@ function toRpc(
|
|
|
346
356
|
request_rpc.keyData = shimKeyData(request.keyData)
|
|
347
357
|
if (typeof request.keyId !== 'undefined') request_rpc.keyId = request.keyId
|
|
348
358
|
if (typeof request.keyType !== 'undefined')
|
|
349
|
-
request_rpc.keyType =
|
|
359
|
+
request_rpc.keyType =
|
|
360
|
+
request.keyType === 'configurable' ? 'multisig' : request.keyType
|
|
350
361
|
if (typeof request.keyAuthorizationSimulation !== 'undefined')
|
|
351
362
|
request_rpc.keyAuthorizationSimulation = z.encode(
|
|
352
|
-
|
|
363
|
+
z_AccountSimulation.AccountSimulation,
|
|
353
364
|
request.keyAuthorizationSimulation,
|
|
354
365
|
)
|
|
355
|
-
if (typeof request.
|
|
366
|
+
if (typeof request.accountSimulation !== 'undefined')
|
|
356
367
|
request_rpc.multisigSimulation = z.encode(
|
|
357
|
-
|
|
358
|
-
request.
|
|
368
|
+
z_AccountSimulation.AccountSimulation,
|
|
369
|
+
request.accountSimulation,
|
|
359
370
|
)
|
|
360
371
|
if (typeof request.validBefore !== 'undefined')
|
|
361
372
|
request_rpc.validBefore = encodeNumberish(request.validBefore)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as core_AccountConfig from '../../../tempo/AccountConfig.js'
|
|
2
|
+
import type * as z from 'zod/mini'
|
|
3
|
+
import { expectTypeOf, test } from 'vp/test'
|
|
4
|
+
import * as z_AccountConfig from '../AccountConfig.js'
|
|
5
|
+
|
|
6
|
+
test('AccountConfig decodes RPC configurations', () => {
|
|
7
|
+
expectTypeOf<core_AccountConfig.Rpc>().toMatchTypeOf<
|
|
8
|
+
z.input<typeof z_AccountConfig.AccountConfig>
|
|
9
|
+
>()
|
|
10
|
+
expectTypeOf<
|
|
11
|
+
z.output<typeof z_AccountConfig.AccountConfig>
|
|
12
|
+
>().toMatchTypeOf<core_AccountConfig.Config>()
|
|
13
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vp/test'
|
|
2
|
-
import * as
|
|
2
|
+
import * as z_AccountConfig from '../AccountConfig.js'
|
|
3
3
|
import * as z from 'zod/mini'
|
|
4
4
|
|
|
5
5
|
const config = {
|
|
@@ -17,20 +17,20 @@ const config = {
|
|
|
17
17
|
const rpc = { ...config, version: '0x0' } as const
|
|
18
18
|
|
|
19
19
|
describe('Config', () => {
|
|
20
|
-
test('accepts valid
|
|
21
|
-
expect(z.safeDecode(
|
|
20
|
+
test('accepts valid account configurations', () => {
|
|
21
|
+
expect(z.safeDecode(z_AccountConfig.Config, config).success).toBe(true)
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
test('round-trips RPC configurations', () => {
|
|
25
|
-
const decoded = z.decode(
|
|
25
|
+
const decoded = z.decode(z_AccountConfig.AccountConfig, rpc)
|
|
26
26
|
|
|
27
27
|
expect(decoded).toEqual(config)
|
|
28
|
-
expect(z.encode(
|
|
28
|
+
expect(z.encode(z_AccountConfig.AccountConfig, decoded)).toEqual(rpc)
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
test('rejects configurations outside protocol limits', () => {
|
|
32
32
|
expect(
|
|
33
|
-
z.safeDecode(
|
|
33
|
+
z.safeDecode(z_AccountConfig.Config, {
|
|
34
34
|
...config,
|
|
35
35
|
owners: [{ ...config.owners[0], weight: 255 }],
|
|
36
36
|
threshold: 256,
|
|
@@ -40,7 +40,7 @@ describe('Config', () => {
|
|
|
40
40
|
|
|
41
41
|
test('rejects non-canonical owner order', () => {
|
|
42
42
|
expect(
|
|
43
|
-
z.safeDecode(
|
|
43
|
+
z.safeDecode(z_AccountConfig.Config, {
|
|
44
44
|
...config,
|
|
45
45
|
owners: [
|
|
46
46
|
{
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type * as core_AccountOperation from '../../../tempo/AccountOperation.js'
|
|
2
|
+
import type * as z from 'zod/mini'
|
|
3
|
+
import { expectTypeOf, test } from 'vp/test'
|
|
4
|
+
import * as z_AccountOperation from '../AccountOperation.js'
|
|
5
|
+
|
|
6
|
+
test('operation schemas decode RPC operations', () => {
|
|
7
|
+
expectTypeOf<core_AccountOperation.TransactionRpc>().toMatchTypeOf<
|
|
8
|
+
z.input<typeof z_AccountOperation.TransactionOperation>
|
|
9
|
+
>()
|
|
10
|
+
expectTypeOf<
|
|
11
|
+
z.output<typeof z_AccountOperation.TransactionOperation>
|
|
12
|
+
>().toMatchTypeOf<core_AccountOperation.TransactionOperation>()
|
|
13
|
+
|
|
14
|
+
expectTypeOf<core_AccountOperation.KeyAuthorizationRpc>().toMatchTypeOf<
|
|
15
|
+
z.input<typeof z_AccountOperation.KeyAuthorizationOperation>
|
|
16
|
+
>()
|
|
17
|
+
expectTypeOf<
|
|
18
|
+
z.output<typeof z_AccountOperation.KeyAuthorizationOperation>
|
|
19
|
+
>().toMatchTypeOf<core_AccountOperation.KeyAuthorizationOperation>()
|
|
20
|
+
|
|
21
|
+
expectTypeOf<core_AccountOperation.Rpc>().toMatchTypeOf<
|
|
22
|
+
z.input<typeof z_AccountOperation.Operation>
|
|
23
|
+
>()
|
|
24
|
+
expectTypeOf<
|
|
25
|
+
z.output<typeof z_AccountOperation.Operation>
|
|
26
|
+
>().toMatchTypeOf<core_AccountOperation.Operation>()
|
|
27
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vp/test'
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as core_AccountOperation from '../../../tempo/AccountOperation.js'
|
|
3
|
+
import * as z_AccountOperation from '../AccountOperation.js'
|
|
4
4
|
import * as z from 'zod/mini'
|
|
5
5
|
|
|
6
6
|
const rpc = {
|
|
@@ -37,21 +37,21 @@ const rpc = {
|
|
|
37
37
|
|
|
38
38
|
describe('TransactionOperation', () => {
|
|
39
39
|
test('decodes an RPC operation', () => {
|
|
40
|
-
expect(z.decode(
|
|
41
|
-
|
|
40
|
+
expect(z.decode(z_AccountOperation.TransactionOperation, rpc)).toEqual(
|
|
41
|
+
core_AccountOperation.fromRpc(rpc),
|
|
42
42
|
)
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
test('round-trips via encode', () => {
|
|
46
|
-
const operation = z.decode(
|
|
46
|
+
const operation = z.decode(z_AccountOperation.TransactionOperation, rpc)
|
|
47
47
|
expect(
|
|
48
|
-
z.encode(
|
|
49
|
-
).toEqual(
|
|
48
|
+
z.encode(z_AccountOperation.TransactionOperation, operation),
|
|
49
|
+
).toEqual(core_AccountOperation.toRpc(operation))
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
test('rejects internally inconsistent operations', () => {
|
|
53
53
|
expect(
|
|
54
|
-
z.safeDecode(
|
|
54
|
+
z.safeDecode(z_AccountOperation.TransactionOperation, {
|
|
55
55
|
...rpc,
|
|
56
56
|
weight: 2,
|
|
57
57
|
}).success,
|
|
@@ -61,6 +61,6 @@ describe('TransactionOperation', () => {
|
|
|
61
61
|
|
|
62
62
|
describe('Operation', () => {
|
|
63
63
|
test('accepts transaction operations', () => {
|
|
64
|
-
expect(z.safeDecode(
|
|
64
|
+
expect(z.safeDecode(z_AccountOperation.Operation, rpc).success).toBe(true)
|
|
65
65
|
})
|
|
66
66
|
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as core_AccountSimulation from '../../../tempo/AccountSimulation.js'
|
|
2
|
+
import type * as z from 'zod/mini'
|
|
3
|
+
import { expectTypeOf, test } from 'vp/test'
|
|
4
|
+
import * as z_AccountSimulation from '../AccountSimulation.js'
|
|
5
|
+
|
|
6
|
+
test('AccountSimulation decodes RPC specs', () => {
|
|
7
|
+
expectTypeOf<core_AccountSimulation.Rpc>().toMatchTypeOf<
|
|
8
|
+
z.input<typeof z_AccountSimulation.AccountSimulation>
|
|
9
|
+
>()
|
|
10
|
+
expectTypeOf<
|
|
11
|
+
z.output<typeof z_AccountSimulation.AccountSimulation>
|
|
12
|
+
>().toMatchTypeOf<core_AccountSimulation.Spec>()
|
|
13
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vp/test'
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as core_AccountSimulation from '../../../tempo/AccountSimulation.js'
|
|
3
|
+
import * as z_AccountSimulation from '../AccountSimulation.js'
|
|
4
4
|
import * as z from 'zod/mini'
|
|
5
5
|
|
|
6
6
|
const rpc = {
|
|
@@ -13,21 +13,21 @@ const rpc = {
|
|
|
13
13
|
],
|
|
14
14
|
config:
|
|
15
15
|
'0xf852a011111111111111111111111111111111111111111111111111111111111111110102eed694aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa01d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01',
|
|
16
|
-
} as const satisfies
|
|
16
|
+
} as const satisfies core_AccountSimulation.Rpc
|
|
17
17
|
|
|
18
|
-
describe('
|
|
18
|
+
describe('AccountSimulation', () => {
|
|
19
19
|
test('behavior: converts between RPC and domain specs', () => {
|
|
20
|
-
const spec = z.decode(
|
|
20
|
+
const spec = z.decode(z_AccountSimulation.AccountSimulation, rpc)
|
|
21
21
|
|
|
22
|
-
expect(spec).toEqual(
|
|
23
|
-
expect(
|
|
24
|
-
|
|
25
|
-
)
|
|
22
|
+
expect(spec).toEqual(core_AccountSimulation.fromRpc(rpc))
|
|
23
|
+
expect(z.encode(z_AccountSimulation.AccountSimulation, spec)).toStrictEqual(
|
|
24
|
+
rpc,
|
|
25
|
+
)
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
test('error: rejects more than eight root approvals', () => {
|
|
29
29
|
expect(
|
|
30
|
-
z.safeDecode(
|
|
30
|
+
z.safeDecode(z_AccountSimulation.Rpc, {
|
|
31
31
|
...rpc,
|
|
32
32
|
approvals: Array.from({ length: 9 }, () => rpc.approvals[0]),
|
|
33
33
|
}).success,
|
|
@@ -35,16 +35,16 @@ describe('MultisigSimulation', () => {
|
|
|
35
35
|
})
|
|
36
36
|
test('error: rejects nested approvals', () => {
|
|
37
37
|
expect(
|
|
38
|
-
z.safeDecode(
|
|
38
|
+
z.safeDecode(z_AccountSimulation.Rpc, {
|
|
39
39
|
...rpc,
|
|
40
|
-
approvals: [{ type: '
|
|
40
|
+
approvals: [{ type: 'configurable', spec: rpc }],
|
|
41
41
|
} as never).success,
|
|
42
42
|
).toMatchInlineSnapshot(`false`)
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
test('error: rejects malformed encoded configurations', () => {
|
|
46
46
|
expect(
|
|
47
|
-
z.safeDecode(
|
|
47
|
+
z.safeDecode(z_AccountSimulation.Rpc, {
|
|
48
48
|
...rpc,
|
|
49
49
|
config: '0x01',
|
|
50
50
|
}).success,
|