@aztec/wallet-sdk 0.0.1-commit.ec5f612 → 0.0.1-commit.ec7ac5448
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 +40 -39
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +123 -73
- package/dest/base-wallet/index.d.ts +2 -2
- package/dest/base-wallet/index.d.ts.map +1 -1
- package/dest/base-wallet/utils.d.ts +3 -2
- package/dest/base-wallet/utils.d.ts.map +1 -1
- package/dest/base-wallet/utils.js +3 -1
- package/dest/crypto.d.ts +39 -1
- package/dest/crypto.d.ts.map +1 -1
- package/dest/crypto.js +88 -0
- package/dest/extension/provider/extension_wallet.d.ts +2 -5
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -1
- package/dest/extension/provider/index.d.ts +2 -2
- package/dest/extension/provider/index.d.ts.map +1 -1
- package/dest/iframe/handlers/iframe_connection_handler.d.ts +118 -0
- package/dest/iframe/handlers/iframe_connection_handler.d.ts.map +1 -0
- package/dest/iframe/handlers/iframe_connection_handler.js +228 -0
- package/dest/iframe/handlers/index.d.ts +2 -0
- package/dest/iframe/handlers/index.d.ts.map +1 -0
- package/dest/iframe/handlers/index.js +1 -0
- package/dest/iframe/provider/iframe_discovery.d.ts +25 -0
- package/dest/iframe/provider/iframe_discovery.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_discovery.js +167 -0
- package/dest/iframe/provider/iframe_provider.d.ts +65 -0
- package/dest/iframe/provider/iframe_provider.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_provider.js +257 -0
- package/dest/iframe/provider/iframe_wallet.d.ts +68 -0
- package/dest/iframe/provider/iframe_wallet.d.ts.map +1 -0
- package/dest/iframe/provider/iframe_wallet.js +200 -0
- package/dest/iframe/provider/index.d.ts +4 -0
- package/dest/iframe/provider/index.d.ts.map +1 -0
- package/dest/iframe/provider/index.js +3 -0
- package/dest/manager/types.d.ts +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 +14 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +4 -0
- package/package.json +12 -8
- package/src/base-wallet/base_wallet.ts +192 -128
- package/src/base-wallet/index.ts +6 -1
- package/src/base-wallet/utils.ts +6 -4
- package/src/crypto.ts +104 -0
- package/src/extension/provider/extension_wallet.ts +1 -6
- package/src/extension/provider/index.ts +1 -1
- package/src/iframe/handlers/iframe_connection_handler.ts +328 -0
- package/src/iframe/handlers/index.ts +7 -0
- package/src/iframe/provider/iframe_discovery.ts +185 -0
- package/src/iframe/provider/iframe_provider.ts +331 -0
- package/src/iframe/provider/iframe_wallet.ts +229 -0
- package/src/iframe/provider/index.ts +3 -0
- package/src/manager/types.ts +2 -1
- package/src/manager/wallet_manager.ts +48 -14
- package/src/types.ts +13 -0
|
@@ -1,13 +1,12 @@
|
|
|
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';
|
|
@@ -15,7 +14,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
15
14
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
16
15
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
17
16
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
18
|
-
import { type TxExecutionRequest, type TxProfileResult,
|
|
17
|
+
import { type TxExecutionRequest, type TxProfileResult, type UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
19
18
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
20
19
|
/**
|
|
21
20
|
* Options to configure fee payment for a transaction
|
|
@@ -27,10 +26,26 @@ export type FeeOptions = {
|
|
|
27
26
|
*/
|
|
28
27
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
29
28
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
30
|
-
accountFeePaymentMethodOptions
|
|
29
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
31
30
|
/** The gas settings to use for the transaction */
|
|
32
31
|
gasSettings: GasSettings;
|
|
33
32
|
};
|
|
33
|
+
/** Options for `simulateViaEntrypoint`. */
|
|
34
|
+
export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'> & {
|
|
35
|
+
/** Fee options for the entrypoint */
|
|
36
|
+
feeOptions: FeeOptions;
|
|
37
|
+
};
|
|
38
|
+
/** Options for `completeFeeOptions`. */
|
|
39
|
+
export type CompleteFeeOptionsConfig = {
|
|
40
|
+
/** The address where the transaction is being sent from. */
|
|
41
|
+
from: AztecAddress | NoFrom;
|
|
42
|
+
/** The address paying for fees (if any fee payment method is embedded in the execution payload). */
|
|
43
|
+
feePayer?: AztecAddress;
|
|
44
|
+
/** User-provided partial gas settings. */
|
|
45
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
46
|
+
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
47
|
+
forEstimation?: boolean;
|
|
48
|
+
};
|
|
34
49
|
/**
|
|
35
50
|
* A base class for Wallet implementations
|
|
36
51
|
*/
|
|
@@ -41,7 +56,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
41
56
|
protected minFeePadding: number;
|
|
42
57
|
protected cancellableTransactions: boolean;
|
|
43
58
|
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
44
|
-
protected scopesFrom(from: AztecAddress, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
59
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
45
60
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
46
61
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
47
62
|
/**
|
|
@@ -53,7 +68,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
53
68
|
*/
|
|
54
69
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
55
70
|
getChainInfo(): Promise<ChainInfo>;
|
|
56
|
-
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
71
|
+
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
57
72
|
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
58
73
|
/**
|
|
59
74
|
* Request capabilities from the wallet.
|
|
@@ -72,42 +87,24 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
72
87
|
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
73
88
|
/**
|
|
74
89
|
* 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
|
|
90
|
+
* @param config - Fee completion config.
|
|
79
91
|
*/
|
|
80
|
-
protected completeFeeOptions(
|
|
81
|
-
/**
|
|
82
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
83
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
84
|
-
* to avoid running out of gas during estimation.
|
|
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
|
|
88
|
-
*/
|
|
89
|
-
protected completeFeeOptionsForEstimation(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
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
|
-
}>;
|
|
92
|
+
protected completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions>;
|
|
99
93
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
100
94
|
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
101
95
|
/**
|
|
102
96
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
103
97
|
* @param executionPayload - The execution payload to simulate.
|
|
104
|
-
* @param
|
|
105
|
-
* @param feeOptions - Fee options for the transaction.
|
|
106
|
-
* @param skipTxValidation - Whether to skip tx validation.
|
|
107
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
108
|
-
* @param scopes - The scopes to use for the simulation.
|
|
98
|
+
* @param opts - Simulation options.
|
|
109
99
|
*/
|
|
110
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload,
|
|
100
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
101
|
+
/**
|
|
102
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
103
|
+
* calls, N+1 = app).
|
|
104
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
105
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
106
|
+
*/
|
|
107
|
+
protected computeAppCallOffset(from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<number>;
|
|
111
108
|
/**
|
|
112
109
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
113
110
|
* on the node while sending the remaining calls through the standard PXE path.
|
|
@@ -116,7 +113,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
116
113
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
117
114
|
* @returns The merged simulation result.
|
|
118
115
|
*/
|
|
119
|
-
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<
|
|
116
|
+
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
120
117
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
121
118
|
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
122
119
|
/**
|
|
@@ -127,9 +124,13 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
127
124
|
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
128
125
|
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
129
126
|
getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
129
|
+
* @param address - The contract address to query.
|
|
130
|
+
*/
|
|
130
131
|
getContractMetadata(address: AztecAddress): Promise<{
|
|
131
132
|
instance: ContractInstanceWithAddress | undefined;
|
|
132
|
-
|
|
133
|
+
initializationStatus: ContractInitializationStatus;
|
|
133
134
|
isContractPublished: boolean;
|
|
134
135
|
isContractUpdated: boolean;
|
|
135
136
|
updatedContractClassId: Fr | undefined;
|
|
@@ -139,4 +140,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
139
140
|
isContractClassPubliclyRegistered: boolean;
|
|
140
141
|
}>;
|
|
141
142
|
}
|
|
142
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
143
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGVBQWU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BVyxFQUFFLGtCQUFrQixHQUM5QixPQUFPLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FlNUI7SUFFRDs7O09BR0c7SUFDRyxtQkFBbUIsQ0FBQyxPQUFPLEVBQUUsWUFBWTs7Ozs7O09BaUM5QztJQUVLLHdCQUF3QixDQUFDLEVBQUUsRUFBRSxFQUFFOzs7T0FNcEM7Q0FDRiJ9
|
|
@@ -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;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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AO,CAAC,MAAM,GAAG,SAAS,CAAC,CAOlF;IAED,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAYpE;IAED,cAAc,CAAC,IAAI,EAAE,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,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 } 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';
|
|
@@ -31,7 +33,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
31
33
|
this.cancellableTransactions = false;
|
|
32
34
|
}
|
|
33
35
|
scopesFrom(from, additionalScopes = []) {
|
|
34
|
-
const allScopes = from
|
|
36
|
+
const allScopes = from === NO_FROM ? additionalScopes : [
|
|
35
37
|
from,
|
|
36
38
|
...additionalScopes
|
|
37
39
|
];
|
|
@@ -62,18 +64,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
62
64
|
}
|
|
63
65
|
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
64
66
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
65
|
-
const executionOptions = {
|
|
66
|
-
txNonce: Fr.random(),
|
|
67
|
-
cancellable: this.cancellableTransactions,
|
|
68
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
69
|
-
};
|
|
70
67
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
71
68
|
feeExecutionPayload,
|
|
72
69
|
executionPayload
|
|
73
70
|
]) : executionPayload;
|
|
74
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
75
71
|
const chainInfo = await this.getChainInfo();
|
|
76
|
-
|
|
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
|
+
}
|
|
77
85
|
}
|
|
78
86
|
async createAuthWit(from, messageHashOrIntent) {
|
|
79
87
|
const account = await this.getAccountFromAddress(from);
|
|
@@ -116,26 +124,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
116
124
|
}
|
|
117
125
|
/**
|
|
118
126
|
* Completes partial user-provided fee options with wallet defaults.
|
|
119
|
-
* @param
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
123
|
-
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
127
|
+
* @param config - Fee completion config.
|
|
128
|
+
*/ async completeFeeOptions(config) {
|
|
129
|
+
const { from, feePayer, gasSettings, forEstimation } = config;
|
|
124
130
|
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
125
131
|
let accountFeePaymentMethodOptions;
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
+
}
|
|
134
144
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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);
|
|
139
154
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
140
155
|
return {
|
|
141
156
|
gasSettings: fullGasSettings,
|
|
@@ -143,24 +158,6 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
143
158
|
accountFeePaymentMethodOptions
|
|
144
159
|
};
|
|
145
160
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
148
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
149
|
-
* to avoid running out of gas during estimation.
|
|
150
|
-
* @param from - The address where the transaction is being sent from
|
|
151
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
152
|
-
* @param gasSettings - User-provided partial gas settings
|
|
153
|
-
*/ async completeFeeOptionsForEstimation(from, feePayer, gasSettings) {
|
|
154
|
-
const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
|
|
155
|
-
const { gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas } } = defaultFeeOptions;
|
|
156
|
-
// Use unrealistically high gas limits for estimation to avoid running out of gas.
|
|
157
|
-
// They will be tuned down after the simulation.
|
|
158
|
-
const gasSettingsForEstimation = new GasSettings(new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT), new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT), maxFeesPerGas, maxPriorityFeesPerGas);
|
|
159
|
-
return {
|
|
160
|
-
...defaultFeeOptions,
|
|
161
|
-
gasSettings: gasSettingsForEstimation
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
161
|
registerSender(address, _alias = '') {
|
|
165
162
|
return this.pxe.registerSender(address);
|
|
166
163
|
}
|
|
@@ -199,19 +196,29 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
199
196
|
/**
|
|
200
197
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
201
198
|
* @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, {
|
|
199
|
+
* @param opts - Simulation options.
|
|
200
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
201
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
202
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
210
203
|
simulatePublic: true,
|
|
211
|
-
skipTxValidation,
|
|
212
|
-
skipFeeEnforcement,
|
|
213
|
-
scopes
|
|
204
|
+
skipTxValidation: opts.skipTxValidation,
|
|
205
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
206
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
214
207
|
});
|
|
208
|
+
const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
|
|
209
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
213
|
+
* calls, N+1 = app).
|
|
214
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
215
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
216
|
+
*/ async computeAppCallOffset(from, feeOptions) {
|
|
217
|
+
if (from === NO_FROM) {
|
|
218
|
+
return 0;
|
|
219
|
+
}
|
|
220
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
221
|
+
return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
|
|
215
222
|
}
|
|
216
223
|
/**
|
|
217
224
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
@@ -221,7 +228,12 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
221
228
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
222
229
|
* @returns The merged simulation result.
|
|
223
230
|
*/ async simulateTx(executionPayload, opts) {
|
|
224
|
-
const feeOptions =
|
|
231
|
+
const feeOptions = await this.completeFeeOptions({
|
|
232
|
+
from: opts.from,
|
|
233
|
+
feePayer: executionPayload.feePayer,
|
|
234
|
+
gasSettings: opts.fee?.gasSettings,
|
|
235
|
+
forEstimation: true
|
|
236
|
+
});
|
|
225
237
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
226
238
|
const remainingPayload = {
|
|
227
239
|
...executionPayload,
|
|
@@ -236,14 +248,25 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
236
248
|
} catch {
|
|
237
249
|
blockHeader = await this.aztecNode.getBlockHeader();
|
|
238
250
|
}
|
|
251
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
239
252
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
240
|
-
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls,
|
|
241
|
-
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload,
|
|
253
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
|
|
254
|
+
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
255
|
+
from: opts.from,
|
|
256
|
+
feeOptions,
|
|
257
|
+
additionalScopes: opts.additionalScopes,
|
|
258
|
+
skipTxValidation: opts.skipTxValidation,
|
|
259
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
260
|
+
}) : Promise.resolve(null)
|
|
242
261
|
]);
|
|
243
262
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
244
263
|
}
|
|
245
264
|
async profileTx(executionPayload, opts) {
|
|
246
|
-
const feeOptions = await this.completeFeeOptions(
|
|
265
|
+
const feeOptions = await this.completeFeeOptions({
|
|
266
|
+
from: opts.from,
|
|
267
|
+
feePayer: executionPayload.feePayer,
|
|
268
|
+
gasSettings: opts.fee?.gasSettings
|
|
269
|
+
});
|
|
247
270
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
248
271
|
return this.pxe.profileTx(txRequest, {
|
|
249
272
|
profileMode: opts.profileMode,
|
|
@@ -252,9 +275,14 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
252
275
|
});
|
|
253
276
|
}
|
|
254
277
|
async sendTx(executionPayload, opts) {
|
|
255
|
-
const feeOptions = await this.completeFeeOptions(
|
|
278
|
+
const feeOptions = await this.completeFeeOptions({
|
|
279
|
+
from: opts.from,
|
|
280
|
+
feePayer: executionPayload.feePayer,
|
|
281
|
+
gasSettings: opts.fee?.gasSettings
|
|
282
|
+
});
|
|
256
283
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
257
284
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
285
|
+
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
258
286
|
const tx = await provenTx.toTx();
|
|
259
287
|
const txHash = tx.getTxHash();
|
|
260
288
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -267,7 +295,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
267
295
|
this.log.info(`Sent transaction ${txHash}`);
|
|
268
296
|
// If wait is NO_WAIT, return txHash immediately
|
|
269
297
|
if (opts.wait === NO_WAIT) {
|
|
270
|
-
return
|
|
298
|
+
return {
|
|
299
|
+
txHash,
|
|
300
|
+
...offchainOutput
|
|
301
|
+
};
|
|
271
302
|
}
|
|
272
303
|
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
273
304
|
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
@@ -276,7 +307,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
276
307
|
if (receipt.debugLogs?.length) {
|
|
277
308
|
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
278
309
|
}
|
|
279
|
-
return
|
|
310
|
+
return {
|
|
311
|
+
receipt,
|
|
312
|
+
...offchainOutput
|
|
313
|
+
};
|
|
280
314
|
}
|
|
281
315
|
/**
|
|
282
316
|
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
@@ -305,9 +339,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
305
339
|
executeUtility(call, opts) {
|
|
306
340
|
return this.pxe.executeUtility(call, {
|
|
307
341
|
authwits: opts.authWitnesses,
|
|
308
|
-
scopes:
|
|
309
|
-
opts.scope
|
|
310
|
-
]
|
|
342
|
+
scopes: opts.scopes
|
|
311
343
|
});
|
|
312
344
|
}
|
|
313
345
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
@@ -326,15 +358,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
326
358
|
});
|
|
327
359
|
return decodedEvents;
|
|
328
360
|
}
|
|
329
|
-
|
|
361
|
+
/**
|
|
362
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
363
|
+
* @param address - The contract address to query.
|
|
364
|
+
*/ async getContractMetadata(address) {
|
|
330
365
|
const instance = await this.pxe.getContractInstance(address);
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
366
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
367
|
+
let initializationStatus;
|
|
368
|
+
if (instance) {
|
|
369
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
370
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
371
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
372
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
373
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNINITIALIZED;
|
|
374
|
+
} else {
|
|
375
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
376
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
377
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
378
|
+
// uninitialized.
|
|
379
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
380
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
381
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
382
|
+
}
|
|
383
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
334
384
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
335
385
|
return {
|
|
336
386
|
instance: instance ?? undefined,
|
|
337
|
-
|
|
387
|
+
initializationStatus,
|
|
338
388
|
isContractPublished: !!publiclyRegisteredContract,
|
|
339
389
|
isContractUpdated: !!isContractUpdated,
|
|
340
390
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { BaseWallet, type FeeOptions } from './base_wallet.js';
|
|
1
|
+
export { BaseWallet, type CompleteFeeOptionsConfig, type FeeOptions, type SimulateViaEntrypointOptions, } from './base_wallet.js';
|
|
2
2
|
export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsVUFBVSxFQUNWLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssVUFBVSxFQUNmLEtBQUssNEJBQTRCLEdBQ2xDLE1BQU0sa0JBQWtCLENBQUM7QUFDMUIsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EACf,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
2
3
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
4
|
import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
|
|
4
5
|
import { type FunctionCall } from '@aztec/stdlib/abi';
|
|
@@ -45,5 +46,5 @@ export declare function simulateViaNode(node: AztecNode, publicStaticCalls: Func
|
|
|
45
46
|
* @param normalResult - Result from normal simulation (null if all calls were optimized).
|
|
46
47
|
* @returns A single TxSimulationResult with return values in original call order.
|
|
47
48
|
*/
|
|
48
|
-
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult:
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalRes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QkFBc0IsZUFBZSxDQUNuQyxJQUFJLEVBQUUsU0FBUyxFQUNmLGlCQUFpQixFQUFFLFlBQVksRUFBRSxFQUNqQyxJQUFJLEVBQUUsWUFBWSxFQUNsQixTQUFTLEVBQUUsU0FBUyxFQUNwQixXQUFXLEVBQUUsV0FBVyxFQUN4QixXQUFXLEVBQUUsV0FBVyxFQUN4QixrQkFBa0IscUJBQWdCLEVBQ2xDLGVBQWUsRUFBRSxvQkFBb0IsR0FDcEMsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUMsQ0F3Qi9CO0FBRUQ7Ozs7Ozs7OztHQVNHO0FBQ0gsd0JBQWdCLDJCQUEyQixDQUN6QyxnQkFBZ0IsRUFBRSxrQkFBa0IsRUFBRSxFQUN0QyxZQUFZLEVBQUUsK0JBQStCLEdBQUcsSUFBSSxHQUNuRCwrQkFBK0IsQ0FxQmpDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAOrB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,gBAAgB,GAAG;IAC9E,uEAAuE;IACvE,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,2BAA2B;IAC3B,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,CAOA;AAuGD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,SAAS,EACf,iBAAiB,EAAE,YAAY,EAAE,EACjC,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,kBAAkB,qBAAgB,EAClC,eAAe,EAAE,oBAAoB,GACpC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAwB/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,YAAY,EAAE,+BAA+B,GAAG,IAAI,GACnD,+BAA+B,CAqBjC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
1
2
|
import { MAX_ENQUEUED_CALLS_PER_CALL } from '@aztec/constants';
|
|
2
3
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -127,5 +128,6 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
127
128
|
...baseResult.publicOutput,
|
|
128
129
|
publicReturnValues: allReturnValues
|
|
129
130
|
} : undefined;
|
|
130
|
-
|
|
131
|
+
const merged = new TxSimulationResult(baseResult.privateExecutionResult, baseResult.publicInputs, mergedPublicOutput, normalResult?.stats);
|
|
132
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(merged, normalResult?.appCallOffset ?? 0);
|
|
131
133
|
}
|
package/dest/crypto.d.ts
CHANGED
|
@@ -189,4 +189,42 @@ export declare const DEFAULT_EMOJI_GRID_SIZE = 9;
|
|
|
189
189
|
* ```
|
|
190
190
|
*/
|
|
191
191
|
export declare function hashToEmoji(hash: string, count?: number): string;
|
|
192
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Derives an AES-256-GCM key from a passphrase using PBKDF2-SHA256.
|
|
194
|
+
*
|
|
195
|
+
* @param passphrase - The user-provided passphrase or PIN
|
|
196
|
+
* @param salt - Random salt bytes
|
|
197
|
+
* @param iterations - PBKDF2 iteration count (default: 2,000,000)
|
|
198
|
+
* @returns An AES-256-GCM CryptoKey
|
|
199
|
+
*/
|
|
200
|
+
export declare function deriveKeyFromPassphrase(passphrase: string, salt: Uint8Array, iterations?: number): Promise<CryptoKey>;
|
|
201
|
+
/**
|
|
202
|
+
* Encrypts arbitrary bytes with a passphrase using PBKDF2 + AES-256-GCM.
|
|
203
|
+
*
|
|
204
|
+
* Output layout: `[salt (16)] [iv (12)] [ciphertext (...)]`
|
|
205
|
+
*
|
|
206
|
+
* @param plaintext - Data to encrypt
|
|
207
|
+
* @param passphrase - User passphrase or PIN
|
|
208
|
+
* @param iterations - PBKDF2 iteration count (default: 2,000,000)
|
|
209
|
+
* @returns A Uint8Array containing salt + iv + ciphertext
|
|
210
|
+
*/
|
|
211
|
+
export declare function encryptWithPassphrase(plaintext: Uint8Array, passphrase: string, iterations?: number): Promise<Uint8Array>;
|
|
212
|
+
/**
|
|
213
|
+
* Decrypts data produced by {@link encryptWithPassphrase}.
|
|
214
|
+
*
|
|
215
|
+
* @param data - The encrypted blob (salt + iv + ciphertext)
|
|
216
|
+
* @param passphrase - The passphrase used during encryption
|
|
217
|
+
* @param iterations - PBKDF2 iteration count (must match encryption)
|
|
218
|
+
* @returns The decrypted plaintext bytes
|
|
219
|
+
* @throws On wrong passphrase (AES-GCM auth tag mismatch)
|
|
220
|
+
*/
|
|
221
|
+
export declare function decryptWithPassphrase(data: Uint8Array, passphrase: string, iterations?: number): Promise<Uint8Array>;
|
|
222
|
+
/**
|
|
223
|
+
* Converts a Uint8Array to a base64 string.
|
|
224
|
+
*/
|
|
225
|
+
export declare function uint8ToBase64(bytes: Uint8Array): string;
|
|
226
|
+
/**
|
|
227
|
+
* Converts a base64 string to a Uint8Array.
|
|
228
|
+
*/
|
|
229
|
+
export declare function base64ToUint8(b64: string): Uint8Array;
|
|
230
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3J5cHRvLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY3J5cHRvLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQThEQTs7OztHQUlHO0FBQ0gsTUFBTSxXQUFXLGlCQUFpQjtJQUNoQyxnREFBZ0Q7SUFDaEQsR0FBRyxFQUFFLE1BQU0sQ0FBQztJQUNaLGtDQUFrQztJQUNsQyxHQUFHLEVBQUUsTUFBTSxDQUFDO0lBQ1osdUNBQXVDO0lBQ3ZDLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDVix1Q0FBdUM7SUFDdkMsQ0FBQyxFQUFFLE1BQU0sQ0FBQztDQUNYO0FBRUQ7Ozs7R0FJRztBQUNILE1BQU0sV0FBVyxnQkFBZ0I7SUFDL0IsdURBQXVEO0lBQ3ZELEVBQUUsRUFBRSxNQUFNLENBQUM7SUFDWCxrQ0FBa0M7SUFDbEMsVUFBVSxFQUFFLE1BQU0sQ0FBQztDQUNwQjtBQUVEOzs7OztHQUtHO0FBQ0gsTUFBTSxXQUFXLGFBQWE7SUFDNUIsaUNBQWlDO0lBQ2pDLFNBQVMsRUFBRSxTQUFTLENBQUM7SUFDckIseURBQXlEO0lBQ3pELFVBQVUsRUFBRSxTQUFTLENBQUM7Q0FDdkI7QUFFRDs7Ozs7R0FLRztBQUNILE1BQU0sV0FBVyxXQUFXO0lBQzFCLHdEQUF3RDtJQUN4RCxhQUFh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