@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.21caa21
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/benchmark.d.ts +61 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +261 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +80 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +334 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +77 -0
- package/dest/bench/utils.d.ts +12 -38
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +26 -66
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +21 -13
- 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 +85 -57
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -25
- 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 +50 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +16 -8
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +13 -19
- package/dest/e2e_epochs/epochs_test.d.ts +59 -18
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +226 -44
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +63 -0
- package/dest/e2e_fees/fees_test.d.ts +21 -10
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +103 -109
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +58 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +10 -7
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +24 -20
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +139 -0
- package/dest/e2e_p2p/p2p_network.d.ts +275 -23
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +184 -131
- package/dest/e2e_p2p/shared.d.ts +43 -7
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +164 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +12 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +50 -26
- package/dest/fixtures/e2e_prover_test.d.ts +63 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +104 -105
- package/dest/fixtures/fixtures.d.ts +6 -7
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +2 -14
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +9 -6
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +44 -18
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +476 -5
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +4 -4
- package/dest/fixtures/setup_p2p_test.d.ts +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +81 -21
- package/dest/fixtures/snapshot_manager.d.ts +17 -9
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +147 -121
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +28 -12
- package/dest/fixtures/utils.d.ts +524 -40
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +464 -369
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts +2 -2
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +39 -34
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +104 -50
- package/dest/shared/gas_portal_test_harness.d.ts +29 -31
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +6 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +14 -12
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +146 -116
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -11
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +15 -16
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +26 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +201 -58
- package/dest/spartan/utils.d.ts +116 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +434 -130
- package/package.json +65 -58
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +447 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +22 -76
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +65 -106
- package/src/e2e_deploy_contract/deploy_test.ts +24 -39
- package/src/e2e_epochs/epochs_test.ts +276 -55
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +142 -138
- package/src/e2e_l1_publisher/write_json.ts +77 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +29 -19
- package/src/e2e_p2p/inactivity_slash_test.ts +182 -0
- package/src/e2e_p2p/p2p_network.ts +279 -169
- package/src/e2e_p2p/shared.ts +247 -29
- package/src/e2e_token_contract/token_contract_test.ts +43 -39
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +107 -152
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +3 -11
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +6 -7
- package/src/fixtures/setup_p2p_test.ts +126 -38
- package/src/fixtures/snapshot_manager.ts +187 -139
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +580 -434
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +108 -79
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +181 -184
- package/src/simulators/lending_simulator.ts +14 -15
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +121 -0
- package/src/spartan/setup_test_wallets.ts +251 -93
- package/src/spartan/utils.ts +490 -130
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
-
import { type AccountWalletWithSecretKey, type AztecNode, type CheatCodes, type CompleteAddress, type DeployL1ContractsReturnType, EthAddress, type Logger } from '@aztec/aztec.js';
|
|
3
|
-
import { type ClientProtocolCircuitVerifier } from '@aztec/bb-prover';
|
|
4
|
-
import type { BlobSinkServer } from '@aztec/blob-sink/server';
|
|
5
|
-
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
|
-
import type { PXEService } from '@aztec/pxe/server';
|
|
7
|
-
import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
|
|
8
|
-
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
9
|
-
/**
|
|
10
|
-
* Largely taken from the e2e_token_contract test file. We deploy 2 accounts and a token contract.
|
|
11
|
-
* However, we then setup a second PXE with a full prover instance.
|
|
12
|
-
* We configure this instance with all of the accounts and contracts.
|
|
13
|
-
* We then prove and verify transactions created via this full prover PXE.
|
|
14
|
-
*/
|
|
15
|
-
export declare class FullProverTest {
|
|
16
|
-
private minNumberOfTxsPerBlock;
|
|
17
|
-
private realProofs;
|
|
18
|
-
static TOKEN_NAME: string;
|
|
19
|
-
static TOKEN_SYMBOL: string;
|
|
20
|
-
static TOKEN_DECIMALS: bigint;
|
|
21
|
-
private snapshotManager;
|
|
22
|
-
logger: Logger;
|
|
23
|
-
deployedAccounts: InitialAccountData[];
|
|
24
|
-
wallets: AccountWalletWithSecretKey[];
|
|
25
|
-
accounts: CompleteAddress[];
|
|
26
|
-
fakeProofsAsset: TokenContract;
|
|
27
|
-
tokenSim: TokenSimulator;
|
|
28
|
-
aztecNode: AztecNode;
|
|
29
|
-
pxe: PXEService;
|
|
30
|
-
cheatCodes: CheatCodes;
|
|
31
|
-
blobSink: BlobSinkServer;
|
|
32
|
-
private provenComponents;
|
|
33
|
-
private bbConfigCleanup?;
|
|
34
|
-
private acvmConfigCleanup?;
|
|
35
|
-
circuitProofVerifier?: ClientProtocolCircuitVerifier;
|
|
36
|
-
provenAssets: TokenContract[];
|
|
37
|
-
private context;
|
|
38
|
-
private proverNode;
|
|
39
|
-
private simulatedProverNode;
|
|
40
|
-
l1Contracts: DeployL1ContractsReturnType;
|
|
41
|
-
proverAddress: EthAddress;
|
|
42
|
-
constructor(testName: string, minNumberOfTxsPerBlock: number, coinbase: EthAddress, realProofs?: boolean);
|
|
43
|
-
/**
|
|
44
|
-
* Adds two state shifts to snapshot manager.
|
|
45
|
-
* 1. Add 2 accounts.
|
|
46
|
-
* 2. Publicly deploy accounts, deploy token contract
|
|
47
|
-
*/
|
|
48
|
-
applyBaseSnapshots(): Promise<void>;
|
|
49
|
-
setup(): Promise<this>;
|
|
50
|
-
private mintL1ERC20;
|
|
51
|
-
snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
|
|
52
|
-
teardown(): Promise<void>;
|
|
53
|
-
applyMintSnapshot(): Promise<void>;
|
|
54
|
-
deployVerifier(): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=e2e_prover_test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"e2e_prover_test.d.ts","sourceRoot":"","sources":["../../src/e2e_prover/e2e_prover_test.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,UAAU,EACV,KAAK,MAAM,EAIZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAqB,KAAK,6BAA6B,EAAuB,MAAM,kBAAkB,CAAC;AAE9G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQpD,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AASlE;;;;;GAKG;AAEH,qBAAa,cAAc;IA4BvB,OAAO,CAAC,sBAAsB;IAE9B,OAAO,CAAC,UAAU;IA7BpB,MAAM,CAAC,UAAU,SAAU;IAC3B,MAAM,CAAC,YAAY,SAAS;IAC5B,MAAM,CAAC,cAAc,SAAO;IAC5B,OAAO,CAAC,eAAe,CAAmB;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,kBAAkB,EAAE,CAAM;IAC5C,OAAO,EAAE,0BAA0B,EAAE,CAAM;IAC3C,QAAQ,EAAE,eAAe,EAAE,CAAM;IACjC,eAAe,EAAG,aAAa,CAAC;IAChC,QAAQ,EAAG,cAAc,CAAC;IAC1B,SAAS,EAAG,SAAS,CAAC;IACtB,GAAG,EAAG,UAAU,CAAC;IACjB,UAAU,EAAG,UAAU,CAAC;IACxB,QAAQ,EAAG,cAAc,CAAC;IAC1B,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,eAAe,CAAC,CAAsB;IAC9C,OAAO,CAAC,iBAAiB,CAAC,CAAsB;IAChD,oBAAoB,CAAC,EAAE,6BAA6B,CAAC;IACrD,YAAY,EAAE,aAAa,EAAE,CAAM;IACnC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,mBAAmB,CAAc;IAClC,WAAW,EAAG,2BAA2B,CAAC;IAC1C,aAAa,EAAG,UAAU,CAAC;gBAGhC,QAAQ,EAAE,MAAM,EACR,sBAAsB,EAAE,MAAM,EACtC,QAAQ,EAAE,UAAU,EACZ,UAAU,UAAO;IAW3B;;;;OAIG;IACG,kBAAkB;IAqDlB,KAAK;YA0JG,WAAW;IAQzB,QAAQ,YACA,MAAM,SACL,CAAC,OAAO,EAAE,iBAAiB,KAAK,QAAQ,CAAC,CAAC,YACxC,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,QAAQ,IAAI,CAAC,KACtE,QAAQ,IAAI,CAAC,CAAwD;IAElE,QAAQ;IAeR,iBAAiB;IAiDjB,cAAc;CA4BrB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// docs:start:all
|
|
2
|
-
import { createPXEClient } from '@aztec/aztec.js';
|
|
3
|
-
const { PXE_URL = 'http://localhost:8080' } = process.env;
|
|
4
|
-
async function main() {
|
|
5
|
-
const pxe = await createPXEClient(PXE_URL);
|
|
6
|
-
const { l1ChainId } = await pxe.getNodeInfo();
|
|
7
|
-
console.log(`Connected to chain ${l1ChainId}`);
|
|
8
|
-
}
|
|
9
|
-
main().catch((err)=>{
|
|
10
|
-
console.error(`Error in app: ${err}`);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}); // docs:end:all
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// docs:start:imports
|
|
2
|
-
import { AztecAddress } from '@aztec/aztec.js';
|
|
3
|
-
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
|
-
import { readFileSync } from 'fs';
|
|
5
|
-
// docs:end:imports
|
|
6
|
-
// docs:start:get-tokens
|
|
7
|
-
export async function getToken(wallet) {
|
|
8
|
-
const addresses = JSON.parse(readFileSync('addresses.json'));
|
|
9
|
-
return TokenContract.at(AztecAddress.fromString(addresses.token), wallet);
|
|
10
|
-
} // docs:end:get-tokens
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// docs:start:deploy-imports
|
|
2
|
-
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
|
|
3
|
-
import { Contract, createPXEClient, waitForPXE } from '@aztec/aztec.js';
|
|
4
|
-
// docs:end:deploy-imports
|
|
5
|
-
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
6
|
-
import { writeFileSync } from 'fs';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
// docs:start:dapp-deploy
|
|
9
|
-
const { PXE_URL = 'http://localhost:8080' } = process.env;
|
|
10
|
-
async function main() {
|
|
11
|
-
const pxe = createPXEClient(PXE_URL);
|
|
12
|
-
await waitForPXE(pxe);
|
|
13
|
-
const [ownerWallet] = await getInitialTestAccountsWallets(pxe);
|
|
14
|
-
const ownerAddress = ownerWallet.getAddress();
|
|
15
|
-
const token = await Contract.deploy(ownerWallet, TokenContractArtifact, [
|
|
16
|
-
ownerAddress,
|
|
17
|
-
'TokenName',
|
|
18
|
-
'TKN',
|
|
19
|
-
18
|
|
20
|
-
]).send().deployed();
|
|
21
|
-
console.log(`Token deployed at ${token.address.toString()}`);
|
|
22
|
-
const addresses = {
|
|
23
|
-
token: token.address.toString()
|
|
24
|
-
};
|
|
25
|
-
writeFileSync('addresses.json', JSON.stringify(addresses, null, 2));
|
|
26
|
-
}
|
|
27
|
-
// docs:end:dapp-deploy
|
|
28
|
-
// Execute main only if run directly
|
|
29
|
-
if (process.argv[1].replace(/\/index\.m?js$/, '') === fileURLToPath(import.meta.url).replace(/\/index\.m?js$/, '')) {
|
|
30
|
-
main().catch((err)=>{
|
|
31
|
-
console.error(`Error in deployment script: ${err}`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
export { main as deploy };
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// docs:start:imports
|
|
2
|
-
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
|
|
3
|
-
import { createPXEClient, waitForPXE } from '@aztec/aztec.js';
|
|
4
|
-
import { fileURLToPath } from '@aztec/foundation/url';
|
|
5
|
-
import { getToken } from './contracts.mjs';
|
|
6
|
-
// docs:end:imports
|
|
7
|
-
const { PXE_URL = 'http://localhost:8080' } = process.env;
|
|
8
|
-
// docs:start:showAccounts
|
|
9
|
-
async function showAccounts(pxe) {
|
|
10
|
-
const accounts = await pxe.getRegisteredAccounts();
|
|
11
|
-
console.log(`User accounts:\n${accounts.map((a)=>a.address).join('\n')}`);
|
|
12
|
-
}
|
|
13
|
-
// docs:end:showAccounts
|
|
14
|
-
// docs:start:showPrivateBalances
|
|
15
|
-
async function showPrivateBalances(pxe) {
|
|
16
|
-
const [owner] = await getInitialTestAccountsWallets(pxe);
|
|
17
|
-
const token = await getToken(owner);
|
|
18
|
-
const accounts = await pxe.getRegisteredAccounts();
|
|
19
|
-
for (const account of accounts){
|
|
20
|
-
// highlight-next-line:showPrivateBalances
|
|
21
|
-
const balance = await token.methods.balance_of_private(account.address).simulate();
|
|
22
|
-
console.log(`Balance of ${account.address}: ${balance}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// docs:end:showPrivateBalances
|
|
26
|
-
// docs:start:mintPrivateFunds
|
|
27
|
-
async function mintPrivateFunds(pxe) {
|
|
28
|
-
const [ownerWallet] = await getInitialTestAccountsWallets(pxe);
|
|
29
|
-
const token = await getToken(ownerWallet);
|
|
30
|
-
await showPrivateBalances(pxe);
|
|
31
|
-
// We mint tokens to the owner
|
|
32
|
-
const mintAmount = 20n;
|
|
33
|
-
const from = ownerWallet.getAddress(); // we are setting from to owner here because we need a sender to calculate the tag
|
|
34
|
-
await token.methods.mint_to_private(from, ownerWallet.getAddress(), mintAmount).send().wait();
|
|
35
|
-
await showPrivateBalances(pxe);
|
|
36
|
-
}
|
|
37
|
-
// docs:end:mintPrivateFunds
|
|
38
|
-
// docs:start:transferPrivateFunds
|
|
39
|
-
async function transferPrivateFunds(pxe) {
|
|
40
|
-
const [owner, recipient] = await getInitialTestAccountsWallets(pxe);
|
|
41
|
-
const token = await getToken(owner);
|
|
42
|
-
await showPrivateBalances(pxe);
|
|
43
|
-
console.log(`Sending transaction, awaiting transaction to be mined`);
|
|
44
|
-
const receipt = await token.methods.transfer(recipient.getAddress(), 1).send().wait();
|
|
45
|
-
console.log(`Transaction ${receipt.txHash} has been mined on block ${receipt.blockNumber}`);
|
|
46
|
-
await showPrivateBalances(pxe);
|
|
47
|
-
}
|
|
48
|
-
// docs:end:transferPrivateFunds
|
|
49
|
-
// docs:start:showPublicBalances
|
|
50
|
-
async function showPublicBalances(pxe) {
|
|
51
|
-
const [owner] = await getInitialTestAccountsWallets(pxe);
|
|
52
|
-
const token = await getToken(owner);
|
|
53
|
-
const accounts = await pxe.getRegisteredAccounts();
|
|
54
|
-
for (const account of accounts){
|
|
55
|
-
// highlight-next-line:showPublicBalances
|
|
56
|
-
const balance = await token.methods.balance_of_public(account.address).simulate();
|
|
57
|
-
console.log(`Balance of ${account.address}: ${balance}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// docs:end:showPublicBalances
|
|
61
|
-
// docs:start:mintPublicFunds
|
|
62
|
-
async function mintPublicFunds(pxe) {
|
|
63
|
-
const [owner] = await getInitialTestAccountsWallets(pxe);
|
|
64
|
-
const token = await getToken(owner);
|
|
65
|
-
await showPublicBalances(pxe);
|
|
66
|
-
console.log(`Sending transaction, awaiting transaction to be mined`);
|
|
67
|
-
const receipt = await token.methods.mint_to_public(owner.getAddress(), 100).send().wait();
|
|
68
|
-
console.log(`Transaction ${receipt.txHash} has been mined on block ${receipt.blockNumber}`);
|
|
69
|
-
await showPublicBalances(pxe);
|
|
70
|
-
// docs:start:showLogs
|
|
71
|
-
const blockNumber = await pxe.getBlockNumber();
|
|
72
|
-
const logs = (await pxe.getPublicLogs({
|
|
73
|
-
fromBlock: blockNumber - 1
|
|
74
|
-
})).logs;
|
|
75
|
-
const textLogs = logs.map((extendedLog)=>extendedLog.toHumanReadable().slice(0, 200));
|
|
76
|
-
for (const log of textLogs)console.log(`Log emitted: ${log}`);
|
|
77
|
-
// docs:end:showLogs
|
|
78
|
-
}
|
|
79
|
-
// docs:end:mintPublicFunds
|
|
80
|
-
async function main() {
|
|
81
|
-
const pxe = createPXEClient(PXE_URL);
|
|
82
|
-
await waitForPXE(pxe);
|
|
83
|
-
const { l1ChainId } = await pxe.getNodeInfo();
|
|
84
|
-
console.log(`Connected to chain ${l1ChainId}`);
|
|
85
|
-
await showAccounts(pxe);
|
|
86
|
-
await mintPrivateFunds(pxe);
|
|
87
|
-
await transferPrivateFunds(pxe);
|
|
88
|
-
await mintPublicFunds(pxe);
|
|
89
|
-
}
|
|
90
|
-
// Execute main only if run directly
|
|
91
|
-
if (process.argv[1].replace(/\/index\.m?js$/, '') === fileURLToPath(import.meta.url).replace(/\/index\.m?js$/, '')) {
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
93
|
-
main().then(()=>process.exit(0)).catch((err)=>{
|
|
94
|
-
console.error(`Error in app: ${err}`);
|
|
95
|
-
process.exit(1);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
export { main };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// docs:start:all
|
|
2
|
-
import { createPXEClient } from '@aztec/aztec.js';
|
|
3
|
-
|
|
4
|
-
const { PXE_URL = 'http://localhost:8080' } = process.env;
|
|
5
|
-
|
|
6
|
-
async function main() {
|
|
7
|
-
const pxe = await createPXEClient(PXE_URL);
|
|
8
|
-
const { l1ChainId } = await pxe.getNodeInfo();
|
|
9
|
-
console.log(`Connected to chain ${l1ChainId}`);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
main().catch(err => {
|
|
13
|
-
console.error(`Error in app: ${err}`);
|
|
14
|
-
process.exit(1);
|
|
15
|
-
});
|
|
16
|
-
// docs:end:all
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// docs:start:imports
|
|
2
|
-
import { AztecAddress } from '@aztec/aztec.js';
|
|
3
|
-
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
|
-
|
|
5
|
-
import { readFileSync } from 'fs';
|
|
6
|
-
|
|
7
|
-
// docs:end:imports
|
|
8
|
-
|
|
9
|
-
// docs:start:get-tokens
|
|
10
|
-
export async function getToken(wallet) {
|
|
11
|
-
const addresses = JSON.parse(readFileSync('addresses.json'));
|
|
12
|
-
return TokenContract.at(AztecAddress.fromString(addresses.token), wallet);
|
|
13
|
-
}
|
|
14
|
-
// docs:end:get-tokens
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// docs:start:deploy-imports
|
|
2
|
-
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
|
|
3
|
-
import { Contract, createPXEClient, loadContractArtifact, waitForPXE } from '@aztec/aztec.js';
|
|
4
|
-
// docs:end:deploy-imports
|
|
5
|
-
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
6
|
-
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
7
|
-
|
|
8
|
-
import { writeFileSync } from 'fs';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
|
|
11
|
-
// docs:start:dapp-deploy
|
|
12
|
-
const { PXE_URL = 'http://localhost:8080' } = process.env;
|
|
13
|
-
|
|
14
|
-
async function main() {
|
|
15
|
-
const pxe = createPXEClient(PXE_URL);
|
|
16
|
-
await waitForPXE(pxe);
|
|
17
|
-
|
|
18
|
-
const [ownerWallet] = await getInitialTestAccountsWallets(pxe);
|
|
19
|
-
const ownerAddress = ownerWallet.getAddress();
|
|
20
|
-
|
|
21
|
-
const token = await Contract.deploy(ownerWallet, TokenContractArtifact, [ownerAddress, 'TokenName', 'TKN', 18])
|
|
22
|
-
.send()
|
|
23
|
-
.deployed();
|
|
24
|
-
|
|
25
|
-
console.log(`Token deployed at ${token.address.toString()}`);
|
|
26
|
-
|
|
27
|
-
const addresses = { token: token.address.toString() };
|
|
28
|
-
writeFileSync('addresses.json', JSON.stringify(addresses, null, 2));
|
|
29
|
-
}
|
|
30
|
-
// docs:end:dapp-deploy
|
|
31
|
-
|
|
32
|
-
// Execute main only if run directly
|
|
33
|
-
if (process.argv[1].replace(/\/index\.m?js$/, '') === fileURLToPath(import.meta.url).replace(/\/index\.m?js$/, '')) {
|
|
34
|
-
main().catch(err => {
|
|
35
|
-
console.error(`Error in deployment script: ${err}`);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { main as deploy };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// docs:start:imports
|
|
2
|
-
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
|
|
3
|
-
import { createPXEClient, waitForPXE } from '@aztec/aztec.js';
|
|
4
|
-
import { fileURLToPath } from '@aztec/foundation/url';
|
|
5
|
-
|
|
6
|
-
import { getToken } from './contracts.mjs';
|
|
7
|
-
|
|
8
|
-
// docs:end:imports
|
|
9
|
-
|
|
10
|
-
const { PXE_URL = 'http://localhost:8080' } = process.env;
|
|
11
|
-
|
|
12
|
-
// docs:start:showAccounts
|
|
13
|
-
async function showAccounts(pxe) {
|
|
14
|
-
const accounts = await pxe.getRegisteredAccounts();
|
|
15
|
-
console.log(`User accounts:\n${accounts.map(a => a.address).join('\n')}`);
|
|
16
|
-
}
|
|
17
|
-
// docs:end:showAccounts
|
|
18
|
-
|
|
19
|
-
// docs:start:showPrivateBalances
|
|
20
|
-
async function showPrivateBalances(pxe) {
|
|
21
|
-
const [owner] = await getInitialTestAccountsWallets(pxe);
|
|
22
|
-
const token = await getToken(owner);
|
|
23
|
-
|
|
24
|
-
const accounts = await pxe.getRegisteredAccounts();
|
|
25
|
-
|
|
26
|
-
for (const account of accounts) {
|
|
27
|
-
// highlight-next-line:showPrivateBalances
|
|
28
|
-
const balance = await token.methods.balance_of_private(account.address).simulate();
|
|
29
|
-
console.log(`Balance of ${account.address}: ${balance}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// docs:end:showPrivateBalances
|
|
33
|
-
|
|
34
|
-
// docs:start:mintPrivateFunds
|
|
35
|
-
async function mintPrivateFunds(pxe) {
|
|
36
|
-
const [ownerWallet] = await getInitialTestAccountsWallets(pxe);
|
|
37
|
-
const token = await getToken(ownerWallet);
|
|
38
|
-
|
|
39
|
-
await showPrivateBalances(pxe);
|
|
40
|
-
|
|
41
|
-
// We mint tokens to the owner
|
|
42
|
-
const mintAmount = 20n;
|
|
43
|
-
const from = ownerWallet.getAddress(); // we are setting from to owner here because we need a sender to calculate the tag
|
|
44
|
-
await token.methods.mint_to_private(from, ownerWallet.getAddress(), mintAmount).send().wait();
|
|
45
|
-
|
|
46
|
-
await showPrivateBalances(pxe);
|
|
47
|
-
}
|
|
48
|
-
// docs:end:mintPrivateFunds
|
|
49
|
-
|
|
50
|
-
// docs:start:transferPrivateFunds
|
|
51
|
-
async function transferPrivateFunds(pxe) {
|
|
52
|
-
const [owner, recipient] = await getInitialTestAccountsWallets(pxe);
|
|
53
|
-
const token = await getToken(owner);
|
|
54
|
-
|
|
55
|
-
await showPrivateBalances(pxe);
|
|
56
|
-
console.log(`Sending transaction, awaiting transaction to be mined`);
|
|
57
|
-
const receipt = await token.methods.transfer(recipient.getAddress(), 1).send().wait();
|
|
58
|
-
|
|
59
|
-
console.log(`Transaction ${receipt.txHash} has been mined on block ${receipt.blockNumber}`);
|
|
60
|
-
await showPrivateBalances(pxe);
|
|
61
|
-
}
|
|
62
|
-
// docs:end:transferPrivateFunds
|
|
63
|
-
|
|
64
|
-
// docs:start:showPublicBalances
|
|
65
|
-
async function showPublicBalances(pxe) {
|
|
66
|
-
const [owner] = await getInitialTestAccountsWallets(pxe);
|
|
67
|
-
const token = await getToken(owner);
|
|
68
|
-
|
|
69
|
-
const accounts = await pxe.getRegisteredAccounts();
|
|
70
|
-
|
|
71
|
-
for (const account of accounts) {
|
|
72
|
-
// highlight-next-line:showPublicBalances
|
|
73
|
-
const balance = await token.methods.balance_of_public(account.address).simulate();
|
|
74
|
-
console.log(`Balance of ${account.address}: ${balance}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// docs:end:showPublicBalances
|
|
78
|
-
|
|
79
|
-
// docs:start:mintPublicFunds
|
|
80
|
-
async function mintPublicFunds(pxe) {
|
|
81
|
-
const [owner] = await getInitialTestAccountsWallets(pxe);
|
|
82
|
-
const token = await getToken(owner);
|
|
83
|
-
|
|
84
|
-
await showPublicBalances(pxe);
|
|
85
|
-
|
|
86
|
-
console.log(`Sending transaction, awaiting transaction to be mined`);
|
|
87
|
-
const receipt = await token.methods.mint_to_public(owner.getAddress(), 100).send().wait();
|
|
88
|
-
console.log(`Transaction ${receipt.txHash} has been mined on block ${receipt.blockNumber}`);
|
|
89
|
-
|
|
90
|
-
await showPublicBalances(pxe);
|
|
91
|
-
|
|
92
|
-
// docs:start:showLogs
|
|
93
|
-
const blockNumber = await pxe.getBlockNumber();
|
|
94
|
-
const logs = (await pxe.getPublicLogs({ fromBlock: blockNumber - 1 })).logs;
|
|
95
|
-
const textLogs = logs.map(extendedLog => extendedLog.toHumanReadable().slice(0, 200));
|
|
96
|
-
for (const log of textLogs) console.log(`Log emitted: ${log}`);
|
|
97
|
-
// docs:end:showLogs
|
|
98
|
-
}
|
|
99
|
-
// docs:end:mintPublicFunds
|
|
100
|
-
|
|
101
|
-
async function main() {
|
|
102
|
-
const pxe = createPXEClient(PXE_URL);
|
|
103
|
-
await waitForPXE(pxe);
|
|
104
|
-
|
|
105
|
-
const { l1ChainId } = await pxe.getNodeInfo();
|
|
106
|
-
console.log(`Connected to chain ${l1ChainId}`);
|
|
107
|
-
|
|
108
|
-
await showAccounts(pxe);
|
|
109
|
-
|
|
110
|
-
await mintPrivateFunds(pxe);
|
|
111
|
-
|
|
112
|
-
await transferPrivateFunds(pxe);
|
|
113
|
-
|
|
114
|
-
await mintPublicFunds(pxe);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Execute main only if run directly
|
|
118
|
-
if (process.argv[1].replace(/\/index\.m?js$/, '') === fileURLToPath(import.meta.url).replace(/\/index\.m?js$/, '')) {
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
120
|
-
main()
|
|
121
|
-
.then(() => process.exit(0))
|
|
122
|
-
.catch(err => {
|
|
123
|
-
console.error(`Error in app: ${err}`);
|
|
124
|
-
process.exit(1);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export { main };
|