viem 2.57.4 → 2.57.5
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 +26 -0
- package/_cjs/actions/public/waitForTransactionReceipt.js +5 -2
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/wallet/waitForCallsStatus.js +25 -2
- package/_cjs/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/_cjs/chains/definitions/arcTestnet.js +11 -8
- package/_cjs/chains/definitions/arcTestnet.js.map +1 -1
- package/_cjs/chains/definitions/qmsTestnet.js +30 -0
- package/_cjs/chains/definitions/qmsTestnet.js.map +1 -0
- package/_cjs/chains/definitions/tempo.js +1 -1
- package/_cjs/chains/definitions/tempoModerato.js +2 -2
- package/_cjs/chains/index.js +7 -5
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/transports/ipc.js +19 -10
- package/_cjs/clients/transports/ipc.js.map +1 -1
- package/_cjs/clients/transports/webSocket.js +19 -10
- package/_cjs/clients/transports/webSocket.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Account.js +40 -40
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Decorator.js +9 -8
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/ExecutionError.js +1 -1
- package/_cjs/tempo/ExecutionError.js.map +1 -1
- package/_cjs/tempo/Formatters.js +8 -7
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/KeyAuthorizationManager.js +25 -16
- package/_cjs/tempo/KeyAuthorizationManager.js.map +1 -1
- package/_cjs/tempo/Relay.js +9 -4
- package/_cjs/tempo/Relay.js.map +1 -1
- package/_cjs/tempo/Transaction.js +9 -9
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/Transport.js +21 -11
- package/_cjs/tempo/Transport.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Config.js +8 -8
- package/_cjs/tempo/{multisig → accounts}/Config.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Operation.js +10 -10
- package/_cjs/tempo/{multisig → accounts}/Operation.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Signature.js +2 -2
- package/_cjs/tempo/accounts/Signature.js.map +1 -0
- package/_cjs/tempo/actions/accessKey.js +60 -37
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/{multisig.js → accounts.js} +13 -18
- package/_cjs/tempo/actions/accounts.js.map +1 -0
- package/_cjs/tempo/actions/index.js +2 -2
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +37 -37
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/index.js +3 -3
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/tempo/internal/relay/{multisig.js → accounts.js} +90 -93
- package/_cjs/tempo/internal/relay/accounts.js.map +1 -0
- package/_cjs/tempo/internal/relay/keyAuthorization.js +296 -0
- package/_cjs/tempo/internal/relay/keyAuthorization.js.map +1 -0
- package/_cjs/tempo/internal/relay/plugin.js +17 -7
- package/_cjs/tempo/internal/relay/plugin.js.map +1 -1
- package/_cjs/utils/hash/normalizeSignature.js +1 -1
- package/_cjs/utils/hash/normalizeSignature.js.map +1 -1
- package/_cjs/utils/rpc/http.js +66 -31
- package/_cjs/utils/rpc/http.js.map +1 -1
- package/_cjs/utils/rpc/socket.js +1 -1
- package/_cjs/utils/rpc/socket.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +5 -2
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/wallet/waitForCallsStatus.js +39 -2
- package/_esm/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/_esm/chains/definitions/arcTestnet.js +11 -8
- package/_esm/chains/definitions/arcTestnet.js.map +1 -1
- package/_esm/chains/definitions/qmsTestnet.js +27 -0
- package/_esm/chains/definitions/qmsTestnet.js.map +1 -0
- package/_esm/chains/definitions/tempo.js +1 -1
- package/_esm/chains/definitions/tempoModerato.js +2 -2
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/transports/ipc.js +21 -10
- package/_esm/clients/transports/ipc.js.map +1 -1
- package/_esm/clients/transports/webSocket.js +21 -10
- package/_esm/clients/transports/webSocket.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Account.js +42 -42
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Client.js +3 -3
- package/_esm/tempo/Decorator.js +9 -8
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/ExecutionError.js +1 -1
- package/_esm/tempo/ExecutionError.js.map +1 -1
- package/_esm/tempo/Formatters.js +11 -10
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/KeyAuthorizationManager.js +58 -16
- package/_esm/tempo/KeyAuthorizationManager.js.map +1 -1
- package/_esm/tempo/Relay.js +49 -8
- package/_esm/tempo/Relay.js.map +1 -1
- package/_esm/tempo/Transaction.js +11 -11
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/Transport.js +22 -12
- package/_esm/tempo/Transport.js.map +1 -1
- package/_esm/tempo/{multisig → accounts}/Config.js +14 -14
- package/_esm/tempo/{multisig → accounts}/Config.js.map +1 -1
- package/_esm/tempo/{multisig → accounts}/Operation.js +17 -17
- package/_esm/tempo/{multisig → accounts}/Operation.js.map +1 -1
- package/_esm/tempo/accounts/Signature.js +9 -0
- package/_esm/tempo/accounts/Signature.js.map +1 -0
- package/_esm/tempo/actions/accessKey.js +93 -38
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/{multisig.js → accounts.js} +31 -36
- package/_esm/tempo/actions/accounts.js.map +1 -0
- package/_esm/tempo/actions/index.js +1 -1
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/chainConfig.js +38 -38
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/index.js +2 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/tempo/internal/relay/{multisig.js → accounts.js} +93 -98
- package/_esm/tempo/internal/relay/accounts.js.map +1 -0
- package/_esm/tempo/internal/relay/feePayer.js +1 -1
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
- package/_esm/tempo/internal/relay/keyAuthorization.js +334 -0
- package/_esm/tempo/internal/relay/keyAuthorization.js.map +1 -0
- package/_esm/tempo/internal/relay/plugin.js +15 -6
- package/_esm/tempo/internal/relay/plugin.js.map +1 -1
- package/_esm/utils/hash/normalizeSignature.js +3 -2
- package/_esm/utils/hash/normalizeSignature.js.map +1 -1
- package/_esm/utils/rpc/http.js +74 -31
- package/_esm/utils/rpc/http.js.map +1 -1
- package/_esm/utils/rpc/socket.js +3 -1
- package/_esm/utils/rpc/socket.js.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
- package/_types/chains/definitions/arcTestnet.d.ts +5 -5
- package/_types/chains/definitions/arcTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/qmsTestnet.d.ts +50 -0
- package/_types/chains/definitions/qmsTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +2 -2
- package/_types/chains/definitions/tempoModerato.d.ts +4 -4
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/transports/ipc.d.ts.map +1 -1
- package/_types/clients/transports/webSocket.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Account.d.ts +28 -28
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Client.d.ts +3 -3
- package/_types/tempo/Decorator.d.ts +63 -37
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorizationManager.d.ts +45 -2
- package/_types/tempo/KeyAuthorizationManager.d.ts.map +1 -1
- package/_types/tempo/Relay.d.ts +62 -12
- package/_types/tempo/Relay.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +14 -11
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/Transport.d.ts +20 -7
- package/_types/tempo/Transport.d.ts.map +1 -1
- package/_types/tempo/{multisig → accounts}/Config.d.ts +7 -7
- package/_types/tempo/accounts/Config.d.ts.map +1 -0
- package/_types/tempo/{multisig → accounts}/Operation.d.ts +7 -7
- package/_types/tempo/accounts/Operation.d.ts.map +1 -0
- package/_types/tempo/{multisig → accounts}/Signature.d.ts +1 -1
- package/_types/tempo/accounts/Signature.d.ts.map +1 -0
- package/_types/tempo/actions/accessKey.d.ts +59 -17
- package/_types/tempo/actions/accessKey.d.ts.map +1 -1
- package/_types/tempo/actions/{multisig.d.ts → accounts.d.ts} +28 -28
- package/_types/tempo/actions/{multisig.d.ts.map → accounts.d.ts.map} +1 -1
- package/_types/tempo/actions/index.d.ts +1 -1
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +3 -2
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/internal/relay/accounts.d.ts +15 -0
- package/_types/tempo/internal/relay/accounts.d.ts.map +1 -0
- package/_types/tempo/internal/relay/keyAuthorization.d.ts +25 -0
- package/_types/tempo/internal/relay/keyAuthorization.d.ts.map +1 -0
- package/_types/tempo/internal/relay/plugin.d.ts +6 -3
- package/_types/tempo/internal/relay/plugin.d.ts.map +1 -1
- package/_types/utils/hash/normalizeSignature.d.ts.map +1 -1
- package/_types/utils/rpc/http.d.ts.map +1 -1
- package/_types/utils/rpc/socket.d.ts.map +1 -1
- package/actions/public/waitForTransactionReceipt.ts +8 -2
- package/actions/wallet/waitForCallsStatus.ts +41 -2
- package/chains/definitions/arcTestnet.ts +11 -8
- package/chains/definitions/qmsTestnet.ts +27 -0
- package/chains/definitions/tempo.ts +1 -1
- package/chains/definitions/tempoModerato.ts +2 -2
- package/chains/index.ts +1 -0
- package/clients/transports/ipc.ts +38 -29
- package/clients/transports/webSocket.ts +42 -33
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/tempo/Account.ts +95 -84
- package/tempo/Client.ts +3 -3
- package/tempo/Decorator.ts +86 -57
- package/tempo/ExecutionError.ts +1 -1
- package/tempo/Formatters.ts +14 -13
- package/tempo/KeyAuthorizationManager.ts +71 -19
- package/tempo/Relay.ts +70 -14
- package/tempo/Transaction.ts +31 -23
- package/tempo/Transport.ts +49 -21
- package/tempo/{multisig → accounts}/Config.ts +21 -21
- package/tempo/{multisig → accounts}/Operation.ts +26 -26
- package/tempo/{multisig → accounts}/Signature.ts +5 -3
- package/tempo/actions/accessKey.ts +179 -79
- package/tempo/actions/{multisig.ts → accounts.ts} +47 -56
- package/tempo/actions/index.ts +1 -1
- package/tempo/chainConfig.ts +52 -52
- package/tempo/index.ts +5 -4
- package/tempo/internal/relay/{multisig.ts → accounts.ts} +118 -118
- package/tempo/internal/relay/feePayer.ts +1 -1
- package/tempo/internal/relay/keyAuthorization.ts +415 -0
- package/tempo/internal/relay/plugin.ts +20 -7
- package/utils/hash/normalizeSignature.ts +3 -2
- package/utils/rpc/http.ts +76 -30
- package/utils/rpc/socket.ts +3 -1
- package/_cjs/tempo/actions/multisig.js.map +0 -1
- package/_cjs/tempo/internal/relay/multisig.js.map +0 -1
- package/_cjs/tempo/multisig/Signature.js.map +0 -1
- package/_esm/tempo/actions/multisig.js.map +0 -1
- package/_esm/tempo/internal/relay/multisig.js.map +0 -1
- package/_esm/tempo/multisig/Signature.js +0 -9
- package/_esm/tempo/multisig/Signature.js.map +0 -1
- package/_types/tempo/internal/relay/multisig.d.ts +0 -4
- package/_types/tempo/internal/relay/multisig.d.ts.map +0 -1
- package/_types/tempo/multisig/Config.d.ts.map +0 -1
- package/_types/tempo/multisig/Operation.d.ts.map +0 -1
- package/_types/tempo/multisig/Signature.d.ts.map +0 -1
|
@@ -2,7 +2,7 @@ import * as Address_ from 'ox/Address';
|
|
|
2
2
|
import * as Hash from 'ox/Hash';
|
|
3
3
|
import * as Hex from 'ox/Hex';
|
|
4
4
|
import * as RpcResponse from 'ox/RpcResponse';
|
|
5
|
-
import {
|
|
5
|
+
import { AccountConfig, AccountOperation, KeyAuthorization, Transaction as ox_Transaction, SignatureEnvelope, TxEnvelopeTempo, } from 'ox/tempo';
|
|
6
6
|
import { getBlockNumber } from '../../../actions/public/getBlockNumber.js';
|
|
7
7
|
import { createClient } from '../../../clients/createClient.js';
|
|
8
8
|
import { custom } from '../../../clients/transports/custom.js';
|
|
@@ -10,20 +10,20 @@ import { decodeFunctionData } from '../../../utils/abi/decodeFunctionData.js';
|
|
|
10
10
|
import { isAddressEqual } from '../../../utils/address/isAddressEqual.js';
|
|
11
11
|
import * as Abis from '../../Abis.js';
|
|
12
12
|
import * as Addresses from '../../Addresses.js';
|
|
13
|
-
import
|
|
14
|
-
import * as
|
|
15
|
-
import
|
|
13
|
+
import * as ConfigStore from '../../accounts/Config.js';
|
|
14
|
+
import * as OperationStore from '../../accounts/Operation.js';
|
|
15
|
+
import { getConfigCommitment } from '../../actions/accounts.js';
|
|
16
16
|
import * as Transaction from '../../Transaction.js';
|
|
17
17
|
import * as Plugin from './plugin.js';
|
|
18
18
|
const submissionTtl = 30_000;
|
|
19
19
|
const pollingInterval = 100;
|
|
20
|
-
/** Creates middleware for
|
|
20
|
+
/** Creates middleware for owner approval coordination. @internal */
|
|
21
21
|
export function create(options) {
|
|
22
22
|
if (!options.store.compareAndSet)
|
|
23
23
|
throw new RpcResponse.InvalidParamsError({
|
|
24
|
-
message: '
|
|
24
|
+
message: 'Account coordination requires a store with atomic `compareAndSet`.',
|
|
25
25
|
});
|
|
26
|
-
return Plugin.
|
|
26
|
+
return Plugin.accounts({
|
|
27
27
|
async handleRequest(context, forward) {
|
|
28
28
|
const { request, options: requestOptions_ } = context;
|
|
29
29
|
const requestOptions = await resolveRequestOptions({
|
|
@@ -42,7 +42,7 @@ export function create(options) {
|
|
|
42
42
|
request: (request, options) => next(request, { ...requestOptions, ...options }),
|
|
43
43
|
}, { retryCount: 0 }),
|
|
44
44
|
});
|
|
45
|
-
if (request.method === '
|
|
45
|
+
if (request.method === 'account_getConfig') {
|
|
46
46
|
const value = request.params?.[0];
|
|
47
47
|
const address = value && typeof value === 'object' && 'address' in value
|
|
48
48
|
? value.address
|
|
@@ -51,7 +51,7 @@ export function create(options) {
|
|
|
51
51
|
!Address_.validate(address) ||
|
|
52
52
|
Hex.toBigInt(address) === 0n)
|
|
53
53
|
throw new RpcResponse.InvalidParamsError({
|
|
54
|
-
message: 'Expected a
|
|
54
|
+
message: 'Expected a configurable account address.',
|
|
55
55
|
});
|
|
56
56
|
const blockNumber = await getBlockNumber(client, { cacheTime: 0 });
|
|
57
57
|
const commitment = await getConfigCommitment(client, {
|
|
@@ -64,18 +64,18 @@ export function create(options) {
|
|
|
64
64
|
});
|
|
65
65
|
if (!config)
|
|
66
66
|
return null;
|
|
67
|
-
return
|
|
67
|
+
return AccountConfig.toRpc(config);
|
|
68
68
|
}
|
|
69
|
-
if (request.method === '
|
|
69
|
+
if (request.method === 'account_getOperation') {
|
|
70
70
|
const hash = request.params?.[0];
|
|
71
71
|
if (typeof hash !== 'string' || !Hash.validate(hash))
|
|
72
72
|
throw new RpcResponse.InvalidParamsError({
|
|
73
|
-
message: 'Expected
|
|
73
|
+
message: 'Expected an account operation hash.',
|
|
74
74
|
});
|
|
75
75
|
const operation = await OperationStore.read(options.store, hash);
|
|
76
|
-
return operation ?
|
|
76
|
+
return operation ? AccountOperation.toRpc(operation) : null;
|
|
77
77
|
}
|
|
78
|
-
if (request.method === '
|
|
78
|
+
if (request.method === 'account_approveKeyAuthorization')
|
|
79
79
|
return await approveKeyAuthorization({
|
|
80
80
|
client,
|
|
81
81
|
request,
|
|
@@ -106,7 +106,7 @@ export function create(options) {
|
|
|
106
106
|
: operation;
|
|
107
107
|
return {
|
|
108
108
|
...receipt,
|
|
109
|
-
|
|
109
|
+
operation: AccountOperation.toRpc(success),
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
if (operation.status === 'pending')
|
|
@@ -125,13 +125,13 @@ export function create(options) {
|
|
|
125
125
|
: operation;
|
|
126
126
|
return {
|
|
127
127
|
...transaction,
|
|
128
|
-
|
|
128
|
+
operation: AccountOperation.toRpc(success),
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
if (request.method !== 'eth_sendRawTransaction' &&
|
|
132
132
|
request.method !== 'eth_sendRawTransactionSync' &&
|
|
133
|
-
request.method !== '
|
|
134
|
-
request.method !== '
|
|
133
|
+
request.method !== 'account_approveRawTransaction' &&
|
|
134
|
+
request.method !== 'account_approveRawTransactionSync')
|
|
135
135
|
return forward();
|
|
136
136
|
const standard = request.method === 'eth_sendRawTransaction' ||
|
|
137
137
|
request.method === 'eth_sendRawTransactionSync';
|
|
@@ -140,7 +140,7 @@ export function create(options) {
|
|
|
140
140
|
if (standard)
|
|
141
141
|
return forward();
|
|
142
142
|
throw new RpcResponse.InvalidParamsError({
|
|
143
|
-
message: 'Expected a serialized Tempo
|
|
143
|
+
message: 'Expected a serialized Tempo configurable account transaction.',
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
return await submit({
|
|
@@ -170,26 +170,26 @@ async function submit(options) {
|
|
|
170
170
|
}
|
|
171
171
|
})();
|
|
172
172
|
const signature = transaction?.signature;
|
|
173
|
-
if (!transaction || signature?.type !== '
|
|
173
|
+
if (!transaction || signature?.type !== 'configurable') {
|
|
174
174
|
if (options.method === 'eth_sendRawTransaction' ||
|
|
175
175
|
options.method === 'eth_sendRawTransactionSync')
|
|
176
176
|
return await options.next(options.request, options.requestOptions);
|
|
177
177
|
throw new RpcResponse.InvalidParamsError({
|
|
178
|
-
message: 'Expected a
|
|
178
|
+
message: 'Expected a configurable account transaction signature.',
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
const { signature: _, ...unsigned } = transaction;
|
|
182
182
|
const envelope = TxEnvelopeTempo.from(unsigned);
|
|
183
183
|
const serializedUnsigned = serializeUnsigned(envelope, options.serialized.startsWith(TxEnvelopeTempo.feePayerMagic));
|
|
184
184
|
const blockNumber = await getBlockNumber(options.client, { cacheTime: 0 });
|
|
185
|
-
const config =
|
|
185
|
+
const config = AccountConfig.from(signature.config);
|
|
186
186
|
const configCommitment = await validateConfig({
|
|
187
187
|
account: signature.account,
|
|
188
188
|
blockNumber,
|
|
189
189
|
client: options.client,
|
|
190
190
|
config,
|
|
191
191
|
});
|
|
192
|
-
const operationHash =
|
|
192
|
+
const operationHash = AccountOperation.getHash({
|
|
193
193
|
account: signature.account,
|
|
194
194
|
config,
|
|
195
195
|
transaction: serializedUnsigned,
|
|
@@ -198,7 +198,7 @@ async function submit(options) {
|
|
|
198
198
|
const incoming = signature.signatures.map((signature) => SignatureEnvelope.serialize(signature));
|
|
199
199
|
if (incoming.length === 0)
|
|
200
200
|
throw new RpcResponse.InvalidParamsError({
|
|
201
|
-
message: 'A
|
|
201
|
+
message: 'A owner approval envelope must include a signature.',
|
|
202
202
|
});
|
|
203
203
|
const now = Date.now();
|
|
204
204
|
const expiredSubmissionIds = new Set();
|
|
@@ -225,7 +225,7 @@ async function submit(options) {
|
|
|
225
225
|
hash: operationHash,
|
|
226
226
|
approvals: [...(existingApprovals?.approvals ?? []), ...incoming],
|
|
227
227
|
});
|
|
228
|
-
return
|
|
228
|
+
return AccountOperation.from({
|
|
229
229
|
account: signature.account,
|
|
230
230
|
approvals: approvals.approvals,
|
|
231
231
|
config,
|
|
@@ -268,7 +268,7 @@ async function submit(options) {
|
|
|
268
268
|
const submissionId = Hex.random(32);
|
|
269
269
|
const timeout = options.request.params?.[1];
|
|
270
270
|
const synchronous = options.method === 'eth_sendRawTransactionSync' ||
|
|
271
|
-
options.method === '
|
|
271
|
+
options.method === 'account_approveRawTransactionSync';
|
|
272
272
|
const leaseTtl = synchronous &&
|
|
273
273
|
typeof timeout === 'number' &&
|
|
274
274
|
Number.isSafeInteger(timeout) &&
|
|
@@ -285,7 +285,7 @@ async function submit(options) {
|
|
|
285
285
|
if (current.weight < current.threshold)
|
|
286
286
|
return current;
|
|
287
287
|
const now = Date.now();
|
|
288
|
-
return
|
|
288
|
+
return AccountOperation.from({
|
|
289
289
|
...current,
|
|
290
290
|
expiresAt: Math.min(now + leaseTtl, Number.MAX_SAFE_INTEGER),
|
|
291
291
|
status: 'submitting',
|
|
@@ -318,7 +318,7 @@ async function submit(options) {
|
|
|
318
318
|
hash: claim.hash,
|
|
319
319
|
approvals: claim.approvals,
|
|
320
320
|
});
|
|
321
|
-
const final =
|
|
321
|
+
const final = AccountOperation.serializeTransaction(claim, {
|
|
322
322
|
approvals: finalApprovals.selectedApprovals,
|
|
323
323
|
});
|
|
324
324
|
const transactionHash = TxEnvelopeTempo.hash(TxEnvelopeTempo.deserialize(final));
|
|
@@ -344,7 +344,7 @@ async function submit(options) {
|
|
|
344
344
|
try {
|
|
345
345
|
result = await options.next({
|
|
346
346
|
method: options.method === 'eth_sendRawTransaction' ||
|
|
347
|
-
options.method === '
|
|
347
|
+
options.method === 'account_approveRawTransaction'
|
|
348
348
|
? 'eth_sendRawTransaction'
|
|
349
349
|
: 'eth_sendRawTransactionSync',
|
|
350
350
|
params: [final, ...(options.request.params?.slice(1) ?? [])],
|
|
@@ -392,7 +392,7 @@ async function submit(options) {
|
|
|
392
392
|
current.submissionId !== submissionId)
|
|
393
393
|
throw new OperationStore.InvalidStoreValueError();
|
|
394
394
|
const { expiresAt: _, submissionId: __, ...operation } = current;
|
|
395
|
-
return
|
|
395
|
+
return AccountOperation.from({
|
|
396
396
|
...operation,
|
|
397
397
|
status: 'success',
|
|
398
398
|
transactionHash,
|
|
@@ -405,16 +405,16 @@ async function submit(options) {
|
|
|
405
405
|
if (options.method === 'eth_sendRawTransactionSync' &&
|
|
406
406
|
result &&
|
|
407
407
|
typeof result === 'object')
|
|
408
|
-
return { ...result,
|
|
408
|
+
return { ...result, operation: AccountOperation.toRpc(success) };
|
|
409
409
|
return await submittedResult(options, success);
|
|
410
410
|
}
|
|
411
|
-
/** Collects approvals for a
|
|
411
|
+
/** Collects approvals for a configurable account key authorization. @internal */
|
|
412
412
|
// biome-ignore lint/correctness/noUnusedVariables: declaration merge
|
|
413
413
|
async function approveKeyAuthorization(options) {
|
|
414
414
|
const value = options.request.params?.[0];
|
|
415
415
|
if (!value || typeof value !== 'object')
|
|
416
416
|
throw new RpcResponse.InvalidParamsError({
|
|
417
|
-
message: 'Expected a
|
|
417
|
+
message: 'Expected a configurable account key authorization approval.',
|
|
418
418
|
});
|
|
419
419
|
const approval = await (async () => {
|
|
420
420
|
if ('keyAuthorization' in value) {
|
|
@@ -424,24 +424,24 @@ async function approveKeyAuthorization(options) {
|
|
|
424
424
|
}
|
|
425
425
|
catch {
|
|
426
426
|
throw new RpcResponse.InvalidParamsError({
|
|
427
|
-
message: 'Invalid
|
|
427
|
+
message: 'Invalid configurable account key authorization.',
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
})();
|
|
431
431
|
const signature = authorization.signature;
|
|
432
|
-
if (signature?.type !== '
|
|
432
|
+
if (signature?.type !== 'configurable')
|
|
433
433
|
throw new RpcResponse.InvalidParamsError({
|
|
434
|
-
message: 'Expected a
|
|
434
|
+
message: 'Expected a configurable account key authorization signature.',
|
|
435
435
|
});
|
|
436
436
|
if (!authorization.account ||
|
|
437
437
|
!isAddressEqual(authorization.account, signature.account))
|
|
438
438
|
throw new RpcResponse.InvalidParamsError({
|
|
439
|
-
message: '
|
|
439
|
+
message: 'Configurable account key authorization account does not match its signature.',
|
|
440
440
|
});
|
|
441
441
|
const { signature: _, ...unsigned } = authorization;
|
|
442
442
|
const keyAuthorization = KeyAuthorization.serialize(KeyAuthorization.from(unsigned));
|
|
443
|
-
const config =
|
|
444
|
-
const hash =
|
|
443
|
+
const config = AccountConfig.from(signature.config);
|
|
444
|
+
const hash = AccountOperation.getHash({
|
|
445
445
|
account: signature.account,
|
|
446
446
|
config,
|
|
447
447
|
keyAuthorization,
|
|
@@ -458,12 +458,12 @@ async function approveKeyAuthorization(options) {
|
|
|
458
458
|
if ('hash' in value && 'signature' in value) {
|
|
459
459
|
if (typeof value.hash !== 'string' || !Hash.validate(value.hash))
|
|
460
460
|
throw new RpcResponse.InvalidParamsError({
|
|
461
|
-
message: 'Expected
|
|
461
|
+
message: 'Expected an account operation hash.',
|
|
462
462
|
});
|
|
463
463
|
const operation = await OperationStore.read(options.store, value.hash);
|
|
464
464
|
if (!operation || operation.type !== 'keyAuthorization')
|
|
465
465
|
throw new RpcResponse.InvalidParamsError({
|
|
466
|
-
message: '
|
|
466
|
+
message: 'Configurable account key authorization operation was not found.',
|
|
467
467
|
});
|
|
468
468
|
if (operation.status === 'success')
|
|
469
469
|
return { operation };
|
|
@@ -473,7 +473,7 @@ async function approveKeyAuthorization(options) {
|
|
|
473
473
|
}
|
|
474
474
|
catch {
|
|
475
475
|
throw new RpcResponse.InvalidParamsError({
|
|
476
|
-
message: 'Invalid
|
|
476
|
+
message: 'Invalid owner signature.',
|
|
477
477
|
});
|
|
478
478
|
}
|
|
479
479
|
})();
|
|
@@ -486,14 +486,14 @@ async function approveKeyAuthorization(options) {
|
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
488
|
throw new RpcResponse.InvalidParamsError({
|
|
489
|
-
message: 'Expected a
|
|
489
|
+
message: 'Expected a configurable account key authorization approval.',
|
|
490
490
|
});
|
|
491
491
|
})();
|
|
492
492
|
if ('operation' in approval)
|
|
493
|
-
return
|
|
493
|
+
return AccountOperation.toRpc(approval.operation);
|
|
494
494
|
if (approval.approvals.length === 0)
|
|
495
495
|
throw new RpcResponse.InvalidParamsError({
|
|
496
|
-
message: 'A
|
|
496
|
+
message: 'A owner approval envelope must include a signature.',
|
|
497
497
|
});
|
|
498
498
|
const blockNumber = await getBlockNumber(options.client, { cacheTime: 0 });
|
|
499
499
|
const commitment = await validateConfig({
|
|
@@ -510,8 +510,8 @@ async function approveKeyAuthorization(options) {
|
|
|
510
510
|
return existing;
|
|
511
511
|
if (existing &&
|
|
512
512
|
(existing.account.toLowerCase() !== approval.account.toLowerCase() ||
|
|
513
|
-
|
|
514
|
-
|
|
513
|
+
AccountConfig.getCommitment(existing.config).toLowerCase() !==
|
|
514
|
+
AccountConfig.getCommitment(approval.config).toLowerCase() ||
|
|
515
515
|
existing.keyAuthorization.toLowerCase() !==
|
|
516
516
|
approval.keyAuthorization.toLowerCase()))
|
|
517
517
|
throw new OperationStore.InvalidStoreValueError();
|
|
@@ -550,10 +550,10 @@ async function approveKeyAuthorization(options) {
|
|
|
550
550
|
weight: approvals.weight,
|
|
551
551
|
};
|
|
552
552
|
if (approvals.weight < approvals.threshold)
|
|
553
|
-
return
|
|
554
|
-
return
|
|
553
|
+
return AccountOperation.from({ ...pending, status: 'pending' });
|
|
554
|
+
return AccountOperation.from({
|
|
555
555
|
...pending,
|
|
556
|
-
keyAuthorization:
|
|
556
|
+
keyAuthorization: AccountOperation.serializeKeyAuthorization(approval.keyAuthorization, {
|
|
557
557
|
account: approval.account,
|
|
558
558
|
approvals: approvals.selectedApprovals,
|
|
559
559
|
config: approval.config,
|
|
@@ -568,7 +568,7 @@ async function approveKeyAuthorization(options) {
|
|
|
568
568
|
});
|
|
569
569
|
if (operation.type !== 'keyAuthorization')
|
|
570
570
|
throw new OperationStore.InvalidStoreValueError();
|
|
571
|
-
return
|
|
571
|
+
return AccountOperation.toRpc(operation);
|
|
572
572
|
}
|
|
573
573
|
/** Deserializes a Tempo transaction or throws an RPC parameter error. */
|
|
574
574
|
function deserialize(serialized) {
|
|
@@ -585,22 +585,22 @@ function deserialize(serialized) {
|
|
|
585
585
|
function assertConfig(options) {
|
|
586
586
|
const { account, commitment, config } = options;
|
|
587
587
|
if (config.version === 0n &&
|
|
588
|
-
|
|
588
|
+
AccountConfig.getAddress(config, {
|
|
589
589
|
factory: Addresses.nativeMultisigFactory,
|
|
590
590
|
}).toLowerCase() !== account.toLowerCase())
|
|
591
591
|
throw new RpcResponse.InvalidParamsError({
|
|
592
|
-
message: 'Initial
|
|
592
|
+
message: 'Initial account config does not match the configurable account.',
|
|
593
593
|
});
|
|
594
594
|
if (config.version === 0n && Hex.toBigInt(commitment) === 0n)
|
|
595
595
|
return;
|
|
596
596
|
if (commitment.toLowerCase() !==
|
|
597
|
-
|
|
597
|
+
AccountConfig.getCommitment(config).toLowerCase())
|
|
598
598
|
throw new RpcResponse.InvalidParamsError({
|
|
599
|
-
message: `
|
|
599
|
+
message: `Account config does not match account ${account}.`,
|
|
600
600
|
});
|
|
601
601
|
}
|
|
602
|
-
/** Reads and validates a config commitment at one block. */
|
|
603
|
-
async function validateConfig(options) {
|
|
602
|
+
/** Reads and validates a config commitment at one block. @internal */
|
|
603
|
+
export async function validateConfig(options) {
|
|
604
604
|
const { account, blockNumber, client, config } = options;
|
|
605
605
|
const commitment = await getConfigCommitment(client, {
|
|
606
606
|
account,
|
|
@@ -631,24 +631,19 @@ async function cacheNextConfigs(options) {
|
|
|
631
631
|
const [current, threshold, owners] = decoded.args;
|
|
632
632
|
const suppliedConfig = (() => {
|
|
633
633
|
try {
|
|
634
|
-
return
|
|
634
|
+
return AccountConfig.from(current);
|
|
635
635
|
}
|
|
636
636
|
catch {
|
|
637
637
|
return undefined;
|
|
638
638
|
}
|
|
639
639
|
})();
|
|
640
640
|
if (!suppliedConfig ||
|
|
641
|
-
|
|
642
|
-
|
|
641
|
+
AccountConfig.getCommitment(suppliedConfig).toLowerCase() !==
|
|
642
|
+
AccountConfig.getCommitment(currentConfig).toLowerCase())
|
|
643
643
|
continue;
|
|
644
644
|
const config = (() => {
|
|
645
645
|
try {
|
|
646
|
-
return
|
|
647
|
-
owners,
|
|
648
|
-
salt: suppliedConfig.salt,
|
|
649
|
-
threshold,
|
|
650
|
-
version: suppliedConfig.version + 1n,
|
|
651
|
-
});
|
|
646
|
+
return AccountConfig.update(suppliedConfig, { owners, threshold });
|
|
652
647
|
}
|
|
653
648
|
catch {
|
|
654
649
|
return undefined;
|
|
@@ -658,19 +653,19 @@ async function cacheNextConfigs(options) {
|
|
|
658
653
|
continue;
|
|
659
654
|
await ConfigStore.write(options.store, {
|
|
660
655
|
address: options.account,
|
|
661
|
-
commitment:
|
|
656
|
+
commitment: AccountConfig.getCommitment(config),
|
|
662
657
|
config,
|
|
663
658
|
});
|
|
664
659
|
currentConfig = config;
|
|
665
660
|
}
|
|
666
661
|
}
|
|
667
|
-
/** Validates primitive approvals and translates invalid input into an RPC error. */
|
|
668
|
-
async function selectApprovals(options) {
|
|
662
|
+
/** Validates primitive approvals and translates invalid input into an RPC error. @internal */
|
|
663
|
+
export async function selectApprovals(options) {
|
|
669
664
|
try {
|
|
670
|
-
return await
|
|
665
|
+
return await AccountOperation.selectApprovals(options);
|
|
671
666
|
}
|
|
672
667
|
catch (error) {
|
|
673
|
-
if (error instanceof
|
|
668
|
+
if (error instanceof AccountOperation.InvalidApprovalError)
|
|
674
669
|
throw new RpcResponse.InvalidParamsError({ message: error.shortMessage });
|
|
675
670
|
throw error;
|
|
676
671
|
}
|
|
@@ -678,10 +673,10 @@ async function selectApprovals(options) {
|
|
|
678
673
|
/** Returns an existing successful operation through the requested send method. */
|
|
679
674
|
async function submittedResult(options, operation) {
|
|
680
675
|
if (options.method === 'eth_sendRawTransaction' ||
|
|
681
|
-
options.method === '
|
|
676
|
+
options.method === 'account_approveRawTransaction')
|
|
682
677
|
return operation.hash;
|
|
683
|
-
if (options.method === '
|
|
684
|
-
return
|
|
678
|
+
if (options.method === 'account_approveRawTransactionSync')
|
|
679
|
+
return AccountOperation.toRpc(operation);
|
|
685
680
|
const timeout = options.request.params?.[1];
|
|
686
681
|
const deadline = Date.now() +
|
|
687
682
|
(typeof timeout === 'number' && timeout >= 0 ? timeout : submissionTtl);
|
|
@@ -691,16 +686,16 @@ async function submittedResult(options, operation) {
|
|
|
691
686
|
params: [operation.transactionHash],
|
|
692
687
|
}, options.requestOptions);
|
|
693
688
|
if (receipt && typeof receipt === 'object')
|
|
694
|
-
return { ...receipt,
|
|
689
|
+
return { ...receipt, operation: AccountOperation.toRpc(operation) };
|
|
695
690
|
if (Date.now() >= deadline)
|
|
696
|
-
throw new Error('Timed out while waiting for the
|
|
691
|
+
throw new Error('Timed out while waiting for the configurable account transaction.');
|
|
697
692
|
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
698
693
|
}
|
|
699
694
|
}
|
|
700
695
|
/** Waits for the relay that owns a live submission lease. */
|
|
701
696
|
async function submittingResult(options, operation) {
|
|
702
697
|
if (options.method === 'eth_sendRawTransaction' ||
|
|
703
|
-
options.method === '
|
|
698
|
+
options.method === 'account_approveRawTransaction')
|
|
704
699
|
return operation.hash;
|
|
705
700
|
const timeout = options.request.params?.[1];
|
|
706
701
|
const deadline = Date.now() +
|
|
@@ -721,10 +716,10 @@ async function submittingResult(options, operation) {
|
|
|
721
716
|
/** Returns a pending result for an operation that has not reached quorum. */
|
|
722
717
|
function pendingResult(method, operation) {
|
|
723
718
|
if (method === 'eth_sendRawTransaction' ||
|
|
724
|
-
method === '
|
|
719
|
+
method === 'account_approveRawTransaction')
|
|
725
720
|
return operation.hash;
|
|
726
|
-
if (method === '
|
|
727
|
-
return
|
|
721
|
+
if (method === 'account_approveRawTransactionSync')
|
|
722
|
+
return AccountOperation.toRpc(operation);
|
|
728
723
|
return {
|
|
729
724
|
blockHash: null,
|
|
730
725
|
blockNumber: null,
|
|
@@ -735,7 +730,7 @@ function pendingResult(method, operation) {
|
|
|
735
730
|
gasUsed: null,
|
|
736
731
|
logs: [],
|
|
737
732
|
logsBloom: null,
|
|
738
|
-
|
|
733
|
+
operation: AccountOperation.toRpc(operation),
|
|
739
734
|
status: 'pending',
|
|
740
735
|
to: null,
|
|
741
736
|
transactionHash: operation.hash,
|
|
@@ -760,7 +755,7 @@ async function completeSubmission(store, operation, transactionHash) {
|
|
|
760
755
|
current.submissionId !== operation.submissionId)
|
|
761
756
|
throw new OperationStore.InvalidStoreValueError();
|
|
762
757
|
const { expiresAt: _, submissionId: __, transactionHash: ___, ...value } = current;
|
|
763
|
-
return
|
|
758
|
+
return AccountOperation.from({
|
|
764
759
|
...value,
|
|
765
760
|
status: 'success',
|
|
766
761
|
transactionHash,
|
|
@@ -779,7 +774,7 @@ async function releaseSubmission(store, hash, submissionId) {
|
|
|
779
774
|
current.submissionId !== submissionId)
|
|
780
775
|
return current;
|
|
781
776
|
const { expiresAt: _, submissionId: __, ...operation } = current;
|
|
782
|
-
return
|
|
777
|
+
return AccountOperation.from({
|
|
783
778
|
...operation,
|
|
784
779
|
status: 'pending',
|
|
785
780
|
updatedAt: Date.now(),
|
|
@@ -812,7 +807,7 @@ function mergeTransaction(existing, incoming) {
|
|
|
812
807
|
async function toTransaction(client, operation) {
|
|
813
808
|
const approvals = await (async () => {
|
|
814
809
|
if (operation.status !== 'pending')
|
|
815
|
-
return await
|
|
810
|
+
return await AccountOperation.selectApprovals({
|
|
816
811
|
account: operation.account,
|
|
817
812
|
approvals: operation.approvals,
|
|
818
813
|
config: operation.config,
|
|
@@ -833,7 +828,7 @@ async function toTransaction(client, operation) {
|
|
|
833
828
|
});
|
|
834
829
|
})();
|
|
835
830
|
const current = operation.status === 'pending'
|
|
836
|
-
?
|
|
831
|
+
? AccountOperation.from({
|
|
837
832
|
...operation,
|
|
838
833
|
approvals: approvals.approvals,
|
|
839
834
|
signatureCount: approvals.signatureCount,
|
|
@@ -841,7 +836,7 @@ async function toTransaction(client, operation) {
|
|
|
841
836
|
weight: approvals.weight,
|
|
842
837
|
})
|
|
843
838
|
: operation;
|
|
844
|
-
const serialized =
|
|
839
|
+
const serialized = AccountOperation.serializeTransaction(current, {
|
|
845
840
|
approvals: approvals.selectedApprovals,
|
|
846
841
|
});
|
|
847
842
|
const transaction = deserialize(serialized);
|
|
@@ -854,7 +849,7 @@ async function toTransaction(client, operation) {
|
|
|
854
849
|
hash: operation.hash,
|
|
855
850
|
transactionIndex: null,
|
|
856
851
|
}, { pending: true }),
|
|
857
|
-
|
|
852
|
+
operation: AccountOperation.toRpc(current),
|
|
858
853
|
};
|
|
859
854
|
}
|
|
860
855
|
/** Returns the persisted transaction hash for a submitting or successful operation. */
|
|
@@ -881,7 +876,7 @@ function maintainSubmissionLease(store, hash, submissionId, leaseTtl) {
|
|
|
881
876
|
if (current.status !== 'submitting' ||
|
|
882
877
|
current.submissionId !== submissionId)
|
|
883
878
|
return current;
|
|
884
|
-
return
|
|
879
|
+
return AccountOperation.from({
|
|
885
880
|
...current,
|
|
886
881
|
expiresAt: Math.min(Date.now() + leaseTtl, Number.MAX_SAFE_INTEGER),
|
|
887
882
|
updatedAt: Date.now(),
|
|
@@ -923,7 +918,7 @@ function getTransactionHash(result) {
|
|
|
923
918
|
typeof result.transactionHash === 'string' &&
|
|
924
919
|
Hash.validate(result.transactionHash))
|
|
925
920
|
return result.transactionHash;
|
|
926
|
-
throw new Error('Expected transaction hash in
|
|
921
|
+
throw new Error('Expected transaction hash in account broadcast result.');
|
|
927
922
|
}
|
|
928
923
|
/** Resolves and validates the chain used by a handled request. */
|
|
929
924
|
async function resolveRequestOptions(options) {
|
|
@@ -952,11 +947,11 @@ async function resolveRequestChainId(request, store) {
|
|
|
952
947
|
const chainId_body = value && typeof value === 'object' && 'chainId' in value
|
|
953
948
|
? parseChainId(value.chainId)
|
|
954
949
|
: undefined;
|
|
955
|
-
const
|
|
950
|
+
const chainId_operation = await (async () => {
|
|
956
951
|
if (request.method === 'eth_sendRawTransaction' ||
|
|
957
952
|
request.method === 'eth_sendRawTransactionSync' ||
|
|
958
|
-
request.method === '
|
|
959
|
-
request.method === '
|
|
953
|
+
request.method === 'account_approveRawTransaction' ||
|
|
954
|
+
request.method === 'account_approveRawTransactionSync') {
|
|
960
955
|
if (!isSerializedTempoTransaction(value))
|
|
961
956
|
return undefined;
|
|
962
957
|
try {
|
|
@@ -966,7 +961,7 @@ async function resolveRequestChainId(request, store) {
|
|
|
966
961
|
return undefined;
|
|
967
962
|
}
|
|
968
963
|
}
|
|
969
|
-
if (request.method === '
|
|
964
|
+
if (request.method === 'account_approveKeyAuthorization' &&
|
|
970
965
|
value &&
|
|
971
966
|
typeof value === 'object' &&
|
|
972
967
|
'keyAuthorization' in value) {
|
|
@@ -981,7 +976,7 @@ async function resolveRequestChainId(request, store) {
|
|
|
981
976
|
if (request.method === 'eth_getTransactionByHash' ||
|
|
982
977
|
request.method === 'eth_getTransactionReceipt')
|
|
983
978
|
return value;
|
|
984
|
-
if (request.method === '
|
|
979
|
+
if (request.method === 'account_approveKeyAuthorization' &&
|
|
985
980
|
value &&
|
|
986
981
|
typeof value === 'object' &&
|
|
987
982
|
'hash' in value)
|
|
@@ -998,12 +993,12 @@ async function resolveRequestChainId(request, store) {
|
|
|
998
993
|
return parseChainId(KeyAuthorization.deserialize(operation.keyAuthorization).chainId);
|
|
999
994
|
})();
|
|
1000
995
|
if (chainId_body !== undefined &&
|
|
1001
|
-
|
|
1002
|
-
chainId_body !==
|
|
996
|
+
chainId_operation !== undefined &&
|
|
997
|
+
chainId_body !== chainId_operation)
|
|
1003
998
|
throw new RpcResponse.InvalidParamsError({
|
|
1004
999
|
message: 'Conflicting chain ids.',
|
|
1005
1000
|
});
|
|
1006
|
-
return chainId_body ??
|
|
1001
|
+
return chainId_body ?? chainId_operation;
|
|
1007
1002
|
}
|
|
1008
1003
|
/** Parses a supported chain ID representation. */
|
|
1009
1004
|
function parseChainId(value) {
|
|
@@ -1031,4 +1026,4 @@ function isSerializedTempoTransaction(value) {
|
|
|
1031
1026
|
return (typeof value === 'string' &&
|
|
1032
1027
|
(value.startsWith('0x76') || value.startsWith('0x78')));
|
|
1033
1028
|
}
|
|
1034
|
-
//# sourceMappingURL=
|
|
1029
|
+
//# sourceMappingURL=accounts.js.map
|