@aztec/end-to-end 0.0.1-commit.43597cc1 → 0.0.1-commit.4ad48494d
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_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 +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +7 -2
- 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 +5 -5
- 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/shared.d.ts +2 -2
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +2 -1
- 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/e2e_prover_test.d.ts +2 -2
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.d.ts +1 -1
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +3 -1
- package/dest/fixtures/setup.d.ts +15 -15
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +20 -79
- 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 +1 -1
- 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 +2 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +3 -1
- package/dest/spartan/utils/bot.d.ts +1 -1
- package/dest/spartan/utils/bot.d.ts.map +1 -1
- package/dest/spartan/utils/bot.js +1 -1
- package/dest/test-wallet/test_wallet.d.ts +82 -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/package.json +40 -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 +4 -4
- package/src/e2e_deploy_contract/deploy_test.ts +3 -3
- package/src/e2e_epochs/epochs_test.ts +12 -3
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +11 -26
- 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 +5 -5
- package/src/e2e_p2p/reqresp/utils.ts +4 -4
- package/src/e2e_p2p/shared.ts +2 -1
- 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/e2e_prover_test.ts +4 -4
- package/src/fixtures/ha_setup.ts +3 -1
- package/src/fixtures/setup.ts +31 -109
- package/src/guides/up_quick_start.sh +3 -3
- package/src/shared/submit-transactions.ts +2 -1
- package/src/shared/uniswap_l1_l2.ts +2 -2
- package/src/simulators/token_simulator.ts +1 -29
- package/src/spartan/setup_test_wallets.ts +3 -1
- package/src/spartan/utils/bot.ts +1 -1
- package/src/test-wallet/test_wallet.ts +305 -0
- package/src/test-wallet/utils.ts +112 -0
|
@@ -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
|
+
}
|