@aztec/wallet-sdk 0.0.1-commit.3d8f95d → 0.0.1-commit.3f296a7d2
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 +33 -18
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +122 -42
- 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 +7 -4
- package/dest/extension/provider/extension_wallet.d.ts +3 -2
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -1
- package/dest/extension/provider/extension_wallet.js +9 -2
- package/dest/manager/types.d.ts +4 -4
- 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 +2 -2
- package/package.json +8 -8
- package/src/base-wallet/base_wallet.ts +171 -75
- package/src/base-wallet/index.ts +1 -1
- package/src/base-wallet/utils.ts +9 -0
- package/src/extension/provider/extension_wallet.ts +12 -4
- package/src/manager/types.ts +3 -3
- package/src/manager/wallet_manager.ts +7 -9
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import type { Account } from '@aztec/aztec.js/account';
|
|
1
|
+
import type { Account, NoFrom } from '@aztec/aztec.js/account';
|
|
2
2
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
3
|
import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
5
|
-
import type
|
|
5
|
+
import { type Aliased, type AppCapabilities, type BatchResults, type BatchedMethod, ContractInitializationStatus, type ExecuteUtilityOptions, type PrivateEvent, type PrivateEventFilter, type ProfileOptions, type SendOptions, type SimulateOptions, type Wallet, type WalletCapabilities } from '@aztec/aztec.js/wallet';
|
|
6
6
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
7
7
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
8
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
9
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
10
|
+
import { type AccessScopes } from '@aztec/pxe/client/lazy';
|
|
10
11
|
import type { PXE } from '@aztec/pxe/server';
|
|
11
12
|
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall } from '@aztec/stdlib/abi';
|
|
12
13
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
13
|
-
import
|
|
14
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
15
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
15
16
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
16
17
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
17
|
-
import { type TxExecutionRequest, type TxProfileResult, TxSimulationResult, type
|
|
18
|
+
import { type TxExecutionRequest, type TxProfileResult, TxSimulationResult, type UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
18
19
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
19
20
|
/**
|
|
20
21
|
* Options to configure fee payment for a transaction
|
|
@@ -26,10 +27,17 @@ export type FeeOptions = {
|
|
|
26
27
|
*/
|
|
27
28
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
28
29
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
29
|
-
accountFeePaymentMethodOptions
|
|
30
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
30
31
|
/** The gas settings to use for the transaction */
|
|
31
32
|
gasSettings: GasSettings;
|
|
32
33
|
};
|
|
34
|
+
/** Options for `simulateViaEntrypoint`. */
|
|
35
|
+
export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'> & {
|
|
36
|
+
/** Fee options for the entrypoint */
|
|
37
|
+
feeOptions: FeeOptions;
|
|
38
|
+
/** Scopes to use for the simulation */
|
|
39
|
+
scopes: AccessScopes;
|
|
40
|
+
};
|
|
33
41
|
/**
|
|
34
42
|
* A base class for Wallet implementations
|
|
35
43
|
*/
|
|
@@ -39,7 +47,8 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
39
47
|
protected log: import("@aztec/foundation/log").Logger;
|
|
40
48
|
protected minFeePadding: number;
|
|
41
49
|
protected cancellableTransactions: boolean;
|
|
42
|
-
protected constructor(pxe: PXE, aztecNode: AztecNode);
|
|
50
|
+
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
51
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
43
52
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
44
53
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
45
54
|
/**
|
|
@@ -51,7 +60,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
51
60
|
*/
|
|
52
61
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
53
62
|
getChainInfo(): Promise<ChainInfo>;
|
|
54
|
-
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
63
|
+
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
55
64
|
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
56
65
|
/**
|
|
57
66
|
* Request capabilities from the wallet.
|
|
@@ -75,7 +84,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
75
84
|
* @param gasSettings - User-provided partial gas settings
|
|
76
85
|
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
77
86
|
*/
|
|
78
|
-
protected completeFeeOptions(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<FeeOptions>;
|
|
87
|
+
protected completeFeeOptions(from: AztecAddress | NoFrom, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<FeeOptions>;
|
|
79
88
|
/**
|
|
80
89
|
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
81
90
|
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
@@ -84,14 +93,14 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
84
93
|
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
85
94
|
* @param gasSettings - User-provided partial gas settings
|
|
86
95
|
*/
|
|
87
|
-
protected completeFeeOptionsForEstimation(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
96
|
+
protected completeFeeOptionsForEstimation(from: AztecAddress | NoFrom, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
88
97
|
/**
|
|
89
98
|
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
90
99
|
* doesn't already include one
|
|
91
100
|
*/
|
|
92
101
|
walletFeePaymentMethod?: FeePaymentMethod | undefined;
|
|
93
102
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
94
|
-
accountFeePaymentMethodOptions
|
|
103
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions | undefined;
|
|
95
104
|
gasSettings: GasSettings;
|
|
96
105
|
}>;
|
|
97
106
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
@@ -99,12 +108,9 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
99
108
|
/**
|
|
100
109
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
101
110
|
* @param executionPayload - The execution payload to simulate.
|
|
102
|
-
* @param
|
|
103
|
-
* @param feeOptions - Fee options for the transaction.
|
|
104
|
-
* @param skipTxValidation - Whether to skip tx validation.
|
|
105
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
111
|
+
* @param opts - Simulation options.
|
|
106
112
|
*/
|
|
107
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload,
|
|
113
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
|
|
108
114
|
/**
|
|
109
115
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
110
116
|
* on the node while sending the remaining calls through the standard PXE path.
|
|
@@ -116,12 +122,21 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
116
122
|
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
117
123
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
118
124
|
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
125
|
+
/**
|
|
126
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
127
|
+
* @param address - The contract address to resolve.
|
|
128
|
+
*/
|
|
129
|
+
protected getContractName(address: AztecAddress): Promise<string | undefined>;
|
|
119
130
|
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
120
|
-
|
|
131
|
+
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
121
132
|
getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
|
|
133
|
+
/**
|
|
134
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
135
|
+
* @param address - The contract address to query.
|
|
136
|
+
*/
|
|
122
137
|
getContractMetadata(address: AztecAddress): Promise<{
|
|
123
138
|
instance: ContractInstanceWithAddress | undefined;
|
|
124
|
-
|
|
139
|
+
initializationStatus: ContractInitializationStatus;
|
|
125
140
|
isContractPublished: boolean;
|
|
126
141
|
isContractUpdated: boolean;
|
|
127
142
|
updatedContractClassId: Fr | undefined;
|
|
@@ -131,4 +146,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
131
146
|
isContractClassPubliclyRegistered: boolean;
|
|
132
147
|
}>;
|
|
133
148
|
}
|
|
134
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
149
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGVBQWUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2pGLE9BQU8sRUFDTCxLQUFLLHNCQUFzQixFQUUzQixLQUFLLFVBQVUsRUFFaEIsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTVELE9BQU8sRUFDTCxLQUFLLE9BQU8sRUFDWixLQUFLLGVBQWUsRUFDcEIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssYUFBYSxFQUNsQiw0QkFBNEIsRUFDNUIsS0FBSyxxQkFBcUIsRUFDMUIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssY0FBYyxFQUNuQixLQUFLLFdBQVcsRUFDaEIsS0FBS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UFBTSxDQUFDLENBQUMsU0FBUyxzQkFBc0IsR0FBRyxTQUFTLEVBQzlELGdCQUFnQixFQUFFLGdCQUFnQixFQUNsQyxJQUFJLEVBQUUsV0FBVyxDQUFDLENBQUMsQ0FBQyxHQUNuQixPQUFPLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBa0N4QjtJQUVEOzs7T0FHRztJQUNILFVBQWdCLGVBQWUsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBT2xGO0lBRUQsU0FBUyxDQUFDLGtCQUFrQixDQUFDLEdBQUcsRUFBRSxLQUFLLEVBQUUsR0FBRyxPQUFPLEVBQUUsTUFBTSxFQUFFLEdBQUcsS0FBSyxDQVlwRTtJQUVELGNBQWMsQ0FBQyxJQUFJLEVBQUUsWUFBWSxFQUFFLElBQUksRUFBRSxxQkFBcUIsR0FBRyxPQUFPLENBQUMsc0JBQXNCLENBQUMsQ0FFL0Y7SUFFSyxnQkFBZ0IsQ0FBQyxDQUFDLEVBQ3RCLFFBQVEsRUFBRSx1QkFBdUIsRUFDakMsV0FBVyxFQUFFLGtCQUFrQixHQUM5QixPQUFPLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FlNUI7SUFFRDs7O09BR0c7SUFDRyxtQkFBbUIsQ0FBQyxPQUFPLEVBQUUsWUFBWTs7Ozs7O09BaUM5QztJQUVLLHdCQUF3QixDQUFDLEVBQUUsRUFBRSxFQUFFOzs7T0FNcEM7Q0FDRiJ9
|
|
@@ -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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|
@@ -1,14 +1,19 @@
|
|
|
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';
|
|
4
|
+
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
3
5
|
import { GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
|
|
4
6
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
7
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
5
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
10
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
7
11
|
import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
12
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
13
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
9
14
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
10
15
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
11
|
-
import {
|
|
16
|
+
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
|
|
12
17
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
13
18
|
import { inspect } from 'util';
|
|
14
19
|
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
@@ -21,13 +26,23 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
21
26
|
minFeePadding;
|
|
22
27
|
cancellableTransactions;
|
|
23
28
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
24
|
-
constructor(pxe, aztecNode){
|
|
29
|
+
constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
|
|
25
30
|
this.pxe = pxe;
|
|
26
31
|
this.aztecNode = aztecNode;
|
|
27
|
-
this.log =
|
|
32
|
+
this.log = log;
|
|
28
33
|
this.minFeePadding = 0.5;
|
|
29
34
|
this.cancellableTransactions = false;
|
|
30
35
|
}
|
|
36
|
+
scopesFrom(from, additionalScopes = []) {
|
|
37
|
+
const allScopes = from === NO_FROM ? additionalScopes : [
|
|
38
|
+
from,
|
|
39
|
+
...additionalScopes
|
|
40
|
+
];
|
|
41
|
+
const scopeSet = new Set(allScopes.map((address)=>address.toString()));
|
|
42
|
+
return [
|
|
43
|
+
...scopeSet
|
|
44
|
+
].map(AztecAddress.fromString);
|
|
45
|
+
}
|
|
31
46
|
/**
|
|
32
47
|
* Returns the list of aliased contacts associated with the wallet.
|
|
33
48
|
* This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
|
|
@@ -50,18 +65,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
50
65
|
}
|
|
51
66
|
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
52
67
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
53
|
-
const executionOptions = {
|
|
54
|
-
txNonce: Fr.random(),
|
|
55
|
-
cancellable: this.cancellableTransactions,
|
|
56
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
57
|
-
};
|
|
58
68
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
59
69
|
feeExecutionPayload,
|
|
60
70
|
executionPayload
|
|
61
71
|
]) : executionPayload;
|
|
62
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
63
72
|
const chainInfo = await this.getChainInfo();
|
|
64
|
-
|
|
73
|
+
if (from === NO_FROM) {
|
|
74
|
+
const entrypoint = new DefaultEntrypoint();
|
|
75
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
76
|
+
} else {
|
|
77
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
78
|
+
const executionOptions = {
|
|
79
|
+
txNonce: Fr.random(),
|
|
80
|
+
cancellable: this.cancellableTransactions,
|
|
81
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
82
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
83
|
+
};
|
|
84
|
+
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
85
|
+
}
|
|
65
86
|
}
|
|
66
87
|
async createAuthWit(from, messageHashOrIntent) {
|
|
67
88
|
const account = await this.getAccountFromAddress(from);
|
|
@@ -111,14 +132,18 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
111
132
|
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
112
133
|
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
113
134
|
let accountFeePaymentMethodOptions;
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
135
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
136
|
+
// account contract entrypoint to use
|
|
137
|
+
if (from !== NO_FROM) {
|
|
138
|
+
if (!feePayer) {
|
|
139
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
140
|
+
// for the account to use its fee juice balance
|
|
141
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
142
|
+
} else {
|
|
143
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
144
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
145
|
+
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
146
|
+
}
|
|
122
147
|
}
|
|
123
148
|
const fullGasSettings = GasSettings.default({
|
|
124
149
|
...gasSettings,
|
|
@@ -187,16 +212,14 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
187
212
|
/**
|
|
188
213
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
189
214
|
* @param executionPayload - The execution payload to simulate.
|
|
190
|
-
* @param
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
194
|
-
*/ async simulateViaEntrypoint(executionPayload, from, feeOptions, skipTxValidation, skipFeeEnforcement) {
|
|
195
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions);
|
|
215
|
+
* @param opts - Simulation options.
|
|
216
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
217
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
196
218
|
return this.pxe.simulateTx(txRequest, {
|
|
197
219
|
simulatePublic: true,
|
|
198
|
-
skipTxValidation,
|
|
199
|
-
skipFeeEnforcement
|
|
220
|
+
skipTxValidation: opts.skipTxValidation,
|
|
221
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
222
|
+
scopes: opts.scopes
|
|
200
223
|
});
|
|
201
224
|
}
|
|
202
225
|
/**
|
|
@@ -214,10 +237,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
214
237
|
calls: remainingCalls
|
|
215
238
|
};
|
|
216
239
|
const chainInfo = await this.getChainInfo();
|
|
217
|
-
|
|
240
|
+
let blockHeader;
|
|
241
|
+
// PXE might not be synced yet, so we pull the latest header from the node
|
|
242
|
+
// To keep things consistent, we'll always try with PXE first
|
|
243
|
+
try {
|
|
244
|
+
blockHeader = await this.pxe.getSyncedBlockHeader();
|
|
245
|
+
} catch {
|
|
246
|
+
blockHeader = await this.aztecNode.getBlockHeader();
|
|
247
|
+
}
|
|
248
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
218
249
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
219
|
-
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls,
|
|
220
|
-
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload,
|
|
250
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
|
|
251
|
+
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
252
|
+
from: opts.from,
|
|
253
|
+
feeOptions,
|
|
254
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
255
|
+
skipTxValidation: opts.skipTxValidation,
|
|
256
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
257
|
+
}) : Promise.resolve(null)
|
|
221
258
|
]);
|
|
222
259
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
223
260
|
}
|
|
@@ -226,13 +263,15 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
226
263
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
227
264
|
return this.pxe.profileTx(txRequest, {
|
|
228
265
|
profileMode: opts.profileMode,
|
|
229
|
-
skipProofGeneration: opts.skipProofGeneration ?? true
|
|
266
|
+
skipProofGeneration: opts.skipProofGeneration ?? true,
|
|
267
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
230
268
|
});
|
|
231
269
|
}
|
|
232
270
|
async sendTx(executionPayload, opts) {
|
|
233
271
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
234
272
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
235
|
-
const provenTx = await this.pxe.proveTx(txRequest);
|
|
273
|
+
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
274
|
+
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
236
275
|
const tx = await provenTx.toTx();
|
|
237
276
|
const txHash = tx.getTxHash();
|
|
238
277
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -245,11 +284,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
245
284
|
this.log.info(`Sent transaction ${txHash}`);
|
|
246
285
|
// If wait is NO_WAIT, return txHash immediately
|
|
247
286
|
if (opts.wait === NO_WAIT) {
|
|
248
|
-
return
|
|
287
|
+
return {
|
|
288
|
+
txHash,
|
|
289
|
+
...offchainOutput
|
|
290
|
+
};
|
|
249
291
|
}
|
|
250
292
|
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
251
293
|
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
252
|
-
|
|
294
|
+
const receipt = await waitForTx(this.aztecNode, txHash, waitOpts);
|
|
295
|
+
// Display debug logs from public execution if present (served in test mode only)
|
|
296
|
+
if (receipt.debugLogs?.length) {
|
|
297
|
+
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
receipt,
|
|
301
|
+
...offchainOutput
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
306
|
+
* @param address - The contract address to resolve.
|
|
307
|
+
*/ async getContractName(address) {
|
|
308
|
+
const instance = await this.pxe.getContractInstance(address);
|
|
309
|
+
if (!instance) {
|
|
310
|
+
return undefined;
|
|
311
|
+
}
|
|
312
|
+
const artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
313
|
+
return artifact?.name;
|
|
253
314
|
}
|
|
254
315
|
contextualizeError(err, ...context) {
|
|
255
316
|
let contextStr = '';
|
|
@@ -264,9 +325,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
264
325
|
}
|
|
265
326
|
return err;
|
|
266
327
|
}
|
|
267
|
-
|
|
268
|
-
return this.pxe.
|
|
269
|
-
authwits
|
|
328
|
+
executeUtility(call, opts) {
|
|
329
|
+
return this.pxe.executeUtility(call, {
|
|
330
|
+
authwits: opts.authWitnesses,
|
|
331
|
+
scopes: opts.scopes
|
|
270
332
|
});
|
|
271
333
|
}
|
|
272
334
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
@@ -285,15 +347,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
285
347
|
});
|
|
286
348
|
return decodedEvents;
|
|
287
349
|
}
|
|
288
|
-
|
|
350
|
+
/**
|
|
351
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
352
|
+
* @param address - The contract address to query.
|
|
353
|
+
*/ async getContractMetadata(address) {
|
|
289
354
|
const instance = await this.pxe.getContractInstance(address);
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
355
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
356
|
+
let initializationStatus;
|
|
357
|
+
if (instance) {
|
|
358
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
359
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
360
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
361
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
362
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNINITIALIZED;
|
|
363
|
+
} else {
|
|
364
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
365
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
366
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
367
|
+
// uninitialized.
|
|
368
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
369
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
370
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
371
|
+
}
|
|
372
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
293
373
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
294
374
|
return {
|
|
295
375
|
instance: instance ?? undefined,
|
|
296
|
-
|
|
376
|
+
initializationStatus,
|
|
297
377
|
isContractPublished: !!publiclyRegisteredContract,
|
|
298
378
|
isContractUpdated: !!isContractUpdated,
|
|
299
379
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { BaseWallet, type FeeOptions } from './base_wallet.js';
|
|
1
|
+
export { BaseWallet, 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLEtBQUssVUFBVSxFQUFFLEtBQUssNEJBQTRCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNsRyxPQUFPLEVBQUUsZUFBZSxFQUFFLDJCQUEyQixFQUFFLG1DQUFtQyxFQUFFLE1BQU0sWUFBWSxDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
2
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
|
+
import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
|
|
3
4
|
import { type FunctionCall } from '@aztec/stdlib/abi';
|
|
4
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
6
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
@@ -33,7 +34,7 @@ export declare function extractOptimizablePublicStaticCalls(payload: ExecutionPa
|
|
|
33
34
|
* @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
|
|
34
35
|
* @returns Array of TxSimulationResult, one per batch.
|
|
35
36
|
*/
|
|
36
|
-
export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement
|
|
37
|
+
export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement: boolean | undefined, getContractName: ContractNameResolver): Promise<TxSimulationResult[]>;
|
|
37
38
|
/**
|
|
38
39
|
* Merges simulation results from the optimized (public static) and normal paths.
|
|
39
40
|
* Since optimized calls are always a leading prefix, return values are simply
|
|
@@ -45,4 +46,4 @@ export declare function simulateViaNode(node: AztecNode, publicStaticCalls: Func
|
|
|
45
46
|
* @returns A single TxSimulationResult with return values in original call order.
|
|
46
47
|
*/
|
|
47
48
|
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult: TxSimulationResult | null): TxSimulationResult;
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV0RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUkvRCxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBR25FLE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBb0IsTUFBTSxtQkFBbUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQVFyRCxPQUFPLEVBQ0wsS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Root":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,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,kBAAkB,GAAG,IAAI,GACtC,kBAAkB,CAoBpB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MAX_ENQUEUED_CALLS_PER_CALL } from '@aztec/constants';
|
|
2
2
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
4
5
|
import { generateSimulatedProvingResult } from '@aztec/pxe/simulator';
|
|
5
6
|
import { ClaimedLengthArray, CountedPublicCallRequest, PrivateCircuitPublicInputs, PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
6
7
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
@@ -34,7 +35,7 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
34
35
|
* @param blockHeader - Block header to use as anchor.
|
|
35
36
|
* @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
|
|
36
37
|
* @returns TxSimulationResult with public return values.
|
|
37
|
-
*/ async function simulateBatchViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement) {
|
|
38
|
+
*/ async function simulateBatchViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement, getContractName) {
|
|
38
39
|
const txContext = new TxContext(chainInfo.chainId, chainInfo.version, gasSettings);
|
|
39
40
|
const publicFunctionCalldata = [];
|
|
40
41
|
for (const call of publicStaticCalls){
|
|
@@ -65,7 +66,7 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
65
66
|
// Minimal entrypoint structure — no real private execution, just public call requests
|
|
66
67
|
const emptyEntrypoint = new PrivateCallExecutionResult(Buffer.alloc(0), Buffer.alloc(0), new Map(), publicInputs, [], new Map(), [], [], [], [], []);
|
|
67
68
|
const privateResult = new PrivateExecutionResult(emptyEntrypoint, Fr.random(), publicFunctionCalldata);
|
|
68
|
-
const provingResult = await generateSimulatedProvingResult(privateResult, (_contractAddress, _functionSelector)=>Promise.resolve(''), 1);
|
|
69
|
+
const provingResult = await generateSimulatedProvingResult(privateResult, (_contractAddress, _functionSelector)=>Promise.resolve(''), node, 1);
|
|
69
70
|
provingResult.publicInputs.feePayer = from;
|
|
70
71
|
const tx = await Tx.create({
|
|
71
72
|
data: provingResult.publicInputs,
|
|
@@ -77,6 +78,8 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
77
78
|
if (publicOutput.revertReason) {
|
|
78
79
|
throw publicOutput.revertReason;
|
|
79
80
|
}
|
|
81
|
+
// Display debug logs from the public simulation.
|
|
82
|
+
await displayDebugLogs(publicOutput.debugLogs, getContractName);
|
|
80
83
|
return new TxSimulationResult(privateResult, provingResult.publicInputs, publicOutput, undefined);
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
@@ -91,14 +94,14 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
91
94
|
* @param blockHeader - Block header to use as anchor.
|
|
92
95
|
* @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
|
|
93
96
|
* @returns Array of TxSimulationResult, one per batch.
|
|
94
|
-
*/ export async function simulateViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement = true) {
|
|
97
|
+
*/ export async function simulateViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement = true, getContractName) {
|
|
95
98
|
const batches = [];
|
|
96
99
|
for(let i = 0; i < publicStaticCalls.length; i += MAX_ENQUEUED_CALLS_PER_CALL){
|
|
97
100
|
batches.push(publicStaticCalls.slice(i, i + MAX_ENQUEUED_CALLS_PER_CALL));
|
|
98
101
|
}
|
|
99
102
|
const results = [];
|
|
100
103
|
for (const batch of batches){
|
|
101
|
-
const result = await simulateBatchViaNode(node, batch, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement);
|
|
104
|
+
const result = await simulateBatchViaNode(node, batch, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement, getContractName);
|
|
102
105
|
results.push(result);
|
|
103
106
|
}
|
|
104
107
|
return results;
|
|
@@ -80,7 +80,8 @@ export declare class ExtensionWallet {
|
|
|
80
80
|
* const accounts = await wallet.getAccounts();
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
83
|
-
static create(extensionId: string, port: MessagePort, sharedKey: CryptoKey, chainInfo: ChainInfo, appId: string):
|
|
83
|
+
static create(extensionId: string, port: MessagePort, sharedKey: CryptoKey, chainInfo: ChainInfo, appId: string): ExtensionWallet;
|
|
84
|
+
asWallet(): Wallet;
|
|
84
85
|
private handleEncryptedResponse;
|
|
85
86
|
private postMessage;
|
|
86
87
|
/**
|
|
@@ -128,4 +129,4 @@ export declare class ExtensionWallet {
|
|
|
128
129
|
*/
|
|
129
130
|
disconnect(): Promise<void>;
|
|
130
131
|
}
|
|
131
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
132
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5zaW9uX3dhbGxldC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2V4dGVuc2lvbi9wcm92aWRlci9leHRlbnNpb25fd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3pELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx3QkFBd0IsQ0FBQztBQW9CbkU7O0dBRUc7QUFDSCxNQUFNLE1BQU0sa0JBQWtCLEdBQUcsTUFBTSxJQUFJLENBQUM7QUFFNUM7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQThCRztBQUNILHFCQUFhLGVBQWU7SUFleEIsT0FBTyxDQUFDLFNBQVM7SUFDakIsT0FBTyxDQUFDLEtBQUs7SUFDYixPQUFPLENBQUMsV0FBVztJQUNuQixPQUFPLENBQUMsSUFBSTtJQUNaLE9BQU8sQ0FBQyxTQUFTO0lBbEJuQixzRUFBc0U7SUFDdEUsT0FBTyxDQ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GA8BG;AACH,qBAAa,eAAe;IAexB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,SAAS;IAlBnB,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAoD;IACpE,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,mBAAmB,CAA4B;IAEvD;;;;;;;OAOG;IACH,OAAO,eAMH;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,MAAM,CACX,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,GACZ,MAAM,
|
|
1
|
+
{"version":3,"file":"extension_wallet.d.ts","sourceRoot":"","sources":["../../../src/extension/provider/extension_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,wBAAwB,CAAC;AAoBnE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,eAAe;IAexB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,SAAS;IAlBnB,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAoD;IACpE,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,mBAAmB,CAA4B;IAEvD;;;;;;;OAOG;IACH,OAAO,eAMH;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,MAAM,CACX,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,GACZ,eAAe,CAkCjB;IAED,QAAQ,IAAI,MAAM,CAIjB;YAUa,uBAAuB;YA8CvB,WAAW;IA0BzB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IA0BxB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,IAAI,CAQrD;IAED;;;;OAIG;IACH,cAAc,IAAI,OAAO,CAExB;IAED;;;;;;;;;;;;;OAaG;IAEG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAahC;CACF"}
|
|
@@ -100,8 +100,10 @@ import { WalletMessageType } from '../../types.js';
|
|
|
100
100
|
};
|
|
101
101
|
wallet.port.start();
|
|
102
102
|
return new Proxy(wallet, {
|
|
103
|
-
get: (target, prop)=>{
|
|
104
|
-
if (
|
|
103
|
+
get: (target, prop, receiver)=>{
|
|
104
|
+
if (prop === 'asWallet') {
|
|
105
|
+
return ()=>receiver;
|
|
106
|
+
} else if (schemaHasMethod(WalletSchema, prop.toString())) {
|
|
105
107
|
return async (...args)=>{
|
|
106
108
|
const result = await target.postMessage({
|
|
107
109
|
type: prop.toString(),
|
|
@@ -115,6 +117,11 @@ import { WalletMessageType } from '../../types.js';
|
|
|
115
117
|
}
|
|
116
118
|
});
|
|
117
119
|
}
|
|
120
|
+
asWallet() {
|
|
121
|
+
// Overridden by the proxy in create() to return the proxy itself.
|
|
122
|
+
// This body is never reached when accessed through create().
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
118
125
|
/**
|
|
119
126
|
* Handles an encrypted response received from the wallet extension.
|
|
120
127
|
*
|