viem 3.0.0-next.13 → 3.0.0-next.14
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/dist/chains/definitions/arcTestnet.d.ts +5 -5
- package/dist/chains/definitions/arcTestnet.d.ts.map +1 -1
- package/dist/chains/definitions/arcTestnet.js +11 -8
- package/dist/chains/definitions/arcTestnet.js.map +1 -1
- package/dist/chains/definitions/qmsTestnet.d.ts +27 -0
- package/dist/chains/definitions/qmsTestnet.d.ts.map +1 -0
- package/dist/chains/definitions/qmsTestnet.js +23 -0
- package/dist/chains/definitions/qmsTestnet.js.map +1 -0
- package/dist/chains/definitions/tempo.d.ts +1 -1
- package/dist/chains/definitions/tempo.js +1 -1
- package/dist/chains/definitions/tempoModerato.d.ts +2 -2
- package/dist/chains/definitions/tempoModerato.js +2 -2
- package/dist/chains/index.d.ts +1 -0
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +1 -0
- package/dist/chains/index.js.map +1 -1
- package/dist/core/actions/transaction/waitForReceipt.d.ts +1 -1
- package/dist/core/actions/transaction/waitForReceipt.d.ts.map +1 -1
- package/dist/core/actions/transaction/waitForReceipt.js +5 -2
- package/dist/core/actions/transaction/waitForReceipt.js.map +1 -1
- package/dist/core/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
- package/dist/core/actions/wallet/waitForCallsStatus.js +24 -1
- package/dist/core/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/dist/internal/inference.d.ts +3 -3
- package/dist/internal/inference.d.ts.map +1 -1
- package/dist/tempo/Abis.d.ts +1935 -899
- package/dist/tempo/Abis.d.ts.map +1 -1
- package/dist/tempo/Abis.js +215 -0
- package/dist/tempo/Abis.js.map +1 -1
- package/dist/tempo/Account.d.ts +30 -30
- package/dist/tempo/Account.d.ts.map +1 -1
- package/dist/tempo/Account.js +43 -43
- package/dist/tempo/Account.js.map +1 -1
- package/dist/tempo/Addresses.d.ts +2 -0
- package/dist/tempo/Addresses.d.ts.map +1 -1
- package/dist/tempo/Addresses.js +2 -0
- package/dist/tempo/Addresses.js.map +1 -1
- package/dist/tempo/Decorator.d.ts +33 -10
- package/dist/tempo/Decorator.d.ts.map +1 -1
- package/dist/tempo/Decorator.js +9 -8
- package/dist/tempo/Decorator.js.map +1 -1
- package/dist/tempo/ExecutionError.js +1 -1
- package/dist/tempo/ExecutionError.js.map +1 -1
- package/dist/tempo/KeyAuthorizationManager.d.ts +24 -13
- package/dist/tempo/KeyAuthorizationManager.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorizationManager.js +44 -25
- package/dist/tempo/KeyAuthorizationManager.js.map +1 -1
- package/dist/tempo/Relay.d.ts +61 -12
- package/dist/tempo/Relay.d.ts.map +1 -1
- package/dist/tempo/Relay.js +48 -8
- package/dist/tempo/Relay.js.map +1 -1
- package/dist/tempo/Selectors.d.ts +12 -0
- package/dist/tempo/Selectors.d.ts.map +1 -1
- package/dist/tempo/Selectors.js +12 -0
- package/dist/tempo/Selectors.js.map +1 -1
- package/dist/tempo/Transport.d.ts +19 -6
- package/dist/tempo/Transport.d.ts.map +1 -1
- package/dist/tempo/Transport.js +18 -12
- package/dist/tempo/Transport.js.map +1 -1
- package/dist/tempo/{multisig → accounts}/Config.d.ts +8 -8
- package/dist/tempo/accounts/Config.d.ts.map +1 -0
- package/dist/tempo/{multisig → accounts}/Config.js +14 -14
- package/dist/tempo/{multisig → accounts}/Config.js.map +1 -1
- package/dist/tempo/{multisig → accounts}/Operation.d.ts +8 -8
- package/dist/tempo/{multisig → accounts}/Operation.d.ts.map +1 -1
- package/dist/tempo/{multisig → accounts}/Operation.js +17 -17
- package/dist/tempo/{multisig → accounts}/Operation.js.map +1 -1
- package/dist/tempo/{multisig → accounts}/Signature.d.ts +1 -1
- package/dist/tempo/accounts/Signature.d.ts.map +1 -0
- package/dist/tempo/accounts/Signature.js +9 -0
- package/dist/tempo/accounts/Signature.js.map +1 -0
- package/dist/tempo/actions/accessKey/index.d.ts +1 -0
- package/dist/tempo/actions/accessKey/index.d.ts.map +1 -1
- package/dist/tempo/actions/accessKey/index.js +1 -0
- package/dist/tempo/actions/accessKey/index.js.map +1 -1
- package/dist/tempo/actions/accessKey/prepareAuthorization.d.ts +4 -4
- package/dist/tempo/actions/accessKey/prepareAuthorization.d.ts.map +1 -1
- package/dist/tempo/actions/accessKey/prepareAuthorization.js +10 -10
- package/dist/tempo/actions/accessKey/prepareAuthorization.js.map +1 -1
- package/dist/tempo/actions/accessKey/saveAuthorization.d.ts +40 -0
- package/dist/tempo/actions/accessKey/saveAuthorization.d.ts.map +1 -0
- package/dist/tempo/actions/accessKey/saveAuthorization.js +32 -0
- package/dist/tempo/actions/accessKey/saveAuthorization.js.map +1 -0
- package/dist/tempo/actions/accessKey/signAuthorization.d.ts +17 -13
- package/dist/tempo/actions/accessKey/signAuthorization.d.ts.map +1 -1
- package/dist/tempo/actions/accessKey/signAuthorization.js +43 -30
- package/dist/tempo/actions/accessKey/signAuthorization.js.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/getConfig.d.ts +5 -5
- package/dist/tempo/actions/accounts/getConfig.d.ts.map +1 -0
- package/dist/tempo/actions/{multisig → accounts}/getConfig.js +5 -5
- package/dist/tempo/actions/accounts/getConfig.js.map +1 -0
- package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.d.ts +3 -3
- package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.js +2 -2
- package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.js.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/getOperation.d.ts +4 -4
- package/dist/tempo/actions/{multisig → accounts}/getOperation.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/getOperation.js +4 -4
- package/dist/tempo/actions/accounts/getOperation.js.map +1 -0
- package/dist/tempo/actions/{multisig → accounts}/index.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/index.js.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/updateConfig.d.ts +12 -12
- package/dist/tempo/actions/{multisig → accounts}/updateConfig.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/updateConfig.js +16 -21
- package/dist/tempo/actions/{multisig → accounts}/updateConfig.js.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.d.ts +6 -6
- package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.js +6 -6
- package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.js.map +1 -1
- package/dist/tempo/actions/index.d.ts +2 -2
- package/dist/tempo/actions/index.d.ts.map +1 -1
- package/dist/tempo/actions/index.js +2 -2
- package/dist/tempo/actions/index.js.map +1 -1
- package/dist/tempo/chainConfig.d.ts +16 -16
- package/dist/tempo/chainConfig.d.ts.map +1 -1
- package/dist/tempo/chainConfig.js +52 -52
- package/dist/tempo/chainConfig.js.map +1 -1
- package/dist/tempo/index.d.ts +2 -2
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +2 -2
- package/dist/tempo/index.js.map +1 -1
- package/dist/tempo/internal/relay/accounts.d.ts +15 -0
- package/dist/tempo/internal/relay/accounts.d.ts.map +1 -0
- package/dist/tempo/internal/relay/{multisig.js → accounts.js} +96 -101
- package/dist/tempo/internal/relay/accounts.js.map +1 -0
- package/dist/tempo/internal/relay/feePayer.js +5 -5
- package/dist/tempo/internal/relay/feePayer.js.map +1 -1
- package/dist/tempo/internal/relay/keyAuthorization.d.ts +25 -0
- package/dist/tempo/internal/relay/keyAuthorization.d.ts.map +1 -0
- package/dist/tempo/internal/relay/keyAuthorization.js +339 -0
- package/dist/tempo/internal/relay/keyAuthorization.js.map +1 -0
- package/dist/tempo/internal/relay/plugin.d.ts +6 -3
- package/dist/tempo/internal/relay/plugin.d.ts.map +1 -1
- package/dist/tempo/internal/relay/plugin.js +15 -6
- package/dist/tempo/internal/relay/plugin.js.map +1 -1
- package/dist/tempo/internal/relay/utils.d.ts +8 -0
- package/dist/tempo/internal/relay/utils.d.ts.map +1 -1
- package/dist/utils/RpcClient.d.ts.map +1 -1
- package/dist/utils/RpcClient.js +36 -19
- package/dist/utils/RpcClient.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/src/chains/definitions/arcTestnet.ts +11 -8
- package/src/chains/definitions/qmsTestnet.ts +23 -0
- package/src/chains/definitions/tempo.ts +1 -1
- package/src/chains/definitions/tempoModerato.ts +2 -2
- package/src/chains/index.ts +1 -0
- package/src/core/actions/transaction/waitForReceipt.ts +5 -3
- package/src/core/actions/wallet/waitForCallsStatus.ts +25 -1
- package/src/internal/inference.ts +3 -3
- package/src/tempo/Abis.ts +216 -0
- package/src/tempo/Account.ts +97 -87
- package/src/tempo/Addresses.ts +2 -0
- package/src/tempo/Decorator.ts +55 -28
- package/src/tempo/ExecutionError.ts +1 -1
- package/src/tempo/KeyAuthorizationManager.ts +53 -31
- package/src/tempo/Relay.ts +69 -14
- package/src/tempo/Selectors.ts +13 -0
- package/src/tempo/Transport.ts +46 -20
- package/src/tempo/{multisig → accounts}/Config.ts +21 -21
- package/src/tempo/{multisig → accounts}/Operation.ts +26 -26
- package/src/tempo/{multisig → accounts}/Signature.ts +5 -3
- package/src/tempo/actions/accessKey/index.ts +1 -0
- package/src/tempo/actions/accessKey/prepareAuthorization.ts +16 -15
- package/src/tempo/actions/accessKey/saveAuthorization.ts +51 -0
- package/src/tempo/actions/accessKey/signAuthorization.ts +73 -51
- package/src/tempo/actions/{multisig → accounts}/getConfig.ts +7 -7
- package/src/tempo/actions/{multisig → accounts}/getConfigCommitment.ts +3 -3
- package/src/tempo/actions/{multisig → accounts}/getOperation.ts +6 -6
- package/src/tempo/actions/{multisig → accounts}/updateConfig.ts +21 -26
- package/src/tempo/actions/{multisig → accounts}/updateConfigSync.ts +7 -7
- package/src/tempo/actions/index.ts +2 -3
- package/src/tempo/chainConfig.ts +87 -85
- package/src/tempo/index.ts +4 -4
- package/src/tempo/internal/relay/{multisig.ts → accounts.ts} +121 -121
- package/src/tempo/internal/relay/feePayer.ts +5 -5
- package/src/tempo/internal/relay/keyAuthorization.ts +419 -0
- package/src/tempo/internal/relay/plugin.ts +20 -7
- package/src/utils/RpcClient.ts +38 -21
- package/src/version.ts +1 -1
- package/dist/tempo/actions/multisig/getConfig.d.ts.map +0 -1
- package/dist/tempo/actions/multisig/getConfig.js.map +0 -1
- package/dist/tempo/actions/multisig/getOperation.js.map +0 -1
- package/dist/tempo/internal/relay/multisig.d.ts +0 -4
- package/dist/tempo/internal/relay/multisig.d.ts.map +0 -1
- package/dist/tempo/internal/relay/multisig.js.map +0 -1
- package/dist/tempo/multisig/Config.d.ts.map +0 -1
- package/dist/tempo/multisig/Signature.d.ts.map +0 -1
- package/dist/tempo/multisig/Signature.js +0 -9
- package/dist/tempo/multisig/Signature.js.map +0 -1
- /package/dist/tempo/actions/{multisig → accounts}/index.d.ts +0 -0
- /package/dist/tempo/actions/{multisig → accounts}/index.js +0 -0
- /package/src/tempo/actions/{multisig → accounts}/index.ts +0 -0
package/src/tempo/chainConfig.ts
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
TransactionRequest as ox_TransactionRequest,
|
|
7
7
|
} from 'ox'
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type
|
|
9
|
+
AccountConfig,
|
|
10
|
+
AccountOperation,
|
|
11
|
+
type AccountSimulation,
|
|
12
12
|
SignatureEnvelope,
|
|
13
13
|
TransactionReceipt as TransactionReceiptTempo,
|
|
14
14
|
TransactionRequest as TransactionRequestTempo,
|
|
@@ -24,13 +24,13 @@ import { get as getTransaction } from '../core/actions/transaction/get.js'
|
|
|
24
24
|
import { verifyDefault, type verifyHash } from '../core/actions/verifyHash.js'
|
|
25
25
|
import * as Contracts from '../core/internal/contracts.js'
|
|
26
26
|
import * as Abis from './Abis.js'
|
|
27
|
-
import type {
|
|
27
|
+
import type { ConfigurableAccount, RootAccount } from './Account.js'
|
|
28
28
|
import * as Addresses from './Addresses.js'
|
|
29
29
|
import type * as Capabilities from './Capabilities.js'
|
|
30
30
|
import type { Hardfork } from './Hardfork.js'
|
|
31
31
|
import type * as KeyAuthorizationManager from './KeyAuthorizationManager.js'
|
|
32
|
-
import { getConfig } from './actions/
|
|
33
|
-
import { parseApproval } from './
|
|
32
|
+
import { getConfig } from './actions/accounts/getConfig.js'
|
|
33
|
+
import { parseApproval } from './accounts/Signature.js'
|
|
34
34
|
import * as Concurrent from './internal/concurrent.js'
|
|
35
35
|
|
|
36
36
|
const maxExpirySecs = 25
|
|
@@ -62,19 +62,19 @@ export type TransactionRequest = Omit<
|
|
|
62
62
|
* an Account to co-sign locally, or an external sponsor URL allowed by the relay.
|
|
63
63
|
*/
|
|
64
64
|
feePayer?: viem_Account.Account | boolean | string | undefined
|
|
65
|
-
/** Stored
|
|
65
|
+
/** Stored account operation to approve. */
|
|
66
66
|
hash?: Hex.Hex | undefined
|
|
67
|
-
/** Owner signing a
|
|
67
|
+
/** Owner signing an approval for a configurable account. */
|
|
68
68
|
owner?: RootAccount | undefined
|
|
69
|
-
/**
|
|
70
|
-
|
|
69
|
+
/** Configurable account, config, and modeled approvals for gas estimation. */
|
|
70
|
+
accountSimulation?: AccountSimulation.Spec | undefined
|
|
71
71
|
/**
|
|
72
72
|
* Nonce key for the 2D nonce system (TIP-1009). `'expiring'` selects an
|
|
73
73
|
* expiring nonce (resolved while the request is prepared); `'random'`
|
|
74
74
|
* selects a random key.
|
|
75
75
|
*/
|
|
76
76
|
nonceKey?: 'expiring' | 'random' | bigint | undefined
|
|
77
|
-
/** Owner approvals to combine into a
|
|
77
|
+
/** Owner approvals to combine into a configurable account signature (TIP-1107). */
|
|
78
78
|
signatures?: readonly SignatureEnvelope.Serialized[] | undefined
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -83,18 +83,18 @@ export type TransactionRequestRpc = TransactionRequestTempo.Rpc
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* A Tempo transaction envelope. Client-side request metadata (`feePayer`,
|
|
86
|
-
* `
|
|
86
|
+
* `accountSimulation`, `signatures`) rides the envelope structurally: the chain's
|
|
87
87
|
* `toEnvelope` hook threads it from the request, and the `serialize` hook
|
|
88
88
|
* (or the signing account) consumes it.
|
|
89
89
|
*/
|
|
90
90
|
export type Envelope = TxEnvelopeTempo.TxEnvelopeTempo & {
|
|
91
91
|
/** Fee payer of the transaction (TIP-1 gas sponsorship). */
|
|
92
92
|
feePayer?: viem_Account.Account | boolean | string | undefined
|
|
93
|
-
/** Owner signing a
|
|
93
|
+
/** Owner signing an approval for a configurable account. */
|
|
94
94
|
owner?: RootAccount | undefined
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
/** Owner approvals to combine into a
|
|
95
|
+
/** Configurable account, config, and modeled approvals for gas estimation. */
|
|
96
|
+
accountSimulation?: AccountSimulation.Spec | undefined
|
|
97
|
+
/** Owner approvals to combine into a configurable account signature (TIP-1107). */
|
|
98
98
|
signatures?: readonly SignatureEnvelope.Serialized[] | undefined
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -150,12 +150,12 @@ export type ChainConfig = {
|
|
|
150
150
|
type PrepareAccount = {
|
|
151
151
|
address: Address.Address
|
|
152
152
|
accessKeyAddress?: Address.Address | undefined
|
|
153
|
-
config?:
|
|
154
|
-
owners?:
|
|
153
|
+
config?: AccountConfig.Config | undefined
|
|
154
|
+
owners?: ConfigurableAccount['owners'] | undefined
|
|
155
155
|
keyAuthorizationManager?:
|
|
156
156
|
| KeyAuthorizationManager.KeyAuthorizationManager
|
|
157
157
|
| undefined
|
|
158
|
-
keyType?: '
|
|
158
|
+
keyType?: 'configurable' | 'p256' | 'secp256k1' | 'webAuthn' | undefined
|
|
159
159
|
source?: string | undefined
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -172,12 +172,12 @@ type PrepareRequest = TransactionRequest & {
|
|
|
172
172
|
type ToEnvelopeRequest = TransactionRequestTempo.TransactionRequest &
|
|
173
173
|
Pick<
|
|
174
174
|
TransactionRequest,
|
|
175
|
-
'feePayer' | '
|
|
175
|
+
'feePayer' | 'accountSimulation' | 'owner' | 'signatures'
|
|
176
176
|
>
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* Shared Tempo chain configuration: RPC converters, transaction hooks
|
|
180
|
-
* (expiring nonces,
|
|
180
|
+
* (expiring nonces, configurable account senders, fee tokens), and signature-envelope
|
|
181
181
|
* verification.
|
|
182
182
|
*/
|
|
183
183
|
export const chainConfig = {
|
|
@@ -192,11 +192,11 @@ export const chainConfig = {
|
|
|
192
192
|
const transaction = TransactionTempo.fromRpc(rpc)
|
|
193
193
|
return {
|
|
194
194
|
...transaction,
|
|
195
|
-
...(rpc.
|
|
195
|
+
...(rpc.operation
|
|
196
196
|
? {
|
|
197
|
-
|
|
198
|
-
rpc.
|
|
199
|
-
) as
|
|
197
|
+
operation: AccountOperation.fromRpc(
|
|
198
|
+
rpc.operation,
|
|
199
|
+
) as AccountOperation.TransactionOperation,
|
|
200
200
|
}
|
|
201
201
|
: {}),
|
|
202
202
|
}
|
|
@@ -212,11 +212,11 @@ export const chainConfig = {
|
|
|
212
212
|
...(rpc.status === 'pending'
|
|
213
213
|
? { status: 'pending' as const, type: 'tempo' as const }
|
|
214
214
|
: {}),
|
|
215
|
-
...(rpc.
|
|
215
|
+
...(rpc.operation
|
|
216
216
|
? {
|
|
217
|
-
|
|
218
|
-
rpc.
|
|
219
|
-
) as
|
|
217
|
+
operation: AccountOperation.fromRpc(
|
|
218
|
+
rpc.operation,
|
|
219
|
+
) as AccountOperation.TransactionOperation,
|
|
220
220
|
}
|
|
221
221
|
: {}),
|
|
222
222
|
}
|
|
@@ -249,38 +249,38 @@ export const chainConfig = {
|
|
|
249
249
|
if (
|
|
250
250
|
!request.account ||
|
|
251
251
|
typeof request.account === 'string' ||
|
|
252
|
-
request.account.source !== '
|
|
252
|
+
request.account.source !== 'configurable'
|
|
253
253
|
)
|
|
254
254
|
throw new Error(
|
|
255
|
-
'A local
|
|
255
|
+
'A local configurable account is required to approve a stored configurable account transaction.',
|
|
256
256
|
)
|
|
257
257
|
if (!request.owner || typeof request.owner === 'string')
|
|
258
258
|
throw new Error(
|
|
259
|
-
'A local owner account is required to approve a stored
|
|
259
|
+
'A local owner account is required to approve a stored configurable account transaction.',
|
|
260
260
|
)
|
|
261
261
|
if (request.owner.source !== 'root')
|
|
262
262
|
throw new Error(
|
|
263
|
-
'A Tempo owner account is required to approve a stored
|
|
263
|
+
'A Tempo owner account is required to approve a stored configurable account transaction.',
|
|
264
264
|
)
|
|
265
265
|
const transaction = await getTransaction(client, {
|
|
266
266
|
hash: request.hash,
|
|
267
267
|
})
|
|
268
268
|
const operation =
|
|
269
|
-
'
|
|
270
|
-
? (transaction.
|
|
271
|
-
|
|
|
269
|
+
'operation' in transaction
|
|
270
|
+
? (transaction.operation as
|
|
271
|
+
| AccountOperation.TransactionOperation
|
|
272
272
|
| undefined)
|
|
273
273
|
: undefined
|
|
274
274
|
if (!operation)
|
|
275
|
-
throw new Error('Expected
|
|
275
|
+
throw new Error('Expected an account operation transaction.')
|
|
276
276
|
if (!Address.isEqual(operation.account, request.account.address))
|
|
277
277
|
throw new Error(
|
|
278
|
-
'
|
|
278
|
+
'Account operation account does not match the requested account.',
|
|
279
279
|
)
|
|
280
280
|
const storedTransaction = TxEnvelopeTempo.deserialize(
|
|
281
281
|
operation.transaction as TxEnvelopeTempo.Serialized,
|
|
282
282
|
)
|
|
283
|
-
const hash =
|
|
283
|
+
const hash = AccountOperation.getHash({
|
|
284
284
|
account: operation.account,
|
|
285
285
|
config: operation.config,
|
|
286
286
|
transaction: operation.transaction as TxEnvelopeTempo.Serialized,
|
|
@@ -288,7 +288,7 @@ export const chainConfig = {
|
|
|
288
288
|
})
|
|
289
289
|
if (hash.toLowerCase() !== request.hash.toLowerCase())
|
|
290
290
|
throw new Error(
|
|
291
|
-
'
|
|
291
|
+
'Account operation hash does not match transaction.',
|
|
292
292
|
)
|
|
293
293
|
Object.assign(request, {
|
|
294
294
|
...storedTransaction,
|
|
@@ -298,9 +298,9 @@ export const chainConfig = {
|
|
|
298
298
|
nonce: Number(storedTransaction.nonce ?? 0n),
|
|
299
299
|
account: request.account,
|
|
300
300
|
from: operation.account,
|
|
301
|
-
|
|
301
|
+
accountSimulation: getAccountSimulation({
|
|
302
302
|
config: operation.config,
|
|
303
|
-
local: request.account as
|
|
303
|
+
local: request.account as ConfigurableAccount,
|
|
304
304
|
}),
|
|
305
305
|
owner: request.owner,
|
|
306
306
|
})
|
|
@@ -336,7 +336,7 @@ export const chainConfig = {
|
|
|
336
336
|
typeof request.type === 'undefined' &&
|
|
337
337
|
(isTempoRequest(request) ||
|
|
338
338
|
account?.source === 'accessKey' ||
|
|
339
|
-
account?.source === '
|
|
339
|
+
account?.source === 'configurable' ||
|
|
340
340
|
(account?.keyType && account.keyType !== 'secp256k1'))
|
|
341
341
|
)
|
|
342
342
|
request.type = 'tempo'
|
|
@@ -360,53 +360,53 @@ export const chainConfig = {
|
|
|
360
360
|
request.keyId = signer.accessKeyAddress
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
const
|
|
364
|
-
if (account?.source === '
|
|
363
|
+
const configurableIdentity = (() => {
|
|
364
|
+
if (account?.source === 'configurable')
|
|
365
365
|
return {
|
|
366
366
|
account: account.address,
|
|
367
|
-
config: (account as
|
|
368
|
-
local: account as
|
|
367
|
+
config: (account as ConfigurableAccount).config,
|
|
368
|
+
local: account as ConfigurableAccount,
|
|
369
369
|
}
|
|
370
370
|
return undefined
|
|
371
371
|
})()
|
|
372
|
-
if (request.owner && !
|
|
372
|
+
if (request.owner && !configurableIdentity)
|
|
373
373
|
throw new Error(
|
|
374
|
-
'A
|
|
374
|
+
'A configurable account is required when an owner is provided.',
|
|
375
375
|
)
|
|
376
376
|
if (request.owner && typeof request.owner === 'string')
|
|
377
377
|
throw new Error(
|
|
378
|
-
'A local owner account is required to approve a
|
|
378
|
+
'A local owner account is required to approve a configurable account transaction.',
|
|
379
379
|
)
|
|
380
380
|
if (request.owner && request.owner.source !== 'root')
|
|
381
381
|
throw new Error(
|
|
382
|
-
'A Tempo owner account is required to approve a
|
|
382
|
+
'A Tempo owner account is required to approve a configurable account transaction.',
|
|
383
383
|
)
|
|
384
|
-
const
|
|
385
|
-
!!
|
|
384
|
+
const coordinated =
|
|
385
|
+
!!configurableIdentity &&
|
|
386
386
|
!!request.owner &&
|
|
387
|
-
(client.transport as {
|
|
388
|
-
if (
|
|
389
|
-
const { account, local } =
|
|
387
|
+
(client.transport as { accounts?: boolean }).accounts === true
|
|
388
|
+
if (configurableIdentity) {
|
|
389
|
+
const { account, local } = configurableIdentity
|
|
390
390
|
if (!account)
|
|
391
391
|
throw new Error(
|
|
392
|
-
'A
|
|
392
|
+
'A configurable account address is required with a current config.',
|
|
393
393
|
)
|
|
394
394
|
const config = await (async () => {
|
|
395
|
-
if (
|
|
396
|
-
if (!
|
|
395
|
+
if (configurableIdentity.config) return configurableIdentity.config
|
|
396
|
+
if (!coordinated) return undefined
|
|
397
397
|
const cachedConfig = await getConfig(client, { address: account })
|
|
398
398
|
if (!cachedConfig)
|
|
399
399
|
throw new Error(
|
|
400
|
-
`No current
|
|
400
|
+
`No current account config is cached for account ${account}. Provide the current config.`,
|
|
401
401
|
)
|
|
402
402
|
return cachedConfig
|
|
403
403
|
})()
|
|
404
404
|
if (!config)
|
|
405
405
|
throw new Error(
|
|
406
|
-
'
|
|
406
|
+
'An account config is required to prepare a transaction.',
|
|
407
407
|
)
|
|
408
408
|
request.from = account
|
|
409
|
-
request.
|
|
409
|
+
request.accountSimulation = getAccountSimulation({
|
|
410
410
|
config,
|
|
411
411
|
local,
|
|
412
412
|
})
|
|
@@ -421,7 +421,7 @@ export const chainConfig = {
|
|
|
421
421
|
request.nonceKey === maxUint256
|
|
422
422
|
)
|
|
423
423
|
return true
|
|
424
|
-
if (
|
|
424
|
+
if (configurableIdentity) return false
|
|
425
425
|
if (request.feePayer && typeof request.nonceKey === 'undefined')
|
|
426
426
|
return true
|
|
427
427
|
const address =
|
|
@@ -433,7 +433,7 @@ export const chainConfig = {
|
|
|
433
433
|
return false
|
|
434
434
|
})()
|
|
435
435
|
|
|
436
|
-
if (
|
|
436
|
+
if (coordinated && typeof request.nonceKey === 'undefined') {
|
|
437
437
|
request.nonceKey = Hex.toBigInt(Hex.random(31)) + 1n
|
|
438
438
|
request.nonce = 0
|
|
439
439
|
} else if (useExpiringNonce) {
|
|
@@ -511,7 +511,7 @@ export const chainConfig = {
|
|
|
511
511
|
// Non-tempo envelopes delegate to the generic default.
|
|
512
512
|
if (!isTempoEnvelope(envelope)) return undefined
|
|
513
513
|
|
|
514
|
-
// Track caller signatures separately from synthesized
|
|
514
|
+
// Track caller signatures separately from synthesized configurable account
|
|
515
515
|
// approvals.
|
|
516
516
|
const signature_provided = (() => {
|
|
517
517
|
if (envelope.signature) return envelope.signature
|
|
@@ -523,26 +523,28 @@ export const chainConfig = {
|
|
|
523
523
|
// Combine owner approvals before fee-payer handling.
|
|
524
524
|
const signature = (() => {
|
|
525
525
|
if (signature_provided) return signature_provided
|
|
526
|
-
if (!envelope.
|
|
526
|
+
if (!envelope.accountSimulation || !envelope.signatures)
|
|
527
527
|
return undefined
|
|
528
528
|
|
|
529
529
|
if (!envelope.from)
|
|
530
|
-
throw new Error(
|
|
530
|
+
throw new Error(
|
|
531
|
+
'A configurable account sender is required for signing.',
|
|
532
|
+
)
|
|
531
533
|
const payload = TxEnvelopeTempo.getSignPayload(
|
|
532
534
|
TxEnvelopeTempo.from(envelope),
|
|
533
535
|
)
|
|
534
536
|
const signatures = envelope.signatures.map((approval) =>
|
|
535
537
|
parseApproval(approval),
|
|
536
538
|
)
|
|
537
|
-
const sorted = SignatureEnvelope.
|
|
539
|
+
const sorted = SignatureEnvelope.sortApprovals({
|
|
538
540
|
payload,
|
|
539
541
|
signatures,
|
|
540
542
|
account: envelope.from!,
|
|
541
|
-
config:
|
|
543
|
+
config: AccountConfig.from(envelope.accountSimulation.config),
|
|
542
544
|
})
|
|
543
545
|
return SignatureEnvelope.from({
|
|
544
546
|
account: envelope.from!,
|
|
545
|
-
config:
|
|
547
|
+
config: AccountConfig.from(envelope.accountSimulation.config),
|
|
546
548
|
signatures: sorted,
|
|
547
549
|
})
|
|
548
550
|
})()
|
|
@@ -581,7 +583,7 @@ export const chainConfig = {
|
|
|
581
583
|
// Non-tempo requests delegate to the generic default.
|
|
582
584
|
if (!isTempoRequest(request)) return undefined
|
|
583
585
|
|
|
584
|
-
const { feePayer,
|
|
586
|
+
const { feePayer, accountSimulation, owner, signatures, ...rest } =
|
|
585
587
|
request as ToEnvelopeRequest
|
|
586
588
|
|
|
587
589
|
const envelope = TransactionRequestTempo.toEnvelope({
|
|
@@ -594,7 +596,7 @@ export const chainConfig = {
|
|
|
594
596
|
return {
|
|
595
597
|
...envelope,
|
|
596
598
|
...(typeof feePayer !== 'undefined' ? { feePayer } : {}),
|
|
597
|
-
...(
|
|
599
|
+
...(accountSimulation ? { accountSimulation } : {}),
|
|
598
600
|
...(owner ? { owner } : {}),
|
|
599
601
|
...(signatures ? { signatures } : {}),
|
|
600
602
|
} as Envelope
|
|
@@ -718,7 +720,7 @@ function isTempoRequest(request: Record<string, unknown>): boolean {
|
|
|
718
720
|
typeof request.keyData !== 'undefined' ||
|
|
719
721
|
typeof request.keyId !== 'undefined' ||
|
|
720
722
|
typeof request.keyType !== 'undefined' ||
|
|
721
|
-
typeof request.
|
|
723
|
+
typeof request.accountSimulation !== 'undefined' ||
|
|
722
724
|
typeof request.owner !== 'undefined' ||
|
|
723
725
|
typeof request.nonceKey !== 'undefined' ||
|
|
724
726
|
typeof request.signature !== 'undefined' ||
|
|
@@ -740,7 +742,7 @@ function encodeRequest(
|
|
|
740
742
|
// Non-tempo requests take the generic encoding.
|
|
741
743
|
if (!isTempoRequest(r)) return ox_TransactionRequest.toRpc(r)
|
|
742
744
|
|
|
743
|
-
// `
|
|
745
|
+
// `accountSimulation`/`signatures` are client-side only. They drive
|
|
744
746
|
// sender derivation, owner signing, and final envelope assembly, but are
|
|
745
747
|
// never sent as raw RPC fields — the wire payload is the serialized tx.
|
|
746
748
|
// An `'expiring'` nonce key is resolved by the prepare hook and never
|
|
@@ -772,11 +774,11 @@ function encodeRequest(
|
|
|
772
774
|
return rpc
|
|
773
775
|
}
|
|
774
776
|
|
|
775
|
-
/** Builds a bounded
|
|
776
|
-
function
|
|
777
|
-
config:
|
|
778
|
-
local?:
|
|
779
|
-
}):
|
|
777
|
+
/** Builds a bounded account spec for gas simulation. */
|
|
778
|
+
function getAccountSimulation(options: {
|
|
779
|
+
config: AccountConfig.Config
|
|
780
|
+
local?: ConfigurableAccount | undefined
|
|
781
|
+
}): AccountSimulation.Spec {
|
|
780
782
|
const { config, local } = options
|
|
781
783
|
return {
|
|
782
784
|
approvals: selectOwners(config).map((owner) => {
|
|
@@ -815,7 +817,7 @@ function getSimulationKey(
|
|
|
815
817
|
}
|
|
816
818
|
|
|
817
819
|
/** Selects a deterministic minimum-cardinality owner quorum. */
|
|
818
|
-
function selectOwners(config:
|
|
820
|
+
function selectOwners(config: AccountConfig.Config) {
|
|
819
821
|
const owners = [...config.owners].sort(
|
|
820
822
|
(a, b) =>
|
|
821
823
|
Number(b.weight) - Number(a.weight) ||
|
|
@@ -823,7 +825,7 @@ function selectOwners(config: MultisigConfig.Config) {
|
|
|
823
825
|
)
|
|
824
826
|
const selected: typeof owners = []
|
|
825
827
|
let weight = 0
|
|
826
|
-
for (const owner of owners.slice(0,
|
|
828
|
+
for (const owner of owners.slice(0, AccountConfig.maxSignatures)) {
|
|
827
829
|
if (weight >= Number(config.threshold)) break
|
|
828
830
|
selected.push(owner)
|
|
829
831
|
weight += Number(owner.weight)
|
|
@@ -835,24 +837,24 @@ function selectOwners(config: MultisigConfig.Config) {
|
|
|
835
837
|
|
|
836
838
|
// Exported so consumer declaration emit can name them. See `internal/inference.ts`.
|
|
837
839
|
export type Transaction = TransactionTempo.Transaction & {
|
|
838
|
-
|
|
840
|
+
operation?: AccountOperation.TransactionOperation | undefined
|
|
839
841
|
}
|
|
840
842
|
export type TransactionRpc = TransactionTempo.Rpc & {
|
|
841
|
-
|
|
843
|
+
operation?: AccountOperation.TransactionRpc | undefined
|
|
842
844
|
}
|
|
843
845
|
export type TransactionReceipt = Omit<
|
|
844
846
|
TransactionReceiptTempo.TransactionReceipt,
|
|
845
847
|
'status'
|
|
846
848
|
> & {
|
|
847
849
|
status: 'success' | 'reverted' | 'pending'
|
|
848
|
-
|
|
850
|
+
operation?: AccountOperation.TransactionOperation | undefined
|
|
849
851
|
}
|
|
850
852
|
export type TransactionReceiptRpc = Omit<
|
|
851
853
|
TransactionReceiptTempo.Rpc,
|
|
852
854
|
'status'
|
|
853
855
|
> & {
|
|
854
856
|
status: '0x0' | '0x1' | 'pending'
|
|
855
|
-
|
|
857
|
+
operation?: AccountOperation.TransactionRpc | undefined
|
|
856
858
|
}
|
|
857
859
|
export type TxEnvelope = ox_TxEnvelope.TxEnvelope
|
|
858
860
|
export type SerializeOptions = TxEnvelopeTempo.serialize.Options
|
package/src/tempo/index.ts
CHANGED
|
@@ -5,9 +5,9 @@ export {
|
|
|
5
5
|
Channel,
|
|
6
6
|
EarnShares,
|
|
7
7
|
KeyAuthorization,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
AccountConfig,
|
|
9
|
+
AccountOperation,
|
|
10
|
+
AccountSimulation,
|
|
11
11
|
Period,
|
|
12
12
|
ReceivePolicyReceipt,
|
|
13
13
|
SignatureEnvelope,
|
|
@@ -67,7 +67,7 @@ export * as Expiry from './Expiry.js'
|
|
|
67
67
|
/** Tempo hardforks & activation helpers. */
|
|
68
68
|
export * as Hardfork from './Hardfork.js'
|
|
69
69
|
|
|
70
|
-
/**
|
|
70
|
+
/** Client-side storage for pending key authorizations, backed by a `Store`. */
|
|
71
71
|
export * as KeyAuthorizationManager from './KeyAuthorizationManager.js'
|
|
72
72
|
|
|
73
73
|
/** P256 (secp256r1) key utilities. Re-exports `ox/P256`. */
|