@aztec/wallet-sdk 0.0.1-commit.d431d1c → 0.0.1-commit.d939eb5aa
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 +217 -294
- package/dest/base-wallet/base_wallet.d.ts +86 -37
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +237 -69
- package/dest/base-wallet/index.d.ts +3 -2
- package/dest/base-wallet/index.d.ts.map +1 -1
- package/dest/base-wallet/index.js +1 -0
- package/dest/base-wallet/utils.d.ts +50 -0
- package/dest/base-wallet/utils.d.ts.map +1 -0
- package/dest/base-wallet/utils.js +133 -0
- package/dest/crypto.d.ts +97 -50
- package/dest/crypto.d.ts.map +1 -1
- package/dest/crypto.js +290 -108
- 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 +129 -0
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -0
- package/dest/{providers/extension → extension/provider}/extension_wallet.js +57 -97
- package/dest/extension/provider/index.d.ts +3 -0
- package/dest/extension/provider/index.d.ts.map +1 -0
- package/dest/{providers/extension → extension/provider}/index.js +0 -2
- 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/index.d.ts +2 -8
- package/dest/manager/index.d.ts.map +1 -1
- package/dest/manager/index.js +0 -6
- package/dest/manager/types.d.ts +92 -9
- 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 +203 -43
- package/dest/types.d.ts +55 -12
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +7 -2
- package/package.json +21 -10
- package/src/base-wallet/base_wallet.ts +334 -126
- package/src/base-wallet/index.ts +7 -1
- package/src/base-wallet/utils.ts +240 -0
- package/src/crypto.ts +341 -113
- 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/{providers/extension → extension/provider}/extension_wallet.ts +61 -116
- package/src/extension/provider/index.ts +7 -0
- 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/index.ts +2 -10
- package/src/manager/types.ts +95 -8
- package/src/manager/wallet_manager.ts +223 -45
- package/src/types.ts +57 -10
- package/dest/providers/extension/extension_provider.d.ts +0 -63
- package/dest/providers/extension/extension_provider.d.ts.map +0 -1
- package/dest/providers/extension/extension_provider.js +0 -124
- package/dest/providers/extension/extension_wallet.d.ts +0 -155
- package/dest/providers/extension/extension_wallet.d.ts.map +0 -1
- package/dest/providers/extension/index.d.ts +0 -6
- package/dest/providers/extension/index.d.ts.map +0 -1
- package/src/providers/extension/extension_provider.ts +0 -167
- package/src/providers/extension/index.ts +0 -5
|
@@ -1,7 +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
|
+
import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
3
4
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
4
|
-
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, TxSimulationResultWithAppOffset, type Wallet, type WalletCapabilities } from '@aztec/aztec.js/wallet';
|
|
5
6
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
6
7
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
7
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -9,12 +10,11 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
9
10
|
import type { PXE } from '@aztec/pxe/server';
|
|
10
11
|
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall } from '@aztec/stdlib/abi';
|
|
11
12
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
12
|
-
import
|
|
13
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
14
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
14
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
15
|
+
import { GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
15
16
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
16
|
-
import
|
|
17
|
-
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
17
|
+
import { ExecutionPayload, type TxExecutionRequest, type TxProfileResult, type UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
18
18
|
/**
|
|
19
19
|
* Options to configure fee payment for a transaction
|
|
20
20
|
*/
|
|
@@ -25,10 +25,31 @@ export type FeeOptions = {
|
|
|
25
25
|
*/
|
|
26
26
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
27
27
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
28
|
-
accountFeePaymentMethodOptions
|
|
28
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
29
29
|
/** The gas settings to use for the transaction */
|
|
30
30
|
gasSettings: GasSettings;
|
|
31
31
|
};
|
|
32
|
+
/** Options for `simulateViaEntrypoint`. */
|
|
33
|
+
export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'> & {
|
|
34
|
+
/** Fee options for the entrypoint */
|
|
35
|
+
feeOptions: FeeOptions;
|
|
36
|
+
};
|
|
37
|
+
/** Options for `completeFeeOptions`. */
|
|
38
|
+
export type CompleteFeeOptionsConfig = {
|
|
39
|
+
/** The address where the transaction is being sent from. */
|
|
40
|
+
from: AztecAddress | NoFrom;
|
|
41
|
+
/** The address paying for fees (if any fee payment method is embedded in the execution payload). */
|
|
42
|
+
feePayer?: AztecAddress;
|
|
43
|
+
/** User-provided partial gas settings. */
|
|
44
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
45
|
+
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
46
|
+
forEstimation?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Assumed network congestion level for fee prediction. Controls how aggressively the wallet
|
|
49
|
+
* estimates future fees. Defaults to Limit (worst case) when not specified.
|
|
50
|
+
*/
|
|
51
|
+
congestionEstimate?: ManaUsageEstimate;
|
|
52
|
+
};
|
|
32
53
|
/**
|
|
33
54
|
* A base class for Wallet implementations
|
|
34
55
|
*/
|
|
@@ -38,7 +59,8 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
38
59
|
protected log: import("@aztec/foundation/log").Logger;
|
|
39
60
|
protected minFeePadding: number;
|
|
40
61
|
protected cancellableTransactions: boolean;
|
|
41
|
-
protected constructor(pxe: PXE, aztecNode: AztecNode);
|
|
62
|
+
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
63
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
42
64
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
43
65
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
44
66
|
/**
|
|
@@ -50,49 +72,76 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
50
72
|
*/
|
|
51
73
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
52
74
|
getChainInfo(): Promise<ChainInfo>;
|
|
53
|
-
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
75
|
+
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
54
76
|
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
77
|
+
/**
|
|
78
|
+
* Request capabilities from the wallet.
|
|
79
|
+
*
|
|
80
|
+
* This method is wallet-implementation-dependent and must be provided by classes extending BaseWallet.
|
|
81
|
+
* Embedded wallets typically don't support capability-based authorization (no user authorization flow),
|
|
82
|
+
* while external wallets (browser extensions, hardware wallets) implement this to reduce authorization
|
|
83
|
+
* friction by allowing apps to request permissions upfront.
|
|
84
|
+
*
|
|
85
|
+
* TODO: Consider making it abstract so implementing it is a conscious decision. Leaving it as-is
|
|
86
|
+
* while the feature stabilizes.
|
|
87
|
+
*
|
|
88
|
+
* @param _manifest - Application capability manifest declaring what operations the app needs
|
|
89
|
+
*/
|
|
90
|
+
requestCapabilities(_manifest: AppCapabilities): Promise<WalletCapabilities>;
|
|
55
91
|
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
56
92
|
/**
|
|
57
93
|
* Completes partial user-provided fee options with wallet defaults.
|
|
58
|
-
* @param
|
|
59
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
60
|
-
* @param gasSettings - User-provided partial gas settings
|
|
61
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
94
|
+
* @param config - Fee completion config.
|
|
62
95
|
*/
|
|
63
|
-
protected completeFeeOptions(
|
|
96
|
+
protected completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions>;
|
|
64
97
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* to
|
|
68
|
-
* @param from - The address where the transaction is being sent from
|
|
69
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
70
|
-
* @param gasSettings - User-provided partial gas settings
|
|
98
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
99
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
100
|
+
* @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
|
|
71
101
|
*/
|
|
72
|
-
protected
|
|
73
|
-
/**
|
|
74
|
-
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
75
|
-
* doesn't already include one
|
|
76
|
-
*/
|
|
77
|
-
walletFeePaymentMethod?: FeePaymentMethod | undefined;
|
|
78
|
-
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
79
|
-
accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
|
|
80
|
-
gasSettings: GasSettings;
|
|
81
|
-
}>;
|
|
102
|
+
protected getMinFees(estimate?: ManaUsageEstimate): Promise<GasFees>;
|
|
82
103
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
83
104
|
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
84
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Simulates calls through the standard PXE path (account entrypoint).
|
|
107
|
+
* @param executionPayload - The execution payload to simulate.
|
|
108
|
+
* @param opts - Simulation options.
|
|
109
|
+
*/
|
|
110
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
111
|
+
/**
|
|
112
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
113
|
+
* calls, N+1 = app).
|
|
114
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
115
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
116
|
+
*/
|
|
117
|
+
protected computeAppCallOffset(from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<number>;
|
|
118
|
+
/**
|
|
119
|
+
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
120
|
+
* on the node while sending the remaining calls through the standard PXE path.
|
|
121
|
+
* Return values from both paths are merged back in original call order.
|
|
122
|
+
* @param executionPayload - The execution payload to simulate.
|
|
123
|
+
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
124
|
+
* @returns The merged simulation result.
|
|
125
|
+
*/
|
|
126
|
+
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
85
127
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
86
|
-
sendTx(executionPayload: ExecutionPayload, opts: SendOptions): Promise<
|
|
128
|
+
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
129
|
+
/**
|
|
130
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
131
|
+
* @param address - The contract address to resolve.
|
|
132
|
+
*/
|
|
133
|
+
protected getContractName(address: AztecAddress): Promise<string | undefined>;
|
|
87
134
|
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
88
|
-
|
|
89
|
-
getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
|
|
135
|
+
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
90
136
|
getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
139
|
+
* @param address - The contract address to query.
|
|
140
|
+
*/
|
|
91
141
|
getContractMetadata(address: AztecAddress): Promise<{
|
|
92
142
|
instance: ContractInstanceWithAddress | undefined;
|
|
93
|
-
|
|
143
|
+
initializationStatus: ContractInitializationStatus;
|
|
94
144
|
isContractPublished: boolean;
|
|
95
|
-
isContractClassPubliclyRegistered: boolean;
|
|
96
145
|
isContractUpdated: boolean;
|
|
97
146
|
updatedContractClassId: Fr | undefined;
|
|
98
147
|
}>;
|
|
@@ -101,4 +150,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
101
150
|
isContractClassPubliclyRegistered: boolean;
|
|
102
151
|
}>;
|
|
103
152
|
}
|
|
104
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
153
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGVBQWUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2pGLE9BQU8sRUFDTCxLQUFLLHNCQUFzQixFQUUzQixLQUFLLFVBQVUsRUFFaEIsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTVELE9BQU8sRUFDTCxLQUFLLE9BQU8sRUFDWixLQUFLLGVBQWUsRUFDcEIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssYUFBYSxFQUNsQiw0QkFBNEIsRUFDNUIsS0FBSyxxQkFBcUIsRUFDMUIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssY0FBYyxFQUNuQixLQUFLLFdBQVcsRUFDaEIsS0FBSyxlQU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":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,+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,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,4BAA4B,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,+BAA+B,EAC/B,KAAK,MAAM,EACX,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,8BAA8B,EAAwC,MAAM,4BAA4B,CAAC;AAElH,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;AAExD,OAAO,KAAK,EAAE,GAAG,EAAsB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D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E,YAAY,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAE/F;IAEK,gBAAgB,CAAC,CAAC,EACtB,QAAQ,EAAE,uBAAuB,EACjC,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAe5B;IAED;;;OAGG;IACG,mBAAmB,CAAC,OAAO,EAAE,YAAY;;;;;;OAiC9C;IAEK,wBAAwB,CAAC,EAAE,EAAE,EAAE;;;OAMpC;CACF"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
+
import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
4
|
+
import { ContractInitializationStatus, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
2
5
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
6
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
3
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
5
10
|
import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
11
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
12
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
7
13
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
8
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
9
|
-
import {
|
|
14
|
+
import { Gas, GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
15
|
+
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
|
|
10
16
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
11
17
|
import { inspect } from 'util';
|
|
18
|
+
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
12
19
|
/**
|
|
13
20
|
* A base class for Wallet implementations
|
|
14
21
|
*/ export class BaseWallet {
|
|
@@ -18,13 +25,23 @@ import { inspect } from 'util';
|
|
|
18
25
|
minFeePadding;
|
|
19
26
|
cancellableTransactions;
|
|
20
27
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
21
|
-
constructor(pxe, aztecNode){
|
|
28
|
+
constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
|
|
22
29
|
this.pxe = pxe;
|
|
23
30
|
this.aztecNode = aztecNode;
|
|
24
|
-
this.log =
|
|
31
|
+
this.log = log;
|
|
25
32
|
this.minFeePadding = 0.5;
|
|
26
33
|
this.cancellableTransactions = false;
|
|
27
34
|
}
|
|
35
|
+
scopesFrom(from, additionalScopes = []) {
|
|
36
|
+
const allScopes = from === NO_FROM ? additionalScopes : [
|
|
37
|
+
from,
|
|
38
|
+
...additionalScopes
|
|
39
|
+
];
|
|
40
|
+
const scopeSet = new Set(allScopes.map((address)=>address.toString()));
|
|
41
|
+
return [
|
|
42
|
+
...scopeSet
|
|
43
|
+
].map(AztecAddress.fromString);
|
|
44
|
+
}
|
|
28
45
|
/**
|
|
29
46
|
* Returns the list of aliased contacts associated with the wallet.
|
|
30
47
|
* This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
|
|
@@ -47,24 +64,45 @@ import { inspect } from 'util';
|
|
|
47
64
|
}
|
|
48
65
|
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
49
66
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
50
|
-
const executionOptions = {
|
|
51
|
-
txNonce: Fr.random(),
|
|
52
|
-
cancellable: this.cancellableTransactions,
|
|
53
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
54
|
-
};
|
|
55
67
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
56
68
|
feeExecutionPayload,
|
|
57
69
|
executionPayload
|
|
58
70
|
]) : executionPayload;
|
|
59
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
60
71
|
const chainInfo = await this.getChainInfo();
|
|
61
|
-
|
|
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
|
+
}
|
|
62
85
|
}
|
|
63
86
|
async createAuthWit(from, messageHashOrIntent) {
|
|
64
87
|
const account = await this.getAccountFromAddress(from);
|
|
65
88
|
const chainInfo = await this.getChainInfo();
|
|
66
89
|
return account.createAuthWit(messageHashOrIntent, chainInfo);
|
|
67
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Request capabilities from the wallet.
|
|
93
|
+
*
|
|
94
|
+
* This method is wallet-implementation-dependent and must be provided by classes extending BaseWallet.
|
|
95
|
+
* Embedded wallets typically don't support capability-based authorization (no user authorization flow),
|
|
96
|
+
* while external wallets (browser extensions, hardware wallets) implement this to reduce authorization
|
|
97
|
+
* friction by allowing apps to request permissions upfront.
|
|
98
|
+
*
|
|
99
|
+
* TODO: Consider making it abstract so implementing it is a conscious decision. Leaving it as-is
|
|
100
|
+
* while the feature stabilizes.
|
|
101
|
+
*
|
|
102
|
+
* @param _manifest - Application capability manifest declaring what operations the app needs
|
|
103
|
+
*/ requestCapabilities(_manifest) {
|
|
104
|
+
throw new Error('Not implemented');
|
|
105
|
+
}
|
|
68
106
|
async batch(methods) {
|
|
69
107
|
const results = [];
|
|
70
108
|
for (const method of methods){
|
|
@@ -86,26 +124,33 @@ import { inspect } from 'util';
|
|
|
86
124
|
}
|
|
87
125
|
/**
|
|
88
126
|
* Completes partial user-provided fee options with wallet defaults.
|
|
89
|
-
* @param
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
94
|
-
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
127
|
+
* @param config - Fee completion config.
|
|
128
|
+
*/ async completeFeeOptions(config) {
|
|
129
|
+
const { from, feePayer, gasSettings, forEstimation, congestionEstimate } = config;
|
|
130
|
+
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.getMinFees(congestionEstimate)).mul(1 + this.minFeePadding);
|
|
95
131
|
let accountFeePaymentMethodOptions;
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
+
}
|
|
104
144
|
}
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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);
|
|
109
154
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
110
155
|
return {
|
|
111
156
|
gasSettings: fullGasSettings,
|
|
@@ -114,22 +159,24 @@ import { inspect } from 'util';
|
|
|
114
159
|
};
|
|
115
160
|
}
|
|
116
161
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* to
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
162
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
163
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
164
|
+
* @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
|
|
165
|
+
*/ async getMinFees(estimate = ManaUsageEstimate.Limit) {
|
|
166
|
+
try {
|
|
167
|
+
const predicted = await this.aztecNode.getPredictedMinFees(estimate);
|
|
168
|
+
if (predicted.length === 0) {
|
|
169
|
+
return this.aztecNode.getCurrentMinFees();
|
|
170
|
+
}
|
|
171
|
+
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
172
|
+
} catch (err) {
|
|
173
|
+
// Fallback for old nodes that don't support getPredictedMinFees.
|
|
174
|
+
// Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
|
|
175
|
+
if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
|
|
176
|
+
return this.aztecNode.getCurrentMinFees();
|
|
177
|
+
}
|
|
178
|
+
throw err;
|
|
179
|
+
}
|
|
133
180
|
}
|
|
134
181
|
registerSender(address, _alias = '') {
|
|
135
182
|
return this.pxe.registerSender(address);
|
|
@@ -166,20 +213,99 @@ import { inspect } from 'util';
|
|
|
166
213
|
}
|
|
167
214
|
return instance;
|
|
168
215
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Simulates calls through the standard PXE path (account entrypoint).
|
|
218
|
+
* @param executionPayload - The execution payload to simulate.
|
|
219
|
+
* @param opts - Simulation options.
|
|
220
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
221
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
222
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
223
|
+
simulatePublic: true,
|
|
224
|
+
skipTxValidation: opts.skipTxValidation,
|
|
225
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
226
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
227
|
+
});
|
|
228
|
+
const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
|
|
229
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
233
|
+
* calls, N+1 = app).
|
|
234
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
235
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
236
|
+
*/ async computeAppCallOffset(from, feeOptions) {
|
|
237
|
+
if (from === NO_FROM) {
|
|
238
|
+
return 0;
|
|
239
|
+
}
|
|
240
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
241
|
+
return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
245
|
+
* on the node while sending the remaining calls through the standard PXE path.
|
|
246
|
+
* Return values from both paths are merged back in original call order.
|
|
247
|
+
* @param executionPayload - The execution payload to simulate.
|
|
248
|
+
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
249
|
+
* @returns The merged simulation result.
|
|
250
|
+
*/ async simulateTx(executionPayload, opts) {
|
|
251
|
+
const feeOptions = await this.completeFeeOptions({
|
|
252
|
+
from: opts.from,
|
|
253
|
+
feePayer: executionPayload.feePayer,
|
|
254
|
+
gasSettings: opts.fee?.gasSettings,
|
|
255
|
+
forEstimation: true,
|
|
256
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
257
|
+
});
|
|
258
|
+
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
259
|
+
const remainingPayload = {
|
|
260
|
+
...executionPayload,
|
|
261
|
+
calls: remainingCalls
|
|
262
|
+
};
|
|
263
|
+
const chainInfo = await this.getChainInfo();
|
|
264
|
+
let blockHeader;
|
|
265
|
+
// PXE might not be synced yet, so we pull the latest header from the node
|
|
266
|
+
// To keep things consistent, we'll always try with PXE first
|
|
267
|
+
try {
|
|
268
|
+
blockHeader = await this.pxe.getSyncedBlockHeader();
|
|
269
|
+
} catch {
|
|
270
|
+
blockHeader = await this.aztecNode.getBlockHeader();
|
|
271
|
+
}
|
|
272
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
273
|
+
const [optimizedResults, normalResult] = await Promise.all([
|
|
274
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
|
|
275
|
+
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
276
|
+
from: opts.from,
|
|
277
|
+
feeOptions,
|
|
278
|
+
additionalScopes: opts.additionalScopes,
|
|
279
|
+
skipTxValidation: opts.skipTxValidation,
|
|
280
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
281
|
+
}) : Promise.resolve(null)
|
|
282
|
+
]);
|
|
283
|
+
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
173
284
|
}
|
|
174
285
|
async profileTx(executionPayload, opts) {
|
|
175
|
-
const feeOptions = await this.completeFeeOptions(
|
|
286
|
+
const feeOptions = await this.completeFeeOptions({
|
|
287
|
+
from: opts.from,
|
|
288
|
+
feePayer: executionPayload.feePayer,
|
|
289
|
+
gasSettings: opts.fee?.gasSettings,
|
|
290
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
291
|
+
});
|
|
176
292
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
177
|
-
return this.pxe.profileTx(txRequest,
|
|
293
|
+
return this.pxe.profileTx(txRequest, {
|
|
294
|
+
profileMode: opts.profileMode,
|
|
295
|
+
skipProofGeneration: opts.skipProofGeneration ?? true,
|
|
296
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
297
|
+
});
|
|
178
298
|
}
|
|
179
299
|
async sendTx(executionPayload, opts) {
|
|
180
|
-
const feeOptions = await this.completeFeeOptions(
|
|
300
|
+
const feeOptions = await this.completeFeeOptions({
|
|
301
|
+
from: opts.from,
|
|
302
|
+
feePayer: executionPayload.feePayer,
|
|
303
|
+
gasSettings: opts.fee?.gasSettings,
|
|
304
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
305
|
+
});
|
|
181
306
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
182
|
-
const provenTx = await this.pxe.proveTx(txRequest);
|
|
307
|
+
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
308
|
+
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
183
309
|
const tx = await provenTx.toTx();
|
|
184
310
|
const txHash = tx.getTxHash();
|
|
185
311
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -190,7 +316,35 @@ import { inspect } from 'util';
|
|
|
190
316
|
throw this.contextualizeError(err, inspect(tx));
|
|
191
317
|
});
|
|
192
318
|
this.log.info(`Sent transaction ${txHash}`);
|
|
193
|
-
return txHash
|
|
319
|
+
// If wait is NO_WAIT, return txHash immediately
|
|
320
|
+
if (opts.wait === NO_WAIT) {
|
|
321
|
+
return {
|
|
322
|
+
txHash,
|
|
323
|
+
...offchainOutput
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
327
|
+
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
328
|
+
const receipt = await waitForTx(this.aztecNode, txHash, waitOpts);
|
|
329
|
+
// Display debug logs from public execution if present (served in test mode only)
|
|
330
|
+
if (receipt.debugLogs?.length) {
|
|
331
|
+
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
receipt,
|
|
335
|
+
...offchainOutput
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
340
|
+
* @param address - The contract address to resolve.
|
|
341
|
+
*/ async getContractName(address) {
|
|
342
|
+
const instance = await this.pxe.getContractInstance(address);
|
|
343
|
+
if (!instance) {
|
|
344
|
+
return undefined;
|
|
345
|
+
}
|
|
346
|
+
const artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
347
|
+
return artifact?.name;
|
|
194
348
|
}
|
|
195
349
|
contextualizeError(err, ...context) {
|
|
196
350
|
let contextStr = '';
|
|
@@ -205,11 +359,11 @@ import { inspect } from 'util';
|
|
|
205
359
|
}
|
|
206
360
|
return err;
|
|
207
361
|
}
|
|
208
|
-
|
|
209
|
-
return this.pxe.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
362
|
+
executeUtility(call, opts) {
|
|
363
|
+
return this.pxe.executeUtility(call, {
|
|
364
|
+
authwits: opts.authWitnesses,
|
|
365
|
+
scopes: opts.scopes
|
|
366
|
+
});
|
|
213
367
|
}
|
|
214
368
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
215
369
|
const pxeEvents = await this.pxe.getPrivateEvents(eventDef.eventSelector, eventFilter);
|
|
@@ -227,20 +381,34 @@ import { inspect } from 'util';
|
|
|
227
381
|
});
|
|
228
382
|
return decodedEvents;
|
|
229
383
|
}
|
|
230
|
-
|
|
384
|
+
/**
|
|
385
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
386
|
+
* @param address - The contract address to query.
|
|
387
|
+
*/ async getContractMetadata(address) {
|
|
231
388
|
const instance = await this.pxe.getContractInstance(address);
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
389
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
390
|
+
let initializationStatus;
|
|
391
|
+
if (instance) {
|
|
392
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
393
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
394
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
395
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
396
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNINITIALIZED;
|
|
397
|
+
} else {
|
|
398
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
399
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
400
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
401
|
+
// uninitialized.
|
|
402
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
403
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
404
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
405
|
+
}
|
|
406
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
238
407
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
239
408
|
return {
|
|
240
409
|
instance: instance ?? undefined,
|
|
241
|
-
|
|
410
|
+
initializationStatus,
|
|
242
411
|
isContractPublished: !!publiclyRegisteredContract,
|
|
243
|
-
isContractClassPubliclyRegistered: !!publiclyRegisteredContractClass,
|
|
244
412
|
isContractUpdated: !!isContractUpdated,
|
|
245
413
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
246
414
|
};
|