@aztec/test-wallet 0.0.1-commit.d3ec352c → 0.0.1-commit.e3c1de76
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/utils.d.ts +32 -6
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +28 -10
- package/dest/wallet/bundle.d.ts +9 -3
- package/dest/wallet/bundle.d.ts.map +1 -1
- package/dest/wallet/bundle.js +15 -4
- package/dest/wallet/lazy.d.ts +9 -3
- package/dest/wallet/lazy.d.ts.map +1 -1
- package/dest/wallet/lazy.js +15 -4
- package/dest/wallet/server.d.ts +9 -3
- package/dest/wallet/server.d.ts.map +1 -1
- package/dest/wallet/server.js +15 -4
- package/dest/wallet/test_wallet.d.ts +27 -7
- package/dest/wallet/test_wallet.d.ts.map +1 -1
- package/dest/wallet/test_wallet.js +42 -14
- package/package.json +11 -11
- package/src/utils.ts +61 -16
- package/src/wallet/bundle.ts +16 -4
- package/src/wallet/lazy.ts +16 -4
- package/src/wallet/server.ts +16 -4
- package/src/wallet/test_wallet.ts +56 -15
package/dest/utils.d.ts
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
-
import { ContractFunctionInteraction, DeployMethod, type DeployOptions, type
|
|
4
|
-
import type
|
|
5
|
-
import { type OffchainEffect, type ProvingStats, Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
import { ContractFunctionInteraction, DeployMethod, type DeployOptions, type NoWait, type SendInteractionOptions, type WaitOpts } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { type AztecNode } from '@aztec/aztec.js/node';
|
|
5
|
+
import { type OffchainEffect, type ProvingStats, Tx, TxHash, type TxReceipt } from '@aztec/stdlib/tx';
|
|
6
6
|
import type { BaseTestWallet } from './wallet/test_wallet.js';
|
|
7
|
+
/**
|
|
8
|
+
* Options for sending a proven transaction.
|
|
9
|
+
*/
|
|
10
|
+
export type ProvenTxSendOpts = {
|
|
11
|
+
/**
|
|
12
|
+
* Whether to wait for the transaction to be mined.
|
|
13
|
+
* - undefined (default): wait with default options and return TxReceipt
|
|
14
|
+
* - WaitOpts object: wait with custom options and return TxReceipt
|
|
15
|
+
* - NO_WAIT: return txHash immediately without waiting
|
|
16
|
+
*/
|
|
17
|
+
wait?: NoWait | WaitOpts;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Return type for ProvenTx.send based on wait option.
|
|
21
|
+
*/
|
|
22
|
+
export type ProvenTxSendReturn<T extends NoWait | WaitOpts | undefined> = T extends NoWait ? TxHash : TxReceipt;
|
|
7
23
|
/**
|
|
8
24
|
* Deploys the SchnorrAccount contracts backed by prefunded addresses
|
|
9
25
|
* at genesis. This can be directly used to pay for transactions in FeeJuice.
|
|
10
26
|
*/
|
|
11
|
-
export declare function deployFundedSchnorrAccounts(wallet: BaseTestWallet,
|
|
27
|
+
export declare function deployFundedSchnorrAccounts(wallet: BaseTestWallet, accountsData: InitialAccountData[], waitOptions?: WaitOpts): Promise<import("@aztec/aztec.js/wallet").AccountManager[]>;
|
|
12
28
|
/**
|
|
13
29
|
* Registers the initial local network accounts in the wallet.
|
|
14
30
|
* @param wallet - Test wallet to use to register the accounts.
|
|
@@ -20,12 +36,22 @@ export declare function registerInitialLocalNetworkAccountsInWallet(wallet: Base
|
|
|
20
36
|
*/
|
|
21
37
|
export declare class ProvenTx extends Tx {
|
|
22
38
|
private node;
|
|
39
|
+
/** The offchain effects emitted during the execution of the transaction. */
|
|
23
40
|
offchainEffects: OffchainEffect[];
|
|
24
41
|
stats?: ProvingStats | undefined;
|
|
25
42
|
constructor(node: AztecNode, tx: Tx,
|
|
26
43
|
/** The offchain effects emitted during the execution of the transaction. */
|
|
27
44
|
offchainEffects: OffchainEffect[], stats?: ProvingStats | undefined);
|
|
28
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Sends the transaction to the network.
|
|
47
|
+
* @param options - Send options including whether to wait.
|
|
48
|
+
* @returns The transaction receipt if waiting, or the transaction hash if not.
|
|
49
|
+
*/
|
|
50
|
+
send(options?: Omit<ProvenTxSendOpts, 'wait'>): Promise<TxReceipt>;
|
|
51
|
+
send<W extends ProvenTxSendOpts['wait']>(options: ProvenTxSendOpts & {
|
|
52
|
+
wait: W;
|
|
53
|
+
}): Promise<ProvenTxSendReturn<W>>;
|
|
54
|
+
private contextualizeError;
|
|
29
55
|
}
|
|
30
56
|
/**
|
|
31
57
|
* Helper function to prove an interaction via a TestWallet
|
|
@@ -35,4 +61,4 @@ export declare class ProvenTx extends Tx {
|
|
|
35
61
|
* @returns - A proven transaction ready do be sent to the network
|
|
36
62
|
*/
|
|
37
63
|
export declare function proveInteraction(wallet: BaseTestWallet, interaction: ContractFunctionInteraction | DeployMethod, options: SendInteractionOptions | DeployOptions): Promise<ProvenTx>;
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRWxFLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEVBQ0wsMkJBQTJCLEVBQzNCLFlBQVksRUFDWixLQUFLLGFBQWEsRUFFbEIsS0FBSyxNQUFNLEVBQ1gsS0FBSyxzQkFBc0IsRUFDM0IsS0FBSyxRQUFRLEVBRWQsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWEsTUFBTSxzQkFBc0IsQ0FBQztBQUVqRSxPQUFPLE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WMsRUFHNUI7SUFFRDs7OztPQUlHO0lBQ0gsSUFBSSxDQUFDLE9BQU8sQ0FBQyxFQUFFLElBQUksQ0FBQyxnQkFBZ0IsRUFBRSxNQUFNLENBQUMsR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7SUFFbkUsSUFBSSxDQUFDLENBQUMsU0FBUyxnQkFBZ0IsQ0FBQyxNQUFNLENBQUMsRUFBRSxPQUFPLEVBQUUsZ0JBQWdCLEdBQUc7UUFBRSxJQUFJLEVBQUUsQ0FBQyxDQUFBO0tBQUUsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztJQWVsSCxPQUFPLENBQUMsa0JBQWtCO0NBVTNCO0FBRUQ7Ozs7OztHQU1HO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUNwQyxNQUFNLEVBQUUsY0FBYyxFQUN0QixXQUFXLEVBQUUsMkJBQTJCLEdBQUcsWUFBWSxFQUN2RCxPQUFPLEVBQUUsc0JBQXNCLEdBQUcsYUFBYSxxQkFTaEQifQ==
|
package/dest/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,2BAA2B,EAC3B,YAAY,EACZ,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,2BAA2B,EAC3B,YAAY,EACZ,KAAK,aAAa,EAElB,KAAK,MAAM,EACX,K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AM,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAelH,OAAO,CAAC,kBAAkB;CAU3B;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,2BAA2B,GAAG,YAAY,EACvD,OAAO,EAAE,sBAAsB,GAAG,aAAa,qBAShD"}
|
package/dest/utils.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing/lazy';
|
|
2
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
-
import { DeployMethod,
|
|
3
|
+
import { DeployMethod, NO_WAIT, toSendOptions } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
5
|
+
import { SimulationError } from '@aztec/stdlib/errors';
|
|
4
6
|
import { Tx } from '@aztec/stdlib/tx';
|
|
7
|
+
import { inspect } from 'util';
|
|
5
8
|
/**
|
|
6
9
|
* Deploys the SchnorrAccount contracts backed by prefunded addresses
|
|
7
10
|
* at genesis. This can be directly used to pay for transactions in FeeJuice.
|
|
8
|
-
*/ export async function deployFundedSchnorrAccounts(wallet,
|
|
11
|
+
*/ export async function deployFundedSchnorrAccounts(wallet, accountsData, waitOptions) {
|
|
9
12
|
const accountManagers = [];
|
|
10
13
|
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
11
14
|
for(let i = 0; i < accountsData.length; i++){
|
|
@@ -14,8 +17,9 @@ import { Tx } from '@aztec/stdlib/tx';
|
|
|
14
17
|
const deployMethod = await accountManager.getDeployMethod();
|
|
15
18
|
await deployMethod.send({
|
|
16
19
|
from: AztecAddress.ZERO,
|
|
17
|
-
skipClassPublication: i !== 0
|
|
18
|
-
|
|
20
|
+
skipClassPublication: i !== 0,
|
|
21
|
+
wait: waitOptions
|
|
22
|
+
});
|
|
19
23
|
accountManagers.push(accountManager);
|
|
20
24
|
}
|
|
21
25
|
return accountManagers;
|
|
@@ -40,12 +44,26 @@ import { Tx } from '@aztec/stdlib/tx';
|
|
|
40
44
|
stats){
|
|
41
45
|
super(tx.getTxHash(), tx.data, tx.chonkProof, tx.contractClassLogFields, tx.publicFunctionCalldata), this.node = node, this.offchainEffects = offchainEffects, this.stats = stats;
|
|
42
46
|
}
|
|
43
|
-
send() {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
|
|
47
|
+
async send(options) {
|
|
48
|
+
const txHash = this.getTxHash();
|
|
49
|
+
await this.node.sendTx(this).catch((err)=>{
|
|
50
|
+
throw this.contextualizeError(err, inspect(this));
|
|
51
|
+
});
|
|
52
|
+
if (options?.wait === NO_WAIT) {
|
|
53
|
+
return txHash;
|
|
54
|
+
}
|
|
55
|
+
const waitOpts = typeof options?.wait === 'object' ? options.wait : undefined;
|
|
56
|
+
return await waitForTx(this.node, txHash, waitOpts);
|
|
57
|
+
}
|
|
58
|
+
contextualizeError(err, ...context) {
|
|
59
|
+
let contextStr = '';
|
|
60
|
+
if (context.length > 0) {
|
|
61
|
+
contextStr = `\nContext:\n${context.join('\n')}`;
|
|
62
|
+
}
|
|
63
|
+
if (err instanceof SimulationError) {
|
|
64
|
+
err.setAztecContext(contextStr);
|
|
65
|
+
}
|
|
66
|
+
return err;
|
|
49
67
|
}
|
|
50
68
|
}
|
|
51
69
|
/**
|
package/dest/wallet/bundle.d.ts
CHANGED
|
@@ -14,10 +14,16 @@ export declare class TestWallet extends BaseTestWallet {
|
|
|
14
14
|
createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager>;
|
|
15
15
|
createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
16
16
|
createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
19
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
20
|
+
* @param address - The address of the account to impersonate
|
|
21
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
22
|
+
*/
|
|
17
23
|
getFakeAccountDataFor(address: AztecAddress): Promise<{
|
|
18
|
-
account: import("
|
|
24
|
+
account: import("@aztec/aztec.js/account").BaseAccount;
|
|
19
25
|
instance: import("@aztec/aztec.js/contracts").ContractInstanceWithAddress;
|
|
20
|
-
artifact: import("
|
|
26
|
+
artifact: import("@aztec/stdlib/abi").ContractArtifact;
|
|
21
27
|
}>;
|
|
22
28
|
}
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L2J1bmRsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUU5RCxPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQUUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ2hELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUN4RCxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQUUsS0FBSyxrQkFBa0IsRUFBMkIsTUFBTSwwQkFBMEIsQ0FBQztBQUc1RyxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFbEQ7Ozs7R0FJRztBQUNILHFCQUFhLFVBQVcsU0FBUSxjQUFjO0lBQzVDLE9BQWEsTUFBTSxDQUNqQixJQUFJLEVBQUUsU0FBUyxFQUNmLGlCQUFpQixDQUFDLEVBQUUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUN0QyxPQUFPLEdBQUUsa0JBQW9DLEdBQzVDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FPckI7SUFFRCxvQkFBb0IsQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsVUFBVSxDQUFDLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FRbkY7SUFFRCxtQkFBbUIsQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsVUFBVSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBT3JGO0lBRUQsbUJBQW1CLENBQUMsTUFBTSxFQUFFLEVBQUUsRUFBRSxJQUFJLEVBQUUsRUFBRSxFQUFFLFVBQVUsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQU9yRjtJQUVEOzs7OztPQUtHO0lBQ0cscUJBQXFCLENBQUMsT0FBTyxFQUFFLFlBQVk7Ozs7T0FzQmhEO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/wallet/bundle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/wallet/bundle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAA2B,MAAM,0BAA0B,CAAC;AAG5G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,cAAc;IAC5C,OAAa,MAAM,CACjB,IAAI,EAAE,SAAS,EACf,iBAAiB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EACtC,OAAO,GAAE,kBAAoC,GAC5C,OAAO,CAAC,UAAU,CAAC,CAOrB;IAED,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAQnF;IAED,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOrF;IAED,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOrF;IAED;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAE,YAAY;;;;OAsBhD;CACF"}
|
package/dest/wallet/bundle.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
3
|
import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
|
|
4
|
+
import { SignerlessAccount } from '@aztec/aztec.js/account';
|
|
4
5
|
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
5
6
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
7
|
import { createPXE, getPXEConfig } from '@aztec/pxe/client/bundle';
|
|
@@ -46,15 +47,25 @@ import { BaseTestWallet } from './test_wallet.js';
|
|
|
46
47
|
};
|
|
47
48
|
return this.createAccount(accountData);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
52
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
53
|
+
* @param address - The address of the account to impersonate
|
|
54
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
55
|
+
*/ async getFakeAccountDataFor(address) {
|
|
51
56
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
57
|
+
// Account contracts can only be overridden if they have an associated address
|
|
58
|
+
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
59
|
+
// since it has no authorization mechanism.
|
|
60
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
61
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
62
|
+
}
|
|
52
63
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
53
|
-
const
|
|
64
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
54
65
|
if (!contractInstance) {
|
|
55
66
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
56
67
|
}
|
|
57
|
-
const stubAccount = createStubAccount(originalAddress
|
|
68
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
58
69
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
59
70
|
salt: Fr.random()
|
|
60
71
|
});
|
package/dest/wallet/lazy.d.ts
CHANGED
|
@@ -14,10 +14,16 @@ export declare class TestWallet extends BaseTestWallet {
|
|
|
14
14
|
createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager>;
|
|
15
15
|
createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
16
16
|
createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
19
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
20
|
+
* @param address - The address of the account to impersonate
|
|
21
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
22
|
+
*/
|
|
17
23
|
getFakeAccountDataFor(address: AztecAddress): Promise<{
|
|
18
|
-
account: import("
|
|
24
|
+
account: import("@aztec/aztec.js/account").BaseAccount;
|
|
19
25
|
instance: import("@aztec/aztec.js/contracts").ContractInstanceWithAddress;
|
|
20
|
-
artifact: import("
|
|
26
|
+
artifact: import("@aztec/stdlib/abi").ContractArtifact;
|
|
21
27
|
}>;
|
|
22
28
|
}
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3dhbGxldC9sYXp5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTlELE9BQU8sRUFBRSxFQUFFLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDaEQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdEQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ3hELE9BQU8sRUFBRSxLQUFLLFNBQVMsRUFBRSxLQUFLLGtCQUFrQixFQUEyQixNQUFNLHdCQUF3QixDQUFDO0FBRzFHLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUVsRDs7OztHQUlHO0FBQ0gscUJBQWEsVUFBVyxTQUFRLGNBQWM7SUFDNUMsT0FBYSxNQUFNLENBQ2pCLElBQUksRUFBRSxTQUFTLEVBQ2YsaUJBQWlCLENBQUMsRUFBRSxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQ3RDLE9BQU8sR0FBRSxrQkFBb0MsR0FDNUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQU9yQjtJQUVELG9CQUFvQixDQUFDLE1BQU0sRUFBRSxFQUFFLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxVQUFVLENBQUMsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQVFuRjtJQUVELG1CQUFtQixDQUFDLE1BQU0sRUFBRSxFQUFFLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxVQUFVLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FPckY7SUFFRCxtQkFBbUIsQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsVUFBVSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBT3JGO0lBRUQ7Ozs7O09BS0c7SUFDRyxxQkFBcUIsQ0FBQyxPQUFPLEVBQUUsWUFBWTs7OztPQXVCaEQ7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/wallet/lazy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/wallet/lazy.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAA2B,MAAM,wBAAwB,CAAC;AAG1G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,cAAc;IAC5C,OAAa,MAAM,CACjB,IAAI,EAAE,SAAS,EACf,iBAAiB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EACtC,OAAO,GAAE,kBAAoC,GAC5C,OAAO,CAAC,UAAU,CAAC,CAOrB;IAED,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAQnF;IAED,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOrF;IAED,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOrF;IAED;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAE,YAAY;;;;OAuBhD;CACF"}
|
package/dest/wallet/lazy.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa/lazy';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr/lazy';
|
|
3
3
|
import { createStubAccount, getStubAccountContractArtifact } from '@aztec/accounts/stub/lazy';
|
|
4
|
+
import { SignerlessAccount } from '@aztec/aztec.js/account';
|
|
4
5
|
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
5
6
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
7
|
import { createPXE, getPXEConfig } from '@aztec/pxe/client/lazy';
|
|
@@ -46,15 +47,25 @@ import { BaseTestWallet } from './test_wallet.js';
|
|
|
46
47
|
};
|
|
47
48
|
return this.createAccount(accountData);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
52
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
53
|
+
* @param address - The address of the account to impersonate
|
|
54
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
55
|
+
*/ async getFakeAccountDataFor(address) {
|
|
51
56
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
57
|
+
// Account contracts can only be overridden if they have an associated address
|
|
58
|
+
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
59
|
+
// since it has no authorization mechanism.
|
|
60
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
61
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
62
|
+
}
|
|
52
63
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
53
|
-
const
|
|
64
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
54
65
|
if (!contractInstance) {
|
|
55
66
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
56
67
|
}
|
|
57
|
-
const stubAccount = createStubAccount(originalAddress
|
|
68
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
58
69
|
const StubAccountContractArtifact = await getStubAccountContractArtifact();
|
|
59
70
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
60
71
|
salt: Fr.random()
|
package/dest/wallet/server.d.ts
CHANGED
|
@@ -14,10 +14,16 @@ export declare class TestWallet extends BaseTestWallet {
|
|
|
14
14
|
createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager>;
|
|
15
15
|
createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
16
16
|
createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
19
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
20
|
+
* @param address - The address of the account to impersonate
|
|
21
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
22
|
+
*/
|
|
17
23
|
getFakeAccountDataFor(address: AztecAddress): Promise<{
|
|
18
|
-
account: import("
|
|
24
|
+
account: import("@aztec/aztec.js/account").BaseAccount;
|
|
19
25
|
instance: import("@aztec/aztec.js/contracts").ContractInstanceWithAddress;
|
|
20
|
-
artifact: import("
|
|
26
|
+
artifact: import("@aztec/stdlib/abi").ContractArtifact;
|
|
21
27
|
}>;
|
|
22
28
|
}
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L3NlcnZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUU5RCxPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQUUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ2hELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUN4RCxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQUUsS0FBSyxrQkFBa0IsRUFBMkIsTUFBTSxtQkFBbUIsQ0FBQztBQUdyRyxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFbEQ7Ozs7R0FJRztBQUNILHFCQUFhLFVBQVcsU0FBUSxjQUFjO0lBQzVDLE9BQWEsTUFBTSxDQUNqQixJQUFJLEVBQUUsU0FBUyxFQUNmLGlCQUFpQixDQUFDLEVBQUUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUN0QyxPQUFPLEdBQUUsa0JBQW9DLEdBQzVDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FPckI7SUFFRCxvQkFBb0IsQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsVUFBVSxDQUFDLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FRbkY7SUFFRCxtQkFBbUIsQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsVUFBVSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBT3JGO0lBRUQsbUJBQW1CLENBQUMsTUFBTSxFQUFFLEVBQUUsRUFBRSxJQUFJLEVBQUUsRUFBRSxFQUFFLFVBQVUsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQU9yRjtJQUVEOzs7OztPQUtHO0lBQ0cscUJBQXFCLENBQUMsT0FBTyxFQUFFLFlBQVk7Ozs7T0FzQmhEO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/wallet/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/wallet/server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAA2B,MAAM,mBAAmB,CAAC;AAGrG,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,cAAc;IAC5C,OAAa,MAAM,CACjB,IAAI,EAAE,SAAS,EACf,iBAAiB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EACtC,OAAO,GAAE,kBAAoC,GAC5C,OAAO,CAAC,UAAU,CAAC,CAOrB;IAED,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAQnF;IAED,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOrF;IAED,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOrF;IAED;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAE,YAAY;;;;OAsBhD;CACF"}
|
package/dest/wallet/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
3
|
import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
|
|
4
|
+
import { SignerlessAccount } from '@aztec/aztec.js/account';
|
|
4
5
|
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
5
6
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
7
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
@@ -46,15 +47,25 @@ import { BaseTestWallet } from './test_wallet.js';
|
|
|
46
47
|
};
|
|
47
48
|
return this.createAccount(accountData);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
52
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
53
|
+
* @param address - The address of the account to impersonate
|
|
54
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
55
|
+
*/ async getFakeAccountDataFor(address) {
|
|
51
56
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
57
|
+
// Account contracts can only be overridden if they have an associated address
|
|
58
|
+
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
59
|
+
// since it has no authorization mechanism.
|
|
60
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
61
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
62
|
+
}
|
|
52
63
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
53
|
-
const
|
|
64
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
54
65
|
if (!contractInstance) {
|
|
55
66
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
56
67
|
}
|
|
57
|
-
const stubAccount = createStubAccount(originalAddress
|
|
68
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
58
69
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
59
70
|
salt: Fr.random()
|
|
60
71
|
});
|
|
@@ -2,12 +2,12 @@ import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
|
2
2
|
import { type Account, type AccountContract } from '@aztec/aztec.js/account';
|
|
3
3
|
import { type CallIntent, type ContractFunctionInteractionCallIntent, type IntentInnerHash, SetPublicAuthwitContractInteraction } from '@aztec/aztec.js/authorization';
|
|
4
4
|
import { AccountManager, type SendOptions, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
5
|
-
import { Fq, Fr } from '@aztec/foundation/
|
|
5
|
+
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
6
6
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
7
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
9
9
|
import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
|
|
10
|
-
import type { TxSimulationResult } from '@aztec/stdlib/tx';
|
|
10
|
+
import type { BlockHeader, TxHash, TxReceipt, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
11
11
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
12
12
|
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
13
13
|
import { ProvenTx } from '../utils.js';
|
|
@@ -55,7 +55,7 @@ export declare abstract class BaseTestWallet extends BaseWallet {
|
|
|
55
55
|
enableSimulatedSimulations(): void;
|
|
56
56
|
/** Disable the "simulated simulation" path for simulateTx. */
|
|
57
57
|
disableSimulatedSimulations(): void;
|
|
58
|
-
|
|
58
|
+
setMinFeePadding(value?: number): void;
|
|
59
59
|
protected getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
60
60
|
getAccounts(): Promise<{
|
|
61
61
|
alias: string;
|
|
@@ -102,9 +102,15 @@ export declare abstract class BaseTestWallet extends BaseWallet {
|
|
|
102
102
|
* of the provided account. This authwit can be verified
|
|
103
103
|
* by the account contract
|
|
104
104
|
* @param from - The address authorizing the action
|
|
105
|
-
* @param
|
|
105
|
+
* @param intent - The action to authorize
|
|
106
|
+
*/
|
|
107
|
+
createAuthWit(from: AztecAddress, intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent): Promise<AuthWitness>;
|
|
108
|
+
/**
|
|
109
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
110
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
111
|
+
* @param address - The address of the account to impersonate
|
|
112
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
106
113
|
*/
|
|
107
|
-
createAuthWit(from: AztecAddress, messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent): Promise<AuthWitness>;
|
|
108
114
|
abstract getFakeAccountDataFor(address: AztecAddress): Promise<{
|
|
109
115
|
account: Account;
|
|
110
116
|
instance: ContractInstanceWithAddress;
|
|
@@ -120,7 +126,14 @@ export declare abstract class BaseTestWallet extends BaseWallet {
|
|
|
120
126
|
* @param opts - The options to configure the interaction
|
|
121
127
|
* @returns - A proven tx ready to be sent to the network
|
|
122
128
|
*/
|
|
123
|
-
proveTx(exec: ExecutionPayload, opts: SendOptions): Promise<ProvenTx>;
|
|
129
|
+
proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx>;
|
|
130
|
+
/**
|
|
131
|
+
* Retrieves the transaction receipt for a given transaction hash.
|
|
132
|
+
* This is a passthrough to the underlying node, provided for convenience in testing.
|
|
133
|
+
* @param txHash - The hash of the transaction.
|
|
134
|
+
* @returns The transaction receipt.
|
|
135
|
+
*/
|
|
136
|
+
getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
|
|
124
137
|
/**
|
|
125
138
|
* A debugging utility to get notes based on the provided filter.
|
|
126
139
|
*
|
|
@@ -133,6 +146,13 @@ export declare abstract class BaseTestWallet extends BaseWallet {
|
|
|
133
146
|
* @returns The requested notes.
|
|
134
147
|
*/
|
|
135
148
|
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
149
|
+
/** Returns the block header up to which the wallet has synced. */
|
|
150
|
+
getSyncedBlockHeader(): Promise<BlockHeader>;
|
|
151
|
+
/**
|
|
152
|
+
* Triggers a sync of the wallet with the node to update the latest block header.
|
|
153
|
+
* Blocks until the sync is complete.
|
|
154
|
+
*/
|
|
155
|
+
sync(): Promise<void>;
|
|
136
156
|
/**
|
|
137
157
|
* Stops the internal job queue.
|
|
138
158
|
*
|
|
@@ -140,4 +160,4 @@ export declare abstract class BaseTestWallet extends BaseWallet {
|
|
|
140
160
|
*/
|
|
141
161
|
stop(): Prom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,CAAC,IAAI,CAAC,CAEpB;CACF"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
2
2
|
import { SignerlessAccount } from '@aztec/aztec.js/account';
|
|
3
|
-
import { SetPublicAuthwitContractInteraction,
|
|
3
|
+
import { SetPublicAuthwitContractInteraction, computeInnerAuthWitHashFromAction, isContractFunctionInteractionCallIntent, lookupValidity } from '@aztec/aztec.js/authorization';
|
|
4
4
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
5
|
-
import { Fr
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
6
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
8
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
8
9
|
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
@@ -34,21 +35,20 @@ import { ProvenTx } from '../utils.js';
|
|
|
34
35
|
/** Disable the "simulated simulation" path for simulateTx. */ disableSimulatedSimulations() {
|
|
35
36
|
this.simulatedSimulations = false;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
this.
|
|
38
|
+
setMinFeePadding(value) {
|
|
39
|
+
this.minFeePadding = value ?? 0.5;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
+
getAccountFromAddress(address) {
|
|
41
42
|
let account;
|
|
42
43
|
if (address.equals(AztecAddress.ZERO)) {
|
|
43
|
-
|
|
44
|
-
account = new SignerlessAccount(chainInfo);
|
|
44
|
+
account = new SignerlessAccount();
|
|
45
45
|
} else {
|
|
46
46
|
account = this.accounts.get(address?.toString() ?? '');
|
|
47
47
|
}
|
|
48
48
|
if (!account) {
|
|
49
49
|
throw new Error(`Account not found in wallet for address: ${address}`);
|
|
50
50
|
}
|
|
51
|
-
return account;
|
|
51
|
+
return Promise.resolve(account);
|
|
52
52
|
}
|
|
53
53
|
getAccounts() {
|
|
54
54
|
return Promise.resolve(Array.from(this.accounts.values()).map((acc)=>({
|
|
@@ -102,12 +102,22 @@ import { ProvenTx } from '../utils.js';
|
|
|
102
102
|
* of the provided account. This authwit can be verified
|
|
103
103
|
* by the account contract
|
|
104
104
|
* @param from - The address authorizing the action
|
|
105
|
-
* @param
|
|
106
|
-
*/ async createAuthWit(from,
|
|
105
|
+
* @param intent - The action to authorize
|
|
106
|
+
*/ async createAuthWit(from, intent) {
|
|
107
107
|
const account = await this.getAccountFromAddress(from);
|
|
108
108
|
const chainInfo = await this.getChainInfo();
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
let intentInnerHash;
|
|
110
|
+
if ('caller' in intent) {
|
|
111
|
+
const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
|
|
112
|
+
const innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
|
|
113
|
+
intentInnerHash = {
|
|
114
|
+
innerHash,
|
|
115
|
+
consumer: call.to
|
|
116
|
+
};
|
|
117
|
+
} else {
|
|
118
|
+
intentInnerHash = intent;
|
|
119
|
+
}
|
|
120
|
+
return account.createAuthWit(intentInnerHash, chainInfo);
|
|
111
121
|
}
|
|
112
122
|
async simulateTx(executionPayload, opts) {
|
|
113
123
|
if (!this.simulatedSimulations) {
|
|
@@ -125,7 +135,8 @@ import { ProvenTx } from '../utils.js';
|
|
|
125
135
|
executionPayload
|
|
126
136
|
]) : executionPayload;
|
|
127
137
|
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(opts.from);
|
|
128
|
-
const
|
|
138
|
+
const chainInfo = await this.getChainInfo();
|
|
139
|
+
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
129
140
|
const contractOverrides = {
|
|
130
141
|
[opts.from.toString()]: {
|
|
131
142
|
instance,
|
|
@@ -152,6 +163,14 @@ import { ProvenTx } from '../utils.js';
|
|
|
152
163
|
return new ProvenTx(this.aztecNode, await txProvingResult.toTx(), txProvingResult.getOffchainEffects(), txProvingResult.stats);
|
|
153
164
|
}
|
|
154
165
|
/**
|
|
166
|
+
* Retrieves the transaction receipt for a given transaction hash.
|
|
167
|
+
* This is a passthrough to the underlying node, provided for convenience in testing.
|
|
168
|
+
* @param txHash - The hash of the transaction.
|
|
169
|
+
* @returns The transaction receipt.
|
|
170
|
+
*/ getTxReceipt(txHash) {
|
|
171
|
+
return this.aztecNode.getTxReceipt(txHash);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
155
174
|
* A debugging utility to get notes based on the provided filter.
|
|
156
175
|
*
|
|
157
176
|
* Note that this should not be used in production code because the structure of notes is considered to be
|
|
@@ -162,7 +181,16 @@ import { ProvenTx } from '../utils.js';
|
|
|
162
181
|
* @param filter - The filter to apply to the notes.
|
|
163
182
|
* @returns The requested notes.
|
|
164
183
|
*/ getNotes(filter) {
|
|
165
|
-
return this.pxe.getNotes(filter);
|
|
184
|
+
return this.pxe.debug.getNotes(filter);
|
|
185
|
+
}
|
|
186
|
+
/** Returns the block header up to which the wallet has synced. */ getSyncedBlockHeader() {
|
|
187
|
+
return this.pxe.debug.getSyncedBlockHeader();
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Triggers a sync of the wallet with the node to update the latest block header.
|
|
191
|
+
* Blocks until the sync is complete.
|
|
192
|
+
*/ sync() {
|
|
193
|
+
return this.pxe.debug.sync();
|
|
166
194
|
}
|
|
167
195
|
/**
|
|
168
196
|
* Stops the internal job queue.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/test-wallet",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/test-wallet",
|
|
4
|
-
"version": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.e3c1de76",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./client/bundle": "./dest/bundle.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "yarn clean && ../scripts/tsc.sh",
|
|
19
19
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
20
|
-
"build:ts": "
|
|
20
|
+
"build:ts": "../scripts/tsc.sh",
|
|
21
21
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
22
22
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
23
23
|
},
|
|
@@ -62,20 +62,20 @@
|
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
66
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
67
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
68
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
69
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
70
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
71
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
72
|
-
"@aztec/wallet-sdk": "0.0.1-commit.
|
|
65
|
+
"@aztec/accounts": "0.0.1-commit.e3c1de76",
|
|
66
|
+
"@aztec/aztec.js": "0.0.1-commit.e3c1de76",
|
|
67
|
+
"@aztec/entrypoints": "0.0.1-commit.e3c1de76",
|
|
68
|
+
"@aztec/foundation": "0.0.1-commit.e3c1de76",
|
|
69
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.e3c1de76",
|
|
70
|
+
"@aztec/pxe": "0.0.1-commit.e3c1de76",
|
|
71
|
+
"@aztec/stdlib": "0.0.1-commit.e3c1de76",
|
|
72
|
+
"@aztec/wallet-sdk": "0.0.1-commit.e3c1de76"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@jest/globals": "^30.0.0",
|
|
76
76
|
"@types/jest": "^30.0.0",
|
|
77
77
|
"@types/node": "^22.15.17",
|
|
78
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
78
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
79
79
|
"jest": "^30.0.0",
|
|
80
80
|
"jest-mock-extended": "^4.0.0",
|
|
81
81
|
"resolve-typescript-plugin": "^2.0.1",
|
package/src/utils.ts
CHANGED
|
@@ -5,23 +5,44 @@ import {
|
|
|
5
5
|
ContractFunctionInteraction,
|
|
6
6
|
DeployMethod,
|
|
7
7
|
type DeployOptions,
|
|
8
|
+
NO_WAIT,
|
|
9
|
+
type NoWait,
|
|
8
10
|
type SendInteractionOptions,
|
|
9
|
-
SentTx,
|
|
10
11
|
type WaitOpts,
|
|
11
12
|
toSendOptions,
|
|
12
13
|
} from '@aztec/aztec.js/contracts';
|
|
13
|
-
import type
|
|
14
|
-
import {
|
|
14
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
15
|
+
import { SimulationError } from '@aztec/stdlib/errors';
|
|
16
|
+
import { type OffchainEffect, type ProvingStats, Tx, TxHash, type TxReceipt } from '@aztec/stdlib/tx';
|
|
17
|
+
|
|
18
|
+
import { inspect } from 'util';
|
|
15
19
|
|
|
16
20
|
import type { BaseTestWallet } from './wallet/test_wallet.js';
|
|
17
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Options for sending a proven transaction.
|
|
24
|
+
*/
|
|
25
|
+
export type ProvenTxSendOpts = {
|
|
26
|
+
/**
|
|
27
|
+
* Whether to wait for the transaction to be mined.
|
|
28
|
+
* - undefined (default): wait with default options and return TxReceipt
|
|
29
|
+
* - WaitOpts object: wait with custom options and return TxReceipt
|
|
30
|
+
* - NO_WAIT: return txHash immediately without waiting
|
|
31
|
+
*/
|
|
32
|
+
wait?: NoWait | WaitOpts;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Return type for ProvenTx.send based on wait option.
|
|
37
|
+
*/
|
|
38
|
+
export type ProvenTxSendReturn<T extends NoWait | WaitOpts | undefined> = T extends NoWait ? TxHash : TxReceipt;
|
|
39
|
+
|
|
18
40
|
/**
|
|
19
41
|
* Deploys the SchnorrAccount contracts backed by prefunded addresses
|
|
20
42
|
* at genesis. This can be directly used to pay for transactions in FeeJuice.
|
|
21
43
|
*/
|
|
22
44
|
export async function deployFundedSchnorrAccounts(
|
|
23
45
|
wallet: BaseTestWallet,
|
|
24
|
-
aztecNode: AztecNode,
|
|
25
46
|
accountsData: InitialAccountData[],
|
|
26
47
|
waitOptions?: WaitOpts,
|
|
27
48
|
) {
|
|
@@ -31,12 +52,11 @@ export async function deployFundedSchnorrAccounts(
|
|
|
31
52
|
const { secret, salt, signingKey } = accountsData[i];
|
|
32
53
|
const accountManager = await wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
33
54
|
const deployMethod = await accountManager.getDeployMethod();
|
|
34
|
-
await deployMethod
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.wait(waitOptions);
|
|
55
|
+
await deployMethod.send({
|
|
56
|
+
from: AztecAddress.ZERO,
|
|
57
|
+
skipClassPublication: i !== 0, // Publish the contract class at most once.
|
|
58
|
+
wait: waitOptions,
|
|
59
|
+
});
|
|
40
60
|
accountManagers.push(accountManager);
|
|
41
61
|
}
|
|
42
62
|
return accountManagers;
|
|
@@ -70,12 +90,37 @@ export class ProvenTx extends Tx {
|
|
|
70
90
|
super(tx.getTxHash(), tx.data, tx.chonkProof, tx.contractClassLogFields, tx.publicFunctionCalldata);
|
|
71
91
|
}
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Sends the transaction to the network.
|
|
95
|
+
* @param options - Send options including whether to wait.
|
|
96
|
+
* @returns The transaction receipt if waiting, or the transaction hash if not.
|
|
97
|
+
*/
|
|
98
|
+
send(options?: Omit<ProvenTxSendOpts, 'wait'>): Promise<TxReceipt>;
|
|
99
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
100
|
+
send<W extends ProvenTxSendOpts['wait']>(options: ProvenTxSendOpts & { wait: W }): Promise<ProvenTxSendReturn<W>>;
|
|
101
|
+
async send(options?: ProvenTxSendOpts): Promise<TxHash | TxReceipt> {
|
|
102
|
+
const txHash = this.getTxHash();
|
|
103
|
+
await this.node.sendTx(this).catch(err => {
|
|
104
|
+
throw this.contextualizeError(err, inspect(this));
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (options?.wait === NO_WAIT) {
|
|
108
|
+
return txHash;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const waitOpts = typeof options?.wait === 'object' ? options.wait : undefined;
|
|
112
|
+
return await waitForTx(this.node, txHash, waitOpts);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private contextualizeError(err: Error, ...context: string[]): Error {
|
|
116
|
+
let contextStr = '';
|
|
117
|
+
if (context.length > 0) {
|
|
118
|
+
contextStr = `\nContext:\n${context.join('\n')}`;
|
|
119
|
+
}
|
|
120
|
+
if (err instanceof SimulationError) {
|
|
121
|
+
err.setAztecContext(contextStr);
|
|
122
|
+
}
|
|
123
|
+
return err;
|
|
79
124
|
}
|
|
80
125
|
}
|
|
81
126
|
|
package/src/wallet/bundle.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
3
|
import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
|
|
4
|
+
import { type Account, SignerlessAccount } from '@aztec/aztec.js/account';
|
|
4
5
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
5
6
|
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
6
7
|
import { Fq, Fr } from '@aztec/aztec.js/fields';
|
|
@@ -58,15 +59,26 @@ export class TestWallet extends BaseTestWallet {
|
|
|
58
59
|
return this.createAccount(accountData);
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
64
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
65
|
+
* @param address - The address of the account to impersonate
|
|
66
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
67
|
+
*/
|
|
61
68
|
async getFakeAccountDataFor(address: AztecAddress) {
|
|
62
|
-
const chainInfo = await this.getChainInfo();
|
|
63
69
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
// Account contracts can only be overridden if they have an associated address
|
|
71
|
+
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
72
|
+
// since it has no authorization mechanism.
|
|
73
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
74
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
75
|
+
}
|
|
76
|
+
const originalAddress = (originalAccount as Account).getCompleteAddress();
|
|
77
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
66
78
|
if (!contractInstance) {
|
|
67
79
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
68
80
|
}
|
|
69
|
-
const stubAccount = createStubAccount(originalAddress
|
|
81
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
70
82
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
71
83
|
salt: Fr.random(),
|
|
72
84
|
});
|
package/src/wallet/lazy.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa/lazy';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr/lazy';
|
|
3
3
|
import { createStubAccount, getStubAccountContractArtifact } from '@aztec/accounts/stub/lazy';
|
|
4
|
+
import { type Account, SignerlessAccount } from '@aztec/aztec.js/account';
|
|
4
5
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
5
6
|
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
6
7
|
import { Fq, Fr } from '@aztec/aztec.js/fields';
|
|
@@ -58,15 +59,26 @@ export class TestWallet extends BaseTestWallet {
|
|
|
58
59
|
return this.createAccount(accountData);
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
64
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
65
|
+
* @param address - The address of the account to impersonate
|
|
66
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
67
|
+
*/
|
|
61
68
|
async getFakeAccountDataFor(address: AztecAddress) {
|
|
62
|
-
const chainInfo = await this.getChainInfo();
|
|
63
69
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
// Account contracts can only be overridden if they have an associated address
|
|
71
|
+
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
72
|
+
// since it has no authorization mechanism.
|
|
73
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
74
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
75
|
+
}
|
|
76
|
+
const originalAddress = (originalAccount as Account).getCompleteAddress();
|
|
77
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
66
78
|
if (!contractInstance) {
|
|
67
79
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
68
80
|
}
|
|
69
|
-
const stubAccount = createStubAccount(originalAddress
|
|
81
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
70
82
|
const StubAccountContractArtifact = await getStubAccountContractArtifact();
|
|
71
83
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
72
84
|
salt: Fr.random(),
|
package/src/wallet/server.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
3
|
import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
|
|
4
|
+
import { type Account, SignerlessAccount } from '@aztec/aztec.js/account';
|
|
4
5
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
5
6
|
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
6
7
|
import { Fq, Fr } from '@aztec/aztec.js/fields';
|
|
@@ -58,15 +59,26 @@ export class TestWallet extends BaseTestWallet {
|
|
|
58
59
|
return this.createAccount(accountData);
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
64
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
65
|
+
* @param address - The address of the account to impersonate
|
|
66
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
67
|
+
*/
|
|
61
68
|
async getFakeAccountDataFor(address: AztecAddress) {
|
|
62
|
-
const chainInfo = await this.getChainInfo();
|
|
63
69
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
// Account contracts can only be overridden if they have an associated address
|
|
71
|
+
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
72
|
+
// since it has no authorization mechanism.
|
|
73
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
74
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
75
|
+
}
|
|
76
|
+
const originalAddress = (originalAccount as Account).getCompleteAddress();
|
|
77
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
66
78
|
if (!contractInstance) {
|
|
67
79
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
68
80
|
}
|
|
69
|
-
const stubAccount = createStubAccount(originalAddress
|
|
81
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
70
82
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
71
83
|
salt: Fr.random(),
|
|
72
84
|
});
|
|
@@ -6,17 +6,19 @@ import {
|
|
|
6
6
|
type ContractFunctionInteractionCallIntent,
|
|
7
7
|
type IntentInnerHash,
|
|
8
8
|
SetPublicAuthwitContractInteraction,
|
|
9
|
-
|
|
9
|
+
computeInnerAuthWitHashFromAction,
|
|
10
|
+
isContractFunctionInteractionCallIntent,
|
|
10
11
|
lookupValidity,
|
|
11
12
|
} from '@aztec/aztec.js/authorization';
|
|
12
13
|
import { AccountManager, type SendOptions, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
13
14
|
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
14
|
-
import { Fq, Fr
|
|
15
|
+
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
16
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
15
17
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
16
18
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
17
19
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
18
20
|
import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
|
|
19
|
-
import type { TxSimulationResult } from '@aztec/stdlib/tx';
|
|
21
|
+
import type { BlockHeader, TxHash, TxReceipt, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
20
22
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
21
23
|
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
22
24
|
|
|
@@ -75,15 +77,14 @@ export abstract class BaseTestWallet extends BaseWallet {
|
|
|
75
77
|
this.simulatedSimulations = false;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
this.
|
|
80
|
+
setMinFeePadding(value?: number) {
|
|
81
|
+
this.minFeePadding = value ?? 0.5;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
protected
|
|
84
|
+
protected getAccountFromAddress(address: AztecAddress): Promise<Account> {
|
|
83
85
|
let account: Account | undefined;
|
|
84
86
|
if (address.equals(AztecAddress.ZERO)) {
|
|
85
|
-
|
|
86
|
-
account = new SignerlessAccount(chainInfo);
|
|
87
|
+
account = new SignerlessAccount();
|
|
87
88
|
} else {
|
|
88
89
|
account = this.accounts.get(address?.toString() ?? '');
|
|
89
90
|
}
|
|
@@ -92,7 +93,7 @@ export abstract class BaseTestWallet extends BaseWallet {
|
|
|
92
93
|
throw new Error(`Account not found in wallet for address: ${address}`);
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
return account;
|
|
96
|
+
return Promise.resolve(account);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
getAccounts() {
|
|
@@ -173,18 +174,33 @@ export abstract class BaseTestWallet extends BaseWallet {
|
|
|
173
174
|
* of the provided account. This authwit can be verified
|
|
174
175
|
* by the account contract
|
|
175
176
|
* @param from - The address authorizing the action
|
|
176
|
-
* @param
|
|
177
|
+
* @param intent - The action to authorize
|
|
177
178
|
*/
|
|
178
179
|
public override async createAuthWit(
|
|
179
180
|
from: AztecAddress,
|
|
180
|
-
|
|
181
|
+
intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
181
182
|
): Promise<AuthWitness> {
|
|
182
183
|
const account = await this.getAccountFromAddress(from);
|
|
183
184
|
const chainInfo = await this.getChainInfo();
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
let intentInnerHash: IntentInnerHash;
|
|
186
|
+
if ('caller' in intent) {
|
|
187
|
+
const call = isContractFunctionInteractionCallIntent(intent)
|
|
188
|
+
? await intent.action.getFunctionCall()
|
|
189
|
+
: intent.call;
|
|
190
|
+
const innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
|
|
191
|
+
intentInnerHash = { innerHash, consumer: call.to };
|
|
192
|
+
} else {
|
|
193
|
+
intentInnerHash = intent;
|
|
194
|
+
}
|
|
195
|
+
return account.createAuthWit(intentInnerHash, chainInfo);
|
|
186
196
|
}
|
|
187
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
200
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
201
|
+
* @param address - The address of the account to impersonate
|
|
202
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
203
|
+
*/
|
|
188
204
|
abstract getFakeAccountDataFor(
|
|
189
205
|
address: AztecAddress, // eslint-disable-next-line jsdoc/require-jsdoc
|
|
190
206
|
): Promise<{ account: Account; instance: ContractInstanceWithAddress; artifact: ContractArtifact }>;
|
|
@@ -206,9 +222,11 @@ export abstract class BaseTestWallet extends BaseWallet {
|
|
|
206
222
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
207
223
|
: executionPayload;
|
|
208
224
|
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(opts.from);
|
|
225
|
+
const chainInfo = await this.getChainInfo();
|
|
209
226
|
const txRequest = await fromAccount.createTxExecutionRequest(
|
|
210
227
|
finalExecutionPayload,
|
|
211
228
|
feeOptions.gasSettings,
|
|
229
|
+
chainInfo,
|
|
212
230
|
executionOptions,
|
|
213
231
|
);
|
|
214
232
|
const contractOverrides = {
|
|
@@ -227,7 +245,7 @@ export abstract class BaseTestWallet extends BaseWallet {
|
|
|
227
245
|
* @param opts - The options to configure the interaction
|
|
228
246
|
* @returns - A proven tx ready to be sent to the network
|
|
229
247
|
*/
|
|
230
|
-
async proveTx(exec: ExecutionPayload, opts: SendOptions): Promise<ProvenTx> {
|
|
248
|
+
async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
|
|
231
249
|
const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
|
|
232
250
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
|
|
233
251
|
const txProvingResult = await this.pxe.proveTx(txRequest);
|
|
@@ -239,6 +257,16 @@ export abstract class BaseTestWallet extends BaseWallet {
|
|
|
239
257
|
);
|
|
240
258
|
}
|
|
241
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Retrieves the transaction receipt for a given transaction hash.
|
|
262
|
+
* This is a passthrough to the underlying node, provided for convenience in testing.
|
|
263
|
+
* @param txHash - The hash of the transaction.
|
|
264
|
+
* @returns The transaction receipt.
|
|
265
|
+
*/
|
|
266
|
+
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
267
|
+
return this.aztecNode.getTxReceipt(txHash);
|
|
268
|
+
}
|
|
269
|
+
|
|
242
270
|
/**
|
|
243
271
|
* A debugging utility to get notes based on the provided filter.
|
|
244
272
|
*
|
|
@@ -251,7 +279,20 @@ export abstract class BaseTestWallet extends BaseWallet {
|
|
|
251
279
|
* @returns The requested notes.
|
|
252
280
|
*/
|
|
253
281
|
getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
254
|
-
return this.pxe.getNotes(filter);
|
|
282
|
+
return this.pxe.debug.getNotes(filter);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Returns the block header up to which the wallet has synced. */
|
|
286
|
+
getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
287
|
+
return this.pxe.debug.getSyncedBlockHeader();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Triggers a sync of the wallet with the node to update the latest block header.
|
|
292
|
+
* Blocks until the sync is complete.
|
|
293
|
+
*/
|
|
294
|
+
sync(): Promise<void> {
|
|
295
|
+
return this.pxe.debug.sync();
|
|
255
296
|
}
|
|
256
297
|
|
|
257
298
|
/**
|