@aztec/wallet-sdk 0.0.1-commit.fce3e4f → 0.0.1-commit.ffe5b04ea
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 +228 -331
- package/dest/base-wallet/base_wallet.d.ts +64 -16
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +165 -33
- package/dest/base-wallet/index.d.ts +2 -1
- 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 +49 -0
- package/dest/base-wallet/utils.d.ts.map +1 -0
- package/dest/base-wallet/utils.js +131 -0
- package/dest/crypto.d.ts +192 -0
- package/dest/crypto.d.ts.map +1 -0
- package/dest/crypto.js +394 -0
- package/dest/emoji_alphabet.d.ts +35 -0
- package/dest/emoji_alphabet.d.ts.map +1 -0
- package/dest/emoji_alphabet.js +299 -0
- package/dest/extension/handlers/background_connection_handler.d.ts +158 -0
- package/dest/extension/handlers/background_connection_handler.d.ts.map +1 -0
- package/dest/extension/handlers/background_connection_handler.js +258 -0
- package/dest/extension/handlers/content_script_connection_handler.d.ts +56 -0
- package/dest/extension/handlers/content_script_connection_handler.d.ts.map +1 -0
- package/dest/extension/handlers/content_script_connection_handler.js +174 -0
- package/dest/extension/handlers/index.d.ts +12 -0
- package/dest/extension/handlers/index.d.ts.map +1 -0
- package/dest/extension/handlers/index.js +10 -0
- package/dest/extension/handlers/internal_message_types.d.ts +63 -0
- package/dest/extension/handlers/internal_message_types.d.ts.map +1 -0
- package/dest/extension/handlers/internal_message_types.js +22 -0
- package/dest/extension/provider/extension_provider.d.ts +107 -0
- package/dest/extension/provider/extension_provider.d.ts.map +1 -0
- package/dest/extension/provider/extension_provider.js +160 -0
- package/dest/extension/provider/extension_wallet.d.ts +132 -0
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -0
- package/dest/extension/provider/extension_wallet.js +278 -0
- package/dest/extension/provider/index.d.ts +3 -0
- package/dest/extension/provider/index.d.ts.map +1 -0
- package/dest/manager/index.d.ts +2 -7
- package/dest/manager/index.d.ts.map +1 -1
- package/dest/manager/index.js +0 -4
- package/dest/manager/types.d.ts +108 -5
- package/dest/manager/types.d.ts.map +1 -1
- package/dest/manager/types.js +17 -1
- package/dest/manager/wallet_manager.d.ts +50 -7
- package/dest/manager/wallet_manager.d.ts.map +1 -1
- package/dest/manager/wallet_manager.js +178 -29
- package/dest/types.d.ts +123 -0
- package/dest/types.d.ts.map +1 -0
- package/dest/types.js +11 -0
- package/package.json +22 -13
- package/src/base-wallet/base_wallet.ts +213 -60
- package/src/base-wallet/index.ts +1 -0
- package/src/base-wallet/utils.ts +238 -0
- package/src/crypto.ts +499 -0
- package/src/emoji_alphabet.ts +317 -0
- package/src/extension/handlers/background_connection_handler.ts +423 -0
- package/src/extension/handlers/content_script_connection_handler.ts +246 -0
- package/src/extension/handlers/index.ts +25 -0
- package/src/extension/handlers/internal_message_types.ts +69 -0
- package/src/extension/provider/extension_provider.ts +233 -0
- package/src/extension/provider/extension_wallet.ts +329 -0
- package/src/extension/provider/index.ts +7 -0
- package/src/manager/index.ts +3 -15
- package/src/manager/types.ts +112 -4
- package/src/manager/wallet_manager.ts +202 -31
- package/src/types.ts +132 -0
- package/dest/providers/extension/extension_provider.d.ts +0 -17
- package/dest/providers/extension/extension_provider.d.ts.map +0 -1
- package/dest/providers/extension/extension_provider.js +0 -56
- package/dest/providers/extension/extension_wallet.d.ts +0 -23
- package/dest/providers/extension/extension_wallet.d.ts.map +0 -1
- package/dest/providers/extension/extension_wallet.js +0 -96
- package/dest/providers/extension/index.d.ts +0 -4
- package/dest/providers/extension/index.d.ts.map +0 -1
- package/dest/providers/types.d.ts +0 -67
- package/dest/providers/types.d.ts.map +0 -1
- package/dest/providers/types.js +0 -3
- package/src/providers/extension/extension_provider.ts +0 -72
- package/src/providers/extension/extension_wallet.ts +0 -124
- package/src/providers/extension/index.ts +0 -3
- package/src/providers/types.ts +0 -71
- /package/dest/{providers/extension → extension/provider}/index.js +0 -0
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import type { Account } from '@aztec/aztec.js/account';
|
|
2
2
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
3
4
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
4
|
-
import type { Aliased,
|
|
5
|
+
import type { Aliased, AppCapabilities, BatchResults, BatchedMethod, ExecuteUtilityOptions, PrivateEvent, PrivateEventFilter, ProfileOptions, SendOptions, SimulateOptions, Wallet, WalletCapabilities } from '@aztec/aztec.js/wallet';
|
|
5
6
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
6
7
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
7
|
-
import { Fr } from '@aztec/foundation/
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
9
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
10
|
+
import { type AccessScopes } from '@aztec/pxe/client/lazy';
|
|
9
11
|
import type { PXE } from '@aztec/pxe/server';
|
|
10
12
|
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall } from '@aztec/stdlib/abi';
|
|
11
13
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
12
|
-
import
|
|
13
|
-
import { type
|
|
14
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
+
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
14
16
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
15
17
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
16
|
-
import type
|
|
18
|
+
import { type TxExecutionRequest, type TxProfileResult, TxSimulationResult, type UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
17
19
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
18
20
|
/**
|
|
19
21
|
* Options to configure fee payment for a transaction
|
|
@@ -36,9 +38,10 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
36
38
|
protected readonly pxe: PXE;
|
|
37
39
|
protected readonly aztecNode: AztecNode;
|
|
38
40
|
protected log: import("@aztec/foundation/log").Logger;
|
|
39
|
-
protected
|
|
41
|
+
protected minFeePadding: number;
|
|
40
42
|
protected cancellableTransactions: boolean;
|
|
41
|
-
protected constructor(pxe: PXE, aztecNode: AztecNode);
|
|
43
|
+
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
44
|
+
protected scopesFrom(from: AztecAddress, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
42
45
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
43
46
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
44
47
|
/**
|
|
@@ -51,8 +54,22 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
51
54
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
52
55
|
getChainInfo(): Promise<ChainInfo>;
|
|
53
56
|
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
54
|
-
createAuthWit(from: AztecAddress, messageHashOrIntent:
|
|
55
|
-
|
|
57
|
+
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
58
|
+
/**
|
|
59
|
+
* Request capabilities from the wallet.
|
|
60
|
+
*
|
|
61
|
+
* This method is wallet-implementation-dependent and must be provided by classes extending BaseWallet.
|
|
62
|
+
* Embedded wallets typically don't support capability-based authorization (no user authorization flow),
|
|
63
|
+
* while external wallets (browser extensions, hardware wallets) implement this to reduce authorization
|
|
64
|
+
* friction by allowing apps to request permissions upfront.
|
|
65
|
+
*
|
|
66
|
+
* TODO: Consider making it abstract so implementing it is a conscious decision. Leaving it as-is
|
|
67
|
+
* while the feature stabilizes.
|
|
68
|
+
*
|
|
69
|
+
* @param _manifest - Application capability manifest declaring what operations the app needs
|
|
70
|
+
*/
|
|
71
|
+
requestCapabilities(_manifest: AppCapabilities): Promise<WalletCapabilities>;
|
|
72
|
+
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
56
73
|
/**
|
|
57
74
|
* Completes partial user-provided fee options with wallet defaults.
|
|
58
75
|
* @param from - The address where the transaction is being sent from
|
|
@@ -81,14 +98,45 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
81
98
|
}>;
|
|
82
99
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
83
100
|
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
101
|
+
/**
|
|
102
|
+
* Simulates calls through the standard PXE path (account entrypoint).
|
|
103
|
+
* @param executionPayload - The execution payload to simulate.
|
|
104
|
+
* @param from - The sender address.
|
|
105
|
+
* @param feeOptions - Fee options for the transaction.
|
|
106
|
+
* @param skipTxValidation - Whether to skip tx validation.
|
|
107
|
+
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
108
|
+
* @param scopes - The scopes to use for the simulation.
|
|
109
|
+
*/
|
|
110
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions, scopes: AccessScopes, skipTxValidation?: boolean, skipFeeEnforcement?: boolean): Promise<TxSimulationResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
113
|
+
* on the node while sending the remaining calls through the standard PXE path.
|
|
114
|
+
* Return values from both paths are merged back in original call order.
|
|
115
|
+
* @param executionPayload - The execution payload to simulate.
|
|
116
|
+
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
117
|
+
* @returns The merged simulation result.
|
|
118
|
+
*/
|
|
84
119
|
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
85
120
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
86
|
-
sendTx(executionPayload: ExecutionPayload, opts: SendOptions): Promise<
|
|
121
|
+
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
122
|
+
/**
|
|
123
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
124
|
+
* @param address - The contract address to resolve.
|
|
125
|
+
*/
|
|
126
|
+
protected getContractName(address: AztecAddress): Promise<string | undefined>;
|
|
87
127
|
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
getContractMetadata(address: AztecAddress): Promise<
|
|
91
|
-
|
|
92
|
-
|
|
128
|
+
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
129
|
+
getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
|
|
130
|
+
getContractMetadata(address: AztecAddress): Promise<{
|
|
131
|
+
instance: ContractInstanceWithAddress | undefined;
|
|
132
|
+
isContractInitialized: boolean;
|
|
133
|
+
isContractPublished: boolean;
|
|
134
|
+
isContractUpdated: boolean;
|
|
135
|
+
updatedContractClassId: Fr | undefined;
|
|
136
|
+
}>;
|
|
137
|
+
getContractClassMetadata(id: Fr): Promise<{
|
|
138
|
+
isArtifactRegistered: boolean;
|
|
139
|
+
isContractClassPubliclyRegistered: boolean;
|
|
140
|
+
}>;
|
|
93
141
|
}
|
|
94
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
142
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9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ozs7T0FlOUM7SUFFSyx3QkFBd0IsQ0FBQyxFQUFFLEVBQUUsRUFBRTs7O09BTXBDO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/base-wallet/base_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/base-wallet/base_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EACL,KAAK,sBAAsB,EAE3B,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,eAAe,EACf,MAAM,EACN,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EAAE,8BAA8B,EAAwC,MAAM,4BAA4B,CAAC;AAClH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EA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,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAe5B;IAEK,mBAAmB,CAAC,OAAO,EAAE,YAAY;;;;;;OAe9C;IAEK,wBAAwB,CAAC,EAAE,EAAE,EAAE;;;OAMpC;CACF"}
|
|
@@ -1,29 +1,45 @@
|
|
|
1
|
+
import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
1
3
|
import { GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
|
|
2
4
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
5
8
|
import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
9
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
10
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
7
11
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
8
12
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
13
|
+
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
9
14
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
10
15
|
import { inspect } from 'util';
|
|
16
|
+
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
11
17
|
/**
|
|
12
18
|
* A base class for Wallet implementations
|
|
13
19
|
*/ export class BaseWallet {
|
|
14
20
|
pxe;
|
|
15
21
|
aztecNode;
|
|
16
22
|
log;
|
|
17
|
-
|
|
23
|
+
minFeePadding;
|
|
18
24
|
cancellableTransactions;
|
|
19
25
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
20
|
-
constructor(pxe, aztecNode){
|
|
26
|
+
constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
|
|
21
27
|
this.pxe = pxe;
|
|
22
28
|
this.aztecNode = aztecNode;
|
|
23
|
-
this.log =
|
|
24
|
-
this.
|
|
29
|
+
this.log = log;
|
|
30
|
+
this.minFeePadding = 0.5;
|
|
25
31
|
this.cancellableTransactions = false;
|
|
26
32
|
}
|
|
33
|
+
scopesFrom(from, additionalScopes = []) {
|
|
34
|
+
const allScopes = from.isZero() ? additionalScopes : [
|
|
35
|
+
from,
|
|
36
|
+
...additionalScopes
|
|
37
|
+
];
|
|
38
|
+
const scopeSet = new Set(allScopes.map((address)=>address.toString()));
|
|
39
|
+
return [
|
|
40
|
+
...scopeSet
|
|
41
|
+
].map(AztecAddress.fromString);
|
|
42
|
+
}
|
|
27
43
|
/**
|
|
28
44
|
* Returns the list of aliased contacts associated with the wallet.
|
|
29
45
|
* This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
|
|
@@ -56,11 +72,28 @@ import { inspect } from 'util';
|
|
|
56
72
|
executionPayload
|
|
57
73
|
]) : executionPayload;
|
|
58
74
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
59
|
-
|
|
75
|
+
const chainInfo = await this.getChainInfo();
|
|
76
|
+
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
60
77
|
}
|
|
61
78
|
async createAuthWit(from, messageHashOrIntent) {
|
|
62
79
|
const account = await this.getAccountFromAddress(from);
|
|
63
|
-
|
|
80
|
+
const chainInfo = await this.getChainInfo();
|
|
81
|
+
return account.createAuthWit(messageHashOrIntent, chainInfo);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Request capabilities from the wallet.
|
|
85
|
+
*
|
|
86
|
+
* This method is wallet-implementation-dependent and must be provided by classes extending BaseWallet.
|
|
87
|
+
* Embedded wallets typically don't support capability-based authorization (no user authorization flow),
|
|
88
|
+
* while external wallets (browser extensions, hardware wallets) implement this to reduce authorization
|
|
89
|
+
* friction by allowing apps to request permissions upfront.
|
|
90
|
+
*
|
|
91
|
+
* TODO: Consider making it abstract so implementing it is a conscious decision. Leaving it as-is
|
|
92
|
+
* while the feature stabilizes.
|
|
93
|
+
*
|
|
94
|
+
* @param _manifest - Application capability manifest declaring what operations the app needs
|
|
95
|
+
*/ requestCapabilities(_manifest) {
|
|
96
|
+
throw new Error('Not implemented');
|
|
64
97
|
}
|
|
65
98
|
async batch(methods) {
|
|
66
99
|
const results = [];
|
|
@@ -88,7 +121,7 @@ import { inspect } from 'util';
|
|
|
88
121
|
* @param gasSettings - User-provided partial gas settings
|
|
89
122
|
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
90
123
|
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
91
|
-
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.
|
|
124
|
+
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
92
125
|
let accountFeePaymentMethodOptions;
|
|
93
126
|
// The transaction does not include a fee payment method, so we set the flag
|
|
94
127
|
// for the account to use its fee juice balance
|
|
@@ -132,7 +165,7 @@ import { inspect } from 'util';
|
|
|
132
165
|
return this.pxe.registerSender(address);
|
|
133
166
|
}
|
|
134
167
|
async registerContract(instance, artifact, secretKey) {
|
|
135
|
-
const
|
|
168
|
+
const existingInstance = await this.pxe.getContractInstance(instance.address);
|
|
136
169
|
if (existingInstance) {
|
|
137
170
|
// Instance already registered in the wallet
|
|
138
171
|
if (artifact) {
|
|
@@ -148,11 +181,10 @@ import { inspect } from 'util';
|
|
|
148
181
|
// Instance not registered yet
|
|
149
182
|
if (!artifact) {
|
|
150
183
|
// Try to get the artifact from the wallet's contract class storage
|
|
151
|
-
|
|
152
|
-
if (!
|
|
184
|
+
artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
185
|
+
if (!artifact) {
|
|
153
186
|
throw new Error(`Cannot register contract at ${instance.address.toString()}: artifact is required but not provided, and wallet does not have the artifact for contract class ${instance.currentContractClassId.toString()}`);
|
|
154
187
|
}
|
|
155
|
-
artifact = classMetadata.artifact;
|
|
156
188
|
}
|
|
157
189
|
await this.pxe.registerContract({
|
|
158
190
|
artifact,
|
|
@@ -164,20 +196,66 @@ import { inspect } from 'util';
|
|
|
164
196
|
}
|
|
165
197
|
return instance;
|
|
166
198
|
}
|
|
167
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Simulates calls through the standard PXE path (account entrypoint).
|
|
201
|
+
* @param executionPayload - The execution payload to simulate.
|
|
202
|
+
* @param from - The sender address.
|
|
203
|
+
* @param feeOptions - Fee options for the transaction.
|
|
204
|
+
* @param skipTxValidation - Whether to skip tx validation.
|
|
205
|
+
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
206
|
+
* @param scopes - The scopes to use for the simulation.
|
|
207
|
+
*/ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement) {
|
|
208
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions);
|
|
209
|
+
return this.pxe.simulateTx(txRequest, {
|
|
210
|
+
simulatePublic: true,
|
|
211
|
+
skipTxValidation,
|
|
212
|
+
skipFeeEnforcement,
|
|
213
|
+
scopes
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
218
|
+
* on the node while sending the remaining calls through the standard PXE path.
|
|
219
|
+
* Return values from both paths are merged back in original call order.
|
|
220
|
+
* @param executionPayload - The execution payload to simulate.
|
|
221
|
+
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
222
|
+
* @returns The merged simulation result.
|
|
223
|
+
*/ async simulateTx(executionPayload, opts) {
|
|
168
224
|
const feeOptions = opts.fee?.estimateGas ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings) : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
169
|
-
const
|
|
170
|
-
|
|
225
|
+
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
226
|
+
const remainingPayload = {
|
|
227
|
+
...executionPayload,
|
|
228
|
+
calls: remainingCalls
|
|
229
|
+
};
|
|
230
|
+
const chainInfo = await this.getChainInfo();
|
|
231
|
+
let blockHeader;
|
|
232
|
+
// PXE might not be synced yet, so we pull the latest header from the node
|
|
233
|
+
// To keep things consistent, we'll always try with PXE first
|
|
234
|
+
try {
|
|
235
|
+
blockHeader = await this.pxe.getSyncedBlockHeader();
|
|
236
|
+
} catch {
|
|
237
|
+
blockHeader = await this.aztecNode.getBlockHeader();
|
|
238
|
+
}
|
|
239
|
+
const [optimizedResults, normalResult] = await Promise.all([
|
|
240
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, opts.from, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
|
|
241
|
+
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, opts.from, feeOptions, this.scopesFrom(opts.from, opts.additionalScopes), opts.skipTxValidation, opts.skipFeeEnforcement ?? true) : Promise.resolve(null)
|
|
242
|
+
]);
|
|
243
|
+
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
171
244
|
}
|
|
172
245
|
async profileTx(executionPayload, opts) {
|
|
173
246
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
174
247
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
175
|
-
return this.pxe.profileTx(txRequest,
|
|
248
|
+
return this.pxe.profileTx(txRequest, {
|
|
249
|
+
profileMode: opts.profileMode,
|
|
250
|
+
skipProofGeneration: opts.skipProofGeneration ?? true,
|
|
251
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
252
|
+
});
|
|
176
253
|
}
|
|
177
254
|
async sendTx(executionPayload, opts) {
|
|
178
255
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
179
256
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
180
|
-
const provenTx = await this.pxe.proveTx(txRequest);
|
|
257
|
+
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
258
|
+
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects());
|
|
181
259
|
const tx = await provenTx.toTx();
|
|
182
260
|
const txHash = tx.getTxHash();
|
|
183
261
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -188,7 +266,35 @@ import { inspect } from 'util';
|
|
|
188
266
|
throw this.contextualizeError(err, inspect(tx));
|
|
189
267
|
});
|
|
190
268
|
this.log.info(`Sent transaction ${txHash}`);
|
|
191
|
-
return txHash
|
|
269
|
+
// If wait is NO_WAIT, return txHash immediately
|
|
270
|
+
if (opts.wait === NO_WAIT) {
|
|
271
|
+
return {
|
|
272
|
+
txHash,
|
|
273
|
+
...offchainOutput
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
277
|
+
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
278
|
+
const receipt = await waitForTx(this.aztecNode, txHash, waitOpts);
|
|
279
|
+
// Display debug logs from public execution if present (served in test mode only)
|
|
280
|
+
if (receipt.debugLogs?.length) {
|
|
281
|
+
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
receipt,
|
|
285
|
+
...offchainOutput
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
290
|
+
* @param address - The contract address to resolve.
|
|
291
|
+
*/ async getContractName(address) {
|
|
292
|
+
const instance = await this.pxe.getContractInstance(address);
|
|
293
|
+
if (!instance) {
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
const artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
297
|
+
return artifact?.name;
|
|
192
298
|
}
|
|
193
299
|
contextualizeError(err, ...context) {
|
|
194
300
|
let contextStr = '';
|
|
@@ -203,23 +309,49 @@ import { inspect } from 'util';
|
|
|
203
309
|
}
|
|
204
310
|
return err;
|
|
205
311
|
}
|
|
206
|
-
|
|
207
|
-
return this.pxe.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
312
|
+
executeUtility(call, opts) {
|
|
313
|
+
return this.pxe.executeUtility(call, {
|
|
314
|
+
authwits: opts.authWitnesses,
|
|
315
|
+
scopes: [
|
|
316
|
+
opts.scope
|
|
317
|
+
]
|
|
318
|
+
});
|
|
211
319
|
}
|
|
212
|
-
|
|
213
|
-
|
|
320
|
+
async getPrivateEvents(eventDef, eventFilter) {
|
|
321
|
+
const pxeEvents = await this.pxe.getPrivateEvents(eventDef.eventSelector, eventFilter);
|
|
322
|
+
const decodedEvents = pxeEvents.map((pxeEvent)=>{
|
|
323
|
+
return {
|
|
324
|
+
event: decodeFromAbi([
|
|
325
|
+
eventDef.abiType
|
|
326
|
+
], pxeEvent.packedEvent),
|
|
327
|
+
metadata: {
|
|
328
|
+
l2BlockNumber: pxeEvent.l2BlockNumber,
|
|
329
|
+
l2BlockHash: pxeEvent.l2BlockHash,
|
|
330
|
+
txHash: pxeEvent.txHash
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
return decodedEvents;
|
|
214
335
|
}
|
|
215
|
-
|
|
216
|
-
|
|
336
|
+
async getContractMetadata(address) {
|
|
337
|
+
const instance = await this.pxe.getContractInstance(address);
|
|
338
|
+
const initNullifier = await siloNullifier(address, address.toField());
|
|
339
|
+
const publiclyRegisteredContract = await this.aztecNode.getContract(address);
|
|
340
|
+
const initNullifierMembershipWitness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
341
|
+
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
342
|
+
return {
|
|
343
|
+
instance: instance ?? undefined,
|
|
344
|
+
isContractInitialized: !!initNullifierMembershipWitness,
|
|
345
|
+
isContractPublished: !!publiclyRegisteredContract,
|
|
346
|
+
isContractUpdated: !!isContractUpdated,
|
|
347
|
+
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
348
|
+
};
|
|
217
349
|
}
|
|
218
|
-
async
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
350
|
+
async getContractClassMetadata(id) {
|
|
351
|
+
const publiclyRegisteredContractClass = await this.aztecNode.getContractClass(id);
|
|
352
|
+
return {
|
|
353
|
+
isArtifactRegistered: !!await this.pxe.getContractArtifact(id),
|
|
354
|
+
isContractClassPubliclyRegistered: !!publiclyRegisteredContractClass
|
|
355
|
+
};
|
|
224
356
|
}
|
|
225
357
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { BaseWallet, type FeeOptions } from './base_wallet.js';
|
|
2
|
-
|
|
2
|
+
export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLEtBQUssVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDL0QsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
|
+
import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
|
|
4
|
+
import { type FunctionCall } from '@aztec/stdlib/abi';
|
|
5
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
7
|
+
import { type BlockHeader, type ExecutionPayload, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
8
|
+
/**
|
|
9
|
+
* Splits an execution payload into a leading prefix of public static calls
|
|
10
|
+
* (eligible for direct node simulation) and the remaining calls.
|
|
11
|
+
*
|
|
12
|
+
* Only a leading run of public static calls is eligible for optimization.
|
|
13
|
+
* Any non-public-static call may enqueue public state mutations
|
|
14
|
+
* (e.g. private calls can enqueue public calls), so all calls that follow
|
|
15
|
+
* must go through the normal simulation path to see the correct state.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractOptimizablePublicStaticCalls(payload: ExecutionPayload): {
|
|
19
|
+
/** Leading public static calls eligible for direct node simulation. */
|
|
20
|
+
optimizableCalls: FunctionCall[];
|
|
21
|
+
/** All remaining calls. */
|
|
22
|
+
remainingCalls: FunctionCall[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Simulates public static calls by splitting them into batches of MAX_ENQUEUED_CALLS_PER_CALL
|
|
26
|
+
* and sending each batch directly to the node.
|
|
27
|
+
*
|
|
28
|
+
* @param node - The Aztec node to simulate on.
|
|
29
|
+
* @param publicStaticCalls - Array of public static function calls to optimize.
|
|
30
|
+
* @param from - The account address making the calls.
|
|
31
|
+
* @param chainInfo - Chain information (chainId and version).
|
|
32
|
+
* @param gasSettings - Gas settings for the transaction.
|
|
33
|
+
* @param blockHeader - Block header to use as anchor.
|
|
34
|
+
* @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
|
|
35
|
+
* @returns Array of TxSimulationResult, one per batch.
|
|
36
|
+
*/
|
|
37
|
+
export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement: boolean | undefined, getContractName: ContractNameResolver): Promise<TxSimulationResult[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Merges simulation results from the optimized (public static) and normal paths.
|
|
40
|
+
* Since optimized calls are always a leading prefix, return values are simply
|
|
41
|
+
* concatenated: optimized first, then normal.
|
|
42
|
+
* Stats are taken from the normal result only (the optimized path doesn't produce them).
|
|
43
|
+
*
|
|
44
|
+
* @param optimizedResults - Results from optimized public static call batches.
|
|
45
|
+
* @param normalResult - Result from normal simulation (null if all calls were optimized).
|
|
46
|
+
* @returns A single TxSimulationResult with return values in original call order.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult: TxS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