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
|
@@ -2,8 +2,8 @@ import type { Address } from 'abitype'
|
|
|
2
2
|
import { AbiFunction, Address as Address_, Hash, Hex, RpcResponse } from 'ox'
|
|
3
3
|
import {
|
|
4
4
|
KeyAuthorization,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
AccountConfig,
|
|
6
|
+
AccountOperation,
|
|
7
7
|
Transaction as ox_Transaction,
|
|
8
8
|
SignatureEnvelope,
|
|
9
9
|
TxEnvelopeTempo,
|
|
@@ -12,9 +12,9 @@ import { getNumber as getBlockNumber } from '../../../core/actions/block/getNumb
|
|
|
12
12
|
import { create as createClient } from '../../../core/Client.js'
|
|
13
13
|
import * as Abis from '../../Abis.js'
|
|
14
14
|
import * as Addresses from '../../Addresses.js'
|
|
15
|
-
import { getConfigCommitment } from '../../actions/
|
|
16
|
-
import * as ConfigStore from '../../
|
|
17
|
-
import * as OperationStore from '../../
|
|
15
|
+
import { getConfigCommitment } from '../../actions/accounts/getConfigCommitment.js'
|
|
16
|
+
import * as ConfigStore from '../../accounts/Config.js'
|
|
17
|
+
import * as OperationStore from '../../accounts/Operation.js'
|
|
18
18
|
import type * as Relay from '../../Relay.js'
|
|
19
19
|
import type * as Store from '../../Store.js'
|
|
20
20
|
import * as Plugin from './plugin.js'
|
|
@@ -22,16 +22,16 @@ import * as Plugin from './plugin.js'
|
|
|
22
22
|
const submissionTtl = 30_000
|
|
23
23
|
const pollingInterval = 100
|
|
24
24
|
|
|
25
|
-
/** Creates middleware for
|
|
25
|
+
/** Creates middleware for owner approval coordination. @internal */
|
|
26
26
|
export function create(
|
|
27
|
-
options: Relay.
|
|
28
|
-
): Relay.
|
|
27
|
+
options: Relay.accounts.Options,
|
|
28
|
+
): Relay.accounts.ReturnType {
|
|
29
29
|
if (!options.store.compareAndSet)
|
|
30
30
|
throw new RpcResponse.InvalidParamsError({
|
|
31
31
|
message:
|
|
32
|
-
'
|
|
32
|
+
'Account coordination requires a store with atomic `compareAndSet`.',
|
|
33
33
|
})
|
|
34
|
-
return Plugin.
|
|
34
|
+
return Plugin.accounts({
|
|
35
35
|
async handleRequest(context, forward) {
|
|
36
36
|
const { request, options: requestOptions_ } = context
|
|
37
37
|
const requestOptions = await resolveRequestOptions({
|
|
@@ -47,9 +47,9 @@ export function create(
|
|
|
47
47
|
}
|
|
48
48
|
const client = createClient({
|
|
49
49
|
transport: {
|
|
50
|
-
key: '
|
|
51
|
-
name: '
|
|
52
|
-
type: '
|
|
50
|
+
key: 'accounts-forward',
|
|
51
|
+
name: 'Accounts Forwarding',
|
|
52
|
+
type: 'accounts-forward',
|
|
53
53
|
setup: () => ({
|
|
54
54
|
request: ((
|
|
55
55
|
request: Relay.handleRequest.Request,
|
|
@@ -62,7 +62,7 @@ export function create(
|
|
|
62
62
|
},
|
|
63
63
|
})
|
|
64
64
|
|
|
65
|
-
if (request.method === '
|
|
65
|
+
if (request.method === 'account_getConfig') {
|
|
66
66
|
const value = request.params?.[0]
|
|
67
67
|
const address =
|
|
68
68
|
value && typeof value === 'object' && 'address' in value
|
|
@@ -74,7 +74,7 @@ export function create(
|
|
|
74
74
|
Hex.toBigInt(address) === 0n
|
|
75
75
|
)
|
|
76
76
|
throw new RpcResponse.InvalidParamsError({
|
|
77
|
-
message: 'Expected a
|
|
77
|
+
message: 'Expected a configurable account address.',
|
|
78
78
|
})
|
|
79
79
|
const blockNumber = await getBlockNumber(client, { cacheTime: 0 })
|
|
80
80
|
const commitment = await getConfigCommitment(client, {
|
|
@@ -86,20 +86,20 @@ export function create(
|
|
|
86
86
|
commitment,
|
|
87
87
|
})
|
|
88
88
|
if (!config) return null
|
|
89
|
-
return
|
|
89
|
+
return AccountConfig.toRpc(config)
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
if (request.method === '
|
|
92
|
+
if (request.method === 'account_getOperation') {
|
|
93
93
|
const hash = request.params?.[0]
|
|
94
94
|
if (typeof hash !== 'string' || !Hash.validate(hash))
|
|
95
95
|
throw new RpcResponse.InvalidParamsError({
|
|
96
|
-
message: 'Expected
|
|
96
|
+
message: 'Expected an account operation hash.',
|
|
97
97
|
})
|
|
98
98
|
const operation = await OperationStore.read(options.store, hash)
|
|
99
|
-
return operation ?
|
|
99
|
+
return operation ? AccountOperation.toRpc(operation) : null
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
if (request.method === '
|
|
102
|
+
if (request.method === 'account_approveKeyAuthorization')
|
|
103
103
|
return await approveKeyAuthorization({
|
|
104
104
|
client,
|
|
105
105
|
request,
|
|
@@ -139,7 +139,7 @@ export function create(
|
|
|
139
139
|
: operation
|
|
140
140
|
return {
|
|
141
141
|
...receipt,
|
|
142
|
-
|
|
142
|
+
operation: AccountOperation.toRpc(success),
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
if (operation.status === 'pending')
|
|
@@ -168,15 +168,15 @@ export function create(
|
|
|
168
168
|
: operation
|
|
169
169
|
return {
|
|
170
170
|
...transaction,
|
|
171
|
-
|
|
171
|
+
operation: AccountOperation.toRpc(success),
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
if (
|
|
176
176
|
request.method !== 'eth_sendRawTransaction' &&
|
|
177
177
|
request.method !== 'eth_sendRawTransactionSync' &&
|
|
178
|
-
request.method !== '
|
|
179
|
-
request.method !== '
|
|
178
|
+
request.method !== 'account_approveRawTransaction' &&
|
|
179
|
+
request.method !== 'account_approveRawTransactionSync'
|
|
180
180
|
)
|
|
181
181
|
return forward()
|
|
182
182
|
|
|
@@ -187,7 +187,8 @@ export function create(
|
|
|
187
187
|
if (!isSerializedTempoTransaction(serialized)) {
|
|
188
188
|
if (standard) return forward()
|
|
189
189
|
throw new RpcResponse.InvalidParamsError({
|
|
190
|
-
message:
|
|
190
|
+
message:
|
|
191
|
+
'Expected a serialized Tempo configurable account transaction.',
|
|
191
192
|
})
|
|
192
193
|
}
|
|
193
194
|
|
|
@@ -220,14 +221,14 @@ async function submit(options: submit.Options) {
|
|
|
220
221
|
}
|
|
221
222
|
})()
|
|
222
223
|
const signature = transaction?.signature
|
|
223
|
-
if (!transaction || signature?.type !== '
|
|
224
|
+
if (!transaction || signature?.type !== 'configurable') {
|
|
224
225
|
if (
|
|
225
226
|
options.method === 'eth_sendRawTransaction' ||
|
|
226
227
|
options.method === 'eth_sendRawTransactionSync'
|
|
227
228
|
)
|
|
228
229
|
return await options.next(options.request, options.requestOptions)
|
|
229
230
|
throw new RpcResponse.InvalidParamsError({
|
|
230
|
-
message: 'Expected a
|
|
231
|
+
message: 'Expected a configurable account transaction signature.',
|
|
231
232
|
})
|
|
232
233
|
}
|
|
233
234
|
|
|
@@ -238,14 +239,14 @@ async function submit(options: submit.Options) {
|
|
|
238
239
|
options.serialized.startsWith(TxEnvelopeTempo.feePayerMagic),
|
|
239
240
|
)
|
|
240
241
|
const blockNumber = await getBlockNumber(options.client, { cacheTime: 0 })
|
|
241
|
-
const config =
|
|
242
|
+
const config = AccountConfig.from(signature.config)
|
|
242
243
|
const configCommitment = await validateConfig({
|
|
243
244
|
account: signature.account,
|
|
244
245
|
blockNumber,
|
|
245
246
|
client: options.client,
|
|
246
247
|
config,
|
|
247
248
|
})
|
|
248
|
-
const operationHash =
|
|
249
|
+
const operationHash = AccountOperation.getHash({
|
|
249
250
|
account: signature.account,
|
|
250
251
|
config,
|
|
251
252
|
transaction: serializedUnsigned,
|
|
@@ -256,7 +257,7 @@ async function submit(options: submit.Options) {
|
|
|
256
257
|
)
|
|
257
258
|
if (incoming.length === 0)
|
|
258
259
|
throw new RpcResponse.InvalidParamsError({
|
|
259
|
-
message: 'A
|
|
260
|
+
message: 'A owner approval envelope must include a signature.',
|
|
260
261
|
})
|
|
261
262
|
const now = Date.now()
|
|
262
263
|
const expiredSubmissionIds = new Set<Hex.Hex>()
|
|
@@ -285,7 +286,7 @@ async function submit(options: submit.Options) {
|
|
|
285
286
|
hash: operationHash,
|
|
286
287
|
approvals: [...(existingApprovals?.approvals ?? []), ...incoming],
|
|
287
288
|
})
|
|
288
|
-
return
|
|
289
|
+
return AccountOperation.from({
|
|
289
290
|
account: signature.account,
|
|
290
291
|
approvals: approvals.approvals,
|
|
291
292
|
config,
|
|
@@ -339,7 +340,7 @@ async function submit(options: submit.Options) {
|
|
|
339
340
|
const timeout = options.request.params?.[1]
|
|
340
341
|
const synchronous =
|
|
341
342
|
options.method === 'eth_sendRawTransactionSync' ||
|
|
342
|
-
options.method === '
|
|
343
|
+
options.method === 'account_approveRawTransactionSync'
|
|
343
344
|
const leaseTtl =
|
|
344
345
|
synchronous &&
|
|
345
346
|
typeof timeout === 'number' &&
|
|
@@ -358,7 +359,7 @@ async function submit(options: submit.Options) {
|
|
|
358
359
|
return current
|
|
359
360
|
if (current.weight < current.threshold) return current
|
|
360
361
|
const now = Date.now()
|
|
361
|
-
return
|
|
362
|
+
return AccountOperation.from({
|
|
362
363
|
...current,
|
|
363
364
|
expiresAt: Math.min(now + leaseTtl, Number.MAX_SAFE_INTEGER),
|
|
364
365
|
status: 'submitting',
|
|
@@ -392,7 +393,7 @@ async function submit(options: submit.Options) {
|
|
|
392
393
|
hash: claim.hash,
|
|
393
394
|
approvals: claim.approvals,
|
|
394
395
|
})
|
|
395
|
-
const final =
|
|
396
|
+
const final = AccountOperation.serializeTransaction(claim, {
|
|
396
397
|
approvals: finalApprovals.selectedApprovals,
|
|
397
398
|
})
|
|
398
399
|
const transactionHash = TxEnvelopeTempo.hash(
|
|
@@ -431,7 +432,7 @@ async function submit(options: submit.Options) {
|
|
|
431
432
|
{
|
|
432
433
|
method:
|
|
433
434
|
options.method === 'eth_sendRawTransaction' ||
|
|
434
|
-
options.method === '
|
|
435
|
+
options.method === 'account_approveRawTransaction'
|
|
435
436
|
? 'eth_sendRawTransaction'
|
|
436
437
|
: 'eth_sendRawTransactionSync',
|
|
437
438
|
params: [final, ...(options.request.params?.slice(1) ?? [])],
|
|
@@ -488,7 +489,7 @@ async function submit(options: submit.Options) {
|
|
|
488
489
|
)
|
|
489
490
|
throw new OperationStore.InvalidStoreValueError()
|
|
490
491
|
const { expiresAt: _, submissionId: __, ...operation } = current
|
|
491
|
-
return
|
|
492
|
+
return AccountOperation.from({
|
|
492
493
|
...operation,
|
|
493
494
|
status: 'success',
|
|
494
495
|
transactionHash,
|
|
@@ -504,7 +505,7 @@ async function submit(options: submit.Options) {
|
|
|
504
505
|
result &&
|
|
505
506
|
typeof result === 'object'
|
|
506
507
|
)
|
|
507
|
-
return { ...result,
|
|
508
|
+
return { ...result, operation: AccountOperation.toRpc(success) }
|
|
508
509
|
return await submittedResult(options, success)
|
|
509
510
|
}
|
|
510
511
|
|
|
@@ -517,8 +518,8 @@ declare namespace submit {
|
|
|
517
518
|
method:
|
|
518
519
|
| 'eth_sendRawTransaction'
|
|
519
520
|
| 'eth_sendRawTransactionSync'
|
|
520
|
-
| '
|
|
521
|
-
| '
|
|
521
|
+
| 'account_approveRawTransaction'
|
|
522
|
+
| 'account_approveRawTransactionSync'
|
|
522
523
|
/** Downstream RPC request handler. */
|
|
523
524
|
next: Relay.handleRequest.Handler
|
|
524
525
|
/** Original RPC request. */
|
|
@@ -527,12 +528,12 @@ declare namespace submit {
|
|
|
527
528
|
requestOptions?: Relay.handleRequest.RequestOptions | undefined
|
|
528
529
|
/** Serialized Tempo transaction. */
|
|
529
530
|
serialized: Hex.Hex
|
|
530
|
-
/** Shared
|
|
531
|
+
/** Shared account store. */
|
|
531
532
|
store: Store.Atomic
|
|
532
533
|
}
|
|
533
534
|
}
|
|
534
535
|
|
|
535
|
-
/** Collects approvals for a
|
|
536
|
+
/** Collects approvals for a configurable account key authorization. @internal */
|
|
536
537
|
// biome-ignore lint/correctness/noUnusedVariables: declaration merge
|
|
537
538
|
async function approveKeyAuthorization(
|
|
538
539
|
options: approveKeyAuthorization.Options,
|
|
@@ -540,7 +541,7 @@ async function approveKeyAuthorization(
|
|
|
540
541
|
const value = options.request.params?.[0]
|
|
541
542
|
if (!value || typeof value !== 'object')
|
|
542
543
|
throw new RpcResponse.InvalidParamsError({
|
|
543
|
-
message: 'Expected a
|
|
544
|
+
message: 'Expected a configurable account key authorization approval.',
|
|
544
545
|
})
|
|
545
546
|
|
|
546
547
|
const approval = await (async () => {
|
|
@@ -552,14 +553,15 @@ async function approveKeyAuthorization(
|
|
|
552
553
|
)
|
|
553
554
|
} catch {
|
|
554
555
|
throw new RpcResponse.InvalidParamsError({
|
|
555
|
-
message: 'Invalid
|
|
556
|
+
message: 'Invalid configurable account key authorization.',
|
|
556
557
|
})
|
|
557
558
|
}
|
|
558
559
|
})()
|
|
559
560
|
const signature = authorization.signature
|
|
560
|
-
if (signature?.type !== '
|
|
561
|
+
if (signature?.type !== 'configurable')
|
|
561
562
|
throw new RpcResponse.InvalidParamsError({
|
|
562
|
-
message:
|
|
563
|
+
message:
|
|
564
|
+
'Expected a configurable account key authorization signature.',
|
|
563
565
|
})
|
|
564
566
|
if (
|
|
565
567
|
!authorization.account ||
|
|
@@ -567,14 +569,14 @@ async function approveKeyAuthorization(
|
|
|
567
569
|
)
|
|
568
570
|
throw new RpcResponse.InvalidParamsError({
|
|
569
571
|
message:
|
|
570
|
-
'
|
|
572
|
+
'Configurable account key authorization account does not match its signature.',
|
|
571
573
|
})
|
|
572
574
|
const { signature: _, ...unsigned } = authorization
|
|
573
575
|
const keyAuthorization = KeyAuthorization.serialize(
|
|
574
576
|
KeyAuthorization.from(unsigned),
|
|
575
577
|
)
|
|
576
|
-
const config =
|
|
577
|
-
const hash =
|
|
578
|
+
const config = AccountConfig.from(signature.config)
|
|
579
|
+
const hash = AccountOperation.getHash({
|
|
578
580
|
account: signature.account,
|
|
579
581
|
config,
|
|
580
582
|
keyAuthorization,
|
|
@@ -594,12 +596,13 @@ async function approveKeyAuthorization(
|
|
|
594
596
|
if ('hash' in value && 'signature' in value) {
|
|
595
597
|
if (typeof value.hash !== 'string' || !Hash.validate(value.hash))
|
|
596
598
|
throw new RpcResponse.InvalidParamsError({
|
|
597
|
-
message: 'Expected
|
|
599
|
+
message: 'Expected an account operation hash.',
|
|
598
600
|
})
|
|
599
601
|
const operation = await OperationStore.read(options.store, value.hash)
|
|
600
602
|
if (!operation || operation.type !== 'keyAuthorization')
|
|
601
603
|
throw new RpcResponse.InvalidParamsError({
|
|
602
|
-
message:
|
|
604
|
+
message:
|
|
605
|
+
'Configurable account key authorization operation was not found.',
|
|
603
606
|
})
|
|
604
607
|
if (operation.status === 'success') return { operation }
|
|
605
608
|
const signature = (() => {
|
|
@@ -609,7 +612,7 @@ async function approveKeyAuthorization(
|
|
|
609
612
|
)
|
|
610
613
|
} catch {
|
|
611
614
|
throw new RpcResponse.InvalidParamsError({
|
|
612
|
-
message: 'Invalid
|
|
615
|
+
message: 'Invalid owner signature.',
|
|
613
616
|
})
|
|
614
617
|
}
|
|
615
618
|
})()
|
|
@@ -623,14 +626,13 @@ async function approveKeyAuthorization(
|
|
|
623
626
|
}
|
|
624
627
|
|
|
625
628
|
throw new RpcResponse.InvalidParamsError({
|
|
626
|
-
message: 'Expected a
|
|
629
|
+
message: 'Expected a configurable account key authorization approval.',
|
|
627
630
|
})
|
|
628
631
|
})()
|
|
629
|
-
if ('operation' in approval)
|
|
630
|
-
return MultisigOperation.toRpc(approval.operation)
|
|
632
|
+
if ('operation' in approval) return AccountOperation.toRpc(approval.operation)
|
|
631
633
|
if (approval.approvals.length === 0)
|
|
632
634
|
throw new RpcResponse.InvalidParamsError({
|
|
633
|
-
message: 'A
|
|
635
|
+
message: 'A owner approval envelope must include a signature.',
|
|
634
636
|
})
|
|
635
637
|
|
|
636
638
|
const blockNumber = await getBlockNumber(options.client, { cacheTime: 0 })
|
|
@@ -651,8 +653,8 @@ async function approveKeyAuthorization(
|
|
|
651
653
|
if (
|
|
652
654
|
existing &&
|
|
653
655
|
(existing.account.toLowerCase() !== approval.account.toLowerCase() ||
|
|
654
|
-
|
|
655
|
-
|
|
656
|
+
AccountConfig.getCommitment(existing.config).toLowerCase() !==
|
|
657
|
+
AccountConfig.getCommitment(approval.config).toLowerCase() ||
|
|
656
658
|
existing.keyAuthorization.toLowerCase() !==
|
|
657
659
|
approval.keyAuthorization.toLowerCase())
|
|
658
660
|
)
|
|
@@ -696,10 +698,10 @@ async function approveKeyAuthorization(
|
|
|
696
698
|
weight: approvals.weight,
|
|
697
699
|
} as const
|
|
698
700
|
if (approvals.weight < approvals.threshold)
|
|
699
|
-
return
|
|
700
|
-
return
|
|
701
|
+
return AccountOperation.from({ ...pending, status: 'pending' })
|
|
702
|
+
return AccountOperation.from({
|
|
701
703
|
...pending,
|
|
702
|
-
keyAuthorization:
|
|
704
|
+
keyAuthorization: AccountOperation.serializeKeyAuthorization(
|
|
703
705
|
approval.keyAuthorization,
|
|
704
706
|
{
|
|
705
707
|
account: approval.account,
|
|
@@ -718,7 +720,7 @@ async function approveKeyAuthorization(
|
|
|
718
720
|
})
|
|
719
721
|
if (operation.type !== 'keyAuthorization')
|
|
720
722
|
throw new OperationStore.InvalidStoreValueError()
|
|
721
|
-
return
|
|
723
|
+
return AccountOperation.toRpc(operation)
|
|
722
724
|
}
|
|
723
725
|
|
|
724
726
|
declare namespace approveKeyAuthorization {
|
|
@@ -728,7 +730,7 @@ declare namespace approveKeyAuthorization {
|
|
|
728
730
|
client: ReturnType<typeof createClient>
|
|
729
731
|
/** Original RPC request. */
|
|
730
732
|
request: Relay.handleRequest.Request
|
|
731
|
-
/** Shared
|
|
733
|
+
/** Shared account store. */
|
|
732
734
|
store: Store.Atomic
|
|
733
735
|
}
|
|
734
736
|
}
|
|
@@ -748,34 +750,35 @@ function deserialize(serialized: Hex.Hex) {
|
|
|
748
750
|
function assertConfig(options: {
|
|
749
751
|
account: `0x${string}`
|
|
750
752
|
commitment: Hex.Hex
|
|
751
|
-
config:
|
|
753
|
+
config: AccountConfig.Config
|
|
752
754
|
}) {
|
|
753
755
|
const { account, commitment, config } = options
|
|
754
756
|
if (
|
|
755
757
|
config.version === 0n &&
|
|
756
|
-
|
|
758
|
+
AccountConfig.getAddress(config, {
|
|
757
759
|
factory: Addresses.nativeMultisigFactory,
|
|
758
760
|
}).toLowerCase() !== account.toLowerCase()
|
|
759
761
|
)
|
|
760
762
|
throw new RpcResponse.InvalidParamsError({
|
|
761
|
-
message:
|
|
763
|
+
message:
|
|
764
|
+
'Initial account config does not match the configurable account.',
|
|
762
765
|
})
|
|
763
766
|
if (config.version === 0n && Hex.toBigInt(commitment) === 0n) return
|
|
764
767
|
if (
|
|
765
768
|
commitment.toLowerCase() !==
|
|
766
|
-
|
|
769
|
+
AccountConfig.getCommitment(config).toLowerCase()
|
|
767
770
|
)
|
|
768
771
|
throw new RpcResponse.InvalidParamsError({
|
|
769
|
-
message: `
|
|
772
|
+
message: `Account config does not match account ${account}.`,
|
|
770
773
|
})
|
|
771
774
|
}
|
|
772
775
|
|
|
773
|
-
/** Reads and validates a config commitment at one block. */
|
|
774
|
-
async function validateConfig(options: {
|
|
776
|
+
/** Reads and validates a config commitment at one block. @internal */
|
|
777
|
+
export async function validateConfig(options: {
|
|
775
778
|
account: `0x${string}`
|
|
776
779
|
blockNumber: bigint
|
|
777
780
|
client: ReturnType<typeof createClient>
|
|
778
|
-
config:
|
|
781
|
+
config: AccountConfig.Config
|
|
779
782
|
}) {
|
|
780
783
|
const { account, blockNumber, client, config } = options
|
|
781
784
|
const commitment = await getConfigCommitment(client, {
|
|
@@ -814,25 +817,20 @@ async function cacheNextConfigs(options: cacheNextConfigs.Options) {
|
|
|
814
817
|
const [current, threshold, owners] = decoded.args
|
|
815
818
|
const suppliedConfig = (() => {
|
|
816
819
|
try {
|
|
817
|
-
return
|
|
820
|
+
return AccountConfig.from(current)
|
|
818
821
|
} catch {
|
|
819
822
|
return undefined
|
|
820
823
|
}
|
|
821
824
|
})()
|
|
822
825
|
if (
|
|
823
826
|
!suppliedConfig ||
|
|
824
|
-
|
|
825
|
-
|
|
827
|
+
AccountConfig.getCommitment(suppliedConfig).toLowerCase() !==
|
|
828
|
+
AccountConfig.getCommitment(currentConfig).toLowerCase()
|
|
826
829
|
)
|
|
827
830
|
continue
|
|
828
831
|
const config = (() => {
|
|
829
832
|
try {
|
|
830
|
-
return
|
|
831
|
-
owners,
|
|
832
|
-
salt: suppliedConfig.salt,
|
|
833
|
-
threshold,
|
|
834
|
-
version: suppliedConfig.version + 1n,
|
|
835
|
-
})
|
|
833
|
+
return AccountConfig.update(suppliedConfig, { owners, threshold })
|
|
836
834
|
} catch {
|
|
837
835
|
return undefined
|
|
838
836
|
}
|
|
@@ -840,7 +838,7 @@ async function cacheNextConfigs(options: cacheNextConfigs.Options) {
|
|
|
840
838
|
if (!config) continue
|
|
841
839
|
await ConfigStore.write(options.store, {
|
|
842
840
|
address: options.account,
|
|
843
|
-
commitment:
|
|
841
|
+
commitment: AccountConfig.getCommitment(config),
|
|
844
842
|
config,
|
|
845
843
|
})
|
|
846
844
|
currentConfig = config
|
|
@@ -850,25 +848,25 @@ async function cacheNextConfigs(options: cacheNextConfigs.Options) {
|
|
|
850
848
|
declare namespace cacheNextConfigs {
|
|
851
849
|
/** Parameters for {@link cacheNextConfigs}. */
|
|
852
850
|
export type Options = {
|
|
853
|
-
/** Root
|
|
851
|
+
/** Root configurable account. */
|
|
854
852
|
account: Address
|
|
855
853
|
/** Root config used to authorize the transaction. */
|
|
856
|
-
config:
|
|
857
|
-
/** Shared
|
|
854
|
+
config: AccountConfig.Config
|
|
855
|
+
/** Shared account store. */
|
|
858
856
|
store: Store.Store
|
|
859
857
|
/** Submitted transaction containing potential config updates. */
|
|
860
858
|
transaction: TxEnvelopeTempo.TxEnvelopeTempo
|
|
861
859
|
}
|
|
862
860
|
}
|
|
863
861
|
|
|
864
|
-
/** Validates primitive approvals and translates invalid input into an RPC error. */
|
|
865
|
-
async function selectApprovals(
|
|
866
|
-
options:
|
|
862
|
+
/** Validates primitive approvals and translates invalid input into an RPC error. @internal */
|
|
863
|
+
export async function selectApprovals(
|
|
864
|
+
options: AccountOperation.selectApprovals.Options,
|
|
867
865
|
) {
|
|
868
866
|
try {
|
|
869
|
-
return await
|
|
867
|
+
return await AccountOperation.selectApprovals(options)
|
|
870
868
|
} catch (error) {
|
|
871
|
-
if (error instanceof
|
|
869
|
+
if (error instanceof AccountOperation.InvalidApprovalError)
|
|
872
870
|
throw new RpcResponse.InvalidParamsError({ message: error.shortMessage })
|
|
873
871
|
throw error
|
|
874
872
|
}
|
|
@@ -877,15 +875,15 @@ async function selectApprovals(
|
|
|
877
875
|
/** Returns an existing successful operation through the requested send method. */
|
|
878
876
|
async function submittedResult(
|
|
879
877
|
options: submit.Options,
|
|
880
|
-
operation:
|
|
878
|
+
operation: AccountOperation.TransactionOperation,
|
|
881
879
|
) {
|
|
882
880
|
if (
|
|
883
881
|
options.method === 'eth_sendRawTransaction' ||
|
|
884
|
-
options.method === '
|
|
882
|
+
options.method === 'account_approveRawTransaction'
|
|
885
883
|
)
|
|
886
884
|
return operation.hash
|
|
887
|
-
if (options.method === '
|
|
888
|
-
return
|
|
885
|
+
if (options.method === 'account_approveRawTransactionSync')
|
|
886
|
+
return AccountOperation.toRpc(operation)
|
|
889
887
|
const timeout = options.request.params?.[1]
|
|
890
888
|
const deadline =
|
|
891
889
|
Date.now() +
|
|
@@ -899,9 +897,11 @@ async function submittedResult(
|
|
|
899
897
|
options.requestOptions,
|
|
900
898
|
)
|
|
901
899
|
if (receipt && typeof receipt === 'object')
|
|
902
|
-
return { ...receipt,
|
|
900
|
+
return { ...receipt, operation: AccountOperation.toRpc(operation) }
|
|
903
901
|
if (Date.now() >= deadline)
|
|
904
|
-
throw new Error(
|
|
902
|
+
throw new Error(
|
|
903
|
+
'Timed out while waiting for the configurable account transaction.',
|
|
904
|
+
)
|
|
905
905
|
await new Promise((resolve) => setTimeout(resolve, pollingInterval))
|
|
906
906
|
}
|
|
907
907
|
}
|
|
@@ -909,11 +909,11 @@ async function submittedResult(
|
|
|
909
909
|
/** Waits for the relay that owns a live submission lease. */
|
|
910
910
|
async function submittingResult(
|
|
911
911
|
options: submit.Options,
|
|
912
|
-
operation:
|
|
912
|
+
operation: AccountOperation.TransactionOperation,
|
|
913
913
|
): Promise<unknown> {
|
|
914
914
|
if (
|
|
915
915
|
options.method === 'eth_sendRawTransaction' ||
|
|
916
|
-
options.method === '
|
|
916
|
+
options.method === 'account_approveRawTransaction'
|
|
917
917
|
)
|
|
918
918
|
return operation.hash
|
|
919
919
|
const timeout = options.request.params?.[1]
|
|
@@ -936,15 +936,15 @@ async function submittingResult(
|
|
|
936
936
|
/** Returns a pending result for an operation that has not reached quorum. */
|
|
937
937
|
function pendingResult(
|
|
938
938
|
method: submit.Options['method'],
|
|
939
|
-
operation:
|
|
939
|
+
operation: AccountOperation.TransactionOperation,
|
|
940
940
|
) {
|
|
941
941
|
if (
|
|
942
942
|
method === 'eth_sendRawTransaction' ||
|
|
943
|
-
method === '
|
|
943
|
+
method === 'account_approveRawTransaction'
|
|
944
944
|
)
|
|
945
945
|
return operation.hash
|
|
946
|
-
if (method === '
|
|
947
|
-
return
|
|
946
|
+
if (method === 'account_approveRawTransactionSync')
|
|
947
|
+
return AccountOperation.toRpc(operation)
|
|
948
948
|
return {
|
|
949
949
|
blockHash: null,
|
|
950
950
|
blockNumber: null,
|
|
@@ -955,7 +955,7 @@ function pendingResult(
|
|
|
955
955
|
gasUsed: null,
|
|
956
956
|
logs: [],
|
|
957
957
|
logsBloom: null,
|
|
958
|
-
|
|
958
|
+
operation: AccountOperation.toRpc(operation),
|
|
959
959
|
status: 'pending',
|
|
960
960
|
to: null,
|
|
961
961
|
transactionHash: operation.hash,
|
|
@@ -967,7 +967,7 @@ function pendingResult(
|
|
|
967
967
|
/** Marks a transaction as successful after a lookup proves that it was submitted. */
|
|
968
968
|
async function completeSubmission(
|
|
969
969
|
store: Store.Atomic,
|
|
970
|
-
operation:
|
|
970
|
+
operation: AccountOperation.TransactionOperation,
|
|
971
971
|
transactionHash: Hex.Hex,
|
|
972
972
|
) {
|
|
973
973
|
if (operation.status !== 'submitting' || !operation.submissionId)
|
|
@@ -997,7 +997,7 @@ async function completeSubmission(
|
|
|
997
997
|
transactionHash: ___,
|
|
998
998
|
...value
|
|
999
999
|
} = current
|
|
1000
|
-
return
|
|
1000
|
+
return AccountOperation.from({
|
|
1001
1001
|
...value,
|
|
1002
1002
|
status: 'success',
|
|
1003
1003
|
transactionHash,
|
|
@@ -1006,7 +1006,7 @@ async function completeSubmission(
|
|
|
1006
1006
|
},
|
|
1007
1007
|
)
|
|
1008
1008
|
await removeSettledSubmission(store, operation.hash, operation.submissionId)
|
|
1009
|
-
return success as
|
|
1009
|
+
return success as AccountOperation.TransactionOperation
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
1012
|
/** Releases a failed submission lease without discarding collected approvals. */
|
|
@@ -1024,7 +1024,7 @@ async function releaseSubmission(
|
|
|
1024
1024
|
)
|
|
1025
1025
|
return current
|
|
1026
1026
|
const { expiresAt: _, submissionId: __, ...operation } = current
|
|
1027
|
-
return
|
|
1027
|
+
return AccountOperation.from({
|
|
1028
1028
|
...operation,
|
|
1029
1029
|
status: 'pending',
|
|
1030
1030
|
updatedAt: Date.now(),
|
|
@@ -1062,11 +1062,11 @@ function mergeTransaction(existing: Hex.Hex | undefined, incoming: Hex.Hex) {
|
|
|
1062
1062
|
/** Returns a synthetic transaction while the downstream transaction is unavailable. */
|
|
1063
1063
|
async function toTransaction(
|
|
1064
1064
|
client: ReturnType<typeof createClient>,
|
|
1065
|
-
operation:
|
|
1065
|
+
operation: AccountOperation.TransactionOperation,
|
|
1066
1066
|
) {
|
|
1067
1067
|
const approvals = await (async () => {
|
|
1068
1068
|
if (operation.status !== 'pending')
|
|
1069
|
-
return await
|
|
1069
|
+
return await AccountOperation.selectApprovals({
|
|
1070
1070
|
account: operation.account,
|
|
1071
1071
|
approvals: operation.approvals,
|
|
1072
1072
|
config: operation.config,
|
|
@@ -1088,7 +1088,7 @@ async function toTransaction(
|
|
|
1088
1088
|
})()
|
|
1089
1089
|
const current =
|
|
1090
1090
|
operation.status === 'pending'
|
|
1091
|
-
?
|
|
1091
|
+
? AccountOperation.from({
|
|
1092
1092
|
...operation,
|
|
1093
1093
|
approvals: approvals.approvals,
|
|
1094
1094
|
signatureCount: approvals.signatureCount,
|
|
@@ -1096,7 +1096,7 @@ async function toTransaction(
|
|
|
1096
1096
|
weight: approvals.weight,
|
|
1097
1097
|
})
|
|
1098
1098
|
: operation
|
|
1099
|
-
const serialized =
|
|
1099
|
+
const serialized = AccountOperation.serializeTransaction(current, {
|
|
1100
1100
|
approvals: approvals.selectedApprovals,
|
|
1101
1101
|
})
|
|
1102
1102
|
const transaction = deserialize(serialized)
|
|
@@ -1112,14 +1112,14 @@ async function toTransaction(
|
|
|
1112
1112
|
} as Parameters<typeof ox_Transaction.toRpc>[0],
|
|
1113
1113
|
{ pending: true },
|
|
1114
1114
|
),
|
|
1115
|
-
|
|
1115
|
+
operation: AccountOperation.toRpc(current),
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
1118
|
|
|
1119
1119
|
/** Returns the persisted transaction hash for a submitting or successful operation. */
|
|
1120
1120
|
async function getSubmittedTransactionHash(
|
|
1121
1121
|
store: Store.Store,
|
|
1122
|
-
operation:
|
|
1122
|
+
operation: AccountOperation.TransactionOperation,
|
|
1123
1123
|
) {
|
|
1124
1124
|
if (operation.status === 'success') return operation.transactionHash!
|
|
1125
1125
|
if (operation.status !== 'submitting' || !operation.submissionId)
|
|
@@ -1156,7 +1156,7 @@ function maintainSubmissionLease(
|
|
|
1156
1156
|
current.submissionId !== submissionId
|
|
1157
1157
|
)
|
|
1158
1158
|
return current
|
|
1159
|
-
return
|
|
1159
|
+
return AccountOperation.from({
|
|
1160
1160
|
...current,
|
|
1161
1161
|
expiresAt: Math.min(
|
|
1162
1162
|
Date.now() + leaseTtl,
|
|
@@ -1212,7 +1212,7 @@ function getTransactionHash(result: unknown): Hex.Hex {
|
|
|
1212
1212
|
Hash.validate(result.transactionHash)
|
|
1213
1213
|
)
|
|
1214
1214
|
return result.transactionHash
|
|
1215
|
-
throw new Error('Expected transaction hash in
|
|
1215
|
+
throw new Error('Expected transaction hash in account broadcast result.')
|
|
1216
1216
|
}
|
|
1217
1217
|
|
|
1218
1218
|
/** Resolves and validates the chain used by a handled request. */
|
|
@@ -1254,12 +1254,12 @@ async function resolveRequestChainId(
|
|
|
1254
1254
|
value && typeof value === 'object' && 'chainId' in value
|
|
1255
1255
|
? parseChainId(value.chainId)
|
|
1256
1256
|
: undefined
|
|
1257
|
-
const
|
|
1257
|
+
const chainId_operation = await (async () => {
|
|
1258
1258
|
if (
|
|
1259
1259
|
request.method === 'eth_sendRawTransaction' ||
|
|
1260
1260
|
request.method === 'eth_sendRawTransactionSync' ||
|
|
1261
|
-
request.method === '
|
|
1262
|
-
request.method === '
|
|
1261
|
+
request.method === 'account_approveRawTransaction' ||
|
|
1262
|
+
request.method === 'account_approveRawTransactionSync'
|
|
1263
1263
|
) {
|
|
1264
1264
|
if (!isSerializedTempoTransaction(value)) return undefined
|
|
1265
1265
|
try {
|
|
@@ -1273,7 +1273,7 @@ async function resolveRequestChainId(
|
|
|
1273
1273
|
}
|
|
1274
1274
|
|
|
1275
1275
|
if (
|
|
1276
|
-
request.method === '
|
|
1276
|
+
request.method === 'account_approveKeyAuthorization' &&
|
|
1277
1277
|
value &&
|
|
1278
1278
|
typeof value === 'object' &&
|
|
1279
1279
|
'keyAuthorization' in value
|
|
@@ -1296,7 +1296,7 @@ async function resolveRequestChainId(
|
|
|
1296
1296
|
)
|
|
1297
1297
|
return value
|
|
1298
1298
|
if (
|
|
1299
|
-
request.method === '
|
|
1299
|
+
request.method === 'account_approveKeyAuthorization' &&
|
|
1300
1300
|
value &&
|
|
1301
1301
|
typeof value === 'object' &&
|
|
1302
1302
|
'hash' in value
|
|
@@ -1320,13 +1320,13 @@ async function resolveRequestChainId(
|
|
|
1320
1320
|
|
|
1321
1321
|
if (
|
|
1322
1322
|
chainId_body !== undefined &&
|
|
1323
|
-
|
|
1324
|
-
chainId_body !==
|
|
1323
|
+
chainId_operation !== undefined &&
|
|
1324
|
+
chainId_body !== chainId_operation
|
|
1325
1325
|
)
|
|
1326
1326
|
throw new RpcResponse.InvalidParamsError({
|
|
1327
1327
|
message: 'Conflicting chain ids.',
|
|
1328
1328
|
})
|
|
1329
|
-
return chainId_body ??
|
|
1329
|
+
return chainId_body ?? chainId_operation
|
|
1330
1330
|
}
|
|
1331
1331
|
|
|
1332
1332
|
/** Parses a supported chain ID representation. */
|