@aztec/wallet-sdk 0.0.1-commit.cbf2c2d5d → 0.0.1-commit.ce4f8c4f2
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.
|
@@ -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';
|
|
@@ -27,7 +27,7 @@ export type FeeOptions = {
|
|
|
27
27
|
*/
|
|
28
28
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
29
29
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
30
|
-
accountFeePaymentMethodOptions
|
|
30
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
31
31
|
/** The gas settings to use for the transaction */
|
|
32
32
|
gasSettings: GasSettings;
|
|
33
33
|
};
|
|
@@ -48,7 +48,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
48
48
|
protected minFeePadding: number;
|
|
49
49
|
protected cancellableTransactions: boolean;
|
|
50
50
|
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
51
|
-
protected scopesFrom(from: AztecAddress, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
51
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
52
52
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
53
53
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
54
54
|
/**
|
|
@@ -60,7 +60,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
60
60
|
*/
|
|
61
61
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
62
62
|
getChainInfo(): Promise<ChainInfo>;
|
|
63
|
-
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
63
|
+
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
64
64
|
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
65
65
|
/**
|
|
66
66
|
* Request capabilities from the wallet.
|
|
@@ -84,7 +84,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
84
84
|
* @param gasSettings - User-provided partial gas settings
|
|
85
85
|
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
86
86
|
*/
|
|
87
|
-
protected completeFeeOptions(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<FeeOptions>;
|
|
87
|
+
protected completeFeeOptions(from: AztecAddress | NoFrom, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<FeeOptions>;
|
|
88
88
|
/**
|
|
89
89
|
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
90
90
|
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
@@ -93,14 +93,14 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
93
93
|
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
94
94
|
* @param gasSettings - User-provided partial gas settings
|
|
95
95
|
*/
|
|
96
|
-
protected completeFeeOptionsForEstimation(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
96
|
+
protected completeFeeOptionsForEstimation(from: AztecAddress | NoFrom, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
97
97
|
/**
|
|
98
98
|
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
99
99
|
* doesn't already include one
|
|
100
100
|
*/
|
|
101
101
|
walletFeePaymentMethod?: FeePaymentMethod | undefined;
|
|
102
102
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
103
|
-
accountFeePaymentMethodOptions
|
|
103
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions | undefined;
|
|
104
104
|
gasSettings: GasSettings;
|
|
105
105
|
}>;
|
|
106
106
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
@@ -132,14 +132,11 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
132
132
|
getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
|
|
133
133
|
/**
|
|
134
134
|
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
135
|
-
*
|
|
136
|
-
* `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
|
|
137
|
-
* instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
|
|
138
135
|
* @param address - The contract address to query.
|
|
139
136
|
*/
|
|
140
137
|
getContractMetadata(address: AztecAddress): Promise<{
|
|
141
138
|
instance: ContractInstanceWithAddress | undefined;
|
|
142
|
-
|
|
139
|
+
initializationStatus: ContractInitializationStatus;
|
|
143
140
|
isContractPublished: boolean;
|
|
144
141
|
isContractUpdated: boolean;
|
|
145
142
|
updatedContractClassId: Fr | undefined;
|
|
@@ -149,4 +146,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
149
146
|
isContractClassPubliclyRegistered: boolean;
|
|
150
147
|
}>;
|
|
151
148
|
}
|
|
152
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
149
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGVBQWUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2pGLE9BQU8sRUFDTCxLQUFLLHNCQUFzQixFQUUzQixLQUFLLFVBQVUsRUFFaEIsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTVELE9BQU8sRUFDTCxLQUFLLE9BQU8sRUFDWixLQUFLLGVBQWUsRUFDcEIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssYUFBYSxFQUNsQiw0QkFBNEIsRUFDNUIsS0FBSyxxQkFBcUIsRUFDMUIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssY0FBYyxFQUNuQixLQUFLLFdBQVcsRUFDaEIsS0FBSyxlQUFlLEVBQ3BCLEtBQUssTUFBTSxFQUNYLEtBQUssa0JBQWtCLEVBQ3hCLE1BQU0sd0JBQXdCLENBQUM7QUFPaEMsT0FBTyxFQUFFLDhCQUE4QixFQUF3QyxNQUF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yxHQUNuQixPQUFPLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBa0N4QjtJQUVEOzs7T0FHRztJQUNILFVBQWdCLGVBQWUsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBT2xGO0lBRUQsU0FBUyxDQUFDLGtCQUFrQixDQUFDLEdBQUcsRUFBRSxLQUFLLEVBQUUsR0FBRyxPQUFPLEVBQUUsTUFBTSxFQUFFLEdBQUcsS0FBSyxDQVlwRTtJQUVELGNBQWMsQ0FBQyxJQUFJLEVBQUUsWUFBWSxFQUFFLElBQUksRUFBRSxxQkFBcUIsR0FBRyxPQUFPLENBQUMsc0JBQXNCLENBQUMsQ0FFL0Y7SUFFSyxnQkFBZ0IsQ0FBQyxDQUFDLEVBQ3RCLFFBQVEsRUFBRSx1QkFBdUIsRUFDakMsV0FBVyxFQUFFLGtCQUFrQixHQUM5QixPQUFPLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FlNUI7SUFFRDs7O09BR0c7SUFDRyxtQkFBbUIsQ0FBQyxPQUFPLEVBQUUsWUFBWTs7Ozs7O09BaUM5QztJQUVLLHdCQUF3QixDQUFDLEVBQUUsRUFBRSxFQUFFOzs7T0FNcEM7Q0FDRiJ9
|
|
@@ -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;
|
|
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,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+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aztec/aztec.js/node';
|
|
4
|
+
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
3
5
|
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';
|
|
4
6
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
7
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
5
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
10
|
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
@@ -10,7 +13,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
10
13
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
11
14
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
12
15
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
13
|
-
import { computeSiloedPrivateInitializationNullifier } from '@aztec/stdlib/hash';
|
|
16
|
+
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
|
|
14
17
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
15
18
|
import { inspect } from 'util';
|
|
16
19
|
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
@@ -31,7 +34,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
31
34
|
this.cancellableTransactions = false;
|
|
32
35
|
}
|
|
33
36
|
scopesFrom(from, additionalScopes = []) {
|
|
34
|
-
const allScopes = from
|
|
37
|
+
const allScopes = from === NO_FROM ? additionalScopes : [
|
|
35
38
|
from,
|
|
36
39
|
...additionalScopes
|
|
37
40
|
];
|
|
@@ -62,18 +65,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
62
65
|
}
|
|
63
66
|
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
64
67
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
65
|
-
const executionOptions = {
|
|
66
|
-
txNonce: Fr.random(),
|
|
67
|
-
cancellable: this.cancellableTransactions,
|
|
68
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
69
|
-
};
|
|
70
68
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
71
69
|
feeExecutionPayload,
|
|
72
70
|
executionPayload
|
|
73
71
|
]) : executionPayload;
|
|
74
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
75
72
|
const chainInfo = await this.getChainInfo();
|
|
76
|
-
|
|
73
|
+
if (from === NO_FROM) {
|
|
74
|
+
const entrypoint = new DefaultEntrypoint();
|
|
75
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
76
|
+
} else {
|
|
77
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
78
|
+
const executionOptions = {
|
|
79
|
+
txNonce: Fr.random(),
|
|
80
|
+
cancellable: this.cancellableTransactions,
|
|
81
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
82
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
83
|
+
};
|
|
84
|
+
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
85
|
+
}
|
|
77
86
|
}
|
|
78
87
|
async createAuthWit(from, messageHashOrIntent) {
|
|
79
88
|
const account = await this.getAccountFromAddress(from);
|
|
@@ -123,14 +132,18 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
123
132
|
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
124
133
|
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
125
134
|
let accountFeePaymentMethodOptions;
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
136
|
+
// account contract entrypoint to use
|
|
137
|
+
if (from !== NO_FROM) {
|
|
138
|
+
if (!feePayer) {
|
|
139
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
140
|
+
// for the account to use its fee juice balance
|
|
141
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
142
|
+
} else {
|
|
143
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
144
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
145
|
+
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
146
|
+
}
|
|
134
147
|
}
|
|
135
148
|
const fullGasSettings = GasSettings.default({
|
|
136
149
|
...gasSettings,
|
|
@@ -232,8 +245,9 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
232
245
|
} catch {
|
|
233
246
|
blockHeader = await this.aztecNode.getBlockHeader();
|
|
234
247
|
}
|
|
248
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
235
249
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
236
|
-
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls,
|
|
250
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
|
|
237
251
|
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
238
252
|
from: opts.from,
|
|
239
253
|
feeOptions,
|
|
@@ -314,9 +328,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
314
328
|
executeUtility(call, opts) {
|
|
315
329
|
return this.pxe.executeUtility(call, {
|
|
316
330
|
authwits: opts.authWitnesses,
|
|
317
|
-
scopes:
|
|
318
|
-
opts.scope
|
|
319
|
-
]
|
|
331
|
+
scopes: opts.scopes
|
|
320
332
|
});
|
|
321
333
|
}
|
|
322
334
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
@@ -337,31 +349,31 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
337
349
|
}
|
|
338
350
|
/**
|
|
339
351
|
* 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
352
|
* @param address - The contract address to query.
|
|
344
353
|
*/ async getContractMetadata(address) {
|
|
345
354
|
const instance = await this.pxe.getContractInstance(address);
|
|
346
355
|
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;
|
|
356
|
+
let initializationStatus;
|
|
355
357
|
if (instance) {
|
|
358
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
359
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
356
360
|
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
357
361
|
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
358
|
-
|
|
362
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNINITIALIZED;
|
|
363
|
+
} else {
|
|
364
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
365
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
366
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
367
|
+
// uninitialized.
|
|
368
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
369
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
370
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
359
371
|
}
|
|
360
372
|
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
361
373
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
362
374
|
return {
|
|
363
375
|
instance: instance ?? undefined,
|
|
364
|
-
|
|
376
|
+
initializationStatus,
|
|
365
377
|
isContractPublished: !!publiclyRegisteredContract,
|
|
366
378
|
isContractUpdated: !!isContractUpdated,
|
|
367
379
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/wallet-sdk",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallet-sdk",
|
|
4
|
-
"version": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.ce4f8c4f2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./base-wallet": "./dest/base-wallet/index.js",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
75
|
-
"@aztec/constants": "0.0.1-commit.
|
|
76
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
77
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
78
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
74
|
+
"@aztec/aztec.js": "0.0.1-commit.ce4f8c4f2",
|
|
75
|
+
"@aztec/constants": "0.0.1-commit.ce4f8c4f2",
|
|
76
|
+
"@aztec/entrypoints": "0.0.1-commit.ce4f8c4f2",
|
|
77
|
+
"@aztec/foundation": "0.0.1-commit.ce4f8c4f2",
|
|
78
|
+
"@aztec/pxe": "0.0.1-commit.ce4f8c4f2",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.ce4f8c4f2"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
82
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.ce4f8c4f2",
|
|
83
83
|
"@jest/globals": "^30.0.0",
|
|
84
84
|
"@types/jest": "^30.0.0",
|
|
85
85
|
"@types/node": "^22.15.17",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Account } from '@aztec/aztec.js/account';
|
|
1
|
+
import type { Account, NoFrom } from '@aztec/aztec.js/account';
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
3
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
4
|
import {
|
|
4
5
|
type InteractionWaitOptions,
|
|
@@ -8,19 +9,20 @@ import {
|
|
|
8
9
|
} from '@aztec/aztec.js/contracts';
|
|
9
10
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
10
11
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
11
|
-
import
|
|
12
|
-
Aliased,
|
|
13
|
-
AppCapabilities,
|
|
14
|
-
BatchResults,
|
|
15
|
-
BatchedMethod,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
import {
|
|
13
|
+
type Aliased,
|
|
14
|
+
type AppCapabilities,
|
|
15
|
+
type BatchResults,
|
|
16
|
+
type BatchedMethod,
|
|
17
|
+
ContractInitializationStatus,
|
|
18
|
+
type ExecuteUtilityOptions,
|
|
19
|
+
type PrivateEvent,
|
|
20
|
+
type PrivateEventFilter,
|
|
21
|
+
type ProfileOptions,
|
|
22
|
+
type SendOptions,
|
|
23
|
+
type SimulateOptions,
|
|
24
|
+
type Wallet,
|
|
25
|
+
type WalletCapabilities,
|
|
24
26
|
} from '@aztec/aztec.js/wallet';
|
|
25
27
|
import {
|
|
26
28
|
GAS_ESTIMATION_DA_GAS_LIMIT,
|
|
@@ -29,6 +31,7 @@ import {
|
|
|
29
31
|
GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT,
|
|
30
32
|
} from '@aztec/constants';
|
|
31
33
|
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
34
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
32
35
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
33
36
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
34
37
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -50,7 +53,10 @@ import {
|
|
|
50
53
|
} from '@aztec/stdlib/contract';
|
|
51
54
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
52
55
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
53
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
computeSiloedPrivateInitializationNullifier,
|
|
58
|
+
computeSiloedPublicInitializationNullifier,
|
|
59
|
+
} from '@aztec/stdlib/hash';
|
|
54
60
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
55
61
|
import {
|
|
56
62
|
BlockHeader,
|
|
@@ -75,7 +81,7 @@ export type FeeOptions = {
|
|
|
75
81
|
*/
|
|
76
82
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
77
83
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
78
|
-
accountFeePaymentMethodOptions
|
|
84
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
79
85
|
/** The gas settings to use for the transaction */
|
|
80
86
|
gasSettings: GasSettings;
|
|
81
87
|
};
|
|
@@ -104,8 +110,8 @@ export abstract class BaseWallet implements Wallet {
|
|
|
104
110
|
protected log = createLogger('wallet-sdk:base_wallet'),
|
|
105
111
|
) {}
|
|
106
112
|
|
|
107
|
-
protected scopesFrom(from: AztecAddress, additionalScopes: AztecAddress[] = []): AztecAddress[] {
|
|
108
|
-
const allScopes = from
|
|
113
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes: AztecAddress[] = []): AztecAddress[] {
|
|
114
|
+
const allScopes = from === NO_FROM ? additionalScopes : [from, ...additionalScopes];
|
|
109
115
|
const scopeSet = new Set(allScopes.map(address => address.toString()));
|
|
110
116
|
return [...scopeSet].map(AztecAddress.fromString);
|
|
111
117
|
}
|
|
@@ -133,26 +139,33 @@ export abstract class BaseWallet implements Wallet {
|
|
|
133
139
|
|
|
134
140
|
protected async createTxExecutionRequestFromPayloadAndFee(
|
|
135
141
|
executionPayload: ExecutionPayload,
|
|
136
|
-
from: AztecAddress,
|
|
142
|
+
from: AztecAddress | NoFrom,
|
|
137
143
|
feeOptions: FeeOptions,
|
|
138
144
|
): Promise<TxExecutionRequest> {
|
|
139
145
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
140
|
-
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
141
|
-
txNonce: Fr.random(),
|
|
142
|
-
cancellable: this.cancellableTransactions,
|
|
143
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
144
|
-
};
|
|
145
146
|
const finalExecutionPayload = feeExecutionPayload
|
|
146
147
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
147
148
|
: executionPayload;
|
|
148
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
149
149
|
const chainInfo = await this.getChainInfo();
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
chainInfo
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
|
|
151
|
+
if (from === NO_FROM) {
|
|
152
|
+
const entrypoint = new DefaultEntrypoint();
|
|
153
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
154
|
+
} else {
|
|
155
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
156
|
+
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
157
|
+
txNonce: Fr.random(),
|
|
158
|
+
cancellable: this.cancellableTransactions,
|
|
159
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
160
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions!,
|
|
161
|
+
};
|
|
162
|
+
return fromAccount.createTxExecutionRequest(
|
|
163
|
+
finalExecutionPayload,
|
|
164
|
+
feeOptions.gasSettings,
|
|
165
|
+
chainInfo,
|
|
166
|
+
executionOptions,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
156
169
|
}
|
|
157
170
|
|
|
158
171
|
public async createAuthWit(
|
|
@@ -207,23 +220,27 @@ export abstract class BaseWallet implements Wallet {
|
|
|
207
220
|
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
208
221
|
*/
|
|
209
222
|
protected async completeFeeOptions(
|
|
210
|
-
from: AztecAddress,
|
|
223
|
+
from: AztecAddress | NoFrom,
|
|
211
224
|
feePayer?: AztecAddress,
|
|
212
225
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
213
226
|
): Promise<FeeOptions> {
|
|
214
227
|
const maxFeesPerGas =
|
|
215
228
|
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
216
229
|
let accountFeePaymentMethodOptions;
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
231
|
+
// account contract entrypoint to use
|
|
232
|
+
if (from !== NO_FROM) {
|
|
233
|
+
if (!feePayer) {
|
|
234
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
235
|
+
// for the account to use its fee juice balance
|
|
236
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
237
|
+
} else {
|
|
238
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
239
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
240
|
+
accountFeePaymentMethodOptions = from.equals(feePayer)
|
|
241
|
+
? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM
|
|
242
|
+
: AccountFeePaymentMethodOptions.EXTERNAL;
|
|
243
|
+
}
|
|
227
244
|
}
|
|
228
245
|
const fullGasSettings: GasSettings = GasSettings.default({ ...gasSettings, maxFeesPerGas });
|
|
229
246
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
@@ -243,7 +260,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
243
260
|
* @param gasSettings - User-provided partial gas settings
|
|
244
261
|
*/
|
|
245
262
|
protected async completeFeeOptionsForEstimation(
|
|
246
|
-
from: AztecAddress,
|
|
263
|
+
from: AztecAddress | NoFrom,
|
|
247
264
|
feePayer?: AztecAddress,
|
|
248
265
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
249
266
|
) {
|
|
@@ -351,12 +368,13 @@ export abstract class BaseWallet implements Wallet {
|
|
|
351
368
|
blockHeader = (await this.aztecNode.getBlockHeader())!;
|
|
352
369
|
}
|
|
353
370
|
|
|
371
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
354
372
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
355
373
|
optimizableCalls.length > 0
|
|
356
374
|
? simulateViaNode(
|
|
357
375
|
this.aztecNode,
|
|
358
376
|
optimizableCalls,
|
|
359
|
-
|
|
377
|
+
simulationOrigin,
|
|
360
378
|
chainInfo,
|
|
361
379
|
feeOptions.gasSettings,
|
|
362
380
|
blockHeader,
|
|
@@ -455,7 +473,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
455
473
|
}
|
|
456
474
|
|
|
457
475
|
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult> {
|
|
458
|
-
return this.pxe.executeUtility(call, { authwits: opts.authWitnesses, scopes:
|
|
476
|
+
return this.pxe.executeUtility(call, { authwits: opts.authWitnesses, scopes: opts.scopes });
|
|
459
477
|
}
|
|
460
478
|
|
|
461
479
|
async getPrivateEvents<T>(
|
|
@@ -480,26 +498,29 @@ export abstract class BaseWallet implements Wallet {
|
|
|
480
498
|
|
|
481
499
|
/**
|
|
482
500
|
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
483
|
-
*
|
|
484
|
-
* `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
|
|
485
|
-
* instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
|
|
486
501
|
* @param address - The contract address to query.
|
|
487
502
|
*/
|
|
488
503
|
async getContractMetadata(address: AztecAddress) {
|
|
489
504
|
const instance = await this.pxe.getContractInstance(address);
|
|
490
505
|
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
// the instance (and thus init_hash), we can't compute it, so we return undefined.
|
|
494
|
-
//
|
|
495
|
-
// We skip the public initialization nullifier because it's not always emitted (contracts without public external
|
|
496
|
-
// functions that require initialization checks won't emit it). If the private one exists, the public one was
|
|
497
|
-
// created in the same tx and will also be present.
|
|
498
|
-
let isContractInitialized: boolean | undefined = undefined;
|
|
506
|
+
|
|
507
|
+
let initializationStatus: ContractInitializationStatus;
|
|
499
508
|
if (instance) {
|
|
509
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
510
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
500
511
|
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
501
512
|
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
502
|
-
|
|
513
|
+
initializationStatus = witness
|
|
514
|
+
? ContractInitializationStatus.INITIALIZED
|
|
515
|
+
: ContractInitializationStatus.UNINITIALIZED;
|
|
516
|
+
} else {
|
|
517
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
518
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
519
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
520
|
+
// uninitialized.
|
|
521
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
522
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
523
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
503
524
|
}
|
|
504
525
|
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
505
526
|
const isContractUpdated =
|
|
@@ -507,7 +528,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
507
528
|
!publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
508
529
|
return {
|
|
509
530
|
instance: instance ?? undefined,
|
|
510
|
-
|
|
531
|
+
initializationStatus,
|
|
511
532
|
isContractPublished: !!publiclyRegisteredContract,
|
|
512
533
|
isContractUpdated: !!isContractUpdated,
|
|
513
534
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined,
|