@aztec/wallet-sdk 5.0.0-private.20260319 → 5.0.0-rc.2
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/README.md +125 -0
- package/dest/base-wallet/base_wallet.d.ts +65 -40
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +196 -80
- package/dest/base-wallet/get_gas_limits.d.ts +36 -0
- package/dest/base-wallet/get_gas_limits.d.ts.map +1 -0
- package/dest/base-wallet/get_gas_limits.js +55 -0
- package/dest/base-wallet/index.d.ts +3 -2
- package/dest/base-wallet/index.d.ts.map +1 -1
- package/dest/base-wallet/index.js +1 -0
- package/dest/base-wallet/utils.d.ts +7 -4
- package/dest/base-wallet/utils.d.ts.map +1 -1
- package/dest/base-wallet/utils.js +11 -5
- package/dest/crypto.d.ts +39 -1
- package/dest/crypto.d.ts.map +1 -1
- package/dest/crypto.js +88 -0
- package/dest/extension/handlers/background_connection_handler.d.ts +12 -2
- package/dest/extension/handlers/background_connection_handler.d.ts.map +1 -1
- package/dest/extension/handlers/background_connection_handler.js +44 -8
- package/dest/extension/handlers/content_script_connection_handler.d.ts +2 -1
- package/dest/extension/handlers/content_script_connection_handler.d.ts.map +1 -1
- package/dest/extension/handlers/content_script_connection_handler.js +19 -0
- package/dest/extension/handlers/internal_message_types.d.ts +3 -1
- package/dest/extension/handlers/internal_message_types.d.ts.map +1 -1
- package/dest/extension/handlers/internal_message_types.js +3 -1
- package/dest/extension/provider/extension_wallet.d.ts +26 -6
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -1
- package/dest/extension/provider/extension_wallet.js +80 -9
- package/dest/extension/provider/index.d.ts +2 -2
- package/dest/extension/provider/index.d.ts.map +1 -1
- package/dest/iframe/handlers/iframe_connection_handler.d.ts +122 -0
- package/dest/iframe/handlers/iframe_connection_handler.d.ts.map +1 -0
- package/dest/iframe/handlers/iframe_connection_handler.js +239 -0
- package/dest/iframe/handlers/index.d.ts +2 -0
- package/dest/iframe/handlers/index.d.ts.map +1 -0
- package/dest/iframe/handlers/index.js +1 -0
- package/dest/iframe/provider/iframe_discovery.d.ts +25 -0
- package/dest/iframe/provider/iframe_discovery.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_discovery.js +167 -0
- package/dest/iframe/provider/iframe_provider.d.ts +65 -0
- package/dest/iframe/provider/iframe_provider.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_provider.js +257 -0
- package/dest/iframe/provider/iframe_wallet.d.ts +85 -0
- package/dest/iframe/provider/iframe_wallet.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_wallet.js +269 -0
- package/dest/iframe/provider/index.d.ts +4 -0
- package/dest/iframe/provider/index.d.ts.map +1 -0
- package/dest/iframe/provider/index.js +3 -0
- package/dest/manager/types.d.ts +3 -2
- package/dest/manager/types.d.ts.map +1 -1
- package/dest/manager/wallet_manager.d.ts +1 -1
- package/dest/manager/wallet_manager.d.ts.map +1 -1
- package/dest/manager/wallet_manager.js +46 -16
- package/dest/types.d.ts +64 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +29 -0
- package/package.json +12 -8
- package/src/base-wallet/base_wallet.ts +257 -125
- package/src/base-wallet/get_gas_limits.ts +88 -0
- package/src/base-wallet/index.ts +7 -1
- package/src/base-wallet/utils.ts +15 -5
- package/src/crypto.ts +104 -0
- package/src/extension/handlers/background_connection_handler.ts +42 -9
- package/src/extension/handlers/content_script_connection_handler.ts +18 -0
- package/src/extension/handlers/internal_message_types.ts +2 -0
- package/src/extension/provider/extension_wallet.ts +94 -13
- package/src/extension/provider/index.ts +1 -1
- package/src/iframe/handlers/iframe_connection_handler.ts +341 -0
- package/src/iframe/handlers/index.ts +7 -0
- package/src/iframe/provider/iframe_discovery.ts +185 -0
- package/src/iframe/provider/iframe_provider.ts +331 -0
- package/src/iframe/provider/iframe_wallet.ts +323 -0
- package/src/iframe/provider/index.ts +3 -0
- package/src/manager/types.ts +2 -1
- package/src/manager/wallet_manager.ts +48 -14
- package/src/types.ts +72 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
1
2
|
import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
|
-
import {
|
|
4
|
+
import { ContractInitializationStatus, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
4
5
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
6
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
5
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
9
|
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
@@ -9,10 +11,11 @@ import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
|
9
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
12
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
11
13
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
12
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
13
|
-
import { computeSiloedPrivateInitializationNullifier } from '@aztec/stdlib/hash';
|
|
14
|
+
import { Gas, GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
15
|
+
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
|
|
14
16
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
15
17
|
import { inspect } from 'util';
|
|
18
|
+
import { assertGasLimitsWithinNetworkLimits } from './get_gas_limits.js';
|
|
16
19
|
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
17
20
|
/**
|
|
18
21
|
* A base class for Wallet implementations
|
|
@@ -22,6 +25,9 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
22
25
|
log;
|
|
23
26
|
minFeePadding;
|
|
24
27
|
cancellableTransactions;
|
|
28
|
+
// A wallet is instantiated for a particular chain, so chain info never changes during its lifetime.
|
|
29
|
+
// We cache it here because getChainInfo is called frequently (every tx simulation, send, auth wit, etc.).
|
|
30
|
+
nodeInfoPromise;
|
|
25
31
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
26
32
|
constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
|
|
27
33
|
this.pxe = pxe;
|
|
@@ -31,14 +37,23 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
31
37
|
this.cancellableTransactions = false;
|
|
32
38
|
}
|
|
33
39
|
scopesFrom(from, additionalScopes = []) {
|
|
34
|
-
const allScopes = from
|
|
40
|
+
const allScopes = from === NO_FROM ? additionalScopes : [
|
|
35
41
|
from,
|
|
36
42
|
...additionalScopes
|
|
37
43
|
];
|
|
38
44
|
const scopeSet = new Set(allScopes.map((address)=>address.toString()));
|
|
39
45
|
return [
|
|
40
46
|
...scopeSet
|
|
41
|
-
].map(AztecAddress.
|
|
47
|
+
].map(AztecAddress.fromStringUnsafe);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Picks the sender address PXE should tag private messages with. Returns `undefined` when there is no signing
|
|
51
|
+
* account (`from === NO_FROM`) and no explicit override; in that case any private log emitted by the tx using
|
|
52
|
+
* the wallet-supplied default sender will fail the "Sender for tags is not set" assertion.
|
|
53
|
+
* @param from - Tx sender, or `NO_FROM`.
|
|
54
|
+
* @param sendMessagesAs - Explicit override.
|
|
55
|
+
*/ senderForTagsFrom(from, sendMessagesAs) {
|
|
56
|
+
return sendMessagesAs ?? (from === NO_FROM ? undefined : from);
|
|
42
57
|
}
|
|
43
58
|
/**
|
|
44
59
|
* Returns the list of aliased contacts associated with the wallet.
|
|
@@ -47,33 +62,64 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
47
62
|
* - Contacts: more general concept akin to a phone's contact list.
|
|
48
63
|
* @returns The aliased collection of AztecAddresses that form this wallet's address book
|
|
49
64
|
*/ async getAddressBook() {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
const sources = await this.pxe.getTaggingSecretSources({
|
|
66
|
+
kind: 'address-derived'
|
|
67
|
+
});
|
|
68
|
+
return sources.map((source)=>({
|
|
69
|
+
item: source.sender,
|
|
53
70
|
alias: ''
|
|
54
71
|
}));
|
|
55
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Fetches and caches the node info for the wallet's lifetime, since a wallet talks to a single network and
|
|
75
|
+
* node info never changes. A rejected fetch clears the cache so the next call retries instead of replaying
|
|
76
|
+
* the cached rejection forever — important because the gas-limit fill-in and validation (run on every send)
|
|
77
|
+
* depend on it.
|
|
78
|
+
*/ getNodeInfo() {
|
|
79
|
+
if (!this.nodeInfoPromise) {
|
|
80
|
+
this.nodeInfoPromise = this.aztecNode.getNodeInfo().catch((err)=>{
|
|
81
|
+
this.nodeInfoPromise = undefined;
|
|
82
|
+
throw err;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return this.nodeInfoPromise;
|
|
86
|
+
}
|
|
56
87
|
async getChainInfo() {
|
|
57
|
-
const { l1ChainId, rollupVersion } = await this.
|
|
88
|
+
const { l1ChainId, rollupVersion } = await this.getNodeInfo();
|
|
58
89
|
return {
|
|
59
90
|
chainId: new Fr(l1ChainId),
|
|
60
91
|
version: new Fr(rollupVersion)
|
|
61
92
|
};
|
|
62
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns the maximum gas limits a single transaction may declare on this wallet's network (the
|
|
96
|
+
* node-advertised `txsLimits.gas`). Internal helper used to fill in default gas limits when sending a
|
|
97
|
+
* transaction without explicit limits, and to validate caller-provided limits before sending. Backed by
|
|
98
|
+
* the cached node info, since a wallet talks to a single network.
|
|
99
|
+
*/ async getMaxTxGasLimits() {
|
|
100
|
+
const { txsLimits } = await this.getNodeInfo();
|
|
101
|
+
return new Gas(txsLimits.gas.daGas, txsLimits.gas.l2Gas);
|
|
102
|
+
}
|
|
63
103
|
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
64
104
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
65
|
-
const executionOptions = {
|
|
66
|
-
txNonce: Fr.random(),
|
|
67
|
-
cancellable: this.cancellableTransactions,
|
|
68
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
69
|
-
};
|
|
70
105
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
71
106
|
feeExecutionPayload,
|
|
72
107
|
executionPayload
|
|
73
108
|
]) : executionPayload;
|
|
74
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
75
109
|
const chainInfo = await this.getChainInfo();
|
|
76
|
-
|
|
110
|
+
if (from === NO_FROM) {
|
|
111
|
+
const entrypoint = new DefaultEntrypoint();
|
|
112
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
113
|
+
} else {
|
|
114
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
115
|
+
const executionOptions = {
|
|
116
|
+
txNonce: Fr.random(),
|
|
117
|
+
cancellable: this.cancellableTransactions,
|
|
118
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
119
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
120
|
+
};
|
|
121
|
+
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
122
|
+
}
|
|
77
123
|
}
|
|
78
124
|
async createAuthWit(from, messageHashOrIntent) {
|
|
79
125
|
const account = await this.getAccountFromAddress(from);
|
|
@@ -116,26 +162,50 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
116
162
|
}
|
|
117
163
|
/**
|
|
118
164
|
* Completes partial user-provided fee options with wallet defaults.
|
|
119
|
-
* @param
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
124
|
-
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
165
|
+
* @param config - Fee completion config.
|
|
166
|
+
*/ async completeFeeOptions(config) {
|
|
167
|
+
const { from, feePayer, gasSettings, forEstimation, congestionEstimate } = config;
|
|
168
|
+
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.getMinFees(congestionEstimate)).mul(1 + this.minFeePadding);
|
|
125
169
|
let accountFeePaymentMethodOptions;
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
if (
|
|
129
|
-
|
|
170
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
171
|
+
// account contract entrypoint to use
|
|
172
|
+
if (from !== NO_FROM) {
|
|
173
|
+
if (!feePayer) {
|
|
174
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
175
|
+
// for the account to use its fee juice balance
|
|
176
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
177
|
+
} else {
|
|
178
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
179
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
180
|
+
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const gasSettingsOverrides = {
|
|
184
|
+
gasLimits: gasSettings?.gasLimits ? Gas.from(gasSettings.gasLimits) : undefined,
|
|
185
|
+
teardownGasLimits: gasSettings?.teardownGasLimits ? Gas.from(gasSettings.teardownGasLimits) : undefined,
|
|
186
|
+
maxFeesPerGas,
|
|
187
|
+
maxPriorityFeesPerGas: gasSettings?.maxPriorityFeesPerGas ?? GasFees.empty()
|
|
188
|
+
};
|
|
189
|
+
// When estimating gas (simulation), use high limits so the simulation doesn't run out of gas.
|
|
190
|
+
// When sending for real without explicit limits, declare the most a single tx may use on this network
|
|
191
|
+
// (the node's per-tx admission limit), so the proposer does not skip the tx for over-declaring gas.
|
|
192
|
+
let fullGasSettings;
|
|
193
|
+
if (forEstimation) {
|
|
194
|
+
// Estimation deliberately uses very high internal limits and skips tx validation, so we do not
|
|
195
|
+
// validate against the network admission limit here.
|
|
196
|
+
fullGasSettings = GasSettings.forEstimation(gasSettingsOverrides);
|
|
130
197
|
} else {
|
|
131
|
-
|
|
132
|
-
//
|
|
133
|
-
|
|
198
|
+
const maxTxGasLimits = await this.getMaxTxGasLimits();
|
|
199
|
+
// If the caller declared explicit gas limits, reject them up front when they exceed the network's
|
|
200
|
+
// per-tx admission limit (mirroring the node's GasLimitsValidator). Otherwise fill in the limit.
|
|
201
|
+
if (gasSettingsOverrides.gasLimits) {
|
|
202
|
+
assertGasLimitsWithinNetworkLimits(gasSettingsOverrides.gasLimits, maxTxGasLimits);
|
|
203
|
+
}
|
|
204
|
+
fullGasSettings = GasSettings.fallback({
|
|
205
|
+
...gasSettingsOverrides,
|
|
206
|
+
gasLimits: gasSettingsOverrides.gasLimits ?? maxTxGasLimits
|
|
207
|
+
});
|
|
134
208
|
}
|
|
135
|
-
const fullGasSettings = GasSettings.default({
|
|
136
|
-
...gasSettings,
|
|
137
|
-
maxFeesPerGas
|
|
138
|
-
});
|
|
139
209
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
140
210
|
return {
|
|
141
211
|
gasSettings: fullGasSettings,
|
|
@@ -144,25 +214,31 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
144
214
|
};
|
|
145
215
|
}
|
|
146
216
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* to
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
217
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
218
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
219
|
+
* @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
|
|
220
|
+
*/ async getMinFees(estimate = ManaUsageEstimate.Limit) {
|
|
221
|
+
try {
|
|
222
|
+
const predicted = await this.aztecNode.getPredictedMinFees(estimate);
|
|
223
|
+
if (predicted.length === 0) {
|
|
224
|
+
return this.aztecNode.getCurrentMinFees();
|
|
225
|
+
}
|
|
226
|
+
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
227
|
+
} catch (err) {
|
|
228
|
+
// Fallback for old nodes that don't support getPredictedMinFees.
|
|
229
|
+
// Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
|
|
230
|
+
if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
|
|
231
|
+
return this.aztecNode.getCurrentMinFees();
|
|
232
|
+
}
|
|
233
|
+
throw err;
|
|
234
|
+
}
|
|
163
235
|
}
|
|
164
|
-
registerSender(address, _alias = '') {
|
|
165
|
-
|
|
236
|
+
async registerSender(address, _alias = '') {
|
|
237
|
+
await this.pxe.registerTaggingSecretSource({
|
|
238
|
+
kind: 'address-derived',
|
|
239
|
+
sender: address
|
|
240
|
+
});
|
|
241
|
+
return address;
|
|
166
242
|
}
|
|
167
243
|
async registerContract(instance, artifact, secretKey) {
|
|
168
244
|
const existingInstance = await this.pxe.getContractInstance(instance.address);
|
|
@@ -196,18 +272,37 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
196
272
|
}
|
|
197
273
|
return instance;
|
|
198
274
|
}
|
|
275
|
+
registerContractClass(artifact) {
|
|
276
|
+
return this.pxe.registerContractClass(artifact);
|
|
277
|
+
}
|
|
199
278
|
/**
|
|
200
279
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
201
280
|
* @param executionPayload - The execution payload to simulate.
|
|
202
281
|
* @param opts - Simulation options.
|
|
203
282
|
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
204
283
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
205
|
-
|
|
284
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
206
285
|
simulatePublic: true,
|
|
207
286
|
skipTxValidation: opts.skipTxValidation,
|
|
208
287
|
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
209
|
-
scopes: opts.
|
|
288
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
289
|
+
senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs),
|
|
290
|
+
overrides: opts.overrides
|
|
210
291
|
});
|
|
292
|
+
const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
|
|
293
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
297
|
+
* calls, N+1 = app).
|
|
298
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
299
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
300
|
+
*/ async computeAppCallOffset(from, feeOptions) {
|
|
301
|
+
if (from === NO_FROM) {
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
305
|
+
return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
|
|
211
306
|
}
|
|
212
307
|
/**
|
|
213
308
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
@@ -217,7 +312,13 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
217
312
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
218
313
|
* @returns The merged simulation result.
|
|
219
314
|
*/ async simulateTx(executionPayload, opts) {
|
|
220
|
-
const feeOptions =
|
|
315
|
+
const feeOptions = await this.completeFeeOptions({
|
|
316
|
+
from: opts.from,
|
|
317
|
+
feePayer: executionPayload.feePayer,
|
|
318
|
+
gasSettings: opts.fee?.gasSettings,
|
|
319
|
+
forEstimation: true,
|
|
320
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
321
|
+
});
|
|
221
322
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
222
323
|
const remainingPayload = {
|
|
223
324
|
...executionPayload,
|
|
@@ -230,37 +331,54 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
230
331
|
try {
|
|
231
332
|
blockHeader = await this.pxe.getSyncedBlockHeader();
|
|
232
333
|
} catch {
|
|
233
|
-
blockHeader = await this.aztecNode.
|
|
334
|
+
blockHeader = (await this.aztecNode.getBlockData('latest')).header;
|
|
234
335
|
}
|
|
336
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
235
337
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
236
|
-
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls,
|
|
338
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this), opts.overrides) : Promise.resolve([]),
|
|
237
339
|
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
238
340
|
from: opts.from,
|
|
239
341
|
feeOptions,
|
|
240
|
-
|
|
342
|
+
additionalScopes: opts.additionalScopes,
|
|
241
343
|
skipTxValidation: opts.skipTxValidation,
|
|
242
|
-
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
344
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
|
|
345
|
+
sendMessagesAs: opts.sendMessagesAs,
|
|
346
|
+
overrides: opts.overrides
|
|
243
347
|
}) : Promise.resolve(null)
|
|
244
348
|
]);
|
|
245
349
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
246
350
|
}
|
|
247
351
|
async profileTx(executionPayload, opts) {
|
|
248
|
-
const feeOptions = await this.completeFeeOptions(
|
|
352
|
+
const feeOptions = await this.completeFeeOptions({
|
|
353
|
+
from: opts.from,
|
|
354
|
+
feePayer: executionPayload.feePayer,
|
|
355
|
+
gasSettings: opts.fee?.gasSettings,
|
|
356
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
357
|
+
});
|
|
249
358
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
250
359
|
return this.pxe.profileTx(txRequest, {
|
|
251
360
|
profileMode: opts.profileMode,
|
|
252
361
|
skipProofGeneration: opts.skipProofGeneration ?? true,
|
|
253
|
-
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
362
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
363
|
+
senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs)
|
|
254
364
|
});
|
|
255
365
|
}
|
|
256
366
|
async sendTx(executionPayload, opts) {
|
|
257
|
-
const feeOptions = await this.completeFeeOptions(
|
|
367
|
+
const feeOptions = await this.completeFeeOptions({
|
|
368
|
+
from: opts.from,
|
|
369
|
+
feePayer: executionPayload.feePayer,
|
|
370
|
+
gasSettings: opts.fee?.gasSettings,
|
|
371
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
372
|
+
});
|
|
258
373
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
259
|
-
const provenTx = await this.pxe.proveTx(txRequest,
|
|
374
|
+
const provenTx = await this.pxe.proveTx(txRequest, {
|
|
375
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
376
|
+
senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs)
|
|
377
|
+
});
|
|
260
378
|
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
261
379
|
const tx = await provenTx.toTx();
|
|
262
380
|
const txHash = tx.getTxHash();
|
|
263
|
-
if (await this.aztecNode.
|
|
381
|
+
if ((await this.aztecNode.getTxReceipt(txHash)).isMined()) {
|
|
264
382
|
throw new Error(`A settled tx with equal hash ${txHash.toString()} exists.`);
|
|
265
383
|
}
|
|
266
384
|
this.log.debug(`Sending transaction ${txHash}`);
|
|
@@ -279,7 +397,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
279
397
|
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
280
398
|
const receipt = await waitForTx(this.aztecNode, txHash, waitOpts);
|
|
281
399
|
// Display debug logs from public execution if present (served in test mode only)
|
|
282
|
-
if (receipt.debugLogs?.length) {
|
|
400
|
+
if (receipt.isMined() && receipt.debugLogs?.length) {
|
|
283
401
|
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
284
402
|
}
|
|
285
403
|
return {
|
|
@@ -314,9 +432,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
314
432
|
executeUtility(call, opts) {
|
|
315
433
|
return this.pxe.executeUtility(call, {
|
|
316
434
|
authwits: opts.authWitnesses,
|
|
317
|
-
scopes:
|
|
318
|
-
opts.scope
|
|
319
|
-
]
|
|
435
|
+
scopes: opts.scopes
|
|
320
436
|
});
|
|
321
437
|
}
|
|
322
438
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
@@ -337,31 +453,31 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
337
453
|
}
|
|
338
454
|
/**
|
|
339
455
|
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
340
|
-
*
|
|
341
|
-
* `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
|
|
342
|
-
* instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
|
|
343
456
|
* @param address - The contract address to query.
|
|
344
457
|
*/ async getContractMetadata(address) {
|
|
345
458
|
const instance = await this.pxe.getContractInstance(address);
|
|
346
459
|
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
347
|
-
|
|
348
|
-
// includes init_hash, preventing observers from determining initialization status from the address alone. Without
|
|
349
|
-
// the instance (and thus init_hash), we can't compute it, so we return undefined.
|
|
350
|
-
//
|
|
351
|
-
// We skip the public initialization nullifier because it's not always emitted (contracts without public external
|
|
352
|
-
// functions that require initialization checks won't emit it). If the private one exists, the public one was
|
|
353
|
-
// created in the same tx and will also be present.
|
|
354
|
-
let isContractInitialized = undefined;
|
|
460
|
+
let initializationStatus;
|
|
355
461
|
if (instance) {
|
|
462
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
463
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
356
464
|
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
357
465
|
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
358
|
-
|
|
466
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNINITIALIZED;
|
|
467
|
+
} else {
|
|
468
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
469
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
470
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
471
|
+
// uninitialized.
|
|
472
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
473
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
474
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
359
475
|
}
|
|
360
476
|
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
361
477
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
362
478
|
return {
|
|
363
479
|
instance: instance ?? undefined,
|
|
364
|
-
|
|
480
|
+
initializationStatus,
|
|
365
481
|
isContractPublished: !!publiclyRegisteredContract,
|
|
366
482
|
isContractUpdated: !!isContractUpdated,
|
|
367
483
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Gas, type GasUsed } from '@aztec/stdlib/gas';
|
|
2
|
+
/**
|
|
3
|
+
* Returns suggested total and teardown gas limits for a simulated tx, clamped to the network's per-tx
|
|
4
|
+
* admission limits.
|
|
5
|
+
*
|
|
6
|
+
* The network only admits transactions that declare up to `maxTxGasLimits` per dimension (the
|
|
7
|
+
* node-advertised `txsLimits.gas`). Wallets pass the value read from their own node info, but since node info
|
|
8
|
+
* is remote input it is defensively clamped here to the per-tx protocol maxima so a value above them is never
|
|
9
|
+
* honored. If the simulated usage already exceeds the resulting admission limits the tx can never be included,
|
|
10
|
+
* so this throws a descriptive error instead of returning a limit the node would reject. Otherwise it pads the
|
|
11
|
+
* usage and clamps each dimension to the admission limit.
|
|
12
|
+
* @param gasUsed - The gas actually consumed during simulation.
|
|
13
|
+
* @param maxTxGasLimits - The maximum gas a single tx may declare on this network (the node-advertised `txsLimits.gas`).
|
|
14
|
+
* @param pad - Fraction to pad the suggested gas limits by (as a decimal, e.g. 0.1 for 10%). The effective
|
|
15
|
+
* padding shrinks to zero as usage approaches the network limit, since the network will not admit a higher
|
|
16
|
+
* declared limit regardless of the buffer.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getGasLimits(gasUsed: GasUsed, maxTxGasLimits: Gas, pad?: number): {
|
|
19
|
+
/**
|
|
20
|
+
* Gas limit for the tx, excluding teardown gas
|
|
21
|
+
*/
|
|
22
|
+
gasLimits: Gas;
|
|
23
|
+
/**
|
|
24
|
+
* Gas limit for the teardown phase
|
|
25
|
+
*/
|
|
26
|
+
teardownGasLimits: Gas;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Validates that caller-declared gas limits do not exceed the network's per-tx admission limits, throwing a
|
|
30
|
+
* descriptive error per dimension when they do. The node's inbound validation checks declared
|
|
31
|
+
* `gasSettings.gasLimits`, so we mirror that here to surface the rejection locally before the tx is sent.
|
|
32
|
+
* @param gasLimits - The gas limits the transaction will declare.
|
|
33
|
+
* @param maxTxGasLimits - The maximum gas a single tx may declare on this network (the node-advertised `txsLimits.gas`).
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertGasLimitsWithinNetworkLimits(gasLimits: Gas, maxTxGasLimits: Gas): void;
|
|
36
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X2dhc19saW1pdHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9nZXRfZ2FzX2xpbWl0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsR0FBRyxFQUFFLEtBQUssT0FBTyxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFFdEQ7Ozs7Ozs7Ozs7Ozs7OztHQWVHO0FBQ0gsd0JBQWdCLFlBQVksQ0FDMUIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsY0FBYyxFQUFFLEdBQUcsRUFDbkIsR0FBRyxTQUFNLEdBQ1I7SUFDRDs7T0FFRztJQUNILFNBQVMsRUFBRSxHQUFHLENBQUM7SUFDZjs7T0FFRztJQUNILGlCQUFpQixFQUFFLEdBQUcsQ0FBQztDQUN4QixDQTZCQTtBQVFEOzs7Ozs7R0FNRztBQUNILHdCQUFnQixrQ0FBa0MsQ0FBQyxTQUFTLEVBQUUsR0FBRyxFQUFFLGNBQWMsRUFBRSxHQUFHLEdBQUcsSUFBSSxDQVc1RiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_gas_limits.d.ts","sourceRoot":"","sources":["../../src/base-wallet/get_gas_limits.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,GAAG,EACnB,GAAG,SAAM,GACR;IACD;;OAEG;IACH,SAAS,EAAE,GAAG,CAAC;IACf;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CA6BA;AAQD;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,GAAG,IAAI,CAW5F"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { MAX_PROCESSABLE_L2_GAS, MAX_TX_DA_GAS } from '@aztec/constants';
|
|
2
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
3
|
+
/**
|
|
4
|
+
* Returns suggested total and teardown gas limits for a simulated tx, clamped to the network's per-tx
|
|
5
|
+
* admission limits.
|
|
6
|
+
*
|
|
7
|
+
* The network only admits transactions that declare up to `maxTxGasLimits` per dimension (the
|
|
8
|
+
* node-advertised `txsLimits.gas`). Wallets pass the value read from their own node info, but since node info
|
|
9
|
+
* is remote input it is defensively clamped here to the per-tx protocol maxima so a value above them is never
|
|
10
|
+
* honored. If the simulated usage already exceeds the resulting admission limits the tx can never be included,
|
|
11
|
+
* so this throws a descriptive error instead of returning a limit the node would reject. Otherwise it pads the
|
|
12
|
+
* usage and clamps each dimension to the admission limit.
|
|
13
|
+
* @param gasUsed - The gas actually consumed during simulation.
|
|
14
|
+
* @param maxTxGasLimits - The maximum gas a single tx may declare on this network (the node-advertised `txsLimits.gas`).
|
|
15
|
+
* @param pad - Fraction to pad the suggested gas limits by (as a decimal, e.g. 0.1 for 10%). The effective
|
|
16
|
+
* padding shrinks to zero as usage approaches the network limit, since the network will not admit a higher
|
|
17
|
+
* declared limit regardless of the buffer.
|
|
18
|
+
*/ export function getGasLimits(gasUsed, maxTxGasLimits, pad = 0.1) {
|
|
19
|
+
const { totalGas, teardownGas } = gasUsed;
|
|
20
|
+
// `maxTxGasLimits` is the node-advertised admission limit. Node info is remote input, so we defensively
|
|
21
|
+
// clamp to the per-tx protocol maxima so a value above them can never be honored.
|
|
22
|
+
const maxLimits = new Gas(Math.min(maxTxGasLimits.daGas, MAX_TX_DA_GAS), Math.min(maxTxGasLimits.l2Gas, MAX_PROCESSABLE_L2_GAS));
|
|
23
|
+
// The simulated usage must fit within the admission limits, otherwise the tx can never be included.
|
|
24
|
+
if (totalGas.daGas > maxLimits.daGas) {
|
|
25
|
+
throw new Error(`Transaction consumes ${totalGas.daGas} DA gas but the network only admits transactions declaring up to ${maxLimits.daGas} DA gas`);
|
|
26
|
+
}
|
|
27
|
+
if (totalGas.l2Gas > maxLimits.l2Gas) {
|
|
28
|
+
throw new Error(`Transaction consumes ${totalGas.l2Gas} L2 gas but the network only admits transactions declaring up to ${maxLimits.l2Gas} L2 gas`);
|
|
29
|
+
}
|
|
30
|
+
// Pad the limits by the buffer, then cap each dimension at the admission limit so the buffer cannot push a
|
|
31
|
+
// declared limit past what inbound validation accepts. Teardown is part of the total, so clamping it to the
|
|
32
|
+
// admission limit is safe.
|
|
33
|
+
return {
|
|
34
|
+
gasLimits: padGas(totalGas, pad, maxLimits),
|
|
35
|
+
teardownGasLimits: padGas(teardownGas, pad, maxLimits)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Pads each gas dimension, capping it at the network admission limit. */ function padGas(gas, pad, cap) {
|
|
39
|
+
const padded = gas.mul(1 + pad);
|
|
40
|
+
return new Gas(Math.min(padded.daGas, cap.daGas), Math.min(padded.l2Gas, cap.l2Gas));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validates that caller-declared gas limits do not exceed the network's per-tx admission limits, throwing a
|
|
44
|
+
* descriptive error per dimension when they do. The node's inbound validation checks declared
|
|
45
|
+
* `gasSettings.gasLimits`, so we mirror that here to surface the rejection locally before the tx is sent.
|
|
46
|
+
* @param gasLimits - The gas limits the transaction will declare.
|
|
47
|
+
* @param maxTxGasLimits - The maximum gas a single tx may declare on this network (the node-advertised `txsLimits.gas`).
|
|
48
|
+
*/ export function assertGasLimitsWithinNetworkLimits(gasLimits, maxTxGasLimits) {
|
|
49
|
+
if (gasLimits.daGas > maxTxGasLimits.daGas) {
|
|
50
|
+
throw new Error(`Declared DA gas limit (${gasLimits.daGas}) exceeds the maximum this network allows per tx (${maxTxGasLimits.daGas})`);
|
|
51
|
+
}
|
|
52
|
+
if (gasLimits.l2Gas > maxTxGasLimits.l2Gas) {
|
|
53
|
+
throw new Error(`Declared L2 gas limit (${gasLimits.l2Gas}) exceeds the maximum this network allows per tx (${maxTxGasLimits.l2Gas})`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { BaseWallet, type FeeOptions, type SimulateViaEntrypointOptions } from './base_wallet.js';
|
|
1
|
+
export { BaseWallet, type CompleteFeeOptionsConfig, type FeeOptions, type SimulateViaEntrypointOptions, } from './base_wallet.js';
|
|
2
2
|
export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
|
|
3
|
-
|
|
3
|
+
export { getGasLimits, assertGasLimitsWithinNetworkLimits } from './get_gas_limits.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsVUFBVSxFQUNWLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssVUFBVSxFQUNmLEtBQUssNEJBQTRCLEdBQ2xDLE1BQU0sa0JBQWtCLENBQUM7QUFDMUIsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQztBQUMvRyxPQUFPLEVBQUUsWUFBWSxFQUFFLGtDQUFrQyxFQUFFLE1BQU0scUJBQXFCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EACf,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC;AAC/G,OAAO,EAAE,YAAY,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
2
3
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
4
|
import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
|
|
4
5
|
import { type FunctionCall } from '@aztec/stdlib/abi';
|
|
5
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
7
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
7
|
-
import { type BlockHeader, type ExecutionPayload, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
8
|
+
import { type BlockHeader, type ExecutionPayload, type SimulationOverrides, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
8
9
|
/**
|
|
9
10
|
* Splits an execution payload into a leading prefix of public static calls
|
|
10
11
|
* (eligible for direct node simulation) and the remaining calls.
|
|
@@ -32,9 +33,11 @@ export declare function extractOptimizablePublicStaticCalls(payload: ExecutionPa
|
|
|
32
33
|
* @param gasSettings - Gas settings for the transaction.
|
|
33
34
|
* @param blockHeader - Block header to use as anchor.
|
|
34
35
|
* @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
|
|
36
|
+
* @param getContractName - Resolver for contract names (used for debug log display).
|
|
37
|
+
* @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
|
|
35
38
|
* @returns Array of TxSimulationResult, one per batch.
|
|
36
39
|
*/
|
|
37
|
-
export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement: boolean | undefined, getContractName: ContractNameResolver): Promise<TxSimulationResult[]>;
|
|
40
|
+
export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement: boolean | undefined, getContractName: ContractNameResolver, overrides?: SimulationOverrides): Promise<TxSimulationResult[]>;
|
|
38
41
|
/**
|
|
39
42
|
* Merges simulation results from the optimized (public static) and normal paths.
|
|
40
43
|
* Since optimized calls are always a leading prefix, return values are simply
|
|
@@ -45,5 +48,5 @@ export declare function simulateViaNode(node: AztecNode, publicStaticCalls: Func
|
|
|
45
48
|
* @param normalResult - Result from normal simulation (null if all calls were optimized).
|
|
46
49
|
* @returns A single TxSimulationResult with return values in original call order.
|
|
47
50
|
*/
|
|
48
|
-
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult:
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
51
|
+
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult: TxSimulationResultWithAppOffset | null): TxSimulationResultWithAppOffset;
|
|
52
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsK0JBQStCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV6RSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUkvRCxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBR25FLE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBb0IsTUFBTSxtQkFBbUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQVFyRCxPQUFPLEVBQ0wsS0FBSyxXQUFXLEVBQ2hCLEtBQUssZ0JBQWdCLEVBS3JCLEtBQUssbUJBQW1CLEVBR3hCLGtCQUFrQixFQUNuQixNQUFNLGtCQUFrQixDQUFDO0FBRTFCOzs7Ozs7Ozs7R0FTRztBQUNILHdCQUFnQixtQ0FBbUMsQ0FBQyxPQUFPLEVBQUUsZ0JBQWdCLEdBQUc7SUFDOUUsdUVBQXVFO0lBQ3ZFLGdCQUFnQixFQUFFLFlBQVksRUFBRSxDQUFDO0lBQ2pDLDJCQUEyQjtJQUMzQixjQUFjLEVBQUUsWUFBWSxFQUFFLENBQUM7Q0FDaEMsQ0FPQTtBQTBHRDs7Ozs7Ozs7Ozs7Ozs7R0FjRztBQUNILHdCQUFzQixlQUFlLENBQ25DLElBQUksRUFBRSxTQUFTLEVBQ2YsaUJBQWlCLEVBQUUsWUFBWSxFQUFFLEVBQ2pDLElBQUksRUFBRSxZQUFZLEVBQ2xCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFdBQVcsRUFBRSxXQUFXLEVBQ3hCLFdBQVcsRUFBRSxXQUFXLEVBQ3hCLGtCQUFrQixxQkFBZ0IsRUFDbEMsZUFBZSxFQUFFLG9CQUFvQixFQUNyQyxTQUFTLENBQUMsRUFBRSxtQkFBbUIsR0FDOUIsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUMsQ0F5Qi9CO0FBRUQ7Ozs7Ozs7OztHQVNHO0FBQ0gsd0JBQWdCLDJCQUEyQixDQUN6QyxnQkFBZ0IsRUFBRSxrQkFBa0IsRUFBRSxFQUN0QyxZQUFZLEVBQUUsK0JBQStCLEdBQUcsSUFBSSxHQUNuRCwrQkFBK0IsQ0FxQmpDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAKrB,KAAK,mBAAmB,EAGxB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,gBAAgB,GAAG;IAC9E,uEAAuE;IACvE,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,2BAA2B;IAC3B,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,CAOA;AA0GD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,SAAS,EACf,iBAAiB,EAAE,YAAY,EAAE,EACjC,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,kBAAkB,qBAAgB,EAClC,eAAe,EAAE,oBAAoB,EACrC,SAAS,CAAC,EAAE,mBAAmB,GAC9B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAyB/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,YAAY,EAAE,+BAA+B,GAAG,IAAI,GACnD,+BAA+B,CAqBjC"}
|