@aztec/wallet-sdk 0.0.1-commit.85d7d01 → 0.0.1-commit.8655d4a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/base-wallet/base_wallet.d.ts +60 -39
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +175 -76
- package/dest/base-wallet/index.d.ts +2 -2
- package/dest/base-wallet/index.d.ts.map +1 -1
- package/dest/base-wallet/utils.d.ts +7 -4
- package/dest/base-wallet/utils.d.ts.map +1 -1
- package/dest/base-wallet/utils.js +11 -5
- package/dest/crypto.d.ts +39 -1
- package/dest/crypto.d.ts.map +1 -1
- package/dest/crypto.js +88 -0
- package/dest/extension/handlers/background_connection_handler.d.ts +12 -2
- package/dest/extension/handlers/background_connection_handler.d.ts.map +1 -1
- package/dest/extension/handlers/background_connection_handler.js +44 -8
- package/dest/extension/handlers/content_script_connection_handler.d.ts +2 -1
- package/dest/extension/handlers/content_script_connection_handler.d.ts.map +1 -1
- package/dest/extension/handlers/content_script_connection_handler.js +19 -0
- package/dest/extension/handlers/internal_message_types.d.ts +3 -1
- package/dest/extension/handlers/internal_message_types.d.ts.map +1 -1
- package/dest/extension/handlers/internal_message_types.js +3 -1
- package/dest/extension/provider/extension_wallet.d.ts +26 -6
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -1
- package/dest/extension/provider/extension_wallet.js +80 -9
- package/dest/extension/provider/index.d.ts +2 -2
- package/dest/extension/provider/index.d.ts.map +1 -1
- package/dest/iframe/handlers/iframe_connection_handler.d.ts +122 -0
- package/dest/iframe/handlers/iframe_connection_handler.d.ts.map +1 -0
- package/dest/iframe/handlers/iframe_connection_handler.js +239 -0
- package/dest/iframe/handlers/index.d.ts +2 -0
- package/dest/iframe/handlers/index.d.ts.map +1 -0
- package/dest/iframe/handlers/index.js +1 -0
- package/dest/iframe/provider/iframe_discovery.d.ts +25 -0
- package/dest/iframe/provider/iframe_discovery.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_discovery.js +167 -0
- package/dest/iframe/provider/iframe_provider.d.ts +65 -0
- package/dest/iframe/provider/iframe_provider.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_provider.js +257 -0
- package/dest/iframe/provider/iframe_wallet.d.ts +85 -0
- package/dest/iframe/provider/iframe_wallet.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_wallet.js +269 -0
- package/dest/iframe/provider/index.d.ts +4 -0
- package/dest/iframe/provider/index.d.ts.map +1 -0
- package/dest/iframe/provider/index.js +3 -0
- package/dest/manager/types.d.ts +3 -2
- package/dest/manager/types.d.ts.map +1 -1
- package/dest/manager/wallet_manager.d.ts +1 -1
- package/dest/manager/wallet_manager.d.ts.map +1 -1
- package/dest/manager/wallet_manager.js +46 -16
- package/dest/types.d.ts +64 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +29 -0
- package/package.json +12 -8
- package/src/base-wallet/base_wallet.ts +255 -129
- package/src/base-wallet/index.ts +6 -1
- package/src/base-wallet/utils.ts +15 -5
- package/src/crypto.ts +104 -0
- package/src/extension/handlers/background_connection_handler.ts +42 -9
- package/src/extension/handlers/content_script_connection_handler.ts +18 -0
- package/src/extension/handlers/internal_message_types.ts +2 -0
- package/src/extension/provider/extension_wallet.ts +94 -13
- package/src/extension/provider/index.ts +1 -1
- package/src/iframe/handlers/iframe_connection_handler.ts +341 -0
- package/src/iframe/handlers/index.ts +7 -0
- package/src/iframe/provider/iframe_discovery.ts +185 -0
- package/src/iframe/provider/iframe_provider.ts +331 -0
- package/src/iframe/provider/iframe_wallet.ts +323 -0
- package/src/iframe/provider/index.ts +3 -0
- package/src/manager/types.ts +2 -1
- package/src/manager/wallet_manager.ts +48 -14
- package/src/types.ts +72 -0
|
@@ -1,22 +1,20 @@
|
|
|
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, TxSimulationResultWithAppOffset, 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';
|
|
9
9
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
10
|
-
import { type AccessScopes } from '@aztec/pxe/client/lazy';
|
|
11
10
|
import type { PXE } from '@aztec/pxe/server';
|
|
12
11
|
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall } from '@aztec/stdlib/abi';
|
|
13
12
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
14
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
14
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
16
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
15
|
+
import { GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
17
16
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
18
|
-
import { type TxExecutionRequest, type TxProfileResult,
|
|
19
|
-
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
17
|
+
import { ExecutionPayload, type TxExecutionRequest, type TxProfileResult, type UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
20
18
|
/**
|
|
21
19
|
* Options to configure fee payment for a transaction
|
|
22
20
|
*/
|
|
@@ -27,10 +25,31 @@ export type FeeOptions = {
|
|
|
27
25
|
*/
|
|
28
26
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
29
27
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
30
|
-
accountFeePaymentMethodOptions
|
|
28
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
31
29
|
/** The gas settings to use for the transaction */
|
|
32
30
|
gasSettings: GasSettings;
|
|
33
31
|
};
|
|
32
|
+
/** Options for `simulateViaEntrypoint`. */
|
|
33
|
+
export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement' | 'sendMessagesAs' | 'overrides'> & {
|
|
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
|
+
};
|
|
34
53
|
/**
|
|
35
54
|
* A base class for Wallet implementations
|
|
36
55
|
*/
|
|
@@ -40,8 +59,17 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
40
59
|
protected log: import("@aztec/foundation/log").Logger;
|
|
41
60
|
protected minFeePadding: number;
|
|
42
61
|
protected cancellableTransactions: boolean;
|
|
62
|
+
private nodeInfoPromise;
|
|
43
63
|
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
44
|
-
protected scopesFrom(from: AztecAddress, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
64
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
65
|
+
/**
|
|
66
|
+
* Picks the sender address PXE should tag private messages with. Returns `undefined` when there is no signing
|
|
67
|
+
* account (`from === NO_FROM`) and no explicit override; in that case any private log emitted by the tx using
|
|
68
|
+
* the wallet-supplied default sender will fail the "Sender for tags is not set" assertion.
|
|
69
|
+
* @param from - Tx sender, or `NO_FROM`.
|
|
70
|
+
* @param sendMessagesAs - Explicit override.
|
|
71
|
+
*/
|
|
72
|
+
protected senderForTagsFrom(from: AztecAddress | NoFrom, sendMessagesAs?: AztecAddress): AztecAddress | undefined;
|
|
45
73
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
46
74
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
47
75
|
/**
|
|
@@ -53,7 +81,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
53
81
|
*/
|
|
54
82
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
55
83
|
getChainInfo(): Promise<ChainInfo>;
|
|
56
|
-
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
84
|
+
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
57
85
|
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
58
86
|
/**
|
|
59
87
|
* Request capabilities from the wallet.
|
|
@@ -72,42 +100,31 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
72
100
|
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
73
101
|
/**
|
|
74
102
|
* Completes partial user-provided fee options with wallet defaults.
|
|
75
|
-
* @param
|
|
76
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
77
|
-
* @param gasSettings - User-provided partial gas settings
|
|
78
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
103
|
+
* @param config - Fee completion config.
|
|
79
104
|
*/
|
|
80
|
-
protected completeFeeOptions(
|
|
105
|
+
protected completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions>;
|
|
81
106
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* to
|
|
85
|
-
* @param from - The address where the transaction is being sent from
|
|
86
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
87
|
-
* @param gasSettings - User-provided partial gas settings
|
|
107
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
108
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
109
|
+
* @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
|
|
88
110
|
*/
|
|
89
|
-
protected
|
|
90
|
-
/**
|
|
91
|
-
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
92
|
-
* doesn't already include one
|
|
93
|
-
*/
|
|
94
|
-
walletFeePaymentMethod?: FeePaymentMethod | undefined;
|
|
95
|
-
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
96
|
-
accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
|
|
97
|
-
gasSettings: GasSettings;
|
|
98
|
-
}>;
|
|
111
|
+
protected getMinFees(estimate?: ManaUsageEstimate): Promise<GasFees>;
|
|
99
112
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
100
113
|
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
114
|
+
registerContractClass(artifact: ContractArtifact): Promise<void>;
|
|
101
115
|
/**
|
|
102
116
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
103
117
|
* @param executionPayload - The execution payload to simulate.
|
|
104
|
-
* @param
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
118
|
+
* @param opts - Simulation options.
|
|
119
|
+
*/
|
|
120
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
121
|
+
/**
|
|
122
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
123
|
+
* calls, N+1 = app).
|
|
124
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
125
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
109
126
|
*/
|
|
110
|
-
protected
|
|
127
|
+
protected computeAppCallOffset(from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<number>;
|
|
111
128
|
/**
|
|
112
129
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
113
130
|
* on the node while sending the remaining calls through the standard PXE path.
|
|
@@ -116,7 +133,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
116
133
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
117
134
|
* @returns The merged simulation result.
|
|
118
135
|
*/
|
|
119
|
-
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<
|
|
136
|
+
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
120
137
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
121
138
|
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
122
139
|
/**
|
|
@@ -127,9 +144,13 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
127
144
|
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
128
145
|
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
129
146
|
getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
149
|
+
* @param address - The contract address to query.
|
|
150
|
+
*/
|
|
130
151
|
getContractMetadata(address: AztecAddress): Promise<{
|
|
131
152
|
instance: ContractInstanceWithAddress | undefined;
|
|
132
|
-
|
|
153
|
+
initializationStatus: ContractInitializationStatus;
|
|
133
154
|
isContractPublished: boolean;
|
|
134
155
|
isContractUpdated: boolean;
|
|
135
156
|
updatedContractClassId: Fr | undefined;
|
|
@@ -139,4 +160,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
139
160
|
isContractClassPubliclyRegistered: boolean;
|
|
140
161
|
}>;
|
|
141
162
|
}
|
|
142
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
163
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGVBQWUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2pGLE9BQU8sRUFDTCxLQUFLLHNCQUFzQixFQUUzQixLQUFLLFVBQVUsRUFFaEIsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyx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QUFZLEdBQUcsT0FBTyxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUMsQ0FPbEY7SUFFRCxTQUFTLENBQUMsa0JBQWtCLENBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxHQUFHLE9BQU8sRUFBRSxNQUFNLEVBQUUsR0FBRyxLQUFLLENBWXBFO0lBRUQsY0FBYyxDQUFDLElBQUksRUFBRSxZQUFZLEVBQUUsSUFBSSxFQUFFLHFCQUFxQixHQUFHLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQUUvRjtJQUVLLGdCQUFnQixDQUFDLENBQUMsRUFDdEIsUUFBUSxFQUFFLHVCQUF1QixFQUNqQyxXQUFXLEVBQUUsa0JBQWtCLEdBQzlCLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQWU1QjtJQUVEOzs7T0FHRztJQUNHLG1CQUFtQixDQUFDLE9BQU8sRUFBRSxZQUFZOzs7Ozs7T0FpQzlDO0lBRUssd0JBQXdCLENBQUMsRUFBRSxFQUFFLEVBQUU7OztPQU1wQztDQUNGIn0=
|
|
@@ -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,+BAA+B,CAAC;AACjF,OAAO,EACL,KAAK,sBAAsB,EAE3B,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;A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;;;OAGG;IACG,mBAAmB,CAAC,OAAO,EAAE,YAAY;;;;;;OAiC9C;IAEK,wBAAwB,CAAC,EAAE,EAAE,EAAE;;;OAMpC;CACF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
+
import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
|
-
import {
|
|
4
|
+
import { ContractInitializationStatus, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
4
5
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
6
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
5
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
9
|
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
@@ -9,8 +11,8 @@ import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
|
9
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
12
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
11
13
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
12
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
13
|
-
import {
|
|
14
|
+
import { Gas, GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
15
|
+
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
|
|
14
16
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
15
17
|
import { inspect } from 'util';
|
|
16
18
|
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
@@ -22,6 +24,9 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
22
24
|
log;
|
|
23
25
|
minFeePadding;
|
|
24
26
|
cancellableTransactions;
|
|
27
|
+
// A wallet is instantiated for a particular chain, so chain info never changes during its lifetime.
|
|
28
|
+
// We cache it here because getChainInfo is called frequently (every tx simulation, send, auth wit, etc.).
|
|
29
|
+
nodeInfoPromise;
|
|
25
30
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
26
31
|
constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
|
|
27
32
|
this.pxe = pxe;
|
|
@@ -31,7 +36,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
31
36
|
this.cancellableTransactions = false;
|
|
32
37
|
}
|
|
33
38
|
scopesFrom(from, additionalScopes = []) {
|
|
34
|
-
const allScopes = from
|
|
39
|
+
const allScopes = from === NO_FROM ? additionalScopes : [
|
|
35
40
|
from,
|
|
36
41
|
...additionalScopes
|
|
37
42
|
];
|
|
@@ -41,6 +46,15 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
41
46
|
].map(AztecAddress.fromString);
|
|
42
47
|
}
|
|
43
48
|
/**
|
|
49
|
+
* Picks the sender address PXE should tag private messages with. Returns `undefined` when there is no signing
|
|
50
|
+
* account (`from === NO_FROM`) and no explicit override; in that case any private log emitted by the tx using
|
|
51
|
+
* the wallet-supplied default sender will fail the "Sender for tags is not set" assertion.
|
|
52
|
+
* @param from - Tx sender, or `NO_FROM`.
|
|
53
|
+
* @param sendMessagesAs - Explicit override.
|
|
54
|
+
*/ senderForTagsFrom(from, sendMessagesAs) {
|
|
55
|
+
return sendMessagesAs ?? (from === NO_FROM ? undefined : from);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
44
58
|
* Returns the list of aliased contacts associated with the wallet.
|
|
45
59
|
* This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
|
|
46
60
|
* - Senders: Addresses we check during synching in case they sent us notes,
|
|
@@ -54,7 +68,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
54
68
|
}));
|
|
55
69
|
}
|
|
56
70
|
async getChainInfo() {
|
|
57
|
-
|
|
71
|
+
if (!this.nodeInfoPromise) {
|
|
72
|
+
this.nodeInfoPromise = this.aztecNode.getNodeInfo();
|
|
73
|
+
}
|
|
74
|
+
const { l1ChainId, rollupVersion } = await this.nodeInfoPromise;
|
|
58
75
|
return {
|
|
59
76
|
chainId: new Fr(l1ChainId),
|
|
60
77
|
version: new Fr(rollupVersion)
|
|
@@ -62,18 +79,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
62
79
|
}
|
|
63
80
|
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
64
81
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
65
|
-
const executionOptions = {
|
|
66
|
-
txNonce: Fr.random(),
|
|
67
|
-
cancellable: this.cancellableTransactions,
|
|
68
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
69
|
-
};
|
|
70
82
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
71
83
|
feeExecutionPayload,
|
|
72
84
|
executionPayload
|
|
73
85
|
]) : executionPayload;
|
|
74
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
75
86
|
const chainInfo = await this.getChainInfo();
|
|
76
|
-
|
|
87
|
+
if (from === NO_FROM) {
|
|
88
|
+
const entrypoint = new DefaultEntrypoint();
|
|
89
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
90
|
+
} else {
|
|
91
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
92
|
+
const executionOptions = {
|
|
93
|
+
txNonce: Fr.random(),
|
|
94
|
+
cancellable: this.cancellableTransactions,
|
|
95
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
96
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
97
|
+
};
|
|
98
|
+
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
99
|
+
}
|
|
77
100
|
}
|
|
78
101
|
async createAuthWit(from, messageHashOrIntent) {
|
|
79
102
|
const account = await this.getAccountFromAddress(from);
|
|
@@ -116,26 +139,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
116
139
|
}
|
|
117
140
|
/**
|
|
118
141
|
* Completes partial user-provided fee options with wallet defaults.
|
|
119
|
-
* @param
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
124
|
-
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
142
|
+
* @param config - Fee completion config.
|
|
143
|
+
*/ async completeFeeOptions(config) {
|
|
144
|
+
const { from, feePayer, gasSettings, forEstimation, congestionEstimate } = config;
|
|
145
|
+
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.getMinFees(congestionEstimate)).mul(1 + this.minFeePadding);
|
|
125
146
|
let accountFeePaymentMethodOptions;
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
147
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
148
|
+
// account contract entrypoint to use
|
|
149
|
+
if (from !== NO_FROM) {
|
|
150
|
+
if (!feePayer) {
|
|
151
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
152
|
+
// for the account to use its fee juice balance
|
|
153
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
154
|
+
} else {
|
|
155
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
156
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
157
|
+
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
158
|
+
}
|
|
134
159
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
160
|
+
const gasSettingsOverrides = {
|
|
161
|
+
gasLimits: gasSettings?.gasLimits ? Gas.from(gasSettings.gasLimits) : undefined,
|
|
162
|
+
teardownGasLimits: gasSettings?.teardownGasLimits ? Gas.from(gasSettings.teardownGasLimits) : undefined,
|
|
163
|
+
maxFeesPerGas,
|
|
164
|
+
maxPriorityFeesPerGas: gasSettings?.maxPriorityFeesPerGas ?? GasFees.empty()
|
|
165
|
+
};
|
|
166
|
+
// When estimating gas (simulation), use high limits so the simulation doesn't run out of gas.
|
|
167
|
+
// When sending for real, use protocol max limits that the network will actually accept.
|
|
168
|
+
const fullGasSettings = forEstimation ? GasSettings.forEstimation(gasSettingsOverrides) : GasSettings.fallback(gasSettingsOverrides);
|
|
139
169
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
140
170
|
return {
|
|
141
171
|
gasSettings: fullGasSettings,
|
|
@@ -144,22 +174,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
144
174
|
};
|
|
145
175
|
}
|
|
146
176
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* to
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
177
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
178
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
179
|
+
* @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
|
|
180
|
+
*/ async getMinFees(estimate = ManaUsageEstimate.Limit) {
|
|
181
|
+
try {
|
|
182
|
+
const predicted = await this.aztecNode.getPredictedMinFees(estimate);
|
|
183
|
+
if (predicted.length === 0) {
|
|
184
|
+
return this.aztecNode.getCurrentMinFees();
|
|
185
|
+
}
|
|
186
|
+
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
187
|
+
} catch (err) {
|
|
188
|
+
// Fallback for old nodes that don't support getPredictedMinFees.
|
|
189
|
+
// Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
|
|
190
|
+
if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
|
|
191
|
+
return this.aztecNode.getCurrentMinFees();
|
|
192
|
+
}
|
|
193
|
+
throw err;
|
|
194
|
+
}
|
|
163
195
|
}
|
|
164
196
|
registerSender(address, _alias = '') {
|
|
165
197
|
return this.pxe.registerSender(address);
|
|
@@ -196,22 +228,37 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
196
228
|
}
|
|
197
229
|
return instance;
|
|
198
230
|
}
|
|
231
|
+
registerContractClass(artifact) {
|
|
232
|
+
return this.pxe.registerContractClass(artifact);
|
|
233
|
+
}
|
|
199
234
|
/**
|
|
200
235
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
201
236
|
* @param executionPayload - The execution payload to simulate.
|
|
202
|
-
* @param
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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, {
|
|
237
|
+
* @param opts - Simulation options.
|
|
238
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
239
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
240
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
210
241
|
simulatePublic: true,
|
|
211
|
-
skipTxValidation,
|
|
212
|
-
skipFeeEnforcement,
|
|
213
|
-
scopes
|
|
242
|
+
skipTxValidation: opts.skipTxValidation,
|
|
243
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
244
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
245
|
+
senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs),
|
|
246
|
+
overrides: opts.overrides
|
|
214
247
|
});
|
|
248
|
+
const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
|
|
249
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
253
|
+
* calls, N+1 = app).
|
|
254
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
255
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
256
|
+
*/ async computeAppCallOffset(from, feeOptions) {
|
|
257
|
+
if (from === NO_FROM) {
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
261
|
+
return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
|
|
215
262
|
}
|
|
216
263
|
/**
|
|
217
264
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
@@ -221,7 +268,13 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
221
268
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
222
269
|
* @returns The merged simulation result.
|
|
223
270
|
*/ async simulateTx(executionPayload, opts) {
|
|
224
|
-
const feeOptions =
|
|
271
|
+
const feeOptions = await this.completeFeeOptions({
|
|
272
|
+
from: opts.from,
|
|
273
|
+
feePayer: executionPayload.feePayer,
|
|
274
|
+
gasSettings: opts.fee?.gasSettings,
|
|
275
|
+
forEstimation: true,
|
|
276
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
277
|
+
});
|
|
225
278
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
226
279
|
const remainingPayload = {
|
|
227
280
|
...executionPayload,
|
|
@@ -234,27 +287,51 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
234
287
|
try {
|
|
235
288
|
blockHeader = await this.pxe.getSyncedBlockHeader();
|
|
236
289
|
} catch {
|
|
237
|
-
blockHeader = await this.aztecNode.
|
|
290
|
+
blockHeader = (await this.aztecNode.getBlockData('latest')).header;
|
|
238
291
|
}
|
|
292
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
239
293
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
240
|
-
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls,
|
|
241
|
-
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload,
|
|
294
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this), opts.overrides) : Promise.resolve([]),
|
|
295
|
+
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
296
|
+
from: opts.from,
|
|
297
|
+
feeOptions,
|
|
298
|
+
additionalScopes: opts.additionalScopes,
|
|
299
|
+
skipTxValidation: opts.skipTxValidation,
|
|
300
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
|
|
301
|
+
sendMessagesAs: opts.sendMessagesAs,
|
|
302
|
+
overrides: opts.overrides
|
|
303
|
+
}) : Promise.resolve(null)
|
|
242
304
|
]);
|
|
243
305
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
244
306
|
}
|
|
245
307
|
async profileTx(executionPayload, opts) {
|
|
246
|
-
const feeOptions = await this.completeFeeOptions(
|
|
308
|
+
const feeOptions = await this.completeFeeOptions({
|
|
309
|
+
from: opts.from,
|
|
310
|
+
feePayer: executionPayload.feePayer,
|
|
311
|
+
gasSettings: opts.fee?.gasSettings,
|
|
312
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
313
|
+
});
|
|
247
314
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
248
315
|
return this.pxe.profileTx(txRequest, {
|
|
249
316
|
profileMode: opts.profileMode,
|
|
250
317
|
skipProofGeneration: opts.skipProofGeneration ?? true,
|
|
251
|
-
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
318
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
319
|
+
senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs)
|
|
252
320
|
});
|
|
253
321
|
}
|
|
254
322
|
async sendTx(executionPayload, opts) {
|
|
255
|
-
const feeOptions = await this.completeFeeOptions(
|
|
323
|
+
const feeOptions = await this.completeFeeOptions({
|
|
324
|
+
from: opts.from,
|
|
325
|
+
feePayer: executionPayload.feePayer,
|
|
326
|
+
gasSettings: opts.fee?.gasSettings,
|
|
327
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
328
|
+
});
|
|
256
329
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
257
|
-
const provenTx = await this.pxe.proveTx(txRequest,
|
|
330
|
+
const provenTx = await this.pxe.proveTx(txRequest, {
|
|
331
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
332
|
+
senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs)
|
|
333
|
+
});
|
|
334
|
+
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
258
335
|
const tx = await provenTx.toTx();
|
|
259
336
|
const txHash = tx.getTxHash();
|
|
260
337
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -267,7 +344,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
267
344
|
this.log.info(`Sent transaction ${txHash}`);
|
|
268
345
|
// If wait is NO_WAIT, return txHash immediately
|
|
269
346
|
if (opts.wait === NO_WAIT) {
|
|
270
|
-
return
|
|
347
|
+
return {
|
|
348
|
+
txHash,
|
|
349
|
+
...offchainOutput
|
|
350
|
+
};
|
|
271
351
|
}
|
|
272
352
|
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
273
353
|
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
@@ -276,7 +356,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
276
356
|
if (receipt.debugLogs?.length) {
|
|
277
357
|
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
278
358
|
}
|
|
279
|
-
return
|
|
359
|
+
return {
|
|
360
|
+
receipt,
|
|
361
|
+
...offchainOutput
|
|
362
|
+
};
|
|
280
363
|
}
|
|
281
364
|
/**
|
|
282
365
|
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
@@ -305,9 +388,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
305
388
|
executeUtility(call, opts) {
|
|
306
389
|
return this.pxe.executeUtility(call, {
|
|
307
390
|
authwits: opts.authWitnesses,
|
|
308
|
-
scopes:
|
|
309
|
-
opts.scope
|
|
310
|
-
]
|
|
391
|
+
scopes: opts.scopes
|
|
311
392
|
});
|
|
312
393
|
}
|
|
313
394
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
@@ -326,15 +407,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
326
407
|
});
|
|
327
408
|
return decodedEvents;
|
|
328
409
|
}
|
|
329
|
-
|
|
410
|
+
/**
|
|
411
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
412
|
+
* @param address - The contract address to query.
|
|
413
|
+
*/ async getContractMetadata(address) {
|
|
330
414
|
const instance = await this.pxe.getContractInstance(address);
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
415
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
416
|
+
let initializationStatus;
|
|
417
|
+
if (instance) {
|
|
418
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
419
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
420
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
421
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
422
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNINITIALIZED;
|
|
423
|
+
} else {
|
|
424
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
425
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
426
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
427
|
+
// uninitialized.
|
|
428
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
429
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
430
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
431
|
+
}
|
|
432
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
334
433
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
335
434
|
return {
|
|
336
435
|
instance: instance ?? undefined,
|
|
337
|
-
|
|
436
|
+
initializationStatus,
|
|
338
437
|
isContractPublished: !!publiclyRegisteredContract,
|
|
339
438
|
isContractUpdated: !!isContractUpdated,
|
|
340
439
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { BaseWallet, type FeeOptions } from './base_wallet.js';
|
|
1
|
+
export { BaseWallet, type CompleteFeeOptionsConfig, type FeeOptions, type SimulateViaEntrypointOptions, } from './base_wallet.js';
|
|
2
2
|
export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsVUFBVSxFQUNWLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssVUFBVSxFQUNmLEtBQUssNEJBQTRCLEdBQ2xDLE1BQU0sa0JBQWtCLENBQUM7QUFDMUIsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQyJ9
|