@aztec/wallet-sdk 0.0.1-commit.6c91f13 → 0.0.1-commit.6d63667d
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 +229 -332
- package/dest/base-wallet/base_wallet.d.ts +34 -11
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +56 -19
- 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 +20 -11
- package/src/base-wallet/base_wallet.ts +76 -30
- 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,17 +1,26 @@
|
|
|
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.6d63667d",
|
|
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": {
|
|
12
15
|
"entryPoints": [
|
|
13
|
-
"./src/index.ts"
|
|
16
|
+
"./src/base-wallet/index.ts",
|
|
17
|
+
"./src/extension/handlers/index.ts",
|
|
18
|
+
"./src/extension/provider/index.ts",
|
|
19
|
+
"./src/crypto.ts",
|
|
20
|
+
"./src/types.ts",
|
|
21
|
+
"./src/manager/index.ts"
|
|
14
22
|
],
|
|
23
|
+
"name": "Wallet SDK",
|
|
15
24
|
"tsconfig": "./tsconfig.json"
|
|
16
25
|
},
|
|
17
26
|
"scripts": {
|
|
@@ -62,19 +71,19 @@
|
|
|
62
71
|
]
|
|
63
72
|
},
|
|
64
73
|
"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.
|
|
74
|
+
"@aztec/aztec.js": "0.0.1-commit.6d63667d",
|
|
75
|
+
"@aztec/constants": "0.0.1-commit.6d63667d",
|
|
76
|
+
"@aztec/entrypoints": "0.0.1-commit.6d63667d",
|
|
77
|
+
"@aztec/foundation": "0.0.1-commit.6d63667d",
|
|
78
|
+
"@aztec/pxe": "0.0.1-commit.6d63667d",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.6d63667d"
|
|
71
80
|
},
|
|
72
81
|
"devDependencies": {
|
|
73
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
82
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.6d63667d",
|
|
74
83
|
"@jest/globals": "^30.0.0",
|
|
75
84
|
"@types/jest": "^30.0.0",
|
|
76
85
|
"@types/node": "^22.15.17",
|
|
77
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
86
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
78
87
|
"jest": "^30.0.0",
|
|
79
88
|
"jest-mock-extended": "^4.0.0",
|
|
80
89
|
"resolve-typescript-plugin": "^2.0.1",
|
|
@@ -1,10 +1,12 @@
|
|
|
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,
|
|
9
11
|
PrivateEvent,
|
|
10
12
|
PrivateEventFilter,
|
|
@@ -12,6 +14,7 @@ import type {
|
|
|
12
14
|
SendOptions,
|
|
13
15
|
SimulateOptions,
|
|
14
16
|
Wallet,
|
|
17
|
+
WalletCapabilities,
|
|
15
18
|
} from '@aztec/aztec.js/wallet';
|
|
16
19
|
import {
|
|
17
20
|
GAS_ESTIMATION_DA_GAS_LIMIT,
|
|
@@ -34,20 +37,17 @@ import {
|
|
|
34
37
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
35
38
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
36
39
|
import {
|
|
37
|
-
type ContractClassMetadata,
|
|
38
40
|
type ContractInstanceWithAddress,
|
|
39
|
-
type ContractMetadata,
|
|
40
41
|
computePartialAddress,
|
|
41
42
|
getContractClassFromArtifact,
|
|
42
43
|
} from '@aztec/stdlib/contract';
|
|
43
44
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
44
45
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
46
|
+
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
45
47
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
46
48
|
import type {
|
|
47
49
|
TxExecutionRequest,
|
|
48
|
-
TxHash,
|
|
49
50
|
TxProfileResult,
|
|
50
|
-
TxReceipt,
|
|
51
51
|
TxSimulationResult,
|
|
52
52
|
UtilitySimulationResult,
|
|
53
53
|
} from '@aztec/stdlib/tx';
|
|
@@ -76,7 +76,7 @@ export type FeeOptions = {
|
|
|
76
76
|
export abstract class BaseWallet implements Wallet {
|
|
77
77
|
protected log = createLogger('wallet-sdk:base_wallet');
|
|
78
78
|
|
|
79
|
-
protected
|
|
79
|
+
protected minFeePadding = 0.5;
|
|
80
80
|
protected cancellableTransactions = false;
|
|
81
81
|
|
|
82
82
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
@@ -121,20 +121,42 @@ export abstract class BaseWallet implements Wallet {
|
|
|
121
121
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
122
122
|
: executionPayload;
|
|
123
123
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
124
|
-
|
|
124
|
+
const chainInfo = await this.getChainInfo();
|
|
125
|
+
return fromAccount.createTxExecutionRequest(
|
|
126
|
+
finalExecutionPayload,
|
|
127
|
+
feeOptions.gasSettings,
|
|
128
|
+
chainInfo,
|
|
129
|
+
executionOptions,
|
|
130
|
+
);
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
public async createAuthWit(
|
|
128
134
|
from: AztecAddress,
|
|
129
|
-
messageHashOrIntent:
|
|
135
|
+
messageHashOrIntent: IntentInnerHash | CallIntent,
|
|
130
136
|
): Promise<AuthWitness> {
|
|
131
137
|
const account = await this.getAccountFromAddress(from);
|
|
132
|
-
|
|
138
|
+
const chainInfo = await this.getChainInfo();
|
|
139
|
+
return account.createAuthWit(messageHashOrIntent, chainInfo);
|
|
140
|
+
}
|
|
141
|
+
|
|
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');
|
|
133
157
|
}
|
|
134
158
|
|
|
135
|
-
public async batch<const T extends readonly BatchedMethod
|
|
136
|
-
methods: T,
|
|
137
|
-
): Promise<BatchResults<T>> {
|
|
159
|
+
public async batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>> {
|
|
138
160
|
const results: any[] = [];
|
|
139
161
|
for (const method of methods) {
|
|
140
162
|
const { name, args } = method;
|
|
@@ -165,7 +187,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
165
187
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
166
188
|
): Promise<FeeOptions> {
|
|
167
189
|
const maxFeesPerGas =
|
|
168
|
-
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.
|
|
190
|
+
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
169
191
|
let accountFeePaymentMethodOptions;
|
|
170
192
|
// The transaction does not include a fee payment method, so we set the flag
|
|
171
193
|
// for the account to use its fee juice balance
|
|
@@ -227,7 +249,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
227
249
|
artifact?: ContractArtifact,
|
|
228
250
|
secretKey?: Fr,
|
|
229
251
|
): Promise<ContractInstanceWithAddress> {
|
|
230
|
-
const
|
|
252
|
+
const existingInstance = await this.pxe.getContractInstance(instance.address);
|
|
231
253
|
|
|
232
254
|
if (existingInstance) {
|
|
233
255
|
// Instance already registered in the wallet
|
|
@@ -244,13 +266,12 @@ export abstract class BaseWallet implements Wallet {
|
|
|
244
266
|
// Instance not registered yet
|
|
245
267
|
if (!artifact) {
|
|
246
268
|
// Try to get the artifact from the wallet's contract class storage
|
|
247
|
-
|
|
248
|
-
if (!
|
|
269
|
+
artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
270
|
+
if (!artifact) {
|
|
249
271
|
throw new Error(
|
|
250
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()}`,
|
|
251
273
|
);
|
|
252
274
|
}
|
|
253
|
-
artifact = classMetadata.artifact;
|
|
254
275
|
}
|
|
255
276
|
await this.pxe.registerContract({ artifact, instance });
|
|
256
277
|
}
|
|
@@ -280,7 +301,10 @@ export abstract class BaseWallet implements Wallet {
|
|
|
280
301
|
return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
|
|
281
302
|
}
|
|
282
303
|
|
|
283
|
-
async sendTx
|
|
304
|
+
public async sendTx<W extends InteractionWaitOptions = undefined>(
|
|
305
|
+
executionPayload: ExecutionPayload,
|
|
306
|
+
opts: SendOptions<W>,
|
|
307
|
+
): Promise<SendReturn<W>> {
|
|
284
308
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
285
309
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
286
310
|
const provenTx = await this.pxe.proveTx(txRequest);
|
|
@@ -294,7 +318,15 @@ export abstract class BaseWallet implements Wallet {
|
|
|
294
318
|
throw this.contextualizeError(err, inspect(tx));
|
|
295
319
|
});
|
|
296
320
|
this.log.info(`Sent transaction ${txHash}`);
|
|
297
|
-
|
|
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>;
|
|
298
330
|
}
|
|
299
331
|
|
|
300
332
|
protected contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -315,17 +347,6 @@ export abstract class BaseWallet implements Wallet {
|
|
|
315
347
|
return this.pxe.simulateUtility(call, authwits);
|
|
316
348
|
}
|
|
317
349
|
|
|
318
|
-
getContractClassMetadata(id: Fr, includeArtifact: boolean = false): Promise<ContractClassMetadata> {
|
|
319
|
-
return this.pxe.getContractClassMetadata(id, includeArtifact);
|
|
320
|
-
}
|
|
321
|
-
getContractMetadata(address: AztecAddress): Promise<ContractMetadata> {
|
|
322
|
-
return this.pxe.getContractMetadata(address);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
326
|
-
return this.aztecNode.getTxReceipt(txHash);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
350
|
async getPrivateEvents<T>(
|
|
330
351
|
eventDef: EventMetadataDefinition,
|
|
331
352
|
eventFilter: PrivateEventFilter,
|
|
@@ -345,4 +366,29 @@ export abstract class BaseWallet implements Wallet {
|
|
|
345
366
|
|
|
346
367
|
return decodedEvents;
|
|
347
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
|
+
}
|
|
348
394
|
}
|