@aztec/wallet-sdk 0.0.1-commit.21caa21 → 0.0.1-commit.23b0eb0
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/README.md +228 -331
- package/dest/base-wallet/base_wallet.d.ts +36 -13
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +70 -24
- package/dest/crypto.d.ts +192 -0
- package/dest/crypto.d.ts.map +1 -0
- package/dest/crypto.js +394 -0
- package/dest/emoji_alphabet.d.ts +35 -0
- package/dest/emoji_alphabet.d.ts.map +1 -0
- package/dest/emoji_alphabet.js +299 -0
- package/dest/extension/handlers/background_connection_handler.d.ts +158 -0
- package/dest/extension/handlers/background_connection_handler.d.ts.map +1 -0
- package/dest/extension/handlers/background_connection_handler.js +258 -0
- package/dest/extension/handlers/content_script_connection_handler.d.ts +56 -0
- package/dest/extension/handlers/content_script_connection_handler.d.ts.map +1 -0
- package/dest/extension/handlers/content_script_connection_handler.js +174 -0
- package/dest/extension/handlers/index.d.ts +12 -0
- package/dest/extension/handlers/index.d.ts.map +1 -0
- package/dest/extension/handlers/index.js +10 -0
- package/dest/extension/handlers/internal_message_types.d.ts +63 -0
- package/dest/extension/handlers/internal_message_types.d.ts.map +1 -0
- package/dest/extension/handlers/internal_message_types.js +22 -0
- package/dest/extension/provider/extension_provider.d.ts +107 -0
- package/dest/extension/provider/extension_provider.d.ts.map +1 -0
- package/dest/extension/provider/extension_provider.js +160 -0
- package/dest/extension/provider/extension_wallet.d.ts +131 -0
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -0
- package/dest/extension/provider/extension_wallet.js +271 -0
- package/dest/extension/provider/index.d.ts +3 -0
- package/dest/extension/provider/index.d.ts.map +1 -0
- package/dest/manager/index.d.ts +2 -7
- package/dest/manager/index.d.ts.map +1 -1
- package/dest/manager/index.js +0 -4
- package/dest/manager/types.d.ts +108 -5
- package/dest/manager/types.d.ts.map +1 -1
- package/dest/manager/types.js +17 -1
- package/dest/manager/wallet_manager.d.ts +50 -7
- package/dest/manager/wallet_manager.d.ts.map +1 -1
- package/dest/manager/wallet_manager.js +178 -29
- package/dest/types.d.ts +123 -0
- package/dest/types.d.ts.map +1 -0
- package/dest/types.js +11 -0
- package/package.json +15 -12
- package/src/base-wallet/base_wallet.ts +94 -42
- package/src/crypto.ts +499 -0
- package/src/emoji_alphabet.ts +317 -0
- package/src/extension/handlers/background_connection_handler.ts +423 -0
- package/src/extension/handlers/content_script_connection_handler.ts +246 -0
- package/src/extension/handlers/index.ts +25 -0
- package/src/extension/handlers/internal_message_types.ts +69 -0
- package/src/extension/provider/extension_provider.ts +233 -0
- package/src/extension/provider/extension_wallet.ts +321 -0
- package/src/extension/provider/index.ts +7 -0
- package/src/manager/index.ts +3 -15
- package/src/manager/types.ts +112 -4
- package/src/manager/wallet_manager.ts +204 -31
- package/src/types.ts +132 -0
- package/dest/providers/extension/extension_provider.d.ts +0 -17
- package/dest/providers/extension/extension_provider.d.ts.map +0 -1
- package/dest/providers/extension/extension_provider.js +0 -56
- package/dest/providers/extension/extension_wallet.d.ts +0 -23
- package/dest/providers/extension/extension_wallet.d.ts.map +0 -1
- package/dest/providers/extension/extension_wallet.js +0 -96
- package/dest/providers/extension/index.d.ts +0 -4
- package/dest/providers/extension/index.d.ts.map +0 -1
- package/dest/providers/types.d.ts +0 -67
- package/dest/providers/types.d.ts.map +0 -1
- package/dest/providers/types.js +0 -3
- package/src/providers/extension/extension_provider.ts +0 -72
- package/src/providers/extension/extension_wallet.ts +0 -124
- package/src/providers/extension/index.ts +0 -3
- package/src/providers/types.ts +0 -71
- /package/dest/{providers/extension → extension/provider}/index.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;GAGG;AACH,oBAAY,iBAAiB;IAC3B,kDAAkD;IAClD,SAAS,2BAA2B;IACpC,uCAAuC;IACvC,kBAAkB,oCAAoC;IACtD,sEAAsE;IACtE,UAAU,4BAA4B;IACtC,oDAAoD;IACpD,oBAAoB,sCAAsC;IAC1D,qDAAqD;IACrD,qBAAqB,uCAAuC;CAC7D;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,gEAAgE;IAChE,SAAS,EAAE,iBAAiB,CAAC;IAC7B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,wBAAwB;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC;IAClC,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,IAAI,EAAE,iBAAiB,CAAC,kBAAkB,CAAC;IAC3C,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,mBAAmB;IACnB,IAAI,EAAE,iBAAiB,CAAC,oBAAoB,CAAC;IAC7C,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mBAAmB;IACnB,IAAI,EAAE,iBAAiB,CAAC,qBAAqB,CAAC;IAC9C,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,SAAS,EAAE,iBAAiB,CAAC;CAC9B"}
|
package/dest/types.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message types for wallet SDK communication.
|
|
3
|
+
* All types are prefixed with 'aztec-wallet-' for namespacing.
|
|
4
|
+
*/ export var WalletMessageType = /*#__PURE__*/ function(WalletMessageType) {
|
|
5
|
+
/** Discovery request to find installed wallets */ WalletMessageType["DISCOVERY"] = "aztec-wallet-discovery";
|
|
6
|
+
/** Discovery response from a wallet */ WalletMessageType["DISCOVERY_RESPONSE"] = "aztec-wallet-discovery-response";
|
|
7
|
+
/** Disconnect message (unencrypted control message, bidirectional) */ WalletMessageType["DISCONNECT"] = "aztec-wallet-disconnect";
|
|
8
|
+
/** Key exchange request sent over MessageChannel */ WalletMessageType["KEY_EXCHANGE_REQUEST"] = "aztec-wallet-key-exchange-request";
|
|
9
|
+
/** Key exchange response sent over MessageChannel */ WalletMessageType["KEY_EXCHANGE_RESPONSE"] = "aztec-wallet-key-exchange-response";
|
|
10
|
+
return WalletMessageType;
|
|
11
|
+
}({});
|
package/package.json
CHANGED
|
@@ -1,11 +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.23b0eb0",
|
|
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
|
+
"./extension/provider": "./dest/extension/provider/index.js",
|
|
10
|
+
"./crypto": "./dest/crypto.js",
|
|
11
|
+
"./types": "./dest/types.js",
|
|
9
12
|
"./manager": "./dest/manager/index.js"
|
|
10
13
|
},
|
|
11
14
|
"typedocOptions": {
|
|
@@ -15,8 +18,8 @@
|
|
|
15
18
|
"tsconfig": "./tsconfig.json"
|
|
16
19
|
},
|
|
17
20
|
"scripts": {
|
|
18
|
-
"build": "yarn clean &&
|
|
19
|
-
"build:dev": "
|
|
21
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
22
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
20
23
|
"build:ts": "tsc -b",
|
|
21
24
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
22
25
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
@@ -62,19 +65,19 @@
|
|
|
62
65
|
]
|
|
63
66
|
},
|
|
64
67
|
"dependencies": {
|
|
65
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
66
|
-
"@aztec/constants": "0.0.1-commit.
|
|
67
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
68
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
69
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
70
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
68
|
+
"@aztec/aztec.js": "0.0.1-commit.23b0eb0",
|
|
69
|
+
"@aztec/constants": "0.0.1-commit.23b0eb0",
|
|
70
|
+
"@aztec/entrypoints": "0.0.1-commit.23b0eb0",
|
|
71
|
+
"@aztec/foundation": "0.0.1-commit.23b0eb0",
|
|
72
|
+
"@aztec/pxe": "0.0.1-commit.23b0eb0",
|
|
73
|
+
"@aztec/stdlib": "0.0.1-commit.23b0eb0"
|
|
71
74
|
},
|
|
72
75
|
"devDependencies": {
|
|
73
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
76
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.23b0eb0",
|
|
74
77
|
"@jest/globals": "^30.0.0",
|
|
75
78
|
"@types/jest": "^30.0.0",
|
|
76
79
|
"@types/node": "^22.15.17",
|
|
77
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
78
81
|
"jest": "^30.0.0",
|
|
79
82
|
"jest-mock-extended": "^4.0.0",
|
|
80
83
|
"resolve-typescript-plugin": "^2.0.1",
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import type { Account } from '@aztec/aztec.js/account';
|
|
2
2
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import { type InteractionWaitOptions, NO_WAIT, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
3
4
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
5
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
4
6
|
import type {
|
|
5
7
|
Aliased,
|
|
8
|
+
AppCapabilities,
|
|
6
9
|
BatchResults,
|
|
7
|
-
BatchableMethods,
|
|
8
10
|
BatchedMethod,
|
|
11
|
+
PrivateEvent,
|
|
12
|
+
PrivateEventFilter,
|
|
9
13
|
ProfileOptions,
|
|
10
14
|
SendOptions,
|
|
11
15
|
SimulateOptions,
|
|
12
16
|
Wallet,
|
|
17
|
+
WalletCapabilities,
|
|
13
18
|
} from '@aztec/aztec.js/wallet';
|
|
14
19
|
import {
|
|
15
20
|
GAS_ESTIMATION_DA_GAS_LIMIT,
|
|
@@ -19,10 +24,10 @@ import {
|
|
|
19
24
|
} from '@aztec/constants';
|
|
20
25
|
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
21
26
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
22
|
-
import { Fr } from '@aztec/foundation/
|
|
27
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
23
28
|
import { createLogger } from '@aztec/foundation/log';
|
|
24
29
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
25
|
-
import type { PXE } from '@aztec/pxe/server';
|
|
30
|
+
import type { PXE, PackedPrivateEvent } from '@aztec/pxe/server';
|
|
26
31
|
import {
|
|
27
32
|
type ContractArtifact,
|
|
28
33
|
type EventMetadataDefinition,
|
|
@@ -32,20 +37,17 @@ import {
|
|
|
32
37
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
33
38
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
34
39
|
import {
|
|
35
|
-
type ContractClassMetadata,
|
|
36
40
|
type ContractInstanceWithAddress,
|
|
37
|
-
type ContractMetadata,
|
|
38
41
|
computePartialAddress,
|
|
39
42
|
getContractClassFromArtifact,
|
|
40
43
|
} from '@aztec/stdlib/contract';
|
|
41
44
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
42
45
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
46
|
+
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
43
47
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
44
48
|
import type {
|
|
45
49
|
TxExecutionRequest,
|
|
46
|
-
TxHash,
|
|
47
50
|
TxProfileResult,
|
|
48
|
-
TxReceipt,
|
|
49
51
|
TxSimulationResult,
|
|
50
52
|
UtilitySimulationResult,
|
|
51
53
|
} from '@aztec/stdlib/tx';
|
|
@@ -74,7 +76,7 @@ export type FeeOptions = {
|
|
|
74
76
|
export abstract class BaseWallet implements Wallet {
|
|
75
77
|
protected log = createLogger('wallet-sdk:base_wallet');
|
|
76
78
|
|
|
77
|
-
protected
|
|
79
|
+
protected minFeePadding = 0.5;
|
|
78
80
|
protected cancellableTransactions = false;
|
|
79
81
|
|
|
80
82
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
@@ -119,20 +121,42 @@ export abstract class BaseWallet implements Wallet {
|
|
|
119
121
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
120
122
|
: executionPayload;
|
|
121
123
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
122
|
-
|
|
124
|
+
const chainInfo = await this.getChainInfo();
|
|
125
|
+
return fromAccount.createTxExecutionRequest(
|
|
126
|
+
finalExecutionPayload,
|
|
127
|
+
feeOptions.gasSettings,
|
|
128
|
+
chainInfo,
|
|
129
|
+
executionOptions,
|
|
130
|
+
);
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
public async createAuthWit(
|
|
126
134
|
from: AztecAddress,
|
|
127
|
-
messageHashOrIntent:
|
|
135
|
+
messageHashOrIntent: IntentInnerHash | CallIntent,
|
|
128
136
|
): Promise<AuthWitness> {
|
|
129
137
|
const account = await this.getAccountFromAddress(from);
|
|
130
|
-
|
|
138
|
+
const chainInfo = await this.getChainInfo();
|
|
139
|
+
return account.createAuthWit(messageHashOrIntent, chainInfo);
|
|
131
140
|
}
|
|
132
141
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Request capabilities from the wallet.
|
|
144
|
+
*
|
|
145
|
+
* This method is wallet-implementation-dependent and must be provided by classes extending BaseWallet.
|
|
146
|
+
* Embedded wallets typically don't support capability-based authorization (no user authorization flow),
|
|
147
|
+
* while external wallets (browser extensions, hardware wallets) implement this to reduce authorization
|
|
148
|
+
* friction by allowing apps to request permissions upfront.
|
|
149
|
+
*
|
|
150
|
+
* TODO: Consider making it abstract so implementing it is a conscious decision. Leaving it as-is
|
|
151
|
+
* while the feature stabilizes.
|
|
152
|
+
*
|
|
153
|
+
* @param _manifest - Application capability manifest declaring what operations the app needs
|
|
154
|
+
*/
|
|
155
|
+
public requestCapabilities(_manifest: AppCapabilities): Promise<WalletCapabilities> {
|
|
156
|
+
throw new Error('Not implemented');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public async batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>> {
|
|
136
160
|
const results: any[] = [];
|
|
137
161
|
for (const method of methods) {
|
|
138
162
|
const { name, args } = method;
|
|
@@ -163,7 +187,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
163
187
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
164
188
|
): Promise<FeeOptions> {
|
|
165
189
|
const maxFeesPerGas =
|
|
166
|
-
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.
|
|
190
|
+
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
167
191
|
let accountFeePaymentMethodOptions;
|
|
168
192
|
// The transaction does not include a fee payment method, so we set the flag
|
|
169
193
|
// for the account to use its fee juice balance
|
|
@@ -225,7 +249,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
225
249
|
artifact?: ContractArtifact,
|
|
226
250
|
secretKey?: Fr,
|
|
227
251
|
): Promise<ContractInstanceWithAddress> {
|
|
228
|
-
const
|
|
252
|
+
const existingInstance = await this.pxe.getContractInstance(instance.address);
|
|
229
253
|
|
|
230
254
|
if (existingInstance) {
|
|
231
255
|
// Instance already registered in the wallet
|
|
@@ -242,13 +266,12 @@ export abstract class BaseWallet implements Wallet {
|
|
|
242
266
|
// Instance not registered yet
|
|
243
267
|
if (!artifact) {
|
|
244
268
|
// Try to get the artifact from the wallet's contract class storage
|
|
245
|
-
|
|
246
|
-
if (!
|
|
269
|
+
artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
270
|
+
if (!artifact) {
|
|
247
271
|
throw new Error(
|
|
248
272
|
`Cannot register contract at ${instance.address.toString()}: artifact is required but not provided, and wallet does not have the artifact for contract class ${instance.currentContractClassId.toString()}`,
|
|
249
273
|
);
|
|
250
274
|
}
|
|
251
|
-
artifact = classMetadata.artifact;
|
|
252
275
|
}
|
|
253
276
|
await this.pxe.registerContract({ artifact, instance });
|
|
254
277
|
}
|
|
@@ -278,7 +301,10 @@ export abstract class BaseWallet implements Wallet {
|
|
|
278
301
|
return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
|
|
279
302
|
}
|
|
280
303
|
|
|
281
|
-
async sendTx
|
|
304
|
+
public async sendTx<W extends InteractionWaitOptions = undefined>(
|
|
305
|
+
executionPayload: ExecutionPayload,
|
|
306
|
+
opts: SendOptions<W>,
|
|
307
|
+
): Promise<SendReturn<W>> {
|
|
282
308
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
283
309
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
284
310
|
const provenTx = await this.pxe.proveTx(txRequest);
|
|
@@ -292,7 +318,15 @@ export abstract class BaseWallet implements Wallet {
|
|
|
292
318
|
throw this.contextualizeError(err, inspect(tx));
|
|
293
319
|
});
|
|
294
320
|
this.log.info(`Sent transaction ${txHash}`);
|
|
295
|
-
|
|
321
|
+
|
|
322
|
+
// If wait is NO_WAIT, return txHash immediately
|
|
323
|
+
if (opts.wait === NO_WAIT) {
|
|
324
|
+
return txHash as SendReturn<W>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
328
|
+
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
329
|
+
return (await waitForTx(this.aztecNode, txHash, waitOpts)) as SendReturn<W>;
|
|
296
330
|
}
|
|
297
331
|
|
|
298
332
|
protected contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -313,30 +347,48 @@ export abstract class BaseWallet implements Wallet {
|
|
|
313
347
|
return this.pxe.simulateUtility(call, authwits);
|
|
314
348
|
}
|
|
315
349
|
|
|
316
|
-
getContractClassMetadata(id: Fr, includeArtifact: boolean = false): Promise<ContractClassMetadata> {
|
|
317
|
-
return this.pxe.getContractClassMetadata(id, includeArtifact);
|
|
318
|
-
}
|
|
319
|
-
getContractMetadata(address: AztecAddress): Promise<ContractMetadata> {
|
|
320
|
-
return this.pxe.getContractMetadata(address);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
324
|
-
return this.aztecNode.getTxReceipt(txHash);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
350
|
async getPrivateEvents<T>(
|
|
328
|
-
contractAddress: AztecAddress,
|
|
329
351
|
eventDef: EventMetadataDefinition,
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
352
|
+
eventFilter: PrivateEventFilter,
|
|
353
|
+
): Promise<PrivateEvent<T>[]> {
|
|
354
|
+
const pxeEvents = await this.pxe.getPrivateEvents(eventDef.eventSelector, eventFilter);
|
|
355
|
+
|
|
356
|
+
const decodedEvents = pxeEvents.map((pxeEvent: PackedPrivateEvent): PrivateEvent<T> => {
|
|
357
|
+
return {
|
|
358
|
+
event: decodeFromAbi([eventDef.abiType], pxeEvent.packedEvent) as T,
|
|
359
|
+
metadata: {
|
|
360
|
+
l2BlockNumber: pxeEvent.l2BlockNumber,
|
|
361
|
+
l2BlockHash: pxeEvent.l2BlockHash,
|
|
362
|
+
txHash: pxeEvent.txHash,
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
});
|
|
339
366
|
|
|
340
367
|
return decodedEvents;
|
|
341
368
|
}
|
|
369
|
+
|
|
370
|
+
async getContractMetadata(address: AztecAddress) {
|
|
371
|
+
const instance = await this.pxe.getContractInstance(address);
|
|
372
|
+
const initNullifier = await siloNullifier(address, address.toField());
|
|
373
|
+
const publiclyRegisteredContract = await this.aztecNode.getContract(address);
|
|
374
|
+
const initNullifierMembershipWitness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
375
|
+
const isContractUpdated =
|
|
376
|
+
publiclyRegisteredContract &&
|
|
377
|
+
!publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
378
|
+
return {
|
|
379
|
+
instance: instance ?? undefined,
|
|
380
|
+
isContractInitialized: !!initNullifierMembershipWitness,
|
|
381
|
+
isContractPublished: !!publiclyRegisteredContract,
|
|
382
|
+
isContractUpdated: !!isContractUpdated,
|
|
383
|
+
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async getContractClassMetadata(id: Fr) {
|
|
388
|
+
const publiclyRegisteredContractClass = await this.aztecNode.getContractClass(id);
|
|
389
|
+
return {
|
|
390
|
+
isArtifactRegistered: !!(await this.pxe.getContractArtifact(id)),
|
|
391
|
+
isContractClassPubliclyRegistered: !!publiclyRegisteredContractClass,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
342
394
|
}
|