@aztec/aztec.js 3.0.0-nightly.20251120 → 3.0.0-nightly.20251122
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/api/account.d.ts +1 -0
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -0
- package/dest/api/wallet.d.ts +0 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +0 -1
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +31 -4
- package/dest/wallet/index.d.ts +0 -1
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +0 -1
- package/package.json +8 -8
- package/src/api/account.ts +1 -0
- package/src/api/wallet.ts +0 -2
- package/src/ethereum/portal_manager.ts +45 -10
- package/src/wallet/index.ts +0 -1
- package/dest/wallet/base_wallet.d.ts +0 -93
- package/dest/wallet/base_wallet.d.ts.map +0 -1
- package/dest/wallet/base_wallet.js +0 -227
- package/src/wallet/base_wallet.ts +0 -344
package/dest/api/account.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { type AccountContract, type AccountInterface, type Salt, getAccountContractAddress } from '../account/index.js';
|
|
2
2
|
export type { AuthWitnessProvider, ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
|
+
export { ChainInfoSchema } from '@aztec/entrypoints/interfaces';
|
|
3
4
|
export { AccountWithSecretKey } from '../account/account_with_secret_key.js';
|
|
4
5
|
export { type Account, BaseAccount } from '../account/account.js';
|
|
5
6
|
export { SignerlessAccount } from '../account/signerless_account.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,IAAI,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACxH,YAAY,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,IAAI,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACxH,YAAY,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,KAAK,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dest/api/account.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { getAccountContractAddress } from '../account/index.js';
|
|
2
|
+
export { ChainInfoSchema } from '@aztec/entrypoints/interfaces';
|
|
2
3
|
export { AccountWithSecretKey } from '../account/account_with_secret_key.js';
|
|
3
4
|
export { BaseAccount } from '../account/account.js';
|
|
4
5
|
export { SignerlessAccount } from '../account/signerless_account.js';
|
package/dest/api/wallet.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { type Aliased, type SimulateOptions, type ProfileOptions, type SendOptions, type BatchableMethods, type BatchedMethod, type BatchedMethodResult, type BatchedMethodResultWrapper, type BatchResults, type Wallet, FunctionCallSchema, ExecutionPayloadSchema, GasSettingsOptionSchema, WalletSimulationFeeOptionSchema, SendOptionsSchema, SimulateOptionsSchema, ProfileOptionsSchema, MessageHashOrIntentSchema, BatchedMethodSchema, ContractMetadataSchema, ContractClassMetadataSchema, EventMetadataDefinitionSchema, WalletSchema, } from '../wallet/wallet.js';
|
|
2
|
-
export { type FeeOptions, BaseWallet } from '../wallet/base_wallet.js';
|
|
3
2
|
export { AccountManager } from '../wallet/account_manager.js';
|
|
4
3
|
export { type DeployAccountOptions, DeployAccountMethod } from '../wallet/deploy_account_method.js';
|
|
5
4
|
//# sourceMappingURL=wallet.d.ts.map
|
package/dest/api/wallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,6BAA6B,EAC7B,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,6BAA6B,EAC7B,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,KAAK,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dest/api/wallet.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { FunctionCallSchema, ExecutionPayloadSchema, GasSettingsOptionSchema, WalletSimulationFeeOptionSchema, SendOptionsSchema, SimulateOptionsSchema, ProfileOptionsSchema, MessageHashOrIntentSchema, BatchedMethodSchema, ContractMetadataSchema, ContractClassMetadataSchema, EventMetadataDefinitionSchema, WalletSchema } from '../wallet/wallet.js';
|
|
2
|
-
export { BaseWallet } from '../wallet/base_wallet.js';
|
|
3
2
|
export { AccountManager } from '../wallet/account_manager.js';
|
|
4
3
|
export { DeployAccountMethod } from '../wallet/deploy_account_method.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal_manager.d.ts","sourceRoot":"","sources":["../../src/ethereum/portal_manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAAE,KAAK,GAAG,EAAmC,MAAM,MAAM,CAAC;AAEjE,+CAA+C;AAC/C,MAAM,MAAM,OAAO,GAAG;IACpB,2BAA2B;IAC3B,WAAW,EAAE,EAAE,CAAC;IAChB,uCAAuC;IACvC,eAAe,EAAE,EAAE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AAY,EAAE,UAAU,EACxB,cAAc,EAAE,UAAU,GAAG,SAAS,EACtC,aAAa,EAAE,UAAU,EACzB,cAAc,EAAE,wBAAwB,EACxC,MAAM,EAAE,MAAM;IAUhB;;;;;;;OAOG;IACU,aAAa,CACxB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,EACrB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;IAoClC;;;;;;OAMG;IACU,oBAAoB,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,YAAY,EACtB,UAAU,GAAE,UAA4B,GACvC,OAAO,CAAC,EAAE,CAAC;CAkBf"}
|
|
@@ -137,8 +137,21 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
137
137
|
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
138
138
|
hash: await this.contract.write.depositToAztecPublic(args)
|
|
139
139
|
});
|
|
140
|
-
this.logger.info('Deposited to Aztec public successfully'
|
|
141
|
-
|
|
140
|
+
this.logger.info('Deposited to Aztec public successfully', {
|
|
141
|
+
txReceipt
|
|
142
|
+
});
|
|
143
|
+
const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>{
|
|
144
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
145
|
+
const normalizeHex = (val)=>{
|
|
146
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
147
|
+
return hexStr.toLowerCase();
|
|
148
|
+
};
|
|
149
|
+
const secretHashMatch = normalizeHex(log.args.secretHash) === normalizeHex(claimSecretHash.toString());
|
|
150
|
+
const amountMatch = log.args.amount === amountToBridge;
|
|
151
|
+
const toMatch = normalizeHex(log.args.to) === normalizeHex(to.toString());
|
|
152
|
+
this.logger.debug(`Event filter matching: secretHash=${secretHashMatch} (${log.args.secretHash} vs ${claimSecretHash.toString()}), ` + `amount=${amountMatch} (${log.args.amount} vs ${amountToBridge}), ` + `to=${toMatch} (${log.args.to} vs ${to.toString()})`);
|
|
153
|
+
return secretHashMatch && amountMatch && toMatch;
|
|
154
|
+
}, this.logger);
|
|
142
155
|
return {
|
|
143
156
|
claimAmount: amountToBridge,
|
|
144
157
|
claimSecret,
|
|
@@ -197,7 +210,14 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
197
210
|
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
198
211
|
hash: await this.extendedClient.writeContract(request)
|
|
199
212
|
});
|
|
200
|
-
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPublic', (log)=>
|
|
213
|
+
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPublic', (log)=>{
|
|
214
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
215
|
+
const normalizeHex = (val)=>{
|
|
216
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
217
|
+
return hexStr.toLowerCase();
|
|
218
|
+
};
|
|
219
|
+
return normalizeHex(log.args.secretHash) === normalizeHex(claimSecretHash.toString()) && log.args.amount === amount && normalizeHex(log.args.to) === normalizeHex(to.toString());
|
|
220
|
+
}, this.logger);
|
|
201
221
|
return {
|
|
202
222
|
claimAmount: amount,
|
|
203
223
|
claimSecret,
|
|
@@ -221,7 +241,14 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
221
241
|
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
222
242
|
hash: await this.extendedClient.writeContract(request)
|
|
223
243
|
});
|
|
224
|
-
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPrivate', (log)=>
|
|
244
|
+
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPrivate', (log)=>{
|
|
245
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
246
|
+
const normalizeHex = (val)=>{
|
|
247
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
248
|
+
return hexStr.toLowerCase();
|
|
249
|
+
};
|
|
250
|
+
return log.args.amount === amount && normalizeHex(log.args.secretHashForL2MessageConsumption) === normalizeHex(claimSecretHash.toString());
|
|
251
|
+
}, this.logger);
|
|
225
252
|
this.logger.info(`Claim message secret: ${claimSecret.toString()}, claim message secret hash: ${claimSecretHash.toString()}`);
|
|
226
253
|
return {
|
|
227
254
|
claimAmount: amount,
|
package/dest/wallet/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
|
package/dest/wallet/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
|
|
4
|
-
"version": "3.0.0-nightly.
|
|
4
|
+
"version": "3.0.0-nightly.20251122",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./abi": "./dest/api/abi.js",
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
88
|
-
"@aztec/entrypoints": "3.0.0-nightly.
|
|
89
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
90
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
91
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
92
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
93
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
87
|
+
"@aztec/constants": "3.0.0-nightly.20251122",
|
|
88
|
+
"@aztec/entrypoints": "3.0.0-nightly.20251122",
|
|
89
|
+
"@aztec/ethereum": "3.0.0-nightly.20251122",
|
|
90
|
+
"@aztec/foundation": "3.0.0-nightly.20251122",
|
|
91
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251122",
|
|
92
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251122",
|
|
93
|
+
"@aztec/stdlib": "3.0.0-nightly.20251122",
|
|
94
94
|
"axios": "^1.12.0",
|
|
95
95
|
"tslib": "^2.4.0",
|
|
96
96
|
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0",
|
package/src/api/account.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { type AccountContract, type AccountInterface, type Salt, getAccountContractAddress } from '../account/index.js';
|
|
2
2
|
export type { AuthWitnessProvider, ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
|
+
export { ChainInfoSchema } from '@aztec/entrypoints/interfaces';
|
|
3
4
|
|
|
4
5
|
export { AccountWithSecretKey } from '../account/account_with_secret_key.js';
|
|
5
6
|
export { type Account, BaseAccount } from '../account/account.js';
|
package/src/api/wallet.ts
CHANGED
|
@@ -24,8 +24,6 @@ export {
|
|
|
24
24
|
WalletSchema,
|
|
25
25
|
} from '../wallet/wallet.js';
|
|
26
26
|
|
|
27
|
-
export { type FeeOptions, BaseWallet } from '../wallet/base_wallet.js';
|
|
28
|
-
|
|
29
27
|
export { AccountManager } from '../wallet/account_manager.js';
|
|
30
28
|
|
|
31
29
|
export { type DeployAccountOptions, DeployAccountMethod } from '../wallet/deploy_account_method.js';
|
|
@@ -177,17 +177,32 @@ export class L1FeeJuicePortalManager {
|
|
|
177
177
|
hash: await this.contract.write.depositToAztecPublic(args),
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
this.logger.info('Deposited to Aztec public successfully');
|
|
180
|
+
this.logger.info('Deposited to Aztec public successfully', { txReceipt });
|
|
181
181
|
|
|
182
182
|
const log = extractEvent(
|
|
183
183
|
txReceipt.logs,
|
|
184
184
|
this.contract.address,
|
|
185
185
|
this.contract.abi,
|
|
186
186
|
'DepositToAztecPublic',
|
|
187
|
-
log =>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
log => {
|
|
188
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
189
|
+
const normalizeHex = (val: string | bigint | number) => {
|
|
190
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
191
|
+
return hexStr.toLowerCase();
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const secretHashMatch = normalizeHex(log.args.secretHash) === normalizeHex(claimSecretHash.toString());
|
|
195
|
+
const amountMatch = log.args.amount === amountToBridge;
|
|
196
|
+
const toMatch = normalizeHex(log.args.to) === normalizeHex(to.toString());
|
|
197
|
+
|
|
198
|
+
this.logger.debug(
|
|
199
|
+
`Event filter matching: secretHash=${secretHashMatch} (${log.args.secretHash} vs ${claimSecretHash.toString()}), ` +
|
|
200
|
+
`amount=${amountMatch} (${log.args.amount} vs ${amountToBridge}), ` +
|
|
201
|
+
`to=${toMatch} (${log.args.to} vs ${to.toString()})`,
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
return secretHashMatch && amountMatch && toMatch;
|
|
205
|
+
},
|
|
191
206
|
this.logger,
|
|
192
207
|
);
|
|
193
208
|
|
|
@@ -282,10 +297,19 @@ export class L1ToL2TokenPortalManager {
|
|
|
282
297
|
this.portal.address,
|
|
283
298
|
this.portal.abi,
|
|
284
299
|
'DepositToAztecPublic',
|
|
285
|
-
log =>
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
300
|
+
log => {
|
|
301
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
302
|
+
const normalizeHex = (val: string | bigint | number) => {
|
|
303
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
304
|
+
return hexStr.toLowerCase();
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
return (
|
|
308
|
+
normalizeHex(log.args.secretHash) === normalizeHex(claimSecretHash.toString()) &&
|
|
309
|
+
log.args.amount === amount &&
|
|
310
|
+
normalizeHex(log.args.to) === normalizeHex(to.toString())
|
|
311
|
+
);
|
|
312
|
+
},
|
|
289
313
|
this.logger,
|
|
290
314
|
);
|
|
291
315
|
|
|
@@ -323,7 +347,18 @@ export class L1ToL2TokenPortalManager {
|
|
|
323
347
|
this.portal.address,
|
|
324
348
|
this.portal.abi,
|
|
325
349
|
'DepositToAztecPrivate',
|
|
326
|
-
log =>
|
|
350
|
+
log => {
|
|
351
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
352
|
+
const normalizeHex = (val: string | bigint | number) => {
|
|
353
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
354
|
+
return hexStr.toLowerCase();
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
return (
|
|
358
|
+
log.args.amount === amount &&
|
|
359
|
+
normalizeHex(log.args.secretHashForL2MessageConsumption) === normalizeHex(claimSecretHash.toString())
|
|
360
|
+
);
|
|
361
|
+
},
|
|
327
362
|
this.logger,
|
|
328
363
|
);
|
|
329
364
|
|
package/src/wallet/index.ts
CHANGED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
2
|
-
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
|
-
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall } from '@aztec/stdlib/abi';
|
|
6
|
-
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
7
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import { type ContractClassMetadata, type ContractInstanceWithAddress, type ContractMetadata } from '@aztec/stdlib/contract';
|
|
9
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
10
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
|
-
import type { TxExecutionRequest, TxHash, TxProfileResult, TxReceipt, TxSimulationResult, UtilitySimulationResult } from '@aztec/stdlib/tx';
|
|
12
|
-
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
13
|
-
import type { Account } from '../account/account.js';
|
|
14
|
-
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
15
|
-
import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
|
|
16
|
-
import type { Aliased, BatchResults, BatchableMethods, BatchedMethod, ProfileOptions, SendOptions, SimulateOptions, Wallet } from './wallet.js';
|
|
17
|
-
/**
|
|
18
|
-
* Options to configure fee payment for a transaction
|
|
19
|
-
*/
|
|
20
|
-
export type FeeOptions = {
|
|
21
|
-
/**
|
|
22
|
-
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
23
|
-
* doesn't already include one
|
|
24
|
-
*/
|
|
25
|
-
walletFeePaymentMethod?: FeePaymentMethod;
|
|
26
|
-
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
27
|
-
accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
|
|
28
|
-
/** The gas settings to use for the transaction */
|
|
29
|
-
gasSettings: GasSettings;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* A base class for Wallet implementations
|
|
33
|
-
*/
|
|
34
|
-
export declare abstract class BaseWallet implements Wallet {
|
|
35
|
-
protected readonly pxe: any;
|
|
36
|
-
protected readonly aztecNode: AztecNode;
|
|
37
|
-
protected log: import("@aztec/foundation/log").Logger;
|
|
38
|
-
protected baseFeePadding: number;
|
|
39
|
-
protected cancellableTransactions: boolean;
|
|
40
|
-
protected constructor(pxe: any, aztecNode: AztecNode);
|
|
41
|
-
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
42
|
-
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Returns the list of aliased contacts associated with the wallet.
|
|
45
|
-
* This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
|
|
46
|
-
* - Senders: Addresses we check during synching in case they sent us notes,
|
|
47
|
-
* - Contacts: more general concept akin to a phone's contact list.
|
|
48
|
-
* @returns The aliased collection of AztecAddresses that form this wallet's address book
|
|
49
|
-
*/
|
|
50
|
-
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
51
|
-
getChainInfo(): Promise<ChainInfo>;
|
|
52
|
-
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
53
|
-
createAuthWit(from: AztecAddress, messageHashOrIntent: Fr | IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
54
|
-
batch<const T extends readonly BatchedMethod<keyof BatchableMethods>[]>(methods: T): Promise<BatchResults<T>>;
|
|
55
|
-
/**
|
|
56
|
-
* Completes partial user-provided fee options with wallet defaults.
|
|
57
|
-
* @param from - The address where the transaction is being sent from
|
|
58
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
59
|
-
* @param gasSettings - User-provided partial gas settings
|
|
60
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
61
|
-
*/
|
|
62
|
-
protected completeFeeOptions(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<FeeOptions>;
|
|
63
|
-
/**
|
|
64
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
65
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
66
|
-
* to avoid running out of gas during estimation.
|
|
67
|
-
* @param from - The address where the transaction is being sent from
|
|
68
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
69
|
-
* @param gasSettings - User-provided partial gas settings
|
|
70
|
-
*/
|
|
71
|
-
protected completeFeeOptionsForEstimation(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
72
|
-
gasSettings: GasSettings;
|
|
73
|
-
/**
|
|
74
|
-
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
75
|
-
* doesn't already include one
|
|
76
|
-
*/
|
|
77
|
-
walletFeePaymentMethod?: FeePaymentMethod;
|
|
78
|
-
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
79
|
-
accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
|
|
80
|
-
}>;
|
|
81
|
-
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
82
|
-
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
83
|
-
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
84
|
-
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
85
|
-
sendTx(executionPayload: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
|
|
86
|
-
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
87
|
-
simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
|
|
88
|
-
getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
|
|
89
|
-
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
90
|
-
getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
|
|
91
|
-
getPrivateEvents<T>(contractAddress: AztecAddress, eventDef: EventMetadataDefinition, from: number, limit: number, recipients?: AztecAddress[]): Promise<T[]>;
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=base_wallet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/base_wallet.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,8BAA8B,EAAwC,MAAM,4BAA4B,CAAC;AAClH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EAGtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACN,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAA0B,MAAM,kBAAkB,CAAC;AAI5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB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,EAAE,EAAE,eAAe,GAAE,OAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAGlG,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIrE,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAI1C,gBAAgB,CAAC,CAAC,EACtB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,uBAAuB,EACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,YAAY,EAAO,GAC9B,OAAO,CAAC,CAAC,EAAE,CAAC;CAShB"}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
|
|
2
|
-
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
3
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
6
|
-
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
7
|
-
import { SimulationError } from '@aztec/stdlib/errors';
|
|
8
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
9
|
-
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
10
|
-
import { inspect } from 'util';
|
|
11
|
-
/**
|
|
12
|
-
* A base class for Wallet implementations
|
|
13
|
-
*/ export class BaseWallet {
|
|
14
|
-
pxe;
|
|
15
|
-
aztecNode;
|
|
16
|
-
log;
|
|
17
|
-
baseFeePadding;
|
|
18
|
-
cancellableTransactions;
|
|
19
|
-
// Protected because we want to force wallets to instantiate their own PXE.
|
|
20
|
-
constructor(// TODO: We cannot type here pxe because we cannot import that package as that would result in a circular
|
|
21
|
-
// dependency. This will eventually get resolved by the introduction of @aztec/wallet-sdk package.
|
|
22
|
-
pxe, aztecNode){
|
|
23
|
-
this.pxe = pxe;
|
|
24
|
-
this.aztecNode = aztecNode;
|
|
25
|
-
this.log = createLogger('aztecjs:base_wallet');
|
|
26
|
-
this.baseFeePadding = 0.5;
|
|
27
|
-
this.cancellableTransactions = false;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Returns the list of aliased contacts associated with the wallet.
|
|
31
|
-
* This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
|
|
32
|
-
* - Senders: Addresses we check during synching in case they sent us notes,
|
|
33
|
-
* - Contacts: more general concept akin to a phone's contact list.
|
|
34
|
-
* @returns The aliased collection of AztecAddresses that form this wallet's address book
|
|
35
|
-
*/ async getAddressBook() {
|
|
36
|
-
const senders = await this.pxe.getSenders();
|
|
37
|
-
return senders.map((sender)=>({
|
|
38
|
-
item: sender,
|
|
39
|
-
alias: ''
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
async getChainInfo() {
|
|
43
|
-
const { l1ChainId, rollupVersion } = await this.aztecNode.getNodeInfo();
|
|
44
|
-
return {
|
|
45
|
-
chainId: new Fr(l1ChainId),
|
|
46
|
-
version: new Fr(rollupVersion)
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
50
|
-
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
51
|
-
const executionOptions = {
|
|
52
|
-
txNonce: Fr.random(),
|
|
53
|
-
cancellable: this.cancellableTransactions,
|
|
54
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
55
|
-
};
|
|
56
|
-
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
57
|
-
feeExecutionPayload,
|
|
58
|
-
executionPayload
|
|
59
|
-
]) : executionPayload;
|
|
60
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
61
|
-
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
|
|
62
|
-
}
|
|
63
|
-
async createAuthWit(from, messageHashOrIntent) {
|
|
64
|
-
const account = await this.getAccountFromAddress(from);
|
|
65
|
-
return account.createAuthWit(messageHashOrIntent);
|
|
66
|
-
}
|
|
67
|
-
async batch(methods) {
|
|
68
|
-
const results = [];
|
|
69
|
-
for (const method of methods){
|
|
70
|
-
const { name, args } = method;
|
|
71
|
-
// Type safety is guaranteed by the BatchedMethod type, which ensures that:
|
|
72
|
-
// 1. `name` is a valid batchable method name
|
|
73
|
-
// 2. `args` matches the parameter types of that specific method
|
|
74
|
-
// 3. The return type is correctly mapped in BatchResults<T>
|
|
75
|
-
// We use dynamic dispatch here for simplicity, but the types are enforced at the call site.
|
|
76
|
-
const fn = this[name];
|
|
77
|
-
const result = await fn.apply(this, args);
|
|
78
|
-
// Wrap result with method name for discriminated union deserialization
|
|
79
|
-
results.push({
|
|
80
|
-
name,
|
|
81
|
-
result
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return results;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Completes partial user-provided fee options with wallet defaults.
|
|
88
|
-
* @param from - The address where the transaction is being sent from
|
|
89
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
90
|
-
* @param gasSettings - User-provided partial gas settings
|
|
91
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
92
|
-
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
93
|
-
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentBaseFees()).mul(1 + this.baseFeePadding);
|
|
94
|
-
let accountFeePaymentMethodOptions;
|
|
95
|
-
// The transaction does not include a fee payment method, so we set the flag
|
|
96
|
-
// for the account to use its fee juice balance
|
|
97
|
-
if (!feePayer) {
|
|
98
|
-
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
99
|
-
} else {
|
|
100
|
-
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
101
|
-
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
102
|
-
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
103
|
-
}
|
|
104
|
-
const fullGasSettings = GasSettings.default({
|
|
105
|
-
...gasSettings,
|
|
106
|
-
maxFeesPerGas
|
|
107
|
-
});
|
|
108
|
-
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
109
|
-
return {
|
|
110
|
-
gasSettings: fullGasSettings,
|
|
111
|
-
walletFeePaymentMethod: undefined,
|
|
112
|
-
accountFeePaymentMethodOptions
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
117
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
118
|
-
* to avoid running out of gas during estimation.
|
|
119
|
-
* @param from - The address where the transaction is being sent from
|
|
120
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
121
|
-
* @param gasSettings - User-provided partial gas settings
|
|
122
|
-
*/ async completeFeeOptionsForEstimation(from, feePayer, gasSettings) {
|
|
123
|
-
const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
|
|
124
|
-
const { gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas } } = defaultFeeOptions;
|
|
125
|
-
// Use unrealistically high gas limits for estimation to avoid running out of gas.
|
|
126
|
-
// They will be tuned down after the simulation.
|
|
127
|
-
const gasSettingsForEstimation = new GasSettings(new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT), new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT), maxFeesPerGas, maxPriorityFeesPerGas);
|
|
128
|
-
return {
|
|
129
|
-
...defaultFeeOptions,
|
|
130
|
-
gasSettings: gasSettingsForEstimation
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
registerSender(address, _alias = '') {
|
|
134
|
-
return this.pxe.registerSender(address);
|
|
135
|
-
}
|
|
136
|
-
async registerContract(instance, artifact, secretKey) {
|
|
137
|
-
const { contractInstance: existingInstance } = await this.pxe.getContractMetadata(instance.address);
|
|
138
|
-
if (existingInstance) {
|
|
139
|
-
// Instance already registered in the wallet
|
|
140
|
-
if (artifact) {
|
|
141
|
-
const thisContractClass = await getContractClassFromArtifact(artifact);
|
|
142
|
-
if (!thisContractClass.id.equals(existingInstance.currentContractClassId)) {
|
|
143
|
-
// wallet holds an outdated version of this contract
|
|
144
|
-
await this.pxe.updateContract(instance.address, artifact);
|
|
145
|
-
instance.currentContractClassId = thisContractClass.id;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// If no artifact provided, we just use the existing registration
|
|
149
|
-
} else {
|
|
150
|
-
// Instance not registered yet
|
|
151
|
-
if (!artifact) {
|
|
152
|
-
// Try to get the artifact from the wallet's contract class storage
|
|
153
|
-
const classMetadata = await this.pxe.getContractClassMetadata(instance.currentContractClassId, true);
|
|
154
|
-
if (!classMetadata.artifact) {
|
|
155
|
-
throw new Error(`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()}`);
|
|
156
|
-
}
|
|
157
|
-
artifact = classMetadata.artifact;
|
|
158
|
-
}
|
|
159
|
-
await this.pxe.registerContract({
|
|
160
|
-
artifact,
|
|
161
|
-
instance
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
if (secretKey) {
|
|
165
|
-
await this.pxe.registerAccount(secretKey, await computePartialAddress(instance));
|
|
166
|
-
}
|
|
167
|
-
return instance;
|
|
168
|
-
}
|
|
169
|
-
async simulateTx(executionPayload, opts) {
|
|
170
|
-
const feeOptions = opts.fee?.estimateGas ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings) : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
171
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
172
|
-
return this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
|
|
173
|
-
}
|
|
174
|
-
async profileTx(executionPayload, opts) {
|
|
175
|
-
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
176
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
177
|
-
return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
|
|
178
|
-
}
|
|
179
|
-
async sendTx(executionPayload, opts) {
|
|
180
|
-
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
181
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
182
|
-
const provenTx = await this.pxe.proveTx(txRequest);
|
|
183
|
-
const tx = await provenTx.toTx();
|
|
184
|
-
const txHash = tx.getTxHash();
|
|
185
|
-
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
186
|
-
throw new Error(`A settled tx with equal hash ${txHash.toString()} exists.`);
|
|
187
|
-
}
|
|
188
|
-
this.log.debug(`Sending transaction ${txHash}`);
|
|
189
|
-
await this.aztecNode.sendTx(tx).catch((err)=>{
|
|
190
|
-
throw this.contextualizeError(err, inspect(tx));
|
|
191
|
-
});
|
|
192
|
-
this.log.info(`Sent transaction ${txHash}`);
|
|
193
|
-
return txHash;
|
|
194
|
-
}
|
|
195
|
-
contextualizeError(err, ...context) {
|
|
196
|
-
let contextStr = '';
|
|
197
|
-
if (context.length > 0) {
|
|
198
|
-
contextStr = `\nContext:\n${context.join('\n')}`;
|
|
199
|
-
}
|
|
200
|
-
if (err instanceof SimulationError) {
|
|
201
|
-
err.setAztecContext(contextStr);
|
|
202
|
-
} else {
|
|
203
|
-
this.log.error(err.name, err);
|
|
204
|
-
this.log.debug(contextStr);
|
|
205
|
-
}
|
|
206
|
-
return err;
|
|
207
|
-
}
|
|
208
|
-
simulateUtility(call, authwits) {
|
|
209
|
-
return this.pxe.simulateUtility(call, authwits);
|
|
210
|
-
}
|
|
211
|
-
getContractClassMetadata(id, includeArtifact = false) {
|
|
212
|
-
return this.pxe.getContractClassMetadata(id, includeArtifact);
|
|
213
|
-
}
|
|
214
|
-
getContractMetadata(address) {
|
|
215
|
-
return this.pxe.getContractMetadata(address);
|
|
216
|
-
}
|
|
217
|
-
getTxReceipt(txHash) {
|
|
218
|
-
return this.aztecNode.getTxReceipt(txHash);
|
|
219
|
-
}
|
|
220
|
-
async getPrivateEvents(contractAddress, eventDef, from, limit, recipients = []) {
|
|
221
|
-
const events = await this.pxe.getPrivateEvents(contractAddress, eventDef.eventSelector, from, limit, recipients);
|
|
222
|
-
const decodedEvents = events.map((event /** PrivateEvent */ )=>decodeFromAbi([
|
|
223
|
-
eventDef.abiType
|
|
224
|
-
], event.packedEvent));
|
|
225
|
-
return decodedEvents;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GAS_ESTIMATION_DA_GAS_LIMIT,
|
|
3
|
-
GAS_ESTIMATION_L2_GAS_LIMIT,
|
|
4
|
-
GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT,
|
|
5
|
-
GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT,
|
|
6
|
-
} from '@aztec/constants';
|
|
7
|
-
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
8
|
-
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
9
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
10
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
11
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
12
|
-
import {
|
|
13
|
-
type ContractArtifact,
|
|
14
|
-
type EventMetadataDefinition,
|
|
15
|
-
type FunctionCall,
|
|
16
|
-
decodeFromAbi,
|
|
17
|
-
} from '@aztec/stdlib/abi';
|
|
18
|
-
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
19
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
20
|
-
import {
|
|
21
|
-
type ContractClassMetadata,
|
|
22
|
-
type ContractInstanceWithAddress,
|
|
23
|
-
type ContractMetadata,
|
|
24
|
-
computePartialAddress,
|
|
25
|
-
getContractClassFromArtifact,
|
|
26
|
-
} from '@aztec/stdlib/contract';
|
|
27
|
-
import { SimulationError } from '@aztec/stdlib/errors';
|
|
28
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
29
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
30
|
-
import type {
|
|
31
|
-
TxExecutionRequest,
|
|
32
|
-
TxHash,
|
|
33
|
-
TxProfileResult,
|
|
34
|
-
TxReceipt,
|
|
35
|
-
TxSimulationResult,
|
|
36
|
-
UtilitySimulationResult,
|
|
37
|
-
} from '@aztec/stdlib/tx';
|
|
38
|
-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
39
|
-
|
|
40
|
-
import { inspect } from 'util';
|
|
41
|
-
|
|
42
|
-
import type { Account } from '../account/account.js';
|
|
43
|
-
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
44
|
-
import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
|
|
45
|
-
import type {
|
|
46
|
-
Aliased,
|
|
47
|
-
BatchResults,
|
|
48
|
-
BatchableMethods,
|
|
49
|
-
BatchedMethod,
|
|
50
|
-
ProfileOptions,
|
|
51
|
-
SendOptions,
|
|
52
|
-
SimulateOptions,
|
|
53
|
-
Wallet,
|
|
54
|
-
} from './wallet.js';
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Options to configure fee payment for a transaction
|
|
58
|
-
*/
|
|
59
|
-
export type FeeOptions = {
|
|
60
|
-
/**
|
|
61
|
-
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
62
|
-
* doesn't already include one
|
|
63
|
-
*/
|
|
64
|
-
walletFeePaymentMethod?: FeePaymentMethod;
|
|
65
|
-
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
66
|
-
accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
|
|
67
|
-
/** The gas settings to use for the transaction */
|
|
68
|
-
gasSettings: GasSettings;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* A base class for Wallet implementations
|
|
73
|
-
*/
|
|
74
|
-
export abstract class BaseWallet implements Wallet {
|
|
75
|
-
protected log = createLogger('aztecjs:base_wallet');
|
|
76
|
-
|
|
77
|
-
protected baseFeePadding = 0.5;
|
|
78
|
-
protected cancellableTransactions = false;
|
|
79
|
-
|
|
80
|
-
// Protected because we want to force wallets to instantiate their own PXE.
|
|
81
|
-
protected constructor(
|
|
82
|
-
// TODO: We cannot type here pxe because we cannot import that package as that would result in a circular
|
|
83
|
-
// dependency. This will eventually get resolved by the introduction of @aztec/wallet-sdk package.
|
|
84
|
-
protected readonly pxe: any,
|
|
85
|
-
protected readonly aztecNode: AztecNode,
|
|
86
|
-
) {}
|
|
87
|
-
|
|
88
|
-
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
89
|
-
|
|
90
|
-
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Returns the list of aliased contacts associated with the wallet.
|
|
94
|
-
* This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
|
|
95
|
-
* - Senders: Addresses we check during synching in case they sent us notes,
|
|
96
|
-
* - Contacts: more general concept akin to a phone's contact list.
|
|
97
|
-
* @returns The aliased collection of AztecAddresses that form this wallet's address book
|
|
98
|
-
*/
|
|
99
|
-
async getAddressBook(): Promise<Aliased<AztecAddress>[]> {
|
|
100
|
-
const senders: AztecAddress[] = await this.pxe.getSenders();
|
|
101
|
-
return senders.map(sender => ({ item: sender, alias: '' }));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async getChainInfo(): Promise<ChainInfo> {
|
|
105
|
-
const { l1ChainId, rollupVersion } = await this.aztecNode.getNodeInfo();
|
|
106
|
-
return { chainId: new Fr(l1ChainId), version: new Fr(rollupVersion) };
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
protected async createTxExecutionRequestFromPayloadAndFee(
|
|
110
|
-
executionPayload: ExecutionPayload,
|
|
111
|
-
from: AztecAddress,
|
|
112
|
-
feeOptions: FeeOptions,
|
|
113
|
-
): Promise<TxExecutionRequest> {
|
|
114
|
-
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
115
|
-
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
116
|
-
txNonce: Fr.random(),
|
|
117
|
-
cancellable: this.cancellableTransactions,
|
|
118
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
119
|
-
};
|
|
120
|
-
const finalExecutionPayload = feeExecutionPayload
|
|
121
|
-
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
122
|
-
: executionPayload;
|
|
123
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
124
|
-
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public async createAuthWit(
|
|
128
|
-
from: AztecAddress,
|
|
129
|
-
messageHashOrIntent: Fr | IntentInnerHash | CallIntent,
|
|
130
|
-
): Promise<AuthWitness> {
|
|
131
|
-
const account = await this.getAccountFromAddress(from);
|
|
132
|
-
return account.createAuthWit(messageHashOrIntent);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
public async batch<const T extends readonly BatchedMethod<keyof BatchableMethods>[]>(
|
|
136
|
-
methods: T,
|
|
137
|
-
): Promise<BatchResults<T>> {
|
|
138
|
-
const results: any[] = [];
|
|
139
|
-
for (const method of methods) {
|
|
140
|
-
const { name, args } = method;
|
|
141
|
-
// Type safety is guaranteed by the BatchedMethod type, which ensures that:
|
|
142
|
-
// 1. `name` is a valid batchable method name
|
|
143
|
-
// 2. `args` matches the parameter types of that specific method
|
|
144
|
-
// 3. The return type is correctly mapped in BatchResults<T>
|
|
145
|
-
// We use dynamic dispatch here for simplicity, but the types are enforced at the call site.
|
|
146
|
-
|
|
147
|
-
const fn = this[name] as (...args: any[]) => Promise<any>;
|
|
148
|
-
const result = await fn.apply(this, args);
|
|
149
|
-
// Wrap result with method name for discriminated union deserialization
|
|
150
|
-
results.push({ name, result });
|
|
151
|
-
}
|
|
152
|
-
return results as BatchResults<T>;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Completes partial user-provided fee options with wallet defaults.
|
|
157
|
-
* @param from - The address where the transaction is being sent from
|
|
158
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
159
|
-
* @param gasSettings - User-provided partial gas settings
|
|
160
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
161
|
-
*/
|
|
162
|
-
protected async completeFeeOptions(
|
|
163
|
-
from: AztecAddress,
|
|
164
|
-
feePayer?: AztecAddress,
|
|
165
|
-
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
166
|
-
): Promise<FeeOptions> {
|
|
167
|
-
const maxFeesPerGas =
|
|
168
|
-
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentBaseFees()).mul(1 + this.baseFeePadding);
|
|
169
|
-
let accountFeePaymentMethodOptions;
|
|
170
|
-
// The transaction does not include a fee payment method, so we set the flag
|
|
171
|
-
// for the account to use its fee juice balance
|
|
172
|
-
if (!feePayer) {
|
|
173
|
-
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
174
|
-
} else {
|
|
175
|
-
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
176
|
-
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
177
|
-
accountFeePaymentMethodOptions = from.equals(feePayer)
|
|
178
|
-
? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM
|
|
179
|
-
: AccountFeePaymentMethodOptions.EXTERNAL;
|
|
180
|
-
}
|
|
181
|
-
const fullGasSettings: GasSettings = GasSettings.default({ ...gasSettings, maxFeesPerGas });
|
|
182
|
-
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
183
|
-
return {
|
|
184
|
-
gasSettings: fullGasSettings,
|
|
185
|
-
walletFeePaymentMethod: undefined,
|
|
186
|
-
accountFeePaymentMethodOptions,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
192
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
193
|
-
* to avoid running out of gas during estimation.
|
|
194
|
-
* @param from - The address where the transaction is being sent from
|
|
195
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
196
|
-
* @param gasSettings - User-provided partial gas settings
|
|
197
|
-
*/
|
|
198
|
-
protected async completeFeeOptionsForEstimation(
|
|
199
|
-
from: AztecAddress,
|
|
200
|
-
feePayer?: AztecAddress,
|
|
201
|
-
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
202
|
-
) {
|
|
203
|
-
const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
|
|
204
|
-
const {
|
|
205
|
-
gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas },
|
|
206
|
-
} = defaultFeeOptions;
|
|
207
|
-
// Use unrealistically high gas limits for estimation to avoid running out of gas.
|
|
208
|
-
// They will be tuned down after the simulation.
|
|
209
|
-
const gasSettingsForEstimation = new GasSettings(
|
|
210
|
-
new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT),
|
|
211
|
-
new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT),
|
|
212
|
-
maxFeesPerGas,
|
|
213
|
-
maxPriorityFeesPerGas,
|
|
214
|
-
);
|
|
215
|
-
return {
|
|
216
|
-
...defaultFeeOptions,
|
|
217
|
-
gasSettings: gasSettingsForEstimation,
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
registerSender(address: AztecAddress, _alias: string = ''): Promise<AztecAddress> {
|
|
222
|
-
return this.pxe.registerSender(address);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
async registerContract(
|
|
226
|
-
instance: ContractInstanceWithAddress,
|
|
227
|
-
artifact?: ContractArtifact,
|
|
228
|
-
secretKey?: Fr,
|
|
229
|
-
): Promise<ContractInstanceWithAddress> {
|
|
230
|
-
const { contractInstance: existingInstance } = await this.pxe.getContractMetadata(instance.address);
|
|
231
|
-
|
|
232
|
-
if (existingInstance) {
|
|
233
|
-
// Instance already registered in the wallet
|
|
234
|
-
if (artifact) {
|
|
235
|
-
const thisContractClass = await getContractClassFromArtifact(artifact);
|
|
236
|
-
if (!thisContractClass.id.equals(existingInstance.currentContractClassId)) {
|
|
237
|
-
// wallet holds an outdated version of this contract
|
|
238
|
-
await this.pxe.updateContract(instance.address, artifact);
|
|
239
|
-
instance.currentContractClassId = thisContractClass.id;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
// If no artifact provided, we just use the existing registration
|
|
243
|
-
} else {
|
|
244
|
-
// Instance not registered yet
|
|
245
|
-
if (!artifact) {
|
|
246
|
-
// Try to get the artifact from the wallet's contract class storage
|
|
247
|
-
const classMetadata = await this.pxe.getContractClassMetadata(instance.currentContractClassId, true);
|
|
248
|
-
if (!classMetadata.artifact) {
|
|
249
|
-
throw new Error(
|
|
250
|
-
`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
|
-
);
|
|
252
|
-
}
|
|
253
|
-
artifact = classMetadata.artifact;
|
|
254
|
-
}
|
|
255
|
-
await this.pxe.registerContract({ artifact, instance });
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (secretKey) {
|
|
259
|
-
await this.pxe.registerAccount(secretKey, await computePartialAddress(instance));
|
|
260
|
-
}
|
|
261
|
-
return instance;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
|
|
265
|
-
const feeOptions = opts.fee?.estimateGas
|
|
266
|
-
? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings)
|
|
267
|
-
: await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
268
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
269
|
-
return this.pxe.simulateTx(
|
|
270
|
-
txRequest,
|
|
271
|
-
true /* simulatePublic */,
|
|
272
|
-
opts?.skipTxValidation,
|
|
273
|
-
opts?.skipFeeEnforcement ?? true,
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
async profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
|
|
278
|
-
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
279
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
280
|
-
return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
async sendTx(executionPayload: ExecutionPayload, opts: SendOptions): Promise<TxHash> {
|
|
284
|
-
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
285
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
286
|
-
const provenTx = await this.pxe.proveTx(txRequest);
|
|
287
|
-
const tx = await provenTx.toTx();
|
|
288
|
-
const txHash = tx.getTxHash();
|
|
289
|
-
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
290
|
-
throw new Error(`A settled tx with equal hash ${txHash.toString()} exists.`);
|
|
291
|
-
}
|
|
292
|
-
this.log.debug(`Sending transaction ${txHash}`);
|
|
293
|
-
await this.aztecNode.sendTx(tx).catch(err => {
|
|
294
|
-
throw this.contextualizeError(err, inspect(tx));
|
|
295
|
-
});
|
|
296
|
-
this.log.info(`Sent transaction ${txHash}`);
|
|
297
|
-
return txHash;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
protected contextualizeError(err: Error, ...context: string[]): Error {
|
|
301
|
-
let contextStr = '';
|
|
302
|
-
if (context.length > 0) {
|
|
303
|
-
contextStr = `\nContext:\n${context.join('\n')}`;
|
|
304
|
-
}
|
|
305
|
-
if (err instanceof SimulationError) {
|
|
306
|
-
err.setAztecContext(contextStr);
|
|
307
|
-
} else {
|
|
308
|
-
this.log.error(err.name, err);
|
|
309
|
-
this.log.debug(contextStr);
|
|
310
|
-
}
|
|
311
|
-
return err;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult> {
|
|
315
|
-
return this.pxe.simulateUtility(call, authwits);
|
|
316
|
-
}
|
|
317
|
-
|
|
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
|
-
async getPrivateEvents<T>(
|
|
330
|
-
contractAddress: AztecAddress,
|
|
331
|
-
eventDef: EventMetadataDefinition,
|
|
332
|
-
from: number,
|
|
333
|
-
limit: number,
|
|
334
|
-
recipients: AztecAddress[] = [],
|
|
335
|
-
): Promise<T[]> {
|
|
336
|
-
const events = await this.pxe.getPrivateEvents(contractAddress, eventDef.eventSelector, from, limit, recipients);
|
|
337
|
-
|
|
338
|
-
const decodedEvents = events.map(
|
|
339
|
-
(event: any /** PrivateEvent */): T => decodeFromAbi([eventDef.abiType], event.packedEvent) as T,
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
return decodedEvents;
|
|
343
|
-
}
|
|
344
|
-
}
|