@aztec/wallet-sdk 0.0.1-commit.e2b2873ed → 0.0.1-commit.e304674f1
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/dest/base-wallet/base_wallet.d.ts +41 -39
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +137 -80
- package/dest/base-wallet/index.d.ts +2 -2
- package/dest/base-wallet/index.d.ts.map +1 -1
- package/dest/base-wallet/utils.d.ts +3 -2
- package/dest/base-wallet/utils.d.ts.map +1 -1
- package/dest/base-wallet/utils.js +7 -4
- package/dest/crypto.d.ts +39 -1
- package/dest/crypto.d.ts.map +1 -1
- package/dest/crypto.js +88 -0
- package/dest/extension/provider/extension_wallet.d.ts +4 -6
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -1
- package/dest/extension/provider/extension_wallet.js +9 -2
- 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 +118 -0
- package/dest/iframe/handlers/iframe_connection_handler.d.ts.map +1 -0
- package/dest/iframe/handlers/iframe_connection_handler.js +228 -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 +68 -0
- package/dest/iframe/provider/iframe_wallet.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_wallet.js +200 -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 +6 -5
- 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 +48 -18
- package/dest/types.d.ts +14 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +4 -0
- package/package.json +12 -8
- package/src/base-wallet/base_wallet.ts +201 -132
- package/src/base-wallet/index.ts +6 -1
- package/src/base-wallet/utils.ts +9 -0
- package/src/crypto.ts +104 -0
- package/src/extension/provider/extension_wallet.ts +13 -10
- package/src/extension/provider/index.ts +1 -1
- package/src/iframe/handlers/iframe_connection_handler.ts +328 -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 +229 -0
- package/src/iframe/provider/index.ts +3 -0
- package/src/manager/types.ts +5 -4
- package/src/manager/wallet_manager.ts +55 -23
- package/src/types.ts +13 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Account } from '@aztec/aztec.js/account';
|
|
1
|
+
import type { Account, NoFrom } from '@aztec/aztec.js/account';
|
|
2
2
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
3
|
import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
5
|
-
import type
|
|
5
|
+
import { type Aliased, type AppCapabilities, type BatchResults, type BatchedMethod, ContractInitializationStatus, type ExecuteUtilityOptions, type PrivateEvent, type PrivateEventFilter, type ProfileOptions, type SendOptions, type SimulateOptions, type Wallet, type WalletCapabilities } from '@aztec/aztec.js/wallet';
|
|
6
6
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
7
7
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
8
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -10,11 +10,11 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
10
10
|
import type { PXE } from '@aztec/pxe/server';
|
|
11
11
|
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall } from '@aztec/stdlib/abi';
|
|
12
12
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
13
|
-
import
|
|
13
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
14
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
15
15
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
16
16
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
17
|
-
import { type TxExecutionRequest, type TxProfileResult, TxSimulationResult, type
|
|
17
|
+
import { type TxExecutionRequest, type TxProfileResult, TxSimulationResult, type UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
18
18
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
19
19
|
/**
|
|
20
20
|
* Options to configure fee payment for a transaction
|
|
@@ -26,10 +26,28 @@ export type FeeOptions = {
|
|
|
26
26
|
*/
|
|
27
27
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
28
28
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
29
|
-
accountFeePaymentMethodOptions
|
|
29
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
30
30
|
/** The gas settings to use for the transaction */
|
|
31
31
|
gasSettings: GasSettings;
|
|
32
32
|
};
|
|
33
|
+
/** Options for `simulateViaEntrypoint`. */
|
|
34
|
+
export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'> & {
|
|
35
|
+
/** Fee options for the entrypoint */
|
|
36
|
+
feeOptions: FeeOptions;
|
|
37
|
+
/** Scopes to use for the simulation */
|
|
38
|
+
scopes: AztecAddress[];
|
|
39
|
+
};
|
|
40
|
+
/** Options for `completeFeeOptions`. */
|
|
41
|
+
export type CompleteFeeOptionsConfig = {
|
|
42
|
+
/** The address where the transaction is being sent from. */
|
|
43
|
+
from: AztecAddress | NoFrom;
|
|
44
|
+
/** The address paying for fees (if any fee payment method is embedded in the execution payload). */
|
|
45
|
+
feePayer?: AztecAddress;
|
|
46
|
+
/** User-provided partial gas settings. */
|
|
47
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
48
|
+
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
49
|
+
forEstimation?: boolean;
|
|
50
|
+
};
|
|
33
51
|
/**
|
|
34
52
|
* A base class for Wallet implementations
|
|
35
53
|
*/
|
|
@@ -40,7 +58,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
40
58
|
protected minFeePadding: number;
|
|
41
59
|
protected cancellableTransactions: boolean;
|
|
42
60
|
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
43
|
-
protected
|
|
61
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
44
62
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
45
63
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
46
64
|
/**
|
|
@@ -52,7 +70,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
52
70
|
*/
|
|
53
71
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
54
72
|
getChainInfo(): Promise<ChainInfo>;
|
|
55
|
-
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
73
|
+
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
56
74
|
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
57
75
|
/**
|
|
58
76
|
* Request capabilities from the wallet.
|
|
@@ -71,42 +89,17 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
71
89
|
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
72
90
|
/**
|
|
73
91
|
* Completes partial user-provided fee options with wallet defaults.
|
|
74
|
-
* @param
|
|
75
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
76
|
-
* @param gasSettings - User-provided partial gas settings
|
|
77
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
92
|
+
* @param config - Fee completion config.
|
|
78
93
|
*/
|
|
79
|
-
protected completeFeeOptions(
|
|
80
|
-
/**
|
|
81
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
82
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
83
|
-
* to avoid running out of gas during estimation.
|
|
84
|
-
* @param from - The address where the transaction is being sent from
|
|
85
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
86
|
-
* @param gasSettings - User-provided partial gas settings
|
|
87
|
-
*/
|
|
88
|
-
protected completeFeeOptionsForEstimation(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
89
|
-
/**
|
|
90
|
-
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
91
|
-
* doesn't already include one
|
|
92
|
-
*/
|
|
93
|
-
walletFeePaymentMethod?: FeePaymentMethod | undefined;
|
|
94
|
-
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
95
|
-
accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
|
|
96
|
-
gasSettings: GasSettings;
|
|
97
|
-
}>;
|
|
94
|
+
protected completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions>;
|
|
98
95
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
99
96
|
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
100
97
|
/**
|
|
101
98
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
102
99
|
* @param executionPayload - The execution payload to simulate.
|
|
103
|
-
* @param
|
|
104
|
-
* @param feeOptions - Fee options for the transaction.
|
|
105
|
-
* @param skipTxValidation - Whether to skip tx validation.
|
|
106
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
107
|
-
* @param scopes - The scopes to use for the simulation.
|
|
100
|
+
* @param opts - Simulation options.
|
|
108
101
|
*/
|
|
109
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload,
|
|
102
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
|
|
110
103
|
/**
|
|
111
104
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
112
105
|
* on the node while sending the remaining calls through the standard PXE path.
|
|
@@ -118,12 +111,21 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
118
111
|
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
119
112
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
120
113
|
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
114
|
+
/**
|
|
115
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
116
|
+
* @param address - The contract address to resolve.
|
|
117
|
+
*/
|
|
118
|
+
protected getContractName(address: AztecAddress): Promise<string | undefined>;
|
|
121
119
|
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
122
|
-
|
|
120
|
+
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
123
121
|
getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
124
|
+
* @param address - The contract address to query.
|
|
125
|
+
*/
|
|
124
126
|
getContractMetadata(address: AztecAddress): Promise<{
|
|
125
127
|
instance: ContractInstanceWithAddress | undefined;
|
|
126
|
-
|
|
128
|
+
initializationStatus: ContractInitializationStatus;
|
|
127
129
|
isContractPublished: boolean;
|
|
128
130
|
isContractUpdated: boolean;
|
|
129
131
|
updatedContractClassId: Fr | undefined;
|
|
@@ -133,4 +135,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
133
135
|
isContractClassPubliclyRegistered: boolean;
|
|
134
136
|
}>;
|
|
135
137
|
}
|
|
136
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
138
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGVBQWUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2pGLE9BQU8sRUFDTCxLQUFLLHNCQUFzQixFQUUzQixLQUFLLFVBQVUsRUFFaEIsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTVELE9BQU8sRUFDTCxLQUFLLE9BQU8sRUFDWixLQUFLLGVBQWUsRUFDcEIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssYUFBYS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@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
+
import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
|
-
import {
|
|
4
|
+
import { ContractInitializationStatus } 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';
|
|
9
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
7
10
|
import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
11
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
12
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
9
13
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
10
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
11
|
-
import {
|
|
14
|
+
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
15
|
+
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
|
|
12
16
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
13
17
|
import { inspect } from 'util';
|
|
14
18
|
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
@@ -28,12 +32,15 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
28
32
|
this.minFeePadding = 0.5;
|
|
29
33
|
this.cancellableTransactions = false;
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
from
|
|
35
|
+
scopesFrom(from, additionalScopes = []) {
|
|
36
|
+
const allScopes = from === NO_FROM ? additionalScopes : [
|
|
37
|
+
from,
|
|
38
|
+
...additionalScopes
|
|
36
39
|
];
|
|
40
|
+
const scopeSet = new Set(allScopes.map((address)=>address.toString()));
|
|
41
|
+
return [
|
|
42
|
+
...scopeSet
|
|
43
|
+
].map(AztecAddress.fromString);
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Returns the list of aliased contacts associated with the wallet.
|
|
@@ -57,18 +64,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
57
64
|
}
|
|
58
65
|
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
59
66
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
60
|
-
const executionOptions = {
|
|
61
|
-
txNonce: Fr.random(),
|
|
62
|
-
cancellable: this.cancellableTransactions,
|
|
63
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
64
|
-
};
|
|
65
67
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
66
68
|
feeExecutionPayload,
|
|
67
69
|
executionPayload
|
|
68
70
|
]) : executionPayload;
|
|
69
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
70
71
|
const chainInfo = await this.getChainInfo();
|
|
71
|
-
|
|
72
|
+
if (from === NO_FROM) {
|
|
73
|
+
const entrypoint = new DefaultEntrypoint();
|
|
74
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
75
|
+
} else {
|
|
76
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
77
|
+
const executionOptions = {
|
|
78
|
+
txNonce: Fr.random(),
|
|
79
|
+
cancellable: this.cancellableTransactions,
|
|
80
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
81
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
82
|
+
};
|
|
83
|
+
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
84
|
+
}
|
|
72
85
|
}
|
|
73
86
|
async createAuthWit(from, messageHashOrIntent) {
|
|
74
87
|
const account = await this.getAccountFromAddress(from);
|
|
@@ -111,26 +124,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
111
124
|
}
|
|
112
125
|
/**
|
|
113
126
|
* Completes partial user-provided fee options with wallet defaults.
|
|
114
|
-
* @param
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
118
|
-
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
127
|
+
* @param config - Fee completion config.
|
|
128
|
+
*/ async completeFeeOptions(config) {
|
|
129
|
+
const { from, feePayer, gasSettings, forEstimation } = config;
|
|
119
130
|
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
120
131
|
let accountFeePaymentMethodOptions;
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
132
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
133
|
+
// account contract entrypoint to use
|
|
134
|
+
if (from !== NO_FROM) {
|
|
135
|
+
if (!feePayer) {
|
|
136
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
137
|
+
// for the account to use its fee juice balance
|
|
138
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
139
|
+
} else {
|
|
140
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
141
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
142
|
+
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
143
|
+
}
|
|
129
144
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
const gasSettingsOverrides = {
|
|
146
|
+
gasLimits: gasSettings?.gasLimits ? Gas.from(gasSettings.gasLimits) : undefined,
|
|
147
|
+
teardownGasLimits: gasSettings?.teardownGasLimits ? Gas.from(gasSettings.teardownGasLimits) : undefined,
|
|
148
|
+
maxFeesPerGas,
|
|
149
|
+
maxPriorityFeesPerGas: gasSettings?.maxPriorityFeesPerGas ?? GasFees.empty()
|
|
150
|
+
};
|
|
151
|
+
// When estimating gas (simulation), use high limits so the simulation doesn't run out of gas.
|
|
152
|
+
// When sending for real, use protocol max limits that the network will actually accept.
|
|
153
|
+
const fullGasSettings = forEstimation ? GasSettings.forEstimation(gasSettingsOverrides) : GasSettings.fallback(gasSettingsOverrides);
|
|
134
154
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
135
155
|
return {
|
|
136
156
|
gasSettings: fullGasSettings,
|
|
@@ -138,24 +158,6 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
138
158
|
accountFeePaymentMethodOptions
|
|
139
159
|
};
|
|
140
160
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
143
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
144
|
-
* to avoid running out of gas during estimation.
|
|
145
|
-
* @param from - The address where the transaction is being sent from
|
|
146
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
147
|
-
* @param gasSettings - User-provided partial gas settings
|
|
148
|
-
*/ async completeFeeOptionsForEstimation(from, feePayer, gasSettings) {
|
|
149
|
-
const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
|
|
150
|
-
const { gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas } } = defaultFeeOptions;
|
|
151
|
-
// Use unrealistically high gas limits for estimation to avoid running out of gas.
|
|
152
|
-
// They will be tuned down after the simulation.
|
|
153
|
-
const gasSettingsForEstimation = new GasSettings(new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT), new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT), maxFeesPerGas, maxPriorityFeesPerGas);
|
|
154
|
-
return {
|
|
155
|
-
...defaultFeeOptions,
|
|
156
|
-
gasSettings: gasSettingsForEstimation
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
161
|
registerSender(address, _alias = '') {
|
|
160
162
|
return this.pxe.registerSender(address);
|
|
161
163
|
}
|
|
@@ -194,18 +196,14 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
194
196
|
/**
|
|
195
197
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
196
198
|
* @param executionPayload - The execution payload to simulate.
|
|
197
|
-
* @param
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
201
|
-
* @param scopes - The scopes to use for the simulation.
|
|
202
|
-
*/ async simulateViaEntrypoint(executionPayload, from, feeOptions, skipTxValidation, skipFeeEnforcement, scopes) {
|
|
203
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions);
|
|
199
|
+
* @param opts - Simulation options.
|
|
200
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
201
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
204
202
|
return this.pxe.simulateTx(txRequest, {
|
|
205
203
|
simulatePublic: true,
|
|
206
|
-
skipTxValidation,
|
|
207
|
-
skipFeeEnforcement,
|
|
208
|
-
scopes
|
|
204
|
+
skipTxValidation: opts.skipTxValidation,
|
|
205
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
206
|
+
scopes: opts.scopes
|
|
209
207
|
});
|
|
210
208
|
}
|
|
211
209
|
/**
|
|
@@ -216,7 +214,12 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
216
214
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
217
215
|
* @returns The merged simulation result.
|
|
218
216
|
*/ async simulateTx(executionPayload, opts) {
|
|
219
|
-
const feeOptions =
|
|
217
|
+
const feeOptions = await this.completeFeeOptions({
|
|
218
|
+
from: opts.from,
|
|
219
|
+
feePayer: executionPayload.feePayer,
|
|
220
|
+
gasSettings: opts.fee?.gasSettings,
|
|
221
|
+
forEstimation: true
|
|
222
|
+
});
|
|
220
223
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
221
224
|
const remainingPayload = {
|
|
222
225
|
...executionPayload,
|
|
@@ -231,25 +234,41 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
231
234
|
} catch {
|
|
232
235
|
blockHeader = await this.aztecNode.getBlockHeader();
|
|
233
236
|
}
|
|
237
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
234
238
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
235
|
-
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls,
|
|
236
|
-
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload,
|
|
239
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
|
|
240
|
+
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
241
|
+
from: opts.from,
|
|
242
|
+
feeOptions,
|
|
243
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
244
|
+
skipTxValidation: opts.skipTxValidation,
|
|
245
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
246
|
+
}) : Promise.resolve(null)
|
|
237
247
|
]);
|
|
238
248
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
239
249
|
}
|
|
240
250
|
async profileTx(executionPayload, opts) {
|
|
241
|
-
const feeOptions = await this.completeFeeOptions(
|
|
251
|
+
const feeOptions = await this.completeFeeOptions({
|
|
252
|
+
from: opts.from,
|
|
253
|
+
feePayer: executionPayload.feePayer,
|
|
254
|
+
gasSettings: opts.fee?.gasSettings
|
|
255
|
+
});
|
|
242
256
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
243
257
|
return this.pxe.profileTx(txRequest, {
|
|
244
258
|
profileMode: opts.profileMode,
|
|
245
259
|
skipProofGeneration: opts.skipProofGeneration ?? true,
|
|
246
|
-
scopes: this.
|
|
260
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
247
261
|
});
|
|
248
262
|
}
|
|
249
263
|
async sendTx(executionPayload, opts) {
|
|
250
|
-
const feeOptions = await this.completeFeeOptions(
|
|
264
|
+
const feeOptions = await this.completeFeeOptions({
|
|
265
|
+
from: opts.from,
|
|
266
|
+
feePayer: executionPayload.feePayer,
|
|
267
|
+
gasSettings: opts.fee?.gasSettings
|
|
268
|
+
});
|
|
251
269
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
252
|
-
const provenTx = await this.pxe.proveTx(txRequest, this.
|
|
270
|
+
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
271
|
+
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
253
272
|
const tx = await provenTx.toTx();
|
|
254
273
|
const txHash = tx.getTxHash();
|
|
255
274
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -262,11 +281,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
262
281
|
this.log.info(`Sent transaction ${txHash}`);
|
|
263
282
|
// If wait is NO_WAIT, return txHash immediately
|
|
264
283
|
if (opts.wait === NO_WAIT) {
|
|
265
|
-
return
|
|
284
|
+
return {
|
|
285
|
+
txHash,
|
|
286
|
+
...offchainOutput
|
|
287
|
+
};
|
|
266
288
|
}
|
|
267
289
|
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
268
290
|
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
269
|
-
|
|
291
|
+
const receipt = await waitForTx(this.aztecNode, txHash, waitOpts);
|
|
292
|
+
// Display debug logs from public execution if present (served in test mode only)
|
|
293
|
+
if (receipt.debugLogs?.length) {
|
|
294
|
+
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
receipt,
|
|
298
|
+
...offchainOutput
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
303
|
+
* @param address - The contract address to resolve.
|
|
304
|
+
*/ async getContractName(address) {
|
|
305
|
+
const instance = await this.pxe.getContractInstance(address);
|
|
306
|
+
if (!instance) {
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
const artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
310
|
+
return artifact?.name;
|
|
270
311
|
}
|
|
271
312
|
contextualizeError(err, ...context) {
|
|
272
313
|
let contextStr = '';
|
|
@@ -281,12 +322,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
281
322
|
}
|
|
282
323
|
return err;
|
|
283
324
|
}
|
|
284
|
-
|
|
285
|
-
return this.pxe.
|
|
325
|
+
executeUtility(call, opts) {
|
|
326
|
+
return this.pxe.executeUtility(call, {
|
|
286
327
|
authwits: opts.authWitnesses,
|
|
287
|
-
scopes:
|
|
288
|
-
opts.scope
|
|
289
|
-
]
|
|
328
|
+
scopes: opts.scopes
|
|
290
329
|
});
|
|
291
330
|
}
|
|
292
331
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
@@ -305,15 +344,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
305
344
|
});
|
|
306
345
|
return decodedEvents;
|
|
307
346
|
}
|
|
308
|
-
|
|
347
|
+
/**
|
|
348
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
349
|
+
* @param address - The contract address to query.
|
|
350
|
+
*/ async getContractMetadata(address) {
|
|
309
351
|
const instance = await this.pxe.getContractInstance(address);
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
352
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
353
|
+
let initializationStatus;
|
|
354
|
+
if (instance) {
|
|
355
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
356
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
357
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
358
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
359
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNINITIALIZED;
|
|
360
|
+
} else {
|
|
361
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
362
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
363
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
364
|
+
// uninitialized.
|
|
365
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
366
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
367
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
368
|
+
}
|
|
369
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
313
370
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
314
371
|
return {
|
|
315
372
|
instance: instance ?? undefined,
|
|
316
|
-
|
|
373
|
+
initializationStatus,
|
|
317
374
|
isContractPublished: !!publiclyRegisteredContract,
|
|
318
375
|
isContractUpdated: !!isContractUpdated,
|
|
319
376
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { BaseWallet, type FeeOptions } 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
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsVUFBVSxFQUNWLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssVUFBVSxFQUNmLEtBQUssNEJBQTRCLEdBQ2xDLE1BQU0sa0JBQWtCLENBQUM7QUFDMUIsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQyJ9
|
|
@@ -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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
2
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
|
+
import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
|
|
3
4
|
import { type FunctionCall } from '@aztec/stdlib/abi';
|
|
4
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
6
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
@@ -33,7 +34,7 @@ export declare function extractOptimizablePublicStaticCalls(payload: ExecutionPa
|
|
|
33
34
|
* @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
|
|
34
35
|
* @returns Array of TxSimulationResult, one per batch.
|
|
35
36
|
*/
|
|
36
|
-
export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement
|
|
37
|
+
export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement: boolean | undefined, getContractName: ContractNameResolver): Promise<TxSimulationResult[]>;
|
|
37
38
|
/**
|
|
38
39
|
* Merges simulation results from the optimized (public static) and normal paths.
|
|
39
40
|
* Since optimized calls are always a leading prefix, return values are simply
|
|
@@ -45,4 +46,4 @@ export declare function simulateViaNode(node: AztecNode, publicStaticCalls: Func
|
|
|
45
46
|
* @returns A single TxSimulationResult with return values in original call order.
|
|
46
47
|
*/
|
|
47
48
|
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult: TxSimulationResult | null): TxSimulationResult;
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV0RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUkvRCxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBR25FLE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBb0IsTUFBTSxtQkFBbUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQVFyRCxPQUFPLEVBQ0wsS0FBSyxXQUFXLEVBQ2hCLEtBQUssZ0JBQWdCLEVBT3JCLGtCQUFrQixFQUNuQixNQUFNLGtCQUFrQixDQUFDO0FBRTFCOzs7Ozs7Ozs7R0FTRztBQUNILHdCQUFnQixtQ0FBbUMsQ0FBQyxPQUFPLEVBQUUsZ0JBQWdCLEdBQUc7SUFDOUUsdUVBQXVFO0lBQ3ZFLGdCQUFnQixFQUFFLFlBQVksRUFBRSxDQUFDO0lBQ2pDLDJCQUEyQjtJQUMzQixjQUFjLEVBQUUsWUFBWSxFQUFFLENBQUM7Q0FDaEMsQ0FPQTtBQXVHRDs7Ozs7Ozs7Ozs7O0dBWUc7QUFDSCx3QkFBc0IsZUFBZSxDQUNuQyxJQUFJLEVBQUUsU0FBUyxFQUNmLGlCQUFpQixFQUFFLFlBQVksRUFBRSxFQUNqQyxJQUFJLEVBQUUsWUFBWSxFQUNsQixTQUFTLEVBQUUsU0FBUyxFQUNwQixXQUFXLEVBQUUsV0FBVyxFQUN4QixXQUFXLEVBQUUsV0FBVyxFQUN4QixrQkFBa0IscUJBQWdCLEVBQ2xDLGVBQWUsRUFBRSxvQkFBb0IsR0FDcEMsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUMsQ0F3Qi9CO0FBRUQ7Ozs7Ozs7OztHQVNHO0FBQ0gsd0JBQWdCLDJCQUEyQixDQUN6QyxnQkFBZ0IsRUFBRSxrQkFBa0IsRUFBRSxFQUN0QyxZQUFZLEVBQUUsa0JBQWtCLEdBQUcsSUFBSSxHQUN0QyxrQkFBa0IsQ0FvQnBCIn0=
|
|
@@ -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;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,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;AAEtD,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,EAOrB,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;AAuGD;;;;;;;;;;;;GAYG;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,GACpC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAwB/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,YAAY,EAAE,kBAAkB,GAAG,IAAI,GACtC,kBAAkB,CAoBpB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MAX_ENQUEUED_CALLS_PER_CALL } from '@aztec/constants';
|
|
2
2
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
4
5
|
import { generateSimulatedProvingResult } from '@aztec/pxe/simulator';
|
|
5
6
|
import { ClaimedLengthArray, CountedPublicCallRequest, PrivateCircuitPublicInputs, PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
6
7
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
@@ -34,7 +35,7 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
34
35
|
* @param blockHeader - Block header to use as anchor.
|
|
35
36
|
* @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
|
|
36
37
|
* @returns TxSimulationResult with public return values.
|
|
37
|
-
*/ async function simulateBatchViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement) {
|
|
38
|
+
*/ async function simulateBatchViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement, getContractName) {
|
|
38
39
|
const txContext = new TxContext(chainInfo.chainId, chainInfo.version, gasSettings);
|
|
39
40
|
const publicFunctionCalldata = [];
|
|
40
41
|
for (const call of publicStaticCalls){
|
|
@@ -65,7 +66,7 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
65
66
|
// Minimal entrypoint structure — no real private execution, just public call requests
|
|
66
67
|
const emptyEntrypoint = new PrivateCallExecutionResult(Buffer.alloc(0), Buffer.alloc(0), new Map(), publicInputs, [], new Map(), [], [], [], [], []);
|
|
67
68
|
const privateResult = new PrivateExecutionResult(emptyEntrypoint, Fr.random(), publicFunctionCalldata);
|
|
68
|
-
const provingResult = await generateSimulatedProvingResult(privateResult, (_contractAddress, _functionSelector)=>Promise.resolve(''), 1);
|
|
69
|
+
const provingResult = await generateSimulatedProvingResult(privateResult, (_contractAddress, _functionSelector)=>Promise.resolve(''), node, 1);
|
|
69
70
|
provingResult.publicInputs.feePayer = from;
|
|
70
71
|
const tx = await Tx.create({
|
|
71
72
|
data: provingResult.publicInputs,
|
|
@@ -77,6 +78,8 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
77
78
|
if (publicOutput.revertReason) {
|
|
78
79
|
throw publicOutput.revertReason;
|
|
79
80
|
}
|
|
81
|
+
// Display debug logs from the public simulation.
|
|
82
|
+
await displayDebugLogs(publicOutput.debugLogs, getContractName);
|
|
80
83
|
return new TxSimulationResult(privateResult, provingResult.publicInputs, publicOutput, undefined);
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
@@ -91,14 +94,14 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
91
94
|
* @param blockHeader - Block header to use as anchor.
|
|
92
95
|
* @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
|
|
93
96
|
* @returns Array of TxSimulationResult, one per batch.
|
|
94
|
-
*/ export async function simulateViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement = true) {
|
|
97
|
+
*/ export async function simulateViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement = true, getContractName) {
|
|
95
98
|
const batches = [];
|
|
96
99
|
for(let i = 0; i < publicStaticCalls.length; i += MAX_ENQUEUED_CALLS_PER_CALL){
|
|
97
100
|
batches.push(publicStaticCalls.slice(i, i + MAX_ENQUEUED_CALLS_PER_CALL));
|
|
98
101
|
}
|
|
99
102
|
const results = [];
|
|
100
103
|
for (const batch of batches){
|
|
101
|
-
const result = await simulateBatchViaNode(node, batch, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement);
|
|
104
|
+
const result = await simulateBatchViaNode(node, batch, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement, getContractName);
|
|
102
105
|
results.push(result);
|
|
103
106
|
}
|
|
104
107
|
return results;
|