@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
package/dest/manager/types.d.ts
CHANGED
|
@@ -107,18 +107,18 @@ export interface WalletProvider {
|
|
|
107
107
|
* After calling this, the wallet returned from confirm() should no longer be used.
|
|
108
108
|
* @returns A promise that resolves when disconnection is complete
|
|
109
109
|
*/
|
|
110
|
-
disconnect
|
|
110
|
+
disconnect(): Promise<void>;
|
|
111
111
|
/**
|
|
112
112
|
* Registers a callback to be invoked when the wallet disconnects unexpectedly.
|
|
113
113
|
* @param callback - Function to call when wallet disconnects
|
|
114
114
|
* @returns A function to unregister the callback
|
|
115
115
|
*/
|
|
116
|
-
onDisconnect
|
|
116
|
+
onDisconnect(callback: ProviderDisconnectionCallback): () => void;
|
|
117
117
|
/**
|
|
118
118
|
* Returns whether the provider's wallet connection has been disconnected.
|
|
119
119
|
* @returns true if the wallet is no longer connected
|
|
120
120
|
*/
|
|
121
|
-
isDisconnected
|
|
121
|
+
isDisconnected(): boolean;
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* Options for discovering wallets
|
|
@@ -164,4 +164,4 @@ export interface DiscoverySession {
|
|
|
164
164
|
/** Cancel discovery immediately and clean up resources */
|
|
165
165
|
cancel: () => void;
|
|
166
166
|
}
|
|
167
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
167
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYW5hZ2VyL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRXJEOzs7Ozs7Ozs7R0FTRztBQUNILE1BQU0sV0FBVyxpQkFBaUI7SUFDaEM7Ozs7T0FJRztJQUNILGdCQUFnQixFQUFFLE1BQU0sQ0FBQztJQUV6Qjs7O09BR0c7SUFDSCxPQUFPLElBQUksT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBRTNCOzs7T0FHRztJQUNILE1BQU0sSUFBSSxJQUFJLENBQUM7Q0FDaEI7QUFFRDs7R0FFRztBQUNILE1BQU0sV0FBVyxxQkFBcUI7SUFDcEMsNENBQTRDO0lBQzVDLE9BQU8sRUFBRSxPQUFPLENBQUM7SUFDakIseURBQXlEO0lBQ3pELFNBQVMsQ0FBQyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ3JCLHlEQUF5RDtJQUN6RCxTQUFTLENBQUM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UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,6BAA6B,GAAG,MAAM,IAAI,CAAC;IAClE;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,SAAS,EAAE,SAAS,CAAC;IACrB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;CACzD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACvC,qEAAqE;IACrE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB"}
|
|
@@ -67,4 +67,4 @@ export declare class WalletManager {
|
|
|
67
67
|
*/
|
|
68
68
|
private isExtensionAllowed;
|
|
69
69
|
}
|
|
70
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
70
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0X21hbmFnZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYW5hZ2VyL3dhbGxldF9tYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sS0FBSyxFQUNWLHNCQUFzQixFQUN0QixnQkFBZ0IsRUFJaEIsbUJBQW1CLEVBRXBCLE1BQU0sWUFBWSxDQUFDO0FBRXBCOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0E4Qkc7QUFDSCxxQkFBYSxhQUFhO0lBQ3hCLE9BQU8sQ0FBQyxNQUFNLENBR1o7SUFFRixPQUFPLGVBQWlCO0lBRXhCOzs7T0FHRztJQUNILE1BQU0sQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFFLG1CQUFtQixHQUFHLGFBQWEsQ0FPM0Q7SUFFRDs7Ozs7Ozs7Ozs7O09BWUc7SUFDSCxtQkFBbUIsQ0FBQyxPQUFPLEVBQUUsc0JBQXNCLEdBQUcsZ0JBQWdCLENBNkVyRTtJQUVEOzs7Ozs7T0FNRztJQUNILE9BQU8sQ0FBQyxrQ0FBa0M7SUEwRTFDOzs7O09BSUc7SUFDSCxPQUFPLENBQUMsa0JBQWtCO0NBVzNCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_manager.d.ts","sourceRoot":"","sources":["../../src/manager/wallet_manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAIhB,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAGZ;IAEF,OAAO,eAAiB;IAExB;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAO3D;IAED;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,gBAAgB,CA6ErE;IAED;;;;;;OAMG;IACH,OAAO,CAAC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"wallet_manager.d.ts","sourceRoot":"","sources":["../../src/manager/wallet_manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAIhB,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAGZ;IAEF,OAAO,eAAiB;IAExB;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAO3D;IAED;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,gBAAgB,CA6ErE;IAED;;;;;;OAMG;IACH,OAAO,CAAC,kCAAkC;IA0E1C;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAW3B"}
|
|
@@ -176,7 +176,8 @@ import { WalletMessageType } from '../types.js';
|
|
|
176
176
|
return {
|
|
177
177
|
verificationHash: connection.info.verificationHash,
|
|
178
178
|
confirm: ()=>{
|
|
179
|
-
|
|
179
|
+
extensionWallet = ExtensionWallet.create(connection.info.id, connection.port, connection.sharedKey, chainInfo, connectAppId);
|
|
180
|
+
return Promise.resolve(extensionWallet.asWallet());
|
|
180
181
|
},
|
|
181
182
|
cancel: ()=>{
|
|
182
183
|
// Send disconnect to terminate the session on the extension side
|
|
@@ -185,7 +186,6 @@ import { WalletMessageType } from '../types.js';
|
|
|
185
186
|
type: WalletMessageType.DISCONNECT,
|
|
186
187
|
requestId: discoveredWallet.requestId
|
|
187
188
|
});
|
|
188
|
-
// Don't close the port - allow retry with fresh key exchange
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
191
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/wallet-sdk",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallet-sdk",
|
|
4
|
-
"version": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.3f296a7d2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./base-wallet": "./dest/base-wallet/index.js",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
75
|
-
"@aztec/constants": "0.0.1-commit.
|
|
76
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
77
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
78
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
74
|
+
"@aztec/aztec.js": "0.0.1-commit.3f296a7d2",
|
|
75
|
+
"@aztec/constants": "0.0.1-commit.3f296a7d2",
|
|
76
|
+
"@aztec/entrypoints": "0.0.1-commit.3f296a7d2",
|
|
77
|
+
"@aztec/foundation": "0.0.1-commit.3f296a7d2",
|
|
78
|
+
"@aztec/pxe": "0.0.1-commit.3f296a7d2",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.3f296a7d2"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
82
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.3f296a7d2",
|
|
83
83
|
"@jest/globals": "^30.0.0",
|
|
84
84
|
"@types/jest": "^30.0.0",
|
|
85
85
|
"@types/node": "^22.15.17",
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import type { Account } from '@aztec/aztec.js/account';
|
|
1
|
+
import type { Account, NoFrom } from '@aztec/aztec.js/account';
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
3
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type InteractionWaitOptions,
|
|
6
|
+
NO_WAIT,
|
|
7
|
+
type SendReturn,
|
|
8
|
+
extractOffchainOutput,
|
|
9
|
+
} from '@aztec/aztec.js/contracts';
|
|
4
10
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
5
11
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
6
|
-
import
|
|
7
|
-
Aliased,
|
|
8
|
-
AppCapabilities,
|
|
9
|
-
BatchResults,
|
|
10
|
-
BatchedMethod,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import {
|
|
13
|
+
type Aliased,
|
|
14
|
+
type AppCapabilities,
|
|
15
|
+
type BatchResults,
|
|
16
|
+
type BatchedMethod,
|
|
17
|
+
ContractInitializationStatus,
|
|
18
|
+
type ExecuteUtilityOptions,
|
|
19
|
+
type PrivateEvent,
|
|
20
|
+
type PrivateEventFilter,
|
|
21
|
+
type ProfileOptions,
|
|
22
|
+
type SendOptions,
|
|
23
|
+
type SimulateOptions,
|
|
24
|
+
type Wallet,
|
|
25
|
+
type WalletCapabilities,
|
|
18
26
|
} from '@aztec/aztec.js/wallet';
|
|
19
27
|
import {
|
|
20
28
|
GAS_ESTIMATION_DA_GAS_LIMIT,
|
|
@@ -23,10 +31,12 @@ import {
|
|
|
23
31
|
GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT,
|
|
24
32
|
} from '@aztec/constants';
|
|
25
33
|
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
34
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
26
35
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
27
36
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
28
37
|
import { createLogger } from '@aztec/foundation/log';
|
|
29
38
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
39
|
+
import { type AccessScopes, displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
30
40
|
import type { PXE, PackedPrivateEvent } from '@aztec/pxe/server';
|
|
31
41
|
import {
|
|
32
42
|
type ContractArtifact,
|
|
@@ -35,7 +45,7 @@ import {
|
|
|
35
45
|
decodeFromAbi,
|
|
36
46
|
} from '@aztec/stdlib/abi';
|
|
37
47
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
38
|
-
import
|
|
48
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
39
49
|
import {
|
|
40
50
|
type ContractInstanceWithAddress,
|
|
41
51
|
computePartialAddress,
|
|
@@ -43,13 +53,17 @@ import {
|
|
|
43
53
|
} from '@aztec/stdlib/contract';
|
|
44
54
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
45
55
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
46
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
computeSiloedPrivateInitializationNullifier,
|
|
58
|
+
computeSiloedPublicInitializationNullifier,
|
|
59
|
+
} from '@aztec/stdlib/hash';
|
|
47
60
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
48
61
|
import {
|
|
62
|
+
BlockHeader,
|
|
49
63
|
type TxExecutionRequest,
|
|
50
64
|
type TxProfileResult,
|
|
51
65
|
TxSimulationResult,
|
|
52
|
-
type
|
|
66
|
+
type UtilityExecutionResult,
|
|
53
67
|
} from '@aztec/stdlib/tx';
|
|
54
68
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
55
69
|
|
|
@@ -67,17 +81,25 @@ export type FeeOptions = {
|
|
|
67
81
|
*/
|
|
68
82
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
69
83
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
70
|
-
accountFeePaymentMethodOptions
|
|
84
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
71
85
|
/** The gas settings to use for the transaction */
|
|
72
86
|
gasSettings: GasSettings;
|
|
73
87
|
};
|
|
74
88
|
|
|
89
|
+
/** Options for `simulateViaEntrypoint`. */
|
|
90
|
+
export type SimulateViaEntrypointOptions = Pick<
|
|
91
|
+
SimulateOptions,
|
|
92
|
+
'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'
|
|
93
|
+
> & {
|
|
94
|
+
/** Fee options for the entrypoint */
|
|
95
|
+
feeOptions: FeeOptions;
|
|
96
|
+
/** Scopes to use for the simulation */
|
|
97
|
+
scopes: AccessScopes;
|
|
98
|
+
};
|
|
75
99
|
/**
|
|
76
100
|
* A base class for Wallet implementations
|
|
77
101
|
*/
|
|
78
102
|
export abstract class BaseWallet implements Wallet {
|
|
79
|
-
protected log = createLogger('wallet-sdk:base_wallet');
|
|
80
|
-
|
|
81
103
|
protected minFeePadding = 0.5;
|
|
82
104
|
protected cancellableTransactions = false;
|
|
83
105
|
|
|
@@ -85,8 +107,15 @@ export abstract class BaseWallet implements Wallet {
|
|
|
85
107
|
protected constructor(
|
|
86
108
|
protected readonly pxe: PXE,
|
|
87
109
|
protected readonly aztecNode: AztecNode,
|
|
110
|
+
protected log = createLogger('wallet-sdk:base_wallet'),
|
|
88
111
|
) {}
|
|
89
112
|
|
|
113
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes: AztecAddress[] = []): AztecAddress[] {
|
|
114
|
+
const allScopes = from === NO_FROM ? additionalScopes : [from, ...additionalScopes];
|
|
115
|
+
const scopeSet = new Set(allScopes.map(address => address.toString()));
|
|
116
|
+
return [...scopeSet].map(AztecAddress.fromString);
|
|
117
|
+
}
|
|
118
|
+
|
|
90
119
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
91
120
|
|
|
92
121
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
@@ -110,26 +139,33 @@ export abstract class BaseWallet implements Wallet {
|
|
|
110
139
|
|
|
111
140
|
protected async createTxExecutionRequestFromPayloadAndFee(
|
|
112
141
|
executionPayload: ExecutionPayload,
|
|
113
|
-
from: AztecAddress,
|
|
142
|
+
from: AztecAddress | NoFrom,
|
|
114
143
|
feeOptions: FeeOptions,
|
|
115
144
|
): Promise<TxExecutionRequest> {
|
|
116
145
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
117
|
-
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
118
|
-
txNonce: Fr.random(),
|
|
119
|
-
cancellable: this.cancellableTransactions,
|
|
120
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
121
|
-
};
|
|
122
146
|
const finalExecutionPayload = feeExecutionPayload
|
|
123
147
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
124
148
|
: executionPayload;
|
|
125
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
126
149
|
const chainInfo = await this.getChainInfo();
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
chainInfo
|
|
131
|
-
|
|
132
|
-
|
|
150
|
+
|
|
151
|
+
if (from === NO_FROM) {
|
|
152
|
+
const entrypoint = new DefaultEntrypoint();
|
|
153
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
154
|
+
} else {
|
|
155
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
156
|
+
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
157
|
+
txNonce: Fr.random(),
|
|
158
|
+
cancellable: this.cancellableTransactions,
|
|
159
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
160
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions!,
|
|
161
|
+
};
|
|
162
|
+
return fromAccount.createTxExecutionRequest(
|
|
163
|
+
finalExecutionPayload,
|
|
164
|
+
feeOptions.gasSettings,
|
|
165
|
+
chainInfo,
|
|
166
|
+
executionOptions,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
133
169
|
}
|
|
134
170
|
|
|
135
171
|
public async createAuthWit(
|
|
@@ -184,23 +220,27 @@ export abstract class BaseWallet implements Wallet {
|
|
|
184
220
|
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
185
221
|
*/
|
|
186
222
|
protected async completeFeeOptions(
|
|
187
|
-
from: AztecAddress,
|
|
223
|
+
from: AztecAddress | NoFrom,
|
|
188
224
|
feePayer?: AztecAddress,
|
|
189
225
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
190
226
|
): Promise<FeeOptions> {
|
|
191
227
|
const maxFeesPerGas =
|
|
192
228
|
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
193
229
|
let accountFeePaymentMethodOptions;
|
|
194
|
-
//
|
|
195
|
-
//
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
230
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
231
|
+
// account contract entrypoint to use
|
|
232
|
+
if (from !== NO_FROM) {
|
|
233
|
+
if (!feePayer) {
|
|
234
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
235
|
+
// for the account to use its fee juice balance
|
|
236
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
237
|
+
} else {
|
|
238
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
239
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
240
|
+
accountFeePaymentMethodOptions = from.equals(feePayer)
|
|
241
|
+
? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM
|
|
242
|
+
: AccountFeePaymentMethodOptions.EXTERNAL;
|
|
243
|
+
}
|
|
204
244
|
}
|
|
205
245
|
const fullGasSettings: GasSettings = GasSettings.default({ ...gasSettings, maxFeesPerGas });
|
|
206
246
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
@@ -220,7 +260,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
220
260
|
* @param gasSettings - User-provided partial gas settings
|
|
221
261
|
*/
|
|
222
262
|
protected async completeFeeOptionsForEstimation(
|
|
223
|
-
from: AztecAddress,
|
|
263
|
+
from: AztecAddress | NoFrom,
|
|
224
264
|
feePayer?: AztecAddress,
|
|
225
265
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
226
266
|
) {
|
|
@@ -287,20 +327,20 @@ export abstract class BaseWallet implements Wallet {
|
|
|
287
327
|
/**
|
|
288
328
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
289
329
|
* @param executionPayload - The execution payload to simulate.
|
|
290
|
-
* @param
|
|
291
|
-
* @param feeOptions - Fee options for the transaction.
|
|
292
|
-
* @param skipTxValidation - Whether to skip tx validation.
|
|
293
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
330
|
+
* @param opts - Simulation options.
|
|
294
331
|
*/
|
|
295
|
-
protected async simulateViaEntrypoint(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
332
|
+
protected async simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions) {
|
|
333
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(
|
|
334
|
+
executionPayload,
|
|
335
|
+
opts.from,
|
|
336
|
+
opts.feeOptions,
|
|
337
|
+
);
|
|
338
|
+
return this.pxe.simulateTx(txRequest, {
|
|
339
|
+
simulatePublic: true,
|
|
340
|
+
skipTxValidation: opts.skipTxValidation,
|
|
341
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
342
|
+
scopes: opts.scopes,
|
|
343
|
+
});
|
|
304
344
|
}
|
|
305
345
|
|
|
306
346
|
/**
|
|
@@ -319,28 +359,37 @@ export abstract class BaseWallet implements Wallet {
|
|
|
319
359
|
const remainingPayload = { ...executionPayload, calls: remainingCalls };
|
|
320
360
|
|
|
321
361
|
const chainInfo = await this.getChainInfo();
|
|
322
|
-
|
|
362
|
+
let blockHeader: BlockHeader;
|
|
363
|
+
// PXE might not be synced yet, so we pull the latest header from the node
|
|
364
|
+
// To keep things consistent, we'll always try with PXE first
|
|
365
|
+
try {
|
|
366
|
+
blockHeader = await this.pxe.getSyncedBlockHeader();
|
|
367
|
+
} catch {
|
|
368
|
+
blockHeader = (await this.aztecNode.getBlockHeader())!;
|
|
369
|
+
}
|
|
323
370
|
|
|
371
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
324
372
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
325
373
|
optimizableCalls.length > 0
|
|
326
374
|
? simulateViaNode(
|
|
327
375
|
this.aztecNode,
|
|
328
376
|
optimizableCalls,
|
|
329
|
-
|
|
377
|
+
simulationOrigin,
|
|
330
378
|
chainInfo,
|
|
331
379
|
feeOptions.gasSettings,
|
|
332
380
|
blockHeader,
|
|
333
381
|
opts.skipFeeEnforcement ?? true,
|
|
382
|
+
this.getContractName.bind(this),
|
|
334
383
|
)
|
|
335
384
|
: Promise.resolve([]),
|
|
336
385
|
remainingCalls.length > 0
|
|
337
|
-
? this.simulateViaEntrypoint(
|
|
338
|
-
|
|
339
|
-
opts.from,
|
|
386
|
+
? this.simulateViaEntrypoint(remainingPayload, {
|
|
387
|
+
from: opts.from,
|
|
340
388
|
feeOptions,
|
|
341
|
-
opts.
|
|
342
|
-
opts.
|
|
343
|
-
|
|
389
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
390
|
+
skipTxValidation: opts.skipTxValidation,
|
|
391
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
|
|
392
|
+
})
|
|
344
393
|
: Promise.resolve(null),
|
|
345
394
|
]);
|
|
346
395
|
|
|
@@ -353,6 +402,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
353
402
|
return this.pxe.profileTx(txRequest, {
|
|
354
403
|
profileMode: opts.profileMode,
|
|
355
404
|
skipProofGeneration: opts.skipProofGeneration ?? true,
|
|
405
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
356
406
|
});
|
|
357
407
|
}
|
|
358
408
|
|
|
@@ -362,7 +412,11 @@ export abstract class BaseWallet implements Wallet {
|
|
|
362
412
|
): Promise<SendReturn<W>> {
|
|
363
413
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
364
414
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
365
|
-
const provenTx = await this.pxe.proveTx(txRequest);
|
|
415
|
+
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
416
|
+
const offchainOutput = extractOffchainOutput(
|
|
417
|
+
provenTx.getOffchainEffects(),
|
|
418
|
+
provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp,
|
|
419
|
+
);
|
|
366
420
|
const tx = await provenTx.toTx();
|
|
367
421
|
const txHash = tx.getTxHash();
|
|
368
422
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -376,12 +430,32 @@ export abstract class BaseWallet implements Wallet {
|
|
|
376
430
|
|
|
377
431
|
// If wait is NO_WAIT, return txHash immediately
|
|
378
432
|
if (opts.wait === NO_WAIT) {
|
|
379
|
-
return txHash as SendReturn<W>;
|
|
433
|
+
return { txHash, ...offchainOutput } as SendReturn<W>;
|
|
380
434
|
}
|
|
381
435
|
|
|
382
436
|
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
383
437
|
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
384
|
-
|
|
438
|
+
const receipt = await waitForTx(this.aztecNode, txHash, waitOpts);
|
|
439
|
+
|
|
440
|
+
// Display debug logs from public execution if present (served in test mode only)
|
|
441
|
+
if (receipt.debugLogs?.length) {
|
|
442
|
+
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return { receipt, ...offchainOutput } as SendReturn<W>;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
450
|
+
* @param address - The contract address to resolve.
|
|
451
|
+
*/
|
|
452
|
+
protected async getContractName(address: AztecAddress): Promise<string | undefined> {
|
|
453
|
+
const instance = await this.pxe.getContractInstance(address);
|
|
454
|
+
if (!instance) {
|
|
455
|
+
return undefined;
|
|
456
|
+
}
|
|
457
|
+
const artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
458
|
+
return artifact?.name;
|
|
385
459
|
}
|
|
386
460
|
|
|
387
461
|
protected contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -398,8 +472,8 @@ export abstract class BaseWallet implements Wallet {
|
|
|
398
472
|
return err;
|
|
399
473
|
}
|
|
400
474
|
|
|
401
|
-
|
|
402
|
-
return this.pxe.
|
|
475
|
+
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult> {
|
|
476
|
+
return this.pxe.executeUtility(call, { authwits: opts.authWitnesses, scopes: opts.scopes });
|
|
403
477
|
}
|
|
404
478
|
|
|
405
479
|
async getPrivateEvents<T>(
|
|
@@ -422,17 +496,39 @@ export abstract class BaseWallet implements Wallet {
|
|
|
422
496
|
return decodedEvents;
|
|
423
497
|
}
|
|
424
498
|
|
|
499
|
+
/**
|
|
500
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
501
|
+
* @param address - The contract address to query.
|
|
502
|
+
*/
|
|
425
503
|
async getContractMetadata(address: AztecAddress) {
|
|
426
504
|
const instance = await this.pxe.getContractInstance(address);
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
505
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
506
|
+
|
|
507
|
+
let initializationStatus: ContractInitializationStatus;
|
|
508
|
+
if (instance) {
|
|
509
|
+
// We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
|
|
510
|
+
// emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
|
|
511
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
512
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
513
|
+
initializationStatus = witness
|
|
514
|
+
? ContractInitializationStatus.INITIALIZED
|
|
515
|
+
: ContractInitializationStatus.UNINITIALIZED;
|
|
516
|
+
} else {
|
|
517
|
+
// Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
|
|
518
|
+
// public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
|
|
519
|
+
// public functions that require initialization checks), so its absence doesn't mean the contract is
|
|
520
|
+
// uninitialized.
|
|
521
|
+
const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
|
|
522
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
|
|
523
|
+
initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
|
|
524
|
+
}
|
|
525
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
430
526
|
const isContractUpdated =
|
|
431
527
|
publiclyRegisteredContract &&
|
|
432
528
|
!publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
433
529
|
return {
|
|
434
530
|
instance: instance ?? undefined,
|
|
435
|
-
|
|
531
|
+
initializationStatus,
|
|
436
532
|
isContractPublished: !!publiclyRegisteredContract,
|
|
437
533
|
isContractUpdated: !!isContractUpdated,
|
|
438
534
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined,
|
package/src/base-wallet/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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';
|
package/src/base-wallet/utils.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
|
4
4
|
import { makeTuple } from '@aztec/foundation/array';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
6
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
7
|
+
import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
|
|
8
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
7
9
|
import { generateSimulatedProvingResult } from '@aztec/pxe/simulator';
|
|
8
10
|
import { type FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
9
11
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -72,6 +74,7 @@ async function simulateBatchViaNode(
|
|
|
72
74
|
gasSettings: GasSettings,
|
|
73
75
|
blockHeader: BlockHeader,
|
|
74
76
|
skipFeeEnforcement: boolean,
|
|
77
|
+
getContractName: ContractNameResolver,
|
|
75
78
|
): Promise<TxSimulationResult> {
|
|
76
79
|
const txContext = new TxContext(chainInfo.chainId, chainInfo.version, gasSettings);
|
|
77
80
|
|
|
@@ -126,6 +129,7 @@ async function simulateBatchViaNode(
|
|
|
126
129
|
const provingResult = await generateSimulatedProvingResult(
|
|
127
130
|
privateResult,
|
|
128
131
|
(_contractAddress: AztecAddress, _functionSelector: FunctionSelector) => Promise.resolve(''),
|
|
132
|
+
node,
|
|
129
133
|
1, // minRevertibleSideEffectCounter
|
|
130
134
|
);
|
|
131
135
|
|
|
@@ -144,6 +148,9 @@ async function simulateBatchViaNode(
|
|
|
144
148
|
throw publicOutput.revertReason;
|
|
145
149
|
}
|
|
146
150
|
|
|
151
|
+
// Display debug logs from the public simulation.
|
|
152
|
+
await displayDebugLogs(publicOutput.debugLogs, getContractName);
|
|
153
|
+
|
|
147
154
|
return new TxSimulationResult(privateResult, provingResult.publicInputs, publicOutput, undefined);
|
|
148
155
|
}
|
|
149
156
|
|
|
@@ -168,6 +175,7 @@ export async function simulateViaNode(
|
|
|
168
175
|
gasSettings: GasSettings,
|
|
169
176
|
blockHeader: BlockHeader,
|
|
170
177
|
skipFeeEnforcement: boolean = true,
|
|
178
|
+
getContractName: ContractNameResolver,
|
|
171
179
|
): Promise<TxSimulationResult[]> {
|
|
172
180
|
const batches: FunctionCall[][] = [];
|
|
173
181
|
|
|
@@ -186,6 +194,7 @@ export async function simulateViaNode(
|
|
|
186
194
|
gasSettings,
|
|
187
195
|
blockHeader,
|
|
188
196
|
skipFeeEnforcement,
|
|
197
|
+
getContractName,
|
|
189
198
|
);
|
|
190
199
|
results.push(result);
|
|
191
200
|
}
|
|
@@ -109,7 +109,7 @@ export class ExtensionWallet {
|
|
|
109
109
|
sharedKey: CryptoKey,
|
|
110
110
|
chainInfo: ChainInfo,
|
|
111
111
|
appId: string,
|
|
112
|
-
):
|
|
112
|
+
): ExtensionWallet {
|
|
113
113
|
const wallet = new ExtensionWallet(chainInfo, appId, extensionId, port, sharedKey);
|
|
114
114
|
|
|
115
115
|
// Set up message handler for encrypted responses and unencrypted control messages
|
|
@@ -127,8 +127,10 @@ export class ExtensionWallet {
|
|
|
127
127
|
wallet.port.start();
|
|
128
128
|
|
|
129
129
|
return new Proxy(wallet, {
|
|
130
|
-
get: (target, prop) => {
|
|
131
|
-
if (
|
|
130
|
+
get: (target, prop, receiver) => {
|
|
131
|
+
if (prop === 'asWallet') {
|
|
132
|
+
return () => receiver as unknown as Wallet;
|
|
133
|
+
} else if (schemaHasMethod(WalletSchema, prop.toString())) {
|
|
132
134
|
return async (...args: unknown[]) => {
|
|
133
135
|
const result = await target.postMessage({
|
|
134
136
|
type: prop.toString() as keyof FunctionsOf<Wallet>,
|
|
@@ -140,7 +142,13 @@ export class ExtensionWallet {
|
|
|
140
142
|
return target[prop as keyof ExtensionWallet];
|
|
141
143
|
}
|
|
142
144
|
},
|
|
143
|
-
})
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
asWallet(): Wallet {
|
|
149
|
+
// Overridden by the proxy in create() to return the proxy itself.
|
|
150
|
+
// This body is never reached when accessed through create().
|
|
151
|
+
return this as unknown as Wallet;
|
|
144
152
|
}
|
|
145
153
|
|
|
146
154
|
/**
|
package/src/manager/types.ts
CHANGED
|
@@ -116,18 +116,18 @@ export interface WalletProvider {
|
|
|
116
116
|
* After calling this, the wallet returned from confirm() should no longer be used.
|
|
117
117
|
* @returns A promise that resolves when disconnection is complete
|
|
118
118
|
*/
|
|
119
|
-
disconnect
|
|
119
|
+
disconnect(): Promise<void>;
|
|
120
120
|
/**
|
|
121
121
|
* Registers a callback to be invoked when the wallet disconnects unexpectedly.
|
|
122
122
|
* @param callback - Function to call when wallet disconnects
|
|
123
123
|
* @returns A function to unregister the callback
|
|
124
124
|
*/
|
|
125
|
-
onDisconnect
|
|
125
|
+
onDisconnect(callback: ProviderDisconnectionCallback): () => void;
|
|
126
126
|
/**
|
|
127
127
|
* Returns whether the provider's wallet connection has been disconnected.
|
|
128
128
|
* @returns true if the wallet is no longer connected
|
|
129
129
|
*/
|
|
130
|
-
isDisconnected
|
|
130
|
+
isDisconnected(): boolean;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|