@aztec/end-to-end 0.0.1-commit.e61ad554 → 0.0.1-commit.ec5f612
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/bench/client_flows/client_flows_benchmark.d.ts +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +3 -3
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +10 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +3 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts +15 -7
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +85 -41
- package/dest/e2e_fees/fees_test.d.ts +2 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +6 -6
- package/dest/e2e_l1_publisher/write_json.d.ts +3 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +1 -7
- package/dest/e2e_p2p/p2p_network.d.ts +2 -2
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +16 -2
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +177 -0
- package/dest/e2e_p2p/shared.d.ts +2 -2
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +7 -3
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +10 -0
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +30 -0
- package/dest/fixtures/e2e_prover_test.d.ts +4 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +28 -35
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +5 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +6 -0
- package/dest/fixtures/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +116 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +40 -24
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +79 -164
- package/dest/fixtures/setup_p2p_test.d.ts +16 -9
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +40 -29
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +3 -2
- package/dest/shared/index.d.ts +2 -1
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.js +10 -1
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- package/dest/shared/submit-transactions.d.ts +2 -2
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +8 -6
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -23
- package/dest/spartan/setup_test_wallets.d.ts +9 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +31 -1
- package/dest/spartan/tx_metrics.d.ts +35 -1
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +150 -0
- package/dest/spartan/utils/bot.d.ts +3 -2
- package/dest/spartan/utils/bot.d.ts.map +1 -1
- package/dest/spartan/utils/bot.js +2 -1
- package/dest/spartan/utils/config.d.ts +7 -1
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +3 -1
- package/dest/spartan/utils/index.d.ts +5 -4
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +4 -2
- package/dest/spartan/utils/k8s.d.ts +31 -1
- package/dest/spartan/utils/k8s.d.ts.map +1 -1
- package/dest/spartan/utils/k8s.js +124 -0
- package/dest/spartan/utils/nodes.d.ts +14 -5
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +204 -33
- package/dest/spartan/utils/scripts.d.ts +18 -4
- package/dest/spartan/utils/scripts.d.ts.map +1 -1
- package/dest/spartan/utils/scripts.js +19 -4
- package/dest/test-wallet/test_wallet.d.ts +83 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +214 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +71 -0
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +48 -0
- package/dest/test-wallet/worker_wallet.d.ts +52 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +151 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +10 -0
- package/package.json +43 -39
- package/src/bench/client_flows/client_flows_benchmark.ts +8 -12
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/utils.ts +1 -1
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +11 -2
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +7 -8
- package/src/e2e_deploy_contract/deploy_test.ts +3 -3
- package/src/e2e_epochs/epochs_test.ts +103 -72
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +12 -27
- package/src/e2e_l1_publisher/write_json.ts +1 -6
- package/src/e2e_nested_contract/nested_contract_test.ts +1 -1
- package/src/e2e_p2p/inactivity_slash_test.ts +4 -4
- package/src/e2e_p2p/p2p_network.ts +29 -7
- package/src/e2e_p2p/reqresp/utils.ts +235 -0
- package/src/e2e_p2p/shared.ts +13 -3
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +11 -2
- package/src/fixtures/authwit_proxy.ts +50 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +29 -39
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +10 -0
- package/src/fixtures/ha_setup.ts +186 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +103 -225
- package/src/fixtures/setup_p2p_test.ts +40 -44
- package/src/fixtures/token_utils.ts +2 -1
- package/src/guides/up_quick_start.sh +3 -3
- package/src/shared/index.ts +1 -0
- package/src/shared/jest_setup.ts +16 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +6 -2
- package/src/shared/uniswap_l1_l2.ts +9 -11
- package/src/simulators/token_simulator.ts +1 -29
- package/src/spartan/setup_test_wallets.ts +58 -4
- package/src/spartan/tx_metrics.ts +126 -0
- package/src/spartan/utils/bot.ts +4 -1
- package/src/spartan/utils/config.ts +2 -0
- package/src/spartan/utils/index.ts +7 -1
- package/src/spartan/utils/k8s.ts +160 -0
- package/src/spartan/utils/nodes.ts +251 -31
- package/src/spartan/utils/scripts.ts +43 -7
- package/src/test-wallet/test_wallet.ts +306 -0
- package/src/test-wallet/utils.ts +112 -0
- package/src/test-wallet/wallet_worker_script.ts +60 -0
- package/src/test-wallet/worker_wallet.ts +213 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
+
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
|
+
import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
|
|
4
|
+
import { type Account, type AccountContract, SignerlessAccount } from '@aztec/aztec.js/account';
|
|
5
|
+
import {
|
|
6
|
+
type CallIntent,
|
|
7
|
+
type ContractFunctionInteractionCallIntent,
|
|
8
|
+
type IntentInnerHash,
|
|
9
|
+
SetPublicAuthwitContractInteraction,
|
|
10
|
+
computeInnerAuthWitHashFromAction,
|
|
11
|
+
isContractFunctionInteractionCallIntent,
|
|
12
|
+
lookupValidity,
|
|
13
|
+
} from '@aztec/aztec.js/authorization';
|
|
14
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
15
|
+
import { AccountManager, type SendOptions } from '@aztec/aztec.js/wallet';
|
|
16
|
+
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
17
|
+
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
18
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
19
|
+
import type { AccessScopes, NotesFilter } from '@aztec/pxe/client/lazy';
|
|
20
|
+
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/config';
|
|
21
|
+
import { PXE, type PXECreationOptions, createPXE } from '@aztec/pxe/server';
|
|
22
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
23
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
24
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
25
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
26
|
+
import type { NoteDao } from '@aztec/stdlib/note';
|
|
27
|
+
import type { BlockHeader, TxHash, TxReceipt, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
28
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
29
|
+
import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
30
|
+
|
|
31
|
+
import { AztecNodeProxy, ProvenTx } from './utils.js';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Data for generating an account.
|
|
35
|
+
*/
|
|
36
|
+
export interface AccountData {
|
|
37
|
+
secret: Fr;
|
|
38
|
+
salt: Fr;
|
|
39
|
+
contract: AccountContract;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Wallet implementation that stores accounts in memory and provides extra debugging
|
|
44
|
+
* utilities
|
|
45
|
+
* It is intended to be used in e2e tests.
|
|
46
|
+
*/
|
|
47
|
+
export class TestWallet extends BaseWallet {
|
|
48
|
+
constructor(
|
|
49
|
+
pxe: PXE,
|
|
50
|
+
private readonly nodeRef: AztecNodeProxy,
|
|
51
|
+
) {
|
|
52
|
+
super(pxe, nodeRef);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static async create(
|
|
56
|
+
node: AztecNode,
|
|
57
|
+
overridePXEConfig?: Partial<PXEConfig>,
|
|
58
|
+
options: PXECreationOptions = { loggers: {} },
|
|
59
|
+
): Promise<TestWallet> {
|
|
60
|
+
const nodeRef = new AztecNodeProxy(node);
|
|
61
|
+
const pxeConfig = Object.assign(getPXEConfig(), {
|
|
62
|
+
proverEnabled: overridePXEConfig?.proverEnabled ?? false,
|
|
63
|
+
...overridePXEConfig,
|
|
64
|
+
});
|
|
65
|
+
const pxe = await createPXE(nodeRef, pxeConfig, options);
|
|
66
|
+
return new TestWallet(pxe, nodeRef);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Updates the underlying node that this wallet and its PXE communicate with.
|
|
71
|
+
* @param node - The new AztecNode to forward all calls to.
|
|
72
|
+
*/
|
|
73
|
+
updateNode(node: AztecNode): void {
|
|
74
|
+
this.nodeRef.updateTargetNode(node);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager> {
|
|
78
|
+
signingKey = signingKey ?? deriveSigningKey(secret);
|
|
79
|
+
const accountData = {
|
|
80
|
+
secret,
|
|
81
|
+
salt,
|
|
82
|
+
contract: new SchnorrAccountContract(signingKey),
|
|
83
|
+
};
|
|
84
|
+
return this.createAccount(accountData);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
|
|
88
|
+
const accountData = {
|
|
89
|
+
secret,
|
|
90
|
+
salt,
|
|
91
|
+
contract: new EcdsaRAccountContract(signingKey),
|
|
92
|
+
};
|
|
93
|
+
return this.createAccount(accountData);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
|
|
97
|
+
const accountData = {
|
|
98
|
+
secret,
|
|
99
|
+
salt,
|
|
100
|
+
contract: new EcdsaKAccountContract(signingKey),
|
|
101
|
+
};
|
|
102
|
+
return this.createAccount(accountData);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async getFakeAccountDataFor(address: AztecAddress) {
|
|
106
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
107
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
108
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
109
|
+
}
|
|
110
|
+
const originalAddress = (originalAccount as Account).getCompleteAddress();
|
|
111
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
112
|
+
if (!contractInstance) {
|
|
113
|
+
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
114
|
+
}
|
|
115
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
116
|
+
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
117
|
+
salt: Fr.random(),
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
account: stubAccount,
|
|
121
|
+
instance,
|
|
122
|
+
artifact: StubAccountContractArtifact,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
protected accounts: Map<string, Account> = new Map();
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Toggle for running "simulated simulations" when calling simulateTx.
|
|
129
|
+
*
|
|
130
|
+
* When this flag is true, simulateViaEntrypoint constructs a request using a fake account
|
|
131
|
+
* (and accepts contract overrides on the input) and the PXE emulates kernel effects without
|
|
132
|
+
* generating kernel witnesses. When false, simulateViaEntrypoint defers to the standard
|
|
133
|
+
* simulation path via the real account entrypoint.
|
|
134
|
+
*/
|
|
135
|
+
private simulatedSimulations = false;
|
|
136
|
+
|
|
137
|
+
enableSimulatedSimulations() {
|
|
138
|
+
this.simulatedSimulations = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
disableSimulatedSimulations() {
|
|
142
|
+
this.simulatedSimulations = false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
setMinFeePadding(value?: number) {
|
|
146
|
+
this.minFeePadding = value ?? 0.5;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
protected getAccountFromAddress(address: AztecAddress): Promise<Account> {
|
|
150
|
+
let account: Account | undefined;
|
|
151
|
+
if (address.equals(AztecAddress.ZERO)) {
|
|
152
|
+
account = new SignerlessAccount();
|
|
153
|
+
} else {
|
|
154
|
+
account = this.accounts.get(address?.toString() ?? '');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (!account) {
|
|
158
|
+
throw new Error(`Account not found in wallet for address: ${address}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return Promise.resolve(account);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
getAccounts() {
|
|
165
|
+
return Promise.resolve(Array.from(this.accounts.values()).map(acc => ({ alias: '', item: acc.getAddress() })));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async createAccount(accountData?: AccountData): Promise<AccountManager> {
|
|
169
|
+
const secret = accountData?.secret ?? Fr.random();
|
|
170
|
+
const salt = accountData?.salt ?? Fr.random();
|
|
171
|
+
const contract = accountData?.contract ?? new SchnorrAccountContract(GrumpkinScalar.random());
|
|
172
|
+
|
|
173
|
+
const accountManager = await AccountManager.create(this, secret, contract, salt);
|
|
174
|
+
|
|
175
|
+
const instance = accountManager.getInstance();
|
|
176
|
+
const artifact = await contract.getContractArtifact();
|
|
177
|
+
|
|
178
|
+
await this.registerContract(instance, artifact, secret);
|
|
179
|
+
|
|
180
|
+
this.accounts.set(accountManager.address.toString(), await accountManager.getAccount());
|
|
181
|
+
|
|
182
|
+
return accountManager;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
lookupValidity(
|
|
186
|
+
onBehalfOf: AztecAddress,
|
|
187
|
+
intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
188
|
+
witness: AuthWitness,
|
|
189
|
+
): Promise<{
|
|
190
|
+
isValidInPrivate: boolean;
|
|
191
|
+
isValidInPublic: boolean;
|
|
192
|
+
}> {
|
|
193
|
+
return lookupValidity(this, onBehalfOf, intent, witness);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public setPublicAuthWit(
|
|
197
|
+
from: AztecAddress,
|
|
198
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
199
|
+
authorized: boolean,
|
|
200
|
+
): Promise<SetPublicAuthwitContractInteraction> {
|
|
201
|
+
return SetPublicAuthwitContractInteraction.create(this, from, messageHashOrIntent, authorized);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
public override async createAuthWit(
|
|
205
|
+
from: AztecAddress,
|
|
206
|
+
intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
207
|
+
): Promise<AuthWitness> {
|
|
208
|
+
const account = await this.getAccountFromAddress(from);
|
|
209
|
+
const chainInfo = await this.getChainInfo();
|
|
210
|
+
let intentInnerHash: IntentInnerHash;
|
|
211
|
+
if ('caller' in intent) {
|
|
212
|
+
const call = isContractFunctionInteractionCallIntent(intent)
|
|
213
|
+
? await intent.action.getFunctionCall()
|
|
214
|
+
: intent.call;
|
|
215
|
+
const innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
|
|
216
|
+
intentInnerHash = { innerHash, consumer: call.to };
|
|
217
|
+
} else {
|
|
218
|
+
intentInnerHash = intent;
|
|
219
|
+
}
|
|
220
|
+
return account.createAuthWit(intentInnerHash, chainInfo);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Override simulateViaEntrypoint to use fake accounts for kernelless simulation
|
|
225
|
+
* when simulatedSimulations is enabled. Otherwise falls through to the real entrypoint path.
|
|
226
|
+
*/
|
|
227
|
+
protected override async simulateViaEntrypoint(
|
|
228
|
+
executionPayload: ExecutionPayload,
|
|
229
|
+
from: AztecAddress,
|
|
230
|
+
feeOptions: FeeOptions,
|
|
231
|
+
scopes: AccessScopes,
|
|
232
|
+
skipTxValidation?: boolean,
|
|
233
|
+
skipFeeEnforcement?: boolean,
|
|
234
|
+
): Promise<TxSimulationResult> {
|
|
235
|
+
if (!this.simulatedSimulations) {
|
|
236
|
+
return super.simulateViaEntrypoint(
|
|
237
|
+
executionPayload,
|
|
238
|
+
from,
|
|
239
|
+
feeOptions,
|
|
240
|
+
scopes,
|
|
241
|
+
skipTxValidation,
|
|
242
|
+
skipFeeEnforcement,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
247
|
+
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
248
|
+
txNonce: Fr.random(),
|
|
249
|
+
cancellable: this.cancellableTransactions,
|
|
250
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
251
|
+
};
|
|
252
|
+
const finalExecutionPayload = feeExecutionPayload
|
|
253
|
+
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
254
|
+
: executionPayload;
|
|
255
|
+
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
256
|
+
const chainInfo = await this.getChainInfo();
|
|
257
|
+
const txRequest = await fromAccount.createTxExecutionRequest(
|
|
258
|
+
finalExecutionPayload,
|
|
259
|
+
feeOptions.gasSettings,
|
|
260
|
+
chainInfo,
|
|
261
|
+
executionOptions,
|
|
262
|
+
);
|
|
263
|
+
const contractOverrides = {
|
|
264
|
+
[from.toString()]: { instance, artifact },
|
|
265
|
+
};
|
|
266
|
+
return this.pxe.simulateTx(txRequest, {
|
|
267
|
+
simulatePublic: true,
|
|
268
|
+
skipFeeEnforcement: true,
|
|
269
|
+
skipTxValidation: true,
|
|
270
|
+
overrides: { contracts: contractOverrides },
|
|
271
|
+
scopes,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
|
|
276
|
+
const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
|
|
277
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
|
|
278
|
+
const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
279
|
+
return new ProvenTx(
|
|
280
|
+
this.aztecNode,
|
|
281
|
+
await txProvingResult.toTx(),
|
|
282
|
+
txProvingResult.getOffchainEffects(),
|
|
283
|
+
txProvingResult.stats,
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
288
|
+
return this.aztecNode.getTxReceipt(txHash);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
292
|
+
return this.pxe.debug.getNotes(filter);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
296
|
+
return this.pxe.getSyncedBlockHeader();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
sync(): Promise<void> {
|
|
300
|
+
return this.pxe.debug.sync();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
stop(): Promise<void> {
|
|
304
|
+
return this.pxe.stop();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContractFunctionInteraction,
|
|
3
|
+
DeployMethod,
|
|
4
|
+
type DeployOptions,
|
|
5
|
+
NO_WAIT,
|
|
6
|
+
type NoWait,
|
|
7
|
+
type SendInteractionOptions,
|
|
8
|
+
type WaitOpts,
|
|
9
|
+
toSendOptions,
|
|
10
|
+
} from '@aztec/aztec.js/contracts';
|
|
11
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
12
|
+
import { SimulationError } from '@aztec/stdlib/errors';
|
|
13
|
+
import { type OffchainEffect, type ProvingStats, Tx, TxHash, type TxReceipt } from '@aztec/stdlib/tx';
|
|
14
|
+
|
|
15
|
+
import { inspect } from 'util';
|
|
16
|
+
|
|
17
|
+
import type { TestWallet } from './test_wallet.js';
|
|
18
|
+
|
|
19
|
+
export type ProvenTxSendOpts = {
|
|
20
|
+
wait?: NoWait | WaitOpts;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type ProvenTxSendReturn<T extends NoWait | WaitOpts | undefined> = T extends NoWait ? TxHash : TxReceipt;
|
|
24
|
+
|
|
25
|
+
export class ProvenTx extends Tx {
|
|
26
|
+
constructor(
|
|
27
|
+
private node: AztecNode,
|
|
28
|
+
tx: Tx,
|
|
29
|
+
public offchainEffects: OffchainEffect[],
|
|
30
|
+
public stats?: ProvingStats,
|
|
31
|
+
) {
|
|
32
|
+
super(tx.getTxHash(), tx.data, tx.chonkProof, tx.contractClassLogFields, tx.publicFunctionCalldata);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
send(options?: Omit<ProvenTxSendOpts, 'wait'>): Promise<TxReceipt>;
|
|
36
|
+
send<W extends ProvenTxSendOpts['wait']>(options: ProvenTxSendOpts & { wait: W }): Promise<ProvenTxSendReturn<W>>;
|
|
37
|
+
async send(options?: ProvenTxSendOpts): Promise<TxHash | TxReceipt> {
|
|
38
|
+
const txHash = this.getTxHash();
|
|
39
|
+
await this.node.sendTx(this).catch(err => {
|
|
40
|
+
throw this.contextualizeError(err, inspect(this));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (options?.wait === NO_WAIT) {
|
|
44
|
+
return txHash;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const waitOpts = typeof options?.wait === 'object' ? options.wait : undefined;
|
|
48
|
+
return await waitForTx(this.node, txHash, waitOpts);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private contextualizeError(err: Error, ...context: string[]): Error {
|
|
52
|
+
let contextStr = '';
|
|
53
|
+
if (context.length > 0) {
|
|
54
|
+
contextStr = `\nContext:\n${context.join('\n')}`;
|
|
55
|
+
}
|
|
56
|
+
if (err instanceof SimulationError) {
|
|
57
|
+
err.setAztecContext(contextStr);
|
|
58
|
+
}
|
|
59
|
+
return err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function proveInteraction(
|
|
64
|
+
wallet: TestWallet,
|
|
65
|
+
interaction: ContractFunctionInteraction | DeployMethod,
|
|
66
|
+
options: SendInteractionOptions | DeployOptions,
|
|
67
|
+
) {
|
|
68
|
+
let execPayload;
|
|
69
|
+
if (interaction instanceof DeployMethod) {
|
|
70
|
+
execPayload = await interaction.request(interaction.convertDeployOptionsToRequestOptions(options));
|
|
71
|
+
} else {
|
|
72
|
+
execPayload = await interaction.request(options);
|
|
73
|
+
}
|
|
74
|
+
return wallet.proveTx(execPayload, toSendOptions(options));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Extends AztecNode via declaration merging so instances can be used wherever AztecNode is expected.
|
|
79
|
+
* The actual method forwarding is handled by a Proxy in the class constructor.
|
|
80
|
+
*/
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
82
|
+
export interface AztecNodeProxy extends AztecNode {}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Mutable wrapper around an AztecNode that forwards all calls to the current target.
|
|
86
|
+
* Allows swapping the underlying node at runtime via updateTargetNode, which is useful
|
|
87
|
+
* for tests that need to redirect a wallet from one node to another without recreating it.
|
|
88
|
+
*/
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
90
|
+
export class AztecNodeProxy {
|
|
91
|
+
constructor(private target: AztecNode) {
|
|
92
|
+
return new Proxy(this, {
|
|
93
|
+
get: (obj, prop, receiver) => {
|
|
94
|
+
// Own properties and methods (updateTargetNode, target) are served directly.
|
|
95
|
+
if (Reflect.has(obj, prop)) {
|
|
96
|
+
return Reflect.get(obj, prop, receiver);
|
|
97
|
+
}
|
|
98
|
+
// Everything else is forwarded to the current target node.
|
|
99
|
+
const val = (obj.target as unknown as Record<string | symbol, unknown>)[prop];
|
|
100
|
+
return typeof val === 'function' ? val.bind(obj.target) : val;
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Updates the underlying node that this reference points to.
|
|
107
|
+
* @param node - The new node to forward calls to.
|
|
108
|
+
*/
|
|
109
|
+
updateTargetNode(node: AztecNode): void {
|
|
110
|
+
this.target = node;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
2
|
+
import type { SendOptions } from '@aztec/aztec.js/wallet';
|
|
3
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import type { ApiSchema, Fr } from '@aztec/foundation/schemas';
|
|
6
|
+
import { parseWithOptionals, schemaHasMethod } from '@aztec/foundation/schemas';
|
|
7
|
+
import { NodeListener, TransportServer } from '@aztec/foundation/transport';
|
|
8
|
+
import { ExecutionPayload, Tx } from '@aztec/stdlib/tx';
|
|
9
|
+
|
|
10
|
+
import { workerData } from 'worker_threads';
|
|
11
|
+
|
|
12
|
+
import { TestWallet } from './test_wallet.js';
|
|
13
|
+
import { WorkerWalletSchema } from './worker_wallet_schema.js';
|
|
14
|
+
|
|
15
|
+
const logger = createLogger('e2e:test-wallet:worker');
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const { nodeUrl, pxeConfig } = workerData as { nodeUrl: string; pxeConfig?: Record<string, unknown> };
|
|
19
|
+
|
|
20
|
+
logger.info('Initializing worker wallet', { nodeUrl });
|
|
21
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
22
|
+
const wallet = await TestWallet.create(node, pxeConfig);
|
|
23
|
+
logger.info('Worker wallet initialized');
|
|
24
|
+
|
|
25
|
+
const customMethods = {
|
|
26
|
+
proveTx: async (exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>) => {
|
|
27
|
+
const provenTx = await wallet.proveTx(exec, opts);
|
|
28
|
+
return new Tx(
|
|
29
|
+
provenTx.getTxHash(),
|
|
30
|
+
provenTx.data,
|
|
31
|
+
provenTx.chonkProof,
|
|
32
|
+
provenTx.contractClassLogFields,
|
|
33
|
+
provenTx.publicFunctionCalldata,
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
registerAccount: async (secret: Fr, salt: Fr) => {
|
|
37
|
+
const manager = await wallet.createSchnorrAccount(secret, salt);
|
|
38
|
+
return manager.address;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const schema = WorkerWalletSchema as ApiSchema;
|
|
43
|
+
const listener = new NodeListener();
|
|
44
|
+
const server = new TransportServer<{ fn: string; args: string }>(listener, async msg => {
|
|
45
|
+
if (!schemaHasMethod(schema, msg.fn)) {
|
|
46
|
+
throw new Error(`Unknown method: ${msg.fn}`);
|
|
47
|
+
}
|
|
48
|
+
const jsonParams = JSON.parse(msg.args) as unknown[];
|
|
49
|
+
const args: any[] = await parseWithOptionals(jsonParams, schema[msg.fn].parameters());
|
|
50
|
+
// we have to erase the fn type in order to be able to spread ...args
|
|
51
|
+
const handler: ((...args: any[]) => Promise<any>) | undefined =
|
|
52
|
+
msg.fn in customMethods ? customMethods[msg.fn as keyof typeof customMethods] : undefined;
|
|
53
|
+
const result = handler ? await handler(...args) : await (wallet as any)[msg.fn](...args);
|
|
54
|
+
return jsonStringify(result);
|
|
55
|
+
});
|
|
56
|
+
server.start();
|
|
57
|
+
} catch (err: unknown) {
|
|
58
|
+
logger.error('Worker wallet initialization failed', { error: err instanceof Error ? err.stack : String(err) });
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
2
|
+
import type { InteractionWaitOptions, SendReturn } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import type {
|
|
4
|
+
Aliased,
|
|
5
|
+
AppCapabilities,
|
|
6
|
+
BatchResults,
|
|
7
|
+
BatchedMethod,
|
|
8
|
+
ContractClassMetadata,
|
|
9
|
+
ContractMetadata,
|
|
10
|
+
ExecuteUtilityOptions,
|
|
11
|
+
PrivateEvent,
|
|
12
|
+
PrivateEventFilter,
|
|
13
|
+
ProfileOptions,
|
|
14
|
+
SendOptions,
|
|
15
|
+
SimulateOptions,
|
|
16
|
+
Wallet,
|
|
17
|
+
WalletCapabilities,
|
|
18
|
+
} from '@aztec/aztec.js/wallet';
|
|
19
|
+
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
20
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
21
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
22
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
23
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
24
|
+
import type { ApiSchema } from '@aztec/foundation/schemas';
|
|
25
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
26
|
+
import { NodeConnector, TransportClient } from '@aztec/foundation/transport';
|
|
27
|
+
import type { PXEConfig } from '@aztec/pxe/config';
|
|
28
|
+
import type { ContractArtifact, EventMetadataDefinition, FunctionCall } from '@aztec/stdlib/abi';
|
|
29
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
30
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
31
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
32
|
+
import type { ExecutionPayload, TxProfileResult, TxSimulationResult, UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
33
|
+
import { Tx } from '@aztec/stdlib/tx';
|
|
34
|
+
|
|
35
|
+
import { Worker } from 'worker_threads';
|
|
36
|
+
|
|
37
|
+
import { WorkerWalletSchema } from './worker_wallet_schema.js';
|
|
38
|
+
|
|
39
|
+
type WorkerMsg = { fn: string; args: string };
|
|
40
|
+
|
|
41
|
+
const log = createLogger('e2e:test-wallet:worker-wallet');
|
|
42
|
+
|
|
43
|
+
const WORKER_READY_TIMEOUT_MS = 120_000;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Wallet implementation that offloads all work to a worker thread.
|
|
47
|
+
* Implements the Wallet interface by proxying calls over a transport layer
|
|
48
|
+
* using JSON serialization with Zod schema parsing on both ends.
|
|
49
|
+
*/
|
|
50
|
+
export class WorkerWallet implements Wallet {
|
|
51
|
+
private constructor(
|
|
52
|
+
private worker: Worker,
|
|
53
|
+
private client: TransportClient<WorkerMsg>,
|
|
54
|
+
) {}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Creates a WorkerWallet by spawning a worker thread that creates a TestWallet internally.
|
|
58
|
+
* @param nodeUrl - URL of the Aztec node to connect to.
|
|
59
|
+
* @param pxeConfig - Optional PXE configuration overrides.
|
|
60
|
+
* @returns A WorkerWallet ready to use.
|
|
61
|
+
*/
|
|
62
|
+
static async create(nodeUrl: string, pxeConfig?: Partial<PXEConfig>): Promise<WorkerWallet> {
|
|
63
|
+
// replace stc/ with dest/ so the wallet works in Jest tests
|
|
64
|
+
const workerUrl = new URL('./wallet_worker_script.js', import.meta.url);
|
|
65
|
+
workerUrl.pathname = workerUrl.pathname.replace('/src/', '/dest/');
|
|
66
|
+
// remove JEST_WORKER_ID so the worker uses pino-pretty transport instead of Jest's raw output.
|
|
67
|
+
const { JEST_WORKER_ID: _, ...parentEnv } = process.env;
|
|
68
|
+
const worker = new Worker(workerUrl, {
|
|
69
|
+
workerData: { nodeUrl, pxeConfig },
|
|
70
|
+
env: {
|
|
71
|
+
...parentEnv,
|
|
72
|
+
...(process.stderr.isTTY || process.env.FORCE_COLOR ? { FORCE_COLOR: '1' } : {}),
|
|
73
|
+
LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? 'warn',
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const connector = new NodeConnector(worker);
|
|
78
|
+
const client = new TransportClient<WorkerMsg>(connector);
|
|
79
|
+
await client.open();
|
|
80
|
+
|
|
81
|
+
const wallet = new WorkerWallet(worker, client);
|
|
82
|
+
|
|
83
|
+
const { promise: workerDied, reject: rejectWorkerDied } = promiseWithResolvers<void>();
|
|
84
|
+
// reject if the worker exits or errors before the warmup completes.
|
|
85
|
+
const onError = (err: Error): void => {
|
|
86
|
+
worker.off('exit', onExit!);
|
|
87
|
+
rejectWorkerDied(new Error(`Worker wallet thread error: ${err.message}`));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const onExit = (code: number): void => {
|
|
91
|
+
worker.off('error', onError!);
|
|
92
|
+
rejectWorkerDied(new Error(`Worker wallet thread exited with code ${code} before becoming ready`));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
worker.once('error', onError);
|
|
96
|
+
worker.once('exit', onExit);
|
|
97
|
+
|
|
98
|
+
const timeout = sleep(WORKER_READY_TIMEOUT_MS).then(() => {
|
|
99
|
+
throw new Error(`Worker wallet creation timed out after ${WORKER_READY_TIMEOUT_MS / 1000}s`);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
// wait for worker wallet to start
|
|
104
|
+
await Promise.race([wallet.getChainInfo(), workerDied, timeout]);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
log.error('Worker wallet creation failed, cleaning up', { error: String(err) });
|
|
107
|
+
client.close();
|
|
108
|
+
await worker.terminate();
|
|
109
|
+
throw err;
|
|
110
|
+
} finally {
|
|
111
|
+
worker.off('error', onError);
|
|
112
|
+
worker.off('exit', onExit);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return wallet;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private async callRaw(fn: string, ...args: any[]): Promise<string> {
|
|
119
|
+
const argsJson = jsonStringify(args);
|
|
120
|
+
return (await this.client.request({ fn, args: argsJson })) as string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private async call(fn: string, ...args: any[]): Promise<any> {
|
|
124
|
+
const resultJson = await this.callRaw(fn, ...args);
|
|
125
|
+
const methodSchema = (WorkerWalletSchema as ApiSchema)[fn];
|
|
126
|
+
return methodSchema.returnType().parseAsync(JSON.parse(resultJson));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getChainInfo(): Promise<ChainInfo> {
|
|
130
|
+
return this.call('getChainInfo');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getContractMetadata(address: AztecAddress): Promise<ContractMetadata> {
|
|
134
|
+
return this.call('getContractMetadata', address);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
getContractClassMetadata(id: Fr): Promise<ContractClassMetadata> {
|
|
138
|
+
return this.call('getContractClassMetadata', id);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getPrivateEvents<T>(
|
|
142
|
+
eventMetadata: EventMetadataDefinition,
|
|
143
|
+
eventFilter: PrivateEventFilter,
|
|
144
|
+
): Promise<PrivateEvent<T>[]> {
|
|
145
|
+
return this.call('getPrivateEvents', eventMetadata, eventFilter);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress> {
|
|
149
|
+
return this.call('registerSender', address, alias);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
getAddressBook(): Promise<Aliased<AztecAddress>[]> {
|
|
153
|
+
return this.call('getAddressBook');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
getAccounts(): Promise<Aliased<AztecAddress>[]> {
|
|
157
|
+
return this.call('getAccounts');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
registerContract(
|
|
161
|
+
instance: ContractInstanceWithAddress,
|
|
162
|
+
artifact?: ContractArtifact,
|
|
163
|
+
secretKey?: Fr,
|
|
164
|
+
): Promise<ContractInstanceWithAddress> {
|
|
165
|
+
return this.call('registerContract', instance, artifact, secretKey);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
|
|
169
|
+
return this.call('simulateTx', exec, opts);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult> {
|
|
173
|
+
return this.call('executeUtility', call, opts);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
|
|
177
|
+
return this.call('profileTx', exec, opts);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
sendTx<W extends InteractionWaitOptions = undefined>(
|
|
181
|
+
exec: ExecutionPayload,
|
|
182
|
+
opts: SendOptions<W>,
|
|
183
|
+
): Promise<SendReturn<W>> {
|
|
184
|
+
return this.call('sendTx', exec, opts);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<Tx> {
|
|
188
|
+
return this.call('proveTx', exec, opts);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Registers an account inside the worker's TestWallet, populating its accounts map. */
|
|
192
|
+
registerAccount(secret: Fr, salt: Fr): Promise<AztecAddress> {
|
|
193
|
+
return this.call('registerAccount', secret, salt);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness> {
|
|
197
|
+
return this.call('createAuthWit', from, messageHashOrIntent);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
requestCapabilities(manifest: AppCapabilities): Promise<WalletCapabilities> {
|
|
201
|
+
return this.call('requestCapabilities', manifest);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>> {
|
|
205
|
+
return this.call('batch', methods);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Shuts down the worker thread and closes the transport. */
|
|
209
|
+
async stop(): Promise<void> {
|
|
210
|
+
this.client.close();
|
|
211
|
+
await this.worker.terminate();
|
|
212
|
+
}
|
|
213
|
+
}
|