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
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { AbiFunction, Address as Address_, Hash, Hex, RpcResponse } from 'ox';
|
|
2
|
-
import { KeyAuthorization,
|
|
2
|
+
import { KeyAuthorization, AccountConfig, AccountOperation, Transaction as ox_Transaction, SignatureEnvelope, TxEnvelopeTempo, } from 'ox/tempo';
|
|
3
3
|
import { getNumber as getBlockNumber } from '../../../core/actions/block/getNumber.js';
|
|
4
4
|
import { create as createClient } from '../../../core/Client.js';
|
|
5
5
|
import * as Abis from '../../Abis.js';
|
|
6
6
|
import * as Addresses from '../../Addresses.js';
|
|
7
|
-
import { getConfigCommitment } from '../../actions/
|
|
8
|
-
import * as ConfigStore from '../../
|
|
9
|
-
import * as OperationStore from '../../
|
|
7
|
+
import { getConfigCommitment } from '../../actions/accounts/getConfigCommitment.js';
|
|
8
|
+
import * as ConfigStore from '../../accounts/Config.js';
|
|
9
|
+
import * as OperationStore from '../../accounts/Operation.js';
|
|
10
10
|
import * as Plugin from './plugin.js';
|
|
11
11
|
const submissionTtl = 30_000;
|
|
12
12
|
const pollingInterval = 100;
|
|
13
|
-
/** Creates middleware for
|
|
13
|
+
/** Creates middleware for owner approval coordination. @internal */
|
|
14
14
|
export function create(options) {
|
|
15
15
|
if (!options.store.compareAndSet)
|
|
16
16
|
throw new RpcResponse.InvalidParamsError({
|
|
17
|
-
message: '
|
|
17
|
+
message: 'Account coordination requires a store with atomic `compareAndSet`.',
|
|
18
18
|
});
|
|
19
|
-
return Plugin.
|
|
19
|
+
return Plugin.accounts({
|
|
20
20
|
async handleRequest(context, forward) {
|
|
21
21
|
const { request, options: requestOptions_ } = context;
|
|
22
22
|
const requestOptions = await resolveRequestOptions({
|
|
@@ -32,15 +32,15 @@ export function create(options) {
|
|
|
32
32
|
};
|
|
33
33
|
const client = createClient({
|
|
34
34
|
transport: {
|
|
35
|
-
key: '
|
|
36
|
-
name: '
|
|
37
|
-
type: '
|
|
35
|
+
key: 'accounts-forward',
|
|
36
|
+
name: 'Accounts Forwarding',
|
|
37
|
+
type: 'accounts-forward',
|
|
38
38
|
setup: () => ({
|
|
39
39
|
request: ((request, options) => next(request, { ...requestOptions, ...options })),
|
|
40
40
|
}),
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
|
-
if (request.method === '
|
|
43
|
+
if (request.method === 'account_getConfig') {
|
|
44
44
|
const value = request.params?.[0];
|
|
45
45
|
const address = value && typeof value === 'object' && 'address' in value
|
|
46
46
|
? value.address
|
|
@@ -49,7 +49,7 @@ export function create(options) {
|
|
|
49
49
|
!Address_.validate(address) ||
|
|
50
50
|
Hex.toBigInt(address) === 0n)
|
|
51
51
|
throw new RpcResponse.InvalidParamsError({
|
|
52
|
-
message: 'Expected a
|
|
52
|
+
message: 'Expected a configurable account address.',
|
|
53
53
|
});
|
|
54
54
|
const blockNumber = await getBlockNumber(client, { cacheTime: 0 });
|
|
55
55
|
const commitment = await getConfigCommitment(client, {
|
|
@@ -62,18 +62,18 @@ export function create(options) {
|
|
|
62
62
|
});
|
|
63
63
|
if (!config)
|
|
64
64
|
return null;
|
|
65
|
-
return
|
|
65
|
+
return AccountConfig.toRpc(config);
|
|
66
66
|
}
|
|
67
|
-
if (request.method === '
|
|
67
|
+
if (request.method === 'account_getOperation') {
|
|
68
68
|
const hash = request.params?.[0];
|
|
69
69
|
if (typeof hash !== 'string' || !Hash.validate(hash))
|
|
70
70
|
throw new RpcResponse.InvalidParamsError({
|
|
71
|
-
message: 'Expected
|
|
71
|
+
message: 'Expected an account operation hash.',
|
|
72
72
|
});
|
|
73
73
|
const operation = await OperationStore.read(options.store, hash);
|
|
74
|
-
return operation ?
|
|
74
|
+
return operation ? AccountOperation.toRpc(operation) : null;
|
|
75
75
|
}
|
|
76
|
-
if (request.method === '
|
|
76
|
+
if (request.method === 'account_approveKeyAuthorization')
|
|
77
77
|
return await approveKeyAuthorization({
|
|
78
78
|
client,
|
|
79
79
|
request,
|
|
@@ -104,7 +104,7 @@ export function create(options) {
|
|
|
104
104
|
: operation;
|
|
105
105
|
return {
|
|
106
106
|
...receipt,
|
|
107
|
-
|
|
107
|
+
operation: AccountOperation.toRpc(success),
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
if (operation.status === 'pending')
|
|
@@ -123,13 +123,13 @@ export function create(options) {
|
|
|
123
123
|
: operation;
|
|
124
124
|
return {
|
|
125
125
|
...transaction,
|
|
126
|
-
|
|
126
|
+
operation: AccountOperation.toRpc(success),
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
if (request.method !== 'eth_sendRawTransaction' &&
|
|
130
130
|
request.method !== 'eth_sendRawTransactionSync' &&
|
|
131
|
-
request.method !== '
|
|
132
|
-
request.method !== '
|
|
131
|
+
request.method !== 'account_approveRawTransaction' &&
|
|
132
|
+
request.method !== 'account_approveRawTransactionSync')
|
|
133
133
|
return forward();
|
|
134
134
|
const standard = request.method === 'eth_sendRawTransaction' ||
|
|
135
135
|
request.method === 'eth_sendRawTransactionSync';
|
|
@@ -138,7 +138,7 @@ export function create(options) {
|
|
|
138
138
|
if (standard)
|
|
139
139
|
return forward();
|
|
140
140
|
throw new RpcResponse.InvalidParamsError({
|
|
141
|
-
message: 'Expected a serialized Tempo
|
|
141
|
+
message: 'Expected a serialized Tempo configurable account transaction.',
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
return await submit({
|
|
@@ -168,26 +168,26 @@ async function submit(options) {
|
|
|
168
168
|
}
|
|
169
169
|
})();
|
|
170
170
|
const signature = transaction?.signature;
|
|
171
|
-
if (!transaction || signature?.type !== '
|
|
171
|
+
if (!transaction || signature?.type !== 'configurable') {
|
|
172
172
|
if (options.method === 'eth_sendRawTransaction' ||
|
|
173
173
|
options.method === 'eth_sendRawTransactionSync')
|
|
174
174
|
return await options.next(options.request, options.requestOptions);
|
|
175
175
|
throw new RpcResponse.InvalidParamsError({
|
|
176
|
-
message: 'Expected a
|
|
176
|
+
message: 'Expected a configurable account transaction signature.',
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
const { signature: _, ...unsigned } = transaction;
|
|
180
180
|
const envelope = TxEnvelopeTempo.from(unsigned);
|
|
181
181
|
const serializedUnsigned = serializeUnsigned(envelope, options.serialized.startsWith(TxEnvelopeTempo.feePayerMagic));
|
|
182
182
|
const blockNumber = await getBlockNumber(options.client, { cacheTime: 0 });
|
|
183
|
-
const config =
|
|
183
|
+
const config = AccountConfig.from(signature.config);
|
|
184
184
|
const configCommitment = await validateConfig({
|
|
185
185
|
account: signature.account,
|
|
186
186
|
blockNumber,
|
|
187
187
|
client: options.client,
|
|
188
188
|
config,
|
|
189
189
|
});
|
|
190
|
-
const operationHash =
|
|
190
|
+
const operationHash = AccountOperation.getHash({
|
|
191
191
|
account: signature.account,
|
|
192
192
|
config,
|
|
193
193
|
transaction: serializedUnsigned,
|
|
@@ -196,7 +196,7 @@ async function submit(options) {
|
|
|
196
196
|
const incoming = signature.signatures.map((signature) => SignatureEnvelope.serialize(signature));
|
|
197
197
|
if (incoming.length === 0)
|
|
198
198
|
throw new RpcResponse.InvalidParamsError({
|
|
199
|
-
message: 'A
|
|
199
|
+
message: 'A owner approval envelope must include a signature.',
|
|
200
200
|
});
|
|
201
201
|
const now = Date.now();
|
|
202
202
|
const expiredSubmissionIds = new Set();
|
|
@@ -223,7 +223,7 @@ async function submit(options) {
|
|
|
223
223
|
hash: operationHash,
|
|
224
224
|
approvals: [...(existingApprovals?.approvals ?? []), ...incoming],
|
|
225
225
|
});
|
|
226
|
-
return
|
|
226
|
+
return AccountOperation.from({
|
|
227
227
|
account: signature.account,
|
|
228
228
|
approvals: approvals.approvals,
|
|
229
229
|
config,
|
|
@@ -266,7 +266,7 @@ async function submit(options) {
|
|
|
266
266
|
const submissionId = Hex.random(32);
|
|
267
267
|
const timeout = options.request.params?.[1];
|
|
268
268
|
const synchronous = options.method === 'eth_sendRawTransactionSync' ||
|
|
269
|
-
options.method === '
|
|
269
|
+
options.method === 'account_approveRawTransactionSync';
|
|
270
270
|
const leaseTtl = synchronous &&
|
|
271
271
|
typeof timeout === 'number' &&
|
|
272
272
|
Number.isSafeInteger(timeout) &&
|
|
@@ -283,7 +283,7 @@ async function submit(options) {
|
|
|
283
283
|
if (current.weight < current.threshold)
|
|
284
284
|
return current;
|
|
285
285
|
const now = Date.now();
|
|
286
|
-
return
|
|
286
|
+
return AccountOperation.from({
|
|
287
287
|
...current,
|
|
288
288
|
expiresAt: Math.min(now + leaseTtl, Number.MAX_SAFE_INTEGER),
|
|
289
289
|
status: 'submitting',
|
|
@@ -316,7 +316,7 @@ async function submit(options) {
|
|
|
316
316
|
hash: claim.hash,
|
|
317
317
|
approvals: claim.approvals,
|
|
318
318
|
});
|
|
319
|
-
const final =
|
|
319
|
+
const final = AccountOperation.serializeTransaction(claim, {
|
|
320
320
|
approvals: finalApprovals.selectedApprovals,
|
|
321
321
|
});
|
|
322
322
|
const transactionHash = TxEnvelopeTempo.hash(TxEnvelopeTempo.deserialize(final));
|
|
@@ -342,7 +342,7 @@ async function submit(options) {
|
|
|
342
342
|
try {
|
|
343
343
|
result = await options.next({
|
|
344
344
|
method: options.method === 'eth_sendRawTransaction' ||
|
|
345
|
-
options.method === '
|
|
345
|
+
options.method === 'account_approveRawTransaction'
|
|
346
346
|
? 'eth_sendRawTransaction'
|
|
347
347
|
: 'eth_sendRawTransactionSync',
|
|
348
348
|
params: [final, ...(options.request.params?.slice(1) ?? [])],
|
|
@@ -390,7 +390,7 @@ async function submit(options) {
|
|
|
390
390
|
current.submissionId !== submissionId)
|
|
391
391
|
throw new OperationStore.InvalidStoreValueError();
|
|
392
392
|
const { expiresAt: _, submissionId: __, ...operation } = current;
|
|
393
|
-
return
|
|
393
|
+
return AccountOperation.from({
|
|
394
394
|
...operation,
|
|
395
395
|
status: 'success',
|
|
396
396
|
transactionHash,
|
|
@@ -403,16 +403,16 @@ async function submit(options) {
|
|
|
403
403
|
if (options.method === 'eth_sendRawTransactionSync' &&
|
|
404
404
|
result &&
|
|
405
405
|
typeof result === 'object')
|
|
406
|
-
return { ...result,
|
|
406
|
+
return { ...result, operation: AccountOperation.toRpc(success) };
|
|
407
407
|
return await submittedResult(options, success);
|
|
408
408
|
}
|
|
409
|
-
/** Collects approvals for a
|
|
409
|
+
/** Collects approvals for a configurable account key authorization. @internal */
|
|
410
410
|
// biome-ignore lint/correctness/noUnusedVariables: declaration merge
|
|
411
411
|
async function approveKeyAuthorization(options) {
|
|
412
412
|
const value = options.request.params?.[0];
|
|
413
413
|
if (!value || typeof value !== 'object')
|
|
414
414
|
throw new RpcResponse.InvalidParamsError({
|
|
415
|
-
message: 'Expected a
|
|
415
|
+
message: 'Expected a configurable account key authorization approval.',
|
|
416
416
|
});
|
|
417
417
|
const approval = await (async () => {
|
|
418
418
|
if ('keyAuthorization' in value) {
|
|
@@ -422,24 +422,24 @@ async function approveKeyAuthorization(options) {
|
|
|
422
422
|
}
|
|
423
423
|
catch {
|
|
424
424
|
throw new RpcResponse.InvalidParamsError({
|
|
425
|
-
message: 'Invalid
|
|
425
|
+
message: 'Invalid configurable account key authorization.',
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
428
|
})();
|
|
429
429
|
const signature = authorization.signature;
|
|
430
|
-
if (signature?.type !== '
|
|
430
|
+
if (signature?.type !== 'configurable')
|
|
431
431
|
throw new RpcResponse.InvalidParamsError({
|
|
432
|
-
message: 'Expected a
|
|
432
|
+
message: 'Expected a configurable account key authorization signature.',
|
|
433
433
|
});
|
|
434
434
|
if (!authorization.account ||
|
|
435
435
|
!Address_.isEqual(authorization.account, signature.account))
|
|
436
436
|
throw new RpcResponse.InvalidParamsError({
|
|
437
|
-
message: '
|
|
437
|
+
message: 'Configurable account key authorization account does not match its signature.',
|
|
438
438
|
});
|
|
439
439
|
const { signature: _, ...unsigned } = authorization;
|
|
440
440
|
const keyAuthorization = KeyAuthorization.serialize(KeyAuthorization.from(unsigned));
|
|
441
|
-
const config =
|
|
442
|
-
const hash =
|
|
441
|
+
const config = AccountConfig.from(signature.config);
|
|
442
|
+
const hash = AccountOperation.getHash({
|
|
443
443
|
account: signature.account,
|
|
444
444
|
config,
|
|
445
445
|
keyAuthorization,
|
|
@@ -456,12 +456,12 @@ async function approveKeyAuthorization(options) {
|
|
|
456
456
|
if ('hash' in value && 'signature' in value) {
|
|
457
457
|
if (typeof value.hash !== 'string' || !Hash.validate(value.hash))
|
|
458
458
|
throw new RpcResponse.InvalidParamsError({
|
|
459
|
-
message: 'Expected
|
|
459
|
+
message: 'Expected an account operation hash.',
|
|
460
460
|
});
|
|
461
461
|
const operation = await OperationStore.read(options.store, value.hash);
|
|
462
462
|
if (!operation || operation.type !== 'keyAuthorization')
|
|
463
463
|
throw new RpcResponse.InvalidParamsError({
|
|
464
|
-
message: '
|
|
464
|
+
message: 'Configurable account key authorization operation was not found.',
|
|
465
465
|
});
|
|
466
466
|
if (operation.status === 'success')
|
|
467
467
|
return { operation };
|
|
@@ -471,7 +471,7 @@ async function approveKeyAuthorization(options) {
|
|
|
471
471
|
}
|
|
472
472
|
catch {
|
|
473
473
|
throw new RpcResponse.InvalidParamsError({
|
|
474
|
-
message: 'Invalid
|
|
474
|
+
message: 'Invalid owner signature.',
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
})();
|
|
@@ -484,14 +484,14 @@ async function approveKeyAuthorization(options) {
|
|
|
484
484
|
};
|
|
485
485
|
}
|
|
486
486
|
throw new RpcResponse.InvalidParamsError({
|
|
487
|
-
message: 'Expected a
|
|
487
|
+
message: 'Expected a configurable account key authorization approval.',
|
|
488
488
|
});
|
|
489
489
|
})();
|
|
490
490
|
if ('operation' in approval)
|
|
491
|
-
return
|
|
491
|
+
return AccountOperation.toRpc(approval.operation);
|
|
492
492
|
if (approval.approvals.length === 0)
|
|
493
493
|
throw new RpcResponse.InvalidParamsError({
|
|
494
|
-
message: 'A
|
|
494
|
+
message: 'A owner approval envelope must include a signature.',
|
|
495
495
|
});
|
|
496
496
|
const blockNumber = await getBlockNumber(options.client, { cacheTime: 0 });
|
|
497
497
|
const commitment = await validateConfig({
|
|
@@ -508,8 +508,8 @@ async function approveKeyAuthorization(options) {
|
|
|
508
508
|
return existing;
|
|
509
509
|
if (existing &&
|
|
510
510
|
(existing.account.toLowerCase() !== approval.account.toLowerCase() ||
|
|
511
|
-
|
|
512
|
-
|
|
511
|
+
AccountConfig.getCommitment(existing.config).toLowerCase() !==
|
|
512
|
+
AccountConfig.getCommitment(approval.config).toLowerCase() ||
|
|
513
513
|
existing.keyAuthorization.toLowerCase() !==
|
|
514
514
|
approval.keyAuthorization.toLowerCase()))
|
|
515
515
|
throw new OperationStore.InvalidStoreValueError();
|
|
@@ -548,10 +548,10 @@ async function approveKeyAuthorization(options) {
|
|
|
548
548
|
weight: approvals.weight,
|
|
549
549
|
};
|
|
550
550
|
if (approvals.weight < approvals.threshold)
|
|
551
|
-
return
|
|
552
|
-
return
|
|
551
|
+
return AccountOperation.from({ ...pending, status: 'pending' });
|
|
552
|
+
return AccountOperation.from({
|
|
553
553
|
...pending,
|
|
554
|
-
keyAuthorization:
|
|
554
|
+
keyAuthorization: AccountOperation.serializeKeyAuthorization(approval.keyAuthorization, {
|
|
555
555
|
account: approval.account,
|
|
556
556
|
approvals: approvals.selectedApprovals,
|
|
557
557
|
config: approval.config,
|
|
@@ -566,7 +566,7 @@ async function approveKeyAuthorization(options) {
|
|
|
566
566
|
});
|
|
567
567
|
if (operation.type !== 'keyAuthorization')
|
|
568
568
|
throw new OperationStore.InvalidStoreValueError();
|
|
569
|
-
return
|
|
569
|
+
return AccountOperation.toRpc(operation);
|
|
570
570
|
}
|
|
571
571
|
/** Deserializes a Tempo transaction or throws an RPC parameter error. */
|
|
572
572
|
function deserialize(serialized) {
|
|
@@ -583,22 +583,22 @@ function deserialize(serialized) {
|
|
|
583
583
|
function assertConfig(options) {
|
|
584
584
|
const { account, commitment, config } = options;
|
|
585
585
|
if (config.version === 0n &&
|
|
586
|
-
|
|
586
|
+
AccountConfig.getAddress(config, {
|
|
587
587
|
factory: Addresses.nativeMultisigFactory,
|
|
588
588
|
}).toLowerCase() !== account.toLowerCase())
|
|
589
589
|
throw new RpcResponse.InvalidParamsError({
|
|
590
|
-
message: 'Initial
|
|
590
|
+
message: 'Initial account config does not match the configurable account.',
|
|
591
591
|
});
|
|
592
592
|
if (config.version === 0n && Hex.toBigInt(commitment) === 0n)
|
|
593
593
|
return;
|
|
594
594
|
if (commitment.toLowerCase() !==
|
|
595
|
-
|
|
595
|
+
AccountConfig.getCommitment(config).toLowerCase())
|
|
596
596
|
throw new RpcResponse.InvalidParamsError({
|
|
597
|
-
message: `
|
|
597
|
+
message: `Account config does not match account ${account}.`,
|
|
598
598
|
});
|
|
599
599
|
}
|
|
600
|
-
/** Reads and validates a config commitment at one block. */
|
|
601
|
-
async function validateConfig(options) {
|
|
600
|
+
/** Reads and validates a config commitment at one block. @internal */
|
|
601
|
+
export async function validateConfig(options) {
|
|
602
602
|
const { account, blockNumber, client, config } = options;
|
|
603
603
|
const commitment = await getConfigCommitment(client, {
|
|
604
604
|
account,
|
|
@@ -635,24 +635,19 @@ async function cacheNextConfigs(options) {
|
|
|
635
635
|
const [current, threshold, owners] = decoded.args;
|
|
636
636
|
const suppliedConfig = (() => {
|
|
637
637
|
try {
|
|
638
|
-
return
|
|
638
|
+
return AccountConfig.from(current);
|
|
639
639
|
}
|
|
640
640
|
catch {
|
|
641
641
|
return undefined;
|
|
642
642
|
}
|
|
643
643
|
})();
|
|
644
644
|
if (!suppliedConfig ||
|
|
645
|
-
|
|
646
|
-
|
|
645
|
+
AccountConfig.getCommitment(suppliedConfig).toLowerCase() !==
|
|
646
|
+
AccountConfig.getCommitment(currentConfig).toLowerCase())
|
|
647
647
|
continue;
|
|
648
648
|
const config = (() => {
|
|
649
649
|
try {
|
|
650
|
-
return
|
|
651
|
-
owners,
|
|
652
|
-
salt: suppliedConfig.salt,
|
|
653
|
-
threshold,
|
|
654
|
-
version: suppliedConfig.version + 1n,
|
|
655
|
-
});
|
|
650
|
+
return AccountConfig.update(suppliedConfig, { owners, threshold });
|
|
656
651
|
}
|
|
657
652
|
catch {
|
|
658
653
|
return undefined;
|
|
@@ -662,19 +657,19 @@ async function cacheNextConfigs(options) {
|
|
|
662
657
|
continue;
|
|
663
658
|
await ConfigStore.write(options.store, {
|
|
664
659
|
address: options.account,
|
|
665
|
-
commitment:
|
|
660
|
+
commitment: AccountConfig.getCommitment(config),
|
|
666
661
|
config,
|
|
667
662
|
});
|
|
668
663
|
currentConfig = config;
|
|
669
664
|
}
|
|
670
665
|
}
|
|
671
|
-
/** Validates primitive approvals and translates invalid input into an RPC error. */
|
|
672
|
-
async function selectApprovals(options) {
|
|
666
|
+
/** Validates primitive approvals and translates invalid input into an RPC error. @internal */
|
|
667
|
+
export async function selectApprovals(options) {
|
|
673
668
|
try {
|
|
674
|
-
return await
|
|
669
|
+
return await AccountOperation.selectApprovals(options);
|
|
675
670
|
}
|
|
676
671
|
catch (error) {
|
|
677
|
-
if (error instanceof
|
|
672
|
+
if (error instanceof AccountOperation.InvalidApprovalError)
|
|
678
673
|
throw new RpcResponse.InvalidParamsError({ message: error.shortMessage });
|
|
679
674
|
throw error;
|
|
680
675
|
}
|
|
@@ -682,10 +677,10 @@ async function selectApprovals(options) {
|
|
|
682
677
|
/** Returns an existing successful operation through the requested send method. */
|
|
683
678
|
async function submittedResult(options, operation) {
|
|
684
679
|
if (options.method === 'eth_sendRawTransaction' ||
|
|
685
|
-
options.method === '
|
|
680
|
+
options.method === 'account_approveRawTransaction')
|
|
686
681
|
return operation.hash;
|
|
687
|
-
if (options.method === '
|
|
688
|
-
return
|
|
682
|
+
if (options.method === 'account_approveRawTransactionSync')
|
|
683
|
+
return AccountOperation.toRpc(operation);
|
|
689
684
|
const timeout = options.request.params?.[1];
|
|
690
685
|
const deadline = Date.now() +
|
|
691
686
|
(typeof timeout === 'number' && timeout >= 0 ? timeout : submissionTtl);
|
|
@@ -695,16 +690,16 @@ async function submittedResult(options, operation) {
|
|
|
695
690
|
params: [operation.transactionHash],
|
|
696
691
|
}, options.requestOptions);
|
|
697
692
|
if (receipt && typeof receipt === 'object')
|
|
698
|
-
return { ...receipt,
|
|
693
|
+
return { ...receipt, operation: AccountOperation.toRpc(operation) };
|
|
699
694
|
if (Date.now() >= deadline)
|
|
700
|
-
throw new Error('Timed out while waiting for the
|
|
695
|
+
throw new Error('Timed out while waiting for the configurable account transaction.');
|
|
701
696
|
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
702
697
|
}
|
|
703
698
|
}
|
|
704
699
|
/** Waits for the relay that owns a live submission lease. */
|
|
705
700
|
async function submittingResult(options, operation) {
|
|
706
701
|
if (options.method === 'eth_sendRawTransaction' ||
|
|
707
|
-
options.method === '
|
|
702
|
+
options.method === 'account_approveRawTransaction')
|
|
708
703
|
return operation.hash;
|
|
709
704
|
const timeout = options.request.params?.[1];
|
|
710
705
|
const deadline = Date.now() +
|
|
@@ -725,10 +720,10 @@ async function submittingResult(options, operation) {
|
|
|
725
720
|
/** Returns a pending result for an operation that has not reached quorum. */
|
|
726
721
|
function pendingResult(method, operation) {
|
|
727
722
|
if (method === 'eth_sendRawTransaction' ||
|
|
728
|
-
method === '
|
|
723
|
+
method === 'account_approveRawTransaction')
|
|
729
724
|
return operation.hash;
|
|
730
|
-
if (method === '
|
|
731
|
-
return
|
|
725
|
+
if (method === 'account_approveRawTransactionSync')
|
|
726
|
+
return AccountOperation.toRpc(operation);
|
|
732
727
|
return {
|
|
733
728
|
blockHash: null,
|
|
734
729
|
blockNumber: null,
|
|
@@ -739,7 +734,7 @@ function pendingResult(method, operation) {
|
|
|
739
734
|
gasUsed: null,
|
|
740
735
|
logs: [],
|
|
741
736
|
logsBloom: null,
|
|
742
|
-
|
|
737
|
+
operation: AccountOperation.toRpc(operation),
|
|
743
738
|
status: 'pending',
|
|
744
739
|
to: null,
|
|
745
740
|
transactionHash: operation.hash,
|
|
@@ -764,7 +759,7 @@ async function completeSubmission(store, operation, transactionHash) {
|
|
|
764
759
|
current.submissionId !== operation.submissionId)
|
|
765
760
|
throw new OperationStore.InvalidStoreValueError();
|
|
766
761
|
const { expiresAt: _, submissionId: __, transactionHash: ___, ...value } = current;
|
|
767
|
-
return
|
|
762
|
+
return AccountOperation.from({
|
|
768
763
|
...value,
|
|
769
764
|
status: 'success',
|
|
770
765
|
transactionHash,
|
|
@@ -783,7 +778,7 @@ async function releaseSubmission(store, hash, submissionId) {
|
|
|
783
778
|
current.submissionId !== submissionId)
|
|
784
779
|
return current;
|
|
785
780
|
const { expiresAt: _, submissionId: __, ...operation } = current;
|
|
786
|
-
return
|
|
781
|
+
return AccountOperation.from({
|
|
787
782
|
...operation,
|
|
788
783
|
status: 'pending',
|
|
789
784
|
updatedAt: Date.now(),
|
|
@@ -816,7 +811,7 @@ function mergeTransaction(existing, incoming) {
|
|
|
816
811
|
async function toTransaction(client, operation) {
|
|
817
812
|
const approvals = await (async () => {
|
|
818
813
|
if (operation.status !== 'pending')
|
|
819
|
-
return await
|
|
814
|
+
return await AccountOperation.selectApprovals({
|
|
820
815
|
account: operation.account,
|
|
821
816
|
approvals: operation.approvals,
|
|
822
817
|
config: operation.config,
|
|
@@ -837,7 +832,7 @@ async function toTransaction(client, operation) {
|
|
|
837
832
|
});
|
|
838
833
|
})();
|
|
839
834
|
const current = operation.status === 'pending'
|
|
840
|
-
?
|
|
835
|
+
? AccountOperation.from({
|
|
841
836
|
...operation,
|
|
842
837
|
approvals: approvals.approvals,
|
|
843
838
|
signatureCount: approvals.signatureCount,
|
|
@@ -845,7 +840,7 @@ async function toTransaction(client, operation) {
|
|
|
845
840
|
weight: approvals.weight,
|
|
846
841
|
})
|
|
847
842
|
: operation;
|
|
848
|
-
const serialized =
|
|
843
|
+
const serialized = AccountOperation.serializeTransaction(current, {
|
|
849
844
|
approvals: approvals.selectedApprovals,
|
|
850
845
|
});
|
|
851
846
|
const transaction = deserialize(serialized);
|
|
@@ -858,7 +853,7 @@ async function toTransaction(client, operation) {
|
|
|
858
853
|
hash: operation.hash,
|
|
859
854
|
transactionIndex: null,
|
|
860
855
|
}, { pending: true }),
|
|
861
|
-
|
|
856
|
+
operation: AccountOperation.toRpc(current),
|
|
862
857
|
};
|
|
863
858
|
}
|
|
864
859
|
/** Returns the persisted transaction hash for a submitting or successful operation. */
|
|
@@ -885,7 +880,7 @@ function maintainSubmissionLease(store, hash, submissionId, leaseTtl) {
|
|
|
885
880
|
if (current.status !== 'submitting' ||
|
|
886
881
|
current.submissionId !== submissionId)
|
|
887
882
|
return current;
|
|
888
|
-
return
|
|
883
|
+
return AccountOperation.from({
|
|
889
884
|
...current,
|
|
890
885
|
expiresAt: Math.min(Date.now() + leaseTtl, Number.MAX_SAFE_INTEGER),
|
|
891
886
|
updatedAt: Date.now(),
|
|
@@ -927,7 +922,7 @@ function getTransactionHash(result) {
|
|
|
927
922
|
typeof result.transactionHash === 'string' &&
|
|
928
923
|
Hash.validate(result.transactionHash))
|
|
929
924
|
return result.transactionHash;
|
|
930
|
-
throw new Error('Expected transaction hash in
|
|
925
|
+
throw new Error('Expected transaction hash in account broadcast result.');
|
|
931
926
|
}
|
|
932
927
|
/** Resolves and validates the chain used by a handled request. */
|
|
933
928
|
async function resolveRequestOptions(options) {
|
|
@@ -956,11 +951,11 @@ async function resolveRequestChainId(request, store) {
|
|
|
956
951
|
const chainId_body = value && typeof value === 'object' && 'chainId' in value
|
|
957
952
|
? parseChainId(value.chainId)
|
|
958
953
|
: undefined;
|
|
959
|
-
const
|
|
954
|
+
const chainId_operation = await (async () => {
|
|
960
955
|
if (request.method === 'eth_sendRawTransaction' ||
|
|
961
956
|
request.method === 'eth_sendRawTransactionSync' ||
|
|
962
|
-
request.method === '
|
|
963
|
-
request.method === '
|
|
957
|
+
request.method === 'account_approveRawTransaction' ||
|
|
958
|
+
request.method === 'account_approveRawTransactionSync') {
|
|
964
959
|
if (!isSerializedTempoTransaction(value))
|
|
965
960
|
return undefined;
|
|
966
961
|
try {
|
|
@@ -971,7 +966,7 @@ async function resolveRequestChainId(request, store) {
|
|
|
971
966
|
return undefined;
|
|
972
967
|
}
|
|
973
968
|
}
|
|
974
|
-
if (request.method === '
|
|
969
|
+
if (request.method === 'account_approveKeyAuthorization' &&
|
|
975
970
|
value &&
|
|
976
971
|
typeof value === 'object' &&
|
|
977
972
|
'keyAuthorization' in value) {
|
|
@@ -986,7 +981,7 @@ async function resolveRequestChainId(request, store) {
|
|
|
986
981
|
if (request.method === 'eth_getTransactionByHash' ||
|
|
987
982
|
request.method === 'eth_getTransactionReceipt')
|
|
988
983
|
return value;
|
|
989
|
-
if (request.method === '
|
|
984
|
+
if (request.method === 'account_approveKeyAuthorization' &&
|
|
990
985
|
value &&
|
|
991
986
|
typeof value === 'object' &&
|
|
992
987
|
'hash' in value)
|
|
@@ -1003,12 +998,12 @@ async function resolveRequestChainId(request, store) {
|
|
|
1003
998
|
return parseChainId(KeyAuthorization.deserialize(operation.keyAuthorization).chainId);
|
|
1004
999
|
})();
|
|
1005
1000
|
if (chainId_body !== undefined &&
|
|
1006
|
-
|
|
1007
|
-
chainId_body !==
|
|
1001
|
+
chainId_operation !== undefined &&
|
|
1002
|
+
chainId_body !== chainId_operation)
|
|
1008
1003
|
throw new RpcResponse.InvalidParamsError({
|
|
1009
1004
|
message: 'Conflicting chain ids.',
|
|
1010
1005
|
});
|
|
1011
|
-
return chainId_body ??
|
|
1006
|
+
return chainId_body ?? chainId_operation;
|
|
1012
1007
|
}
|
|
1013
1008
|
/** Parses a supported chain ID representation. */
|
|
1014
1009
|
function parseChainId(value) {
|
|
@@ -1036,4 +1031,4 @@ function isSerializedTempoTransaction(value) {
|
|
|
1036
1031
|
return (typeof value === 'string' &&
|
|
1037
1032
|
(value.startsWith('0x76') || value.startsWith('0x78')));
|
|
1038
1033
|
}
|
|
1039
|
-
//# sourceMappingURL=
|
|
1034
|
+
//# sourceMappingURL=accounts.js.map
|