@aztec/wallet-sdk 0.0.1-commit.9ee6fcc6 → 0.0.1-commit.9ef841308
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 +10 -13
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +46 -34
- 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 +79 -58
- 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,5 +1,6 @@
|
|
|
1
1
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
2
2
|
import { ExtensionProvider, ExtensionWallet } from '../extension/provider/index.js';
|
|
3
|
+
import { discoverWebWallets } from '../iframe/provider/iframe_discovery.js';
|
|
3
4
|
import { WalletMessageType } from '../types.js';
|
|
4
5
|
/**
|
|
5
6
|
* Manager for wallet discovery, configuration, and connection.
|
|
@@ -75,6 +76,20 @@ import { WalletMessageType } from '../types.js';
|
|
|
75
76
|
let pendingResolve = null;
|
|
76
77
|
let completed = false;
|
|
77
78
|
const { promise: donePromise, resolve: resolveDone } = promiseWithResolvers();
|
|
79
|
+
const pendingSources = new Set();
|
|
80
|
+
const emit = (provider)=>{
|
|
81
|
+
options.onWalletDiscovered?.(provider);
|
|
82
|
+
if (pendingResolve) {
|
|
83
|
+
const resolve = pendingResolve;
|
|
84
|
+
pendingResolve = null;
|
|
85
|
+
resolve({
|
|
86
|
+
value: provider,
|
|
87
|
+
done: false
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
pendingProviders.push(provider);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
78
93
|
const markComplete = ()=>{
|
|
79
94
|
completed = true;
|
|
80
95
|
resolveDone();
|
|
@@ -87,7 +102,14 @@ import { WalletMessageType } from '../types.js';
|
|
|
87
102
|
});
|
|
88
103
|
}
|
|
89
104
|
};
|
|
105
|
+
const sourceComplete = (source)=>{
|
|
106
|
+
pendingSources.delete(source);
|
|
107
|
+
if (pendingSources.size === 0) {
|
|
108
|
+
markComplete();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
90
111
|
if (this.config.extensions?.enabled) {
|
|
112
|
+
pendingSources.add('extensions');
|
|
91
113
|
const extensionConfig = this.config.extensions;
|
|
92
114
|
void ExtensionProvider.discoverWallets(chainInfo, {
|
|
93
115
|
appId,
|
|
@@ -95,25 +117,33 @@ import { WalletMessageType } from '../types.js';
|
|
|
95
117
|
signal: abortController.signal,
|
|
96
118
|
onWalletDiscovered: (discoveredWallet)=>{
|
|
97
119
|
const provider = this.createProviderFromDiscoveredWallet(discoveredWallet, chainInfo, extensionConfig);
|
|
98
|
-
if (
|
|
99
|
-
|
|
120
|
+
if (provider) {
|
|
121
|
+
emit(provider);
|
|
100
122
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
}
|
|
124
|
+
}).then(()=>sourceComplete('extensions'));
|
|
125
|
+
}
|
|
126
|
+
if (this.config.webWallets?.urls && this.config.webWallets.urls.length > 0) {
|
|
127
|
+
pendingSources.add('webWallets');
|
|
128
|
+
const webSession = discoverWebWallets(this.config.webWallets.urls, chainInfo);
|
|
129
|
+
// Forward discovered web wallets into the shared iterator
|
|
130
|
+
void (async ()=>{
|
|
131
|
+
try {
|
|
132
|
+
for await (const provider of webSession.wallets){
|
|
133
|
+
if (abortController.signal.aborted) {
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
emit(provider);
|
|
113
137
|
}
|
|
138
|
+
} finally{
|
|
139
|
+
sourceComplete('webWallets');
|
|
114
140
|
}
|
|
115
|
-
})
|
|
116
|
-
|
|
141
|
+
})();
|
|
142
|
+
abortController.signal.addEventListener('abort', ()=>webSession.cancel(), {
|
|
143
|
+
once: true
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (pendingSources.size === 0) {
|
|
117
147
|
markComplete();
|
|
118
148
|
}
|
|
119
149
|
const wallets = {
|
package/dest/types.d.ts
CHANGED
|
@@ -14,7 +14,15 @@ export declare enum WalletMessageType {
|
|
|
14
14
|
/** Key exchange request sent over MessageChannel */
|
|
15
15
|
KEY_EXCHANGE_REQUEST = "aztec-wallet-key-exchange-request",
|
|
16
16
|
/** Key exchange response sent over MessageChannel */
|
|
17
|
-
KEY_EXCHANGE_RESPONSE = "aztec-wallet-key-exchange-response"
|
|
17
|
+
KEY_EXCHANGE_RESPONSE = "aztec-wallet-key-exchange-response",
|
|
18
|
+
/** Wallet ready signal */
|
|
19
|
+
WALLET_READY = "aztec-wallet-ready",
|
|
20
|
+
/** Encrypted wallet message wrapper */
|
|
21
|
+
SECURE_MESSAGE = "aztec-wallet-secure-message",
|
|
22
|
+
/** Encrypted wallet response wrapper */
|
|
23
|
+
SECURE_RESPONSE = "aztec-wallet-secure-response",
|
|
24
|
+
/** Session disconnected notification */
|
|
25
|
+
SESSION_DISCONNECTED = "aztec-wallet-session-disconnected"
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
20
28
|
* Information about an installed Aztec wallet.
|
|
@@ -120,4 +128,8 @@ export interface KeyExchangeResponse {
|
|
|
120
128
|
/** Wallet's ECDH public key for deriving shared secret */
|
|
121
129
|
publicKey: ExportedPublicKey;
|
|
122
130
|
}
|
|
123
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Callback invoked when a wallet connection is disconnected.
|
|
133
|
+
*/
|
|
134
|
+
export type DisconnectCallback = () => void;
|
|
135
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2Vz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rypted control message, bidirectional) */ WalletMessageType["DISCONNECT"] = "aztec-wallet-disconnect";
|
|
8
8
|
/** Key exchange request sent over MessageChannel */ WalletMessageType["KEY_EXCHANGE_REQUEST"] = "aztec-wallet-key-exchange-request";
|
|
9
9
|
/** Key exchange response sent over MessageChannel */ WalletMessageType["KEY_EXCHANGE_RESPONSE"] = "aztec-wallet-key-exchange-response";
|
|
10
|
+
/** Wallet ready signal */ WalletMessageType["WALLET_READY"] = "aztec-wallet-ready";
|
|
11
|
+
/** Encrypted wallet message wrapper */ WalletMessageType["SECURE_MESSAGE"] = "aztec-wallet-secure-message";
|
|
12
|
+
/** Encrypted wallet response wrapper */ WalletMessageType["SECURE_RESPONSE"] = "aztec-wallet-secure-response";
|
|
13
|
+
/** Session disconnected notification */ WalletMessageType["SESSION_DISCONNECTED"] = "aztec-wallet-session-disconnected";
|
|
10
14
|
return WalletMessageType;
|
|
11
15
|
}({});
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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.9ef841308",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./base-wallet": "./dest/base-wallet/index.js",
|
|
8
8
|
"./extension/handlers": "./dest/extension/handlers/index.js",
|
|
9
9
|
"./extension/provider": "./dest/extension/provider/index.js",
|
|
10
|
+
"./iframe/handlers": "./dest/iframe/handlers/index.js",
|
|
11
|
+
"./iframe/provider": "./dest/iframe/provider/index.js",
|
|
10
12
|
"./crypto": "./dest/crypto.js",
|
|
11
13
|
"./types": "./dest/types.js",
|
|
12
14
|
"./manager": "./dest/manager/index.js"
|
|
@@ -16,6 +18,8 @@
|
|
|
16
18
|
"./src/base-wallet/index.ts",
|
|
17
19
|
"./src/extension/handlers/index.ts",
|
|
18
20
|
"./src/extension/provider/index.ts",
|
|
21
|
+
"./src/iframe/handlers/index.ts",
|
|
22
|
+
"./src/iframe/provider/index.ts",
|
|
19
23
|
"./src/crypto.ts",
|
|
20
24
|
"./src/types.ts",
|
|
21
25
|
"./src/manager/index.ts"
|
|
@@ -71,15 +75,15 @@
|
|
|
71
75
|
]
|
|
72
76
|
},
|
|
73
77
|
"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.
|
|
78
|
+
"@aztec/aztec.js": "0.0.1-commit.9ef841308",
|
|
79
|
+
"@aztec/constants": "0.0.1-commit.9ef841308",
|
|
80
|
+
"@aztec/entrypoints": "0.0.1-commit.9ef841308",
|
|
81
|
+
"@aztec/foundation": "0.0.1-commit.9ef841308",
|
|
82
|
+
"@aztec/pxe": "0.0.1-commit.9ef841308",
|
|
83
|
+
"@aztec/stdlib": "0.0.1-commit.9ef841308"
|
|
80
84
|
},
|
|
81
85
|
"devDependencies": {
|
|
82
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
86
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.9ef841308",
|
|
83
87
|
"@jest/globals": "^30.0.0",
|
|
84
88
|
"@types/jest": "^30.0.0",
|
|
85
89
|
"@types/node": "^22.15.17",
|
|
@@ -1,4 +1,5 @@
|
|
|
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
4
|
import {
|
|
4
5
|
type InteractionWaitOptions,
|
|
@@ -8,19 +9,20 @@ import {
|
|
|
8
9
|
} from '@aztec/aztec.js/contracts';
|
|
9
10
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
10
11
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
11
|
-
import
|
|
12
|
-
Aliased,
|
|
13
|
-
AppCapabilities,
|
|
14
|
-
BatchResults,
|
|
15
|
-
BatchedMethod,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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,
|
|
24
26
|
} from '@aztec/aztec.js/wallet';
|
|
25
27
|
import {
|
|
26
28
|
GAS_ESTIMATION_DA_GAS_LIMIT,
|
|
@@ -29,6 +31,7 @@ import {
|
|
|
29
31
|
GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT,
|
|
30
32
|
} from '@aztec/constants';
|
|
31
33
|
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
34
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
32
35
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
33
36
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
34
37
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -50,7 +53,10 @@ import {
|
|
|
50
53
|
} from '@aztec/stdlib/contract';
|
|
51
54
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
52
55
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
53
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
computeSiloedPrivateInitializationNullifier,
|
|
58
|
+
computeSiloedPublicInitializationNullifier,
|
|
59
|
+
} from '@aztec/stdlib/hash';
|
|
54
60
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
55
61
|
import {
|
|
56
62
|
BlockHeader,
|
|
@@ -75,7 +81,7 @@ export type FeeOptions = {
|
|
|
75
81
|
*/
|
|
76
82
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
77
83
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
78
|
-
accountFeePaymentMethodOptions
|
|
84
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
79
85
|
/** The gas settings to use for the transaction */
|
|
80
86
|
gasSettings: GasSettings;
|
|
81
87
|
};
|
|
@@ -104,8 +110,8 @@ export abstract class BaseWallet implements Wallet {
|
|
|
104
110
|
protected log = createLogger('wallet-sdk:base_wallet'),
|
|
105
111
|
) {}
|
|
106
112
|
|
|
107
|
-
protected scopesFrom(from: AztecAddress, additionalScopes: AztecAddress[] = []): AztecAddress[] {
|
|
108
|
-
const allScopes = from
|
|
113
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes: AztecAddress[] = []): AztecAddress[] {
|
|
114
|
+
const allScopes = from === NO_FROM ? additionalScopes : [from, ...additionalScopes];
|
|
109
115
|
const scopeSet = new Set(allScopes.map(address => address.toString()));
|
|
110
116
|
return [...scopeSet].map(AztecAddress.fromString);
|
|
111
117
|
}
|
|
@@ -133,26 +139,33 @@ export abstract class BaseWallet implements Wallet {
|
|
|
133
139
|
|
|
134
140
|
protected async createTxExecutionRequestFromPayloadAndFee(
|
|
135
141
|
executionPayload: ExecutionPayload,
|
|
136
|
-
from: AztecAddress,
|
|
142
|
+
from: AztecAddress | NoFrom,
|
|
137
143
|
feeOptions: FeeOptions,
|
|
138
144
|
): Promise<TxExecutionRequest> {
|
|
139
145
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
140
|
-
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
141
|
-
txNonce: Fr.random(),
|
|
142
|
-
cancellable: this.cancellableTransactions,
|
|
143
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
144
|
-
};
|
|
145
146
|
const finalExecutionPayload = feeExecutionPayload
|
|
146
147
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
147
148
|
: executionPayload;
|
|
148
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
149
149
|
const chainInfo = await this.getChainInfo();
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
chainInfo
|
|
154
|
-
|
|
155
|
-
|
|
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
|
+
}
|
|
156
169
|
}
|
|
157
170
|
|
|
158
171
|
public async createAuthWit(
|
|
@@ -207,23 +220,27 @@ export abstract class BaseWallet implements Wallet {
|
|
|
207
220
|
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
208
221
|
*/
|
|
209
222
|
protected async completeFeeOptions(
|
|
210
|
-
from: AztecAddress,
|
|
223
|
+
from: AztecAddress | NoFrom,
|
|
211
224
|
feePayer?: AztecAddress,
|
|
212
225
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
213
226
|
): Promise<FeeOptions> {
|
|
214
227
|
const maxFeesPerGas =
|
|
215
228
|
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
216
229
|
let accountFeePaymentMethodOptions;
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
+
}
|
|
227
244
|
}
|
|
228
245
|
const fullGasSettings: GasSettings = GasSettings.default({ ...gasSettings, maxFeesPerGas });
|
|
229
246
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
@@ -243,7 +260,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
243
260
|
* @param gasSettings - User-provided partial gas settings
|
|
244
261
|
*/
|
|
245
262
|
protected async completeFeeOptionsForEstimation(
|
|
246
|
-
from: AztecAddress,
|
|
263
|
+
from: AztecAddress | NoFrom,
|
|
247
264
|
feePayer?: AztecAddress,
|
|
248
265
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
249
266
|
) {
|
|
@@ -351,12 +368,13 @@ export abstract class BaseWallet implements Wallet {
|
|
|
351
368
|
blockHeader = (await this.aztecNode.getBlockHeader())!;
|
|
352
369
|
}
|
|
353
370
|
|
|
371
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
354
372
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
355
373
|
optimizableCalls.length > 0
|
|
356
374
|
? simulateViaNode(
|
|
357
375
|
this.aztecNode,
|
|
358
376
|
optimizableCalls,
|
|
359
|
-
|
|
377
|
+
simulationOrigin,
|
|
360
378
|
chainInfo,
|
|
361
379
|
feeOptions.gasSettings,
|
|
362
380
|
blockHeader,
|
|
@@ -455,7 +473,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
455
473
|
}
|
|
456
474
|
|
|
457
475
|
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult> {
|
|
458
|
-
return this.pxe.executeUtility(call, { authwits: opts.authWitnesses, scopes:
|
|
476
|
+
return this.pxe.executeUtility(call, { authwits: opts.authWitnesses, scopes: opts.scopes });
|
|
459
477
|
}
|
|
460
478
|
|
|
461
479
|
async getPrivateEvents<T>(
|
|
@@ -480,26 +498,29 @@ export abstract class BaseWallet implements Wallet {
|
|
|
480
498
|
|
|
481
499
|
/**
|
|
482
500
|
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
483
|
-
*
|
|
484
|
-
* `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
|
|
485
|
-
* instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
|
|
486
501
|
* @param address - The contract address to query.
|
|
487
502
|
*/
|
|
488
503
|
async getContractMetadata(address: AztecAddress) {
|
|
489
504
|
const instance = await this.pxe.getContractInstance(address);
|
|
490
505
|
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
// the instance (and thus init_hash), we can't compute it, so we return undefined.
|
|
494
|
-
//
|
|
495
|
-
// We skip the public initialization nullifier because it's not always emitted (contracts without public external
|
|
496
|
-
// functions that require initialization checks won't emit it). If the private one exists, the public one was
|
|
497
|
-
// created in the same tx and will also be present.
|
|
498
|
-
let isContractInitialized: boolean | undefined = undefined;
|
|
506
|
+
|
|
507
|
+
let initializationStatus: ContractInitializationStatus;
|
|
499
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.
|
|
500
511
|
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
501
512
|
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
502
|
-
|
|
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;
|
|
503
524
|
}
|
|
504
525
|
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
505
526
|
const isContractUpdated =
|
|
@@ -507,7 +528,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
507
528
|
!publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
508
529
|
return {
|
|
509
530
|
instance: instance ?? undefined,
|
|
510
|
-
|
|
531
|
+
initializationStatus,
|
|
511
532
|
isContractPublished: !!publiclyRegisteredContract,
|
|
512
533
|
isContractUpdated: !!isContractUpdated,
|
|
513
534
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined,
|
package/src/crypto.ts
CHANGED
|
@@ -497,3 +497,107 @@ export function hashToEmoji(hash: string, count: number = DEFAULT_EMOJI_GRID_SIZ
|
|
|
497
497
|
}
|
|
498
498
|
return emojis.join('');
|
|
499
499
|
}
|
|
500
|
+
|
|
501
|
+
// ─── Passphrase-based encryption (PBKDF2 + AES-256-GCM) ───────────────────
|
|
502
|
+
|
|
503
|
+
/** Default PBKDF2 iteration count. High to compensate for short PINs (~1-2s on modern hardware). */
|
|
504
|
+
const DEFAULT_PBKDF2_ITERATIONS = 2_000_000;
|
|
505
|
+
const PBKDF2_SALT_BYTES = 16;
|
|
506
|
+
const PBKDF2_IV_BYTES = 12;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Derives an AES-256-GCM key from a passphrase using PBKDF2-SHA256.
|
|
510
|
+
*
|
|
511
|
+
* @param passphrase - The user-provided passphrase or PIN
|
|
512
|
+
* @param salt - Random salt bytes
|
|
513
|
+
* @param iterations - PBKDF2 iteration count (default: 2,000,000)
|
|
514
|
+
* @returns An AES-256-GCM CryptoKey
|
|
515
|
+
*/
|
|
516
|
+
export async function deriveKeyFromPassphrase(
|
|
517
|
+
passphrase: string,
|
|
518
|
+
salt: Uint8Array,
|
|
519
|
+
iterations: number = DEFAULT_PBKDF2_ITERATIONS,
|
|
520
|
+
): Promise<CryptoKey> {
|
|
521
|
+
const keyMaterial = await crypto.subtle.importKey('raw', new TextEncoder().encode(passphrase), 'PBKDF2', false, [
|
|
522
|
+
'deriveKey',
|
|
523
|
+
]);
|
|
524
|
+
return crypto.subtle.deriveKey(
|
|
525
|
+
{ name: 'PBKDF2', salt: salt as BufferSource, iterations, hash: 'SHA-256' },
|
|
526
|
+
keyMaterial,
|
|
527
|
+
{ name: 'AES-GCM', length: 256 },
|
|
528
|
+
false,
|
|
529
|
+
['encrypt', 'decrypt'],
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Encrypts arbitrary bytes with a passphrase using PBKDF2 + AES-256-GCM.
|
|
535
|
+
*
|
|
536
|
+
* Output layout: `[salt (16)] [iv (12)] [ciphertext (...)]`
|
|
537
|
+
*
|
|
538
|
+
* @param plaintext - Data to encrypt
|
|
539
|
+
* @param passphrase - User passphrase or PIN
|
|
540
|
+
* @param iterations - PBKDF2 iteration count (default: 2,000,000)
|
|
541
|
+
* @returns A Uint8Array containing salt + iv + ciphertext
|
|
542
|
+
*/
|
|
543
|
+
export async function encryptWithPassphrase(
|
|
544
|
+
plaintext: Uint8Array,
|
|
545
|
+
passphrase: string,
|
|
546
|
+
iterations: number = DEFAULT_PBKDF2_ITERATIONS,
|
|
547
|
+
): Promise<Uint8Array> {
|
|
548
|
+
const salt = crypto.getRandomValues(new Uint8Array(PBKDF2_SALT_BYTES));
|
|
549
|
+
const iv = crypto.getRandomValues(new Uint8Array(PBKDF2_IV_BYTES));
|
|
550
|
+
const key = await deriveKeyFromPassphrase(passphrase, salt, iterations);
|
|
551
|
+
const ciphertext = new Uint8Array(
|
|
552
|
+
await crypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, plaintext as BufferSource),
|
|
553
|
+
);
|
|
554
|
+
const result = new Uint8Array(PBKDF2_SALT_BYTES + PBKDF2_IV_BYTES + ciphertext.length);
|
|
555
|
+
result.set(salt, 0);
|
|
556
|
+
result.set(iv, PBKDF2_SALT_BYTES);
|
|
557
|
+
result.set(ciphertext, PBKDF2_SALT_BYTES + PBKDF2_IV_BYTES);
|
|
558
|
+
return result;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Decrypts data produced by {@link encryptWithPassphrase}.
|
|
563
|
+
*
|
|
564
|
+
* @param data - The encrypted blob (salt + iv + ciphertext)
|
|
565
|
+
* @param passphrase - The passphrase used during encryption
|
|
566
|
+
* @param iterations - PBKDF2 iteration count (must match encryption)
|
|
567
|
+
* @returns The decrypted plaintext bytes
|
|
568
|
+
* @throws On wrong passphrase (AES-GCM auth tag mismatch)
|
|
569
|
+
*/
|
|
570
|
+
export async function decryptWithPassphrase(
|
|
571
|
+
data: Uint8Array,
|
|
572
|
+
passphrase: string,
|
|
573
|
+
iterations: number = DEFAULT_PBKDF2_ITERATIONS,
|
|
574
|
+
): Promise<Uint8Array> {
|
|
575
|
+
const salt = data.slice(0, PBKDF2_SALT_BYTES);
|
|
576
|
+
const iv = data.slice(PBKDF2_SALT_BYTES, PBKDF2_SALT_BYTES + PBKDF2_IV_BYTES);
|
|
577
|
+
const ciphertext = data.slice(PBKDF2_SALT_BYTES + PBKDF2_IV_BYTES);
|
|
578
|
+
const key = await deriveKeyFromPassphrase(passphrase, salt, iterations);
|
|
579
|
+
return new Uint8Array(await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, ciphertext as BufferSource));
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Converts a Uint8Array to a base64 string.
|
|
584
|
+
*/
|
|
585
|
+
export function uint8ToBase64(bytes: Uint8Array): string {
|
|
586
|
+
let binary = '';
|
|
587
|
+
for (const b of bytes) {
|
|
588
|
+
binary += String.fromCharCode(b);
|
|
589
|
+
}
|
|
590
|
+
return btoa(binary);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Converts a base64 string to a Uint8Array.
|
|
595
|
+
*/
|
|
596
|
+
export function base64ToUint8(b64: string): Uint8Array {
|
|
597
|
+
const binary = atob(b64);
|
|
598
|
+
const bytes = new Uint8Array(binary.length);
|
|
599
|
+
for (let i = 0; i < binary.length; i++) {
|
|
600
|
+
bytes[i] = binary.charCodeAt(i);
|
|
601
|
+
}
|
|
602
|
+
return bytes;
|
|
603
|
+
}
|
|
@@ -6,7 +6,7 @@ import { schemaHasMethod } from '@aztec/foundation/schemas';
|
|
|
6
6
|
import type { FunctionsOf } from '@aztec/foundation/types';
|
|
7
7
|
|
|
8
8
|
import { type EncryptedPayload, decrypt, encrypt } from '../../crypto.js';
|
|
9
|
-
import { type WalletMessage, WalletMessageType, type WalletResponse } from '../../types.js';
|
|
9
|
+
import { type DisconnectCallback, type WalletMessage, WalletMessageType, type WalletResponse } from '../../types.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal type representing a wallet method call before encryption.
|
|
@@ -19,11 +19,6 @@ type WalletMethodCall = {
|
|
|
19
19
|
args: unknown[];
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* Callback type for wallet disconnect events.
|
|
24
|
-
*/
|
|
25
|
-
export type DisconnectCallback = () => void;
|
|
26
|
-
|
|
27
22
|
/**
|
|
28
23
|
* A wallet implementation that communicates with browser extension wallets
|
|
29
24
|
* using an encrypted MessageChannel.
|