@aztec/aztec 0.0.0-test.1 → 0.0.1-commit.017a351
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/README.md +1 -1
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +28 -13
- package/dest/cli/admin_api_key_store.d.ts +45 -0
- package/dest/cli/admin_api_key_store.d.ts.map +1 -0
- package/dest/cli/admin_api_key_store.js +98 -0
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +107 -49
- package/dest/cli/aztec_start_options.d.ts +6 -4
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +160 -223
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +11 -7
- package/dest/cli/cmds/compile.d.ts +4 -0
- package/dest/cli/cmds/compile.d.ts.map +1 -0
- package/dest/cli/cmds/compile.js +166 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
- package/dest/cli/cmds/migrate_ha_db.js +27 -0
- package/dest/cli/cmds/profile.d.ts +4 -0
- package/dest/cli/cmds/profile.d.ts.map +1 -0
- package/dest/cli/cmds/profile.js +8 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
- package/dest/cli/cmds/profile_flamegraph.js +52 -0
- package/dest/cli/cmds/profile_gates.d.ts +4 -0
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
- package/dest/cli/cmds/profile_gates.js +76 -0
- package/dest/cli/cmds/profile_utils.d.ts +18 -0
- package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
- package/dest/cli/cmds/profile_utils.js +50 -0
- package/dest/cli/cmds/standby.d.ts +30 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +97 -0
- package/dest/cli/cmds/start_bot.d.ts +4 -7
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +32 -17
- package/dest/cli/cmds/start_node.d.ts +3 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +113 -86
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.js +10 -6
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +29 -12
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +25 -10
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +6 -5
- package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
- package/dest/cli/cmds/utils/artifacts.js +24 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
- package/dest/cli/cmds/utils/needs_recompile.js +90 -0
- package/dest/cli/cmds/utils/spawn.d.ts +3 -0
- package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
- package/dest/cli/cmds/utils/spawn.js +16 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
- package/dest/cli/index.d.ts +1 -1
- package/dest/cli/preload_crs.d.ts +3 -0
- package/dest/cli/preload_crs.d.ts.map +1 -0
- package/dest/cli/preload_crs.js +6 -0
- package/dest/cli/util.d.ts +37 -17
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +171 -35
- package/dest/cli/versioning.d.ts +1 -1
- package/dest/cli/versioning.js +3 -3
- package/dest/examples/token.d.ts +1 -1
- package/dest/examples/token.js +31 -18
- package/dest/examples/util.d.ts +5 -6
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/examples/util.js +5 -6
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +11 -0
- package/dest/local-network/banana_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/banana_fpc.js +29 -27
- package/dest/local-network/index.d.ts +4 -0
- package/dest/local-network/index.d.ts.map +1 -0
- package/dest/local-network/index.js +3 -0
- package/dest/local-network/local-network.d.ts +50 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/local-network/local-network.js +248 -0
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/local-network/sponsored_fpc.js +18 -0
- package/dest/mnemonic.d.ts +1 -1
- package/dest/splash.d.ts +1 -1
- package/dest/testing/anvil_test_watcher.d.ts +54 -0
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
- package/dest/testing/anvil_test_watcher.js +235 -0
- package/dest/testing/cheat_codes.d.ts +44 -0
- package/dest/testing/cheat_codes.d.ts.map +1 -0
- package/dest/testing/cheat_codes.js +98 -0
- package/dest/testing/epoch_test_settler.d.ts +19 -0
- package/dest/testing/epoch_test_settler.d.ts.map +1 -0
- package/dest/testing/epoch_test_settler.js +63 -0
- package/dest/testing/index.d.ts +6 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +5 -0
- package/dest/testing/token_allowed_setup.d.ts +7 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +20 -0
- package/package.json +56 -45
- package/scripts/add_crate.sh +53 -0
- package/scripts/aztec.sh +73 -0
- package/scripts/init.sh +39 -0
- package/scripts/new.sh +83 -0
- package/scripts/setup_workspace.sh +69 -0
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/bin/index.ts +33 -13
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +100 -46
- package/src/cli/aztec_start_options.ts +183 -226
- package/src/cli/cli.ts +19 -11
- package/src/cli/cmds/compile.ts +192 -0
- package/src/cli/cmds/migrate_ha_db.ts +43 -0
- package/src/cli/cmds/profile.ts +26 -0
- package/src/cli/cmds/profile_flamegraph.ts +64 -0
- package/src/cli/cmds/profile_gates.ts +84 -0
- package/src/cli/cmds/profile_utils.ts +58 -0
- package/src/cli/cmds/standby.ts +132 -0
- package/src/cli/cmds/start_bot.ts +43 -19
- package/src/cli/cmds/start_node.ts +142 -91
- package/src/cli/cmds/start_p2p_bootstrap.ts +14 -6
- package/src/cli/cmds/start_prover_agent.ts +25 -16
- package/src/cli/cmds/start_prover_broker.ts +32 -9
- package/src/cli/cmds/start_txe.ts +7 -5
- package/src/cli/cmds/utils/artifacts.ts +44 -0
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +98 -0
- package/src/cli/cmds/utils/spawn.ts +16 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
- package/src/cli/preload_crs.ts +7 -0
- package/src/cli/util.ts +192 -56
- package/src/cli/versioning.ts +3 -3
- package/src/examples/token.ts +23 -19
- package/src/examples/util.ts +6 -8
- package/src/index.ts +5 -6
- package/src/local-network/auth_registry.ts +19 -0
- package/src/{sandbox → local-network}/banana_fpc.ts +32 -29
- package/src/local-network/index.ts +7 -0
- package/src/local-network/local-network.ts +303 -0
- package/src/local-network/sponsored_fpc.ts +26 -0
- package/src/testing/anvil_test_watcher.ts +273 -0
- package/src/testing/cheat_codes.ts +132 -0
- package/src/testing/epoch_test_settler.ts +69 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/token_allowed_setup.ts +19 -0
- package/dest/cli/chain_l2_config.d.ts +0 -19
- package/dest/cli/chain_l2_config.d.ts.map +0 -1
- package/dest/cli/chain_l2_config.js +0 -56
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -42
- package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
- package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
- package/dest/cli/cmds/start_blob_sink.js +0 -17
- package/dest/cli/cmds/start_faucet.d.ts +0 -4
- package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
- package/dest/cli/cmds/start_faucet.js +0 -20
- package/dest/cli/cmds/start_prover_node.d.ts +0 -7
- package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
- package/dest/cli/cmds/start_prover_node.js +0 -110
- package/dest/cli/cmds/start_pxe.d.ts +0 -16
- package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
- package/dest/cli/cmds/start_pxe.js +0 -95
- package/dest/cli/get_l1_config.d.ts +0 -7
- package/dest/cli/get_l1_config.d.ts.map +0 -1
- package/dest/cli/get_l1_config.js +0 -13
- package/dest/sandbox/banana_fpc.d.ts +0 -11
- package/dest/sandbox/banana_fpc.d.ts.map +0 -1
- package/dest/sandbox/index.d.ts +0 -5
- package/dest/sandbox/index.d.ts.map +0 -1
- package/dest/sandbox/index.js +0 -4
- package/dest/sandbox/sandbox.d.ts +0 -76
- package/dest/sandbox/sandbox.d.ts.map +0 -1
- package/dest/sandbox/sandbox.js +0 -181
- package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
- package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
- package/dest/sandbox/sponsored_fpc.d.ts +0 -6
- package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fpc.js +0 -26
- package/src/cli/chain_l2_config.ts +0 -74
- package/src/cli/cmds/start_archiver.ts +0 -55
- package/src/cli/cmds/start_blob_sink.ts +0 -31
- package/src/cli/cmds/start_faucet.ts +0 -34
- package/src/cli/cmds/start_prover_node.ts +0 -121
- package/src/cli/cmds/start_pxe.ts +0 -129
- package/src/cli/get_l1_config.ts +0 -18
- package/src/sandbox/index.ts +0 -5
- package/src/sandbox/sandbox.ts +0 -229
- package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
- package/src/sandbox/sponsored_fpc.ts +0 -38
package/src/examples/token.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
5
6
|
|
|
6
7
|
const logger = createLogger('example:token');
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
+
const nodeUrl = 'http://localhost:8080';
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
11
12
|
|
|
12
13
|
const ALICE_MINT_BALANCE = 333n;
|
|
13
14
|
const TRANSFER_AMOUNT = 33n;
|
|
@@ -18,39 +19,42 @@ const TRANSFER_AMOUNT = 33n;
|
|
|
18
19
|
async function main() {
|
|
19
20
|
logger.info('Running token contract test on HTTP interface.');
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
-
const alice = aliceWallet.getCompleteAddress();
|
|
23
|
-
const bob = bobWallet.getCompleteAddress();
|
|
22
|
+
const wallet = await EmbeddedWallet.create(node);
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
// During local network setup we deploy a few accounts. Below we add them to our wallet.
|
|
25
|
+
const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
|
|
26
|
+
await wallet.createSchnorrAccount(aliceInitialAccountData.secret, aliceInitialAccountData.salt);
|
|
27
|
+
await wallet.createSchnorrAccount(bobInitialAccountData.secret, bobInitialAccountData.salt);
|
|
28
|
+
|
|
29
|
+
const alice = aliceInitialAccountData.address;
|
|
30
|
+
const bob = bobInitialAccountData.address;
|
|
31
|
+
|
|
32
|
+
logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
|
|
26
33
|
|
|
27
34
|
logger.info('Deploying Token...');
|
|
28
|
-
const token = await TokenContract.deploy(
|
|
35
|
+
const { contract: token } = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
|
|
36
|
+
from: alice,
|
|
37
|
+
});
|
|
29
38
|
logger.info('Token deployed');
|
|
30
39
|
|
|
31
|
-
// Create the contract abstraction and link it to Alice's and Bob's wallet for future signing
|
|
32
|
-
const tokenAlice = await TokenContract.at(token.address, aliceWallet);
|
|
33
|
-
const tokenBob = await TokenContract.at(token.address, bobWallet);
|
|
34
|
-
|
|
35
40
|
// Mint tokens to Alice
|
|
36
41
|
logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
|
|
37
|
-
|
|
38
|
-
await tokenAlice.methods.mint_to_private(from, aliceWallet.getAddress(), ALICE_MINT_BALANCE).send().wait();
|
|
42
|
+
await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice });
|
|
39
43
|
|
|
40
44
|
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
41
45
|
|
|
42
|
-
const balanceAfterMint = await
|
|
46
|
+
const { result: balanceAfterMint } = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
43
47
|
logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
|
|
44
48
|
|
|
45
49
|
// We will now transfer tokens from Alice to Bob
|
|
46
50
|
logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
|
|
47
|
-
await
|
|
51
|
+
await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice });
|
|
48
52
|
|
|
49
53
|
// Check the new balances
|
|
50
|
-
const aliceBalance = await
|
|
54
|
+
const { result: aliceBalance } = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
51
55
|
logger.info(`Alice's balance ${aliceBalance}`);
|
|
52
56
|
|
|
53
|
-
const bobBalance = await
|
|
57
|
+
const { result: bobBalance } = await token.methods.balance_of_private(bob).simulate({ from: bob });
|
|
54
58
|
logger.info(`Bob's balance ${bobBalance}`);
|
|
55
59
|
}
|
|
56
60
|
|
package/src/examples/util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EthAddress } from '@aztec/aztec.js';
|
|
2
|
-
import type {
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
3
3
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
4
|
|
|
5
5
|
import type { Abi, Narrow } from 'abitype';
|
|
@@ -7,27 +7,25 @@ import type { Hex } from 'viem';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Helper function to deploy ETH contracts.
|
|
10
|
-
* @param
|
|
11
|
-
* @param publicClient - A viem PublicClient.
|
|
10
|
+
* @param l1Client - A viem WalletClient extended with public actions.
|
|
12
11
|
* @param abi - The ETH contract's ABI (as abitype's Abi).
|
|
13
12
|
* @param bytecode - The ETH contract's bytecode.
|
|
14
13
|
* @param args - Constructor arguments for the contract.
|
|
15
14
|
* @returns The ETH address the contract was deployed to.
|
|
16
15
|
*/
|
|
17
16
|
export async function deployL1Contract(
|
|
18
|
-
|
|
19
|
-
publicClient: ViemPublicClient,
|
|
17
|
+
l1Client: ExtendedViemWalletClient,
|
|
20
18
|
abi: Narrow<Abi | readonly unknown[]>,
|
|
21
19
|
bytecode: Hex,
|
|
22
20
|
args: readonly unknown[] = [],
|
|
23
21
|
): Promise<EthAddress> {
|
|
24
|
-
const hash = await
|
|
22
|
+
const hash = await l1Client.deployContract({
|
|
25
23
|
abi,
|
|
26
24
|
bytecode,
|
|
27
25
|
args,
|
|
28
26
|
});
|
|
29
27
|
|
|
30
|
-
const receipt = await
|
|
28
|
+
const receipt = await l1Client.waitForTransactionReceipt({ hash });
|
|
31
29
|
const contractAddress = receipt.contractAddress;
|
|
32
30
|
if (!contractAddress) {
|
|
33
31
|
throw new Error(`No contract address found in receipt: ${jsonStringify(receipt)}`);
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from './sandbox/index.js';
|
|
2
|
+
createLocalNetwork,
|
|
3
|
+
registerDeployedBananaCoinInWalletAndGetAddress,
|
|
4
|
+
registerDeployedBananaFPCInWalletAndGetAddress,
|
|
5
|
+
registerDeployedSponsoredFPCInWalletAndGetAddress,
|
|
6
|
+
} from './local-network/index.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
3
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
4
|
+
import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
5
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
|
|
7
|
+
export async function publishStandardAuthRegistry(
|
|
8
|
+
wallet: Wallet,
|
|
9
|
+
from: AztecAddress,
|
|
10
|
+
waitOpts?: WaitOpts,
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
const { instance, contractClass } = await getStandardAuthRegistry();
|
|
13
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
14
|
+
await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from, wait: waitOpts });
|
|
15
|
+
}
|
|
16
|
+
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
|
|
17
|
+
await publishInstance(wallet, instance).send({ from, wait: waitOpts });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { type InitialAccountData,
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
6
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
6
7
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
7
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import { type ContractInstanceWithAddress,
|
|
9
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
9
|
+
import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
10
10
|
|
|
11
11
|
const BANANA_COIN_SALT = new Fr(0);
|
|
12
12
|
const bananaCoinArgs = {
|
|
@@ -23,7 +23,7 @@ function getBananaAdmin(initialAccounts: InitialAccountData[]): AztecAddress {
|
|
|
23
23
|
|
|
24
24
|
async function getBananaCoinInstance(initialAccounts: InitialAccountData[]): Promise<ContractInstanceWithAddress> {
|
|
25
25
|
const admin = getBananaAdmin(initialAccounts);
|
|
26
|
-
return await
|
|
26
|
+
return await getContractInstanceFromInstantiationParams(TokenContract.artifact, {
|
|
27
27
|
constructorArgs: [admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal],
|
|
28
28
|
salt: BANANA_COIN_SALT,
|
|
29
29
|
});
|
|
@@ -36,7 +36,7 @@ export async function getBananaCoinAddress(initialAccounts: InitialAccountData[]
|
|
|
36
36
|
async function getBananaFPCInstance(initialAccounts: InitialAccountData[]): Promise<ContractInstanceWithAddress> {
|
|
37
37
|
const bananaCoin = await getBananaCoinAddress(initialAccounts);
|
|
38
38
|
const admin = getBananaAdmin(initialAccounts);
|
|
39
|
-
return await
|
|
39
|
+
return await getContractInstanceFromInstantiationParams(FPCContract.artifact, {
|
|
40
40
|
constructorArgs: [bananaCoin, admin],
|
|
41
41
|
salt: BANANA_FPC_SALT,
|
|
42
42
|
});
|
|
@@ -46,38 +46,41 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
|
|
|
46
46
|
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export async function setupBananaFPC(
|
|
49
|
+
export async function setupBananaFPC(
|
|
50
|
+
initialAccounts: InitialAccountData[],
|
|
51
|
+
wallet: Wallet,
|
|
52
|
+
log: LogFn,
|
|
53
|
+
waitOpts?: WaitOpts,
|
|
54
|
+
) {
|
|
50
55
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
51
56
|
const admin = getBananaAdmin(initialAccounts);
|
|
52
|
-
const [bananaCoin, fpc] = await Promise.all([
|
|
53
|
-
TokenContract.deploy(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
58
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
|
|
59
|
+
salt: BANANA_COIN_SALT,
|
|
60
|
+
universalDeploy: true,
|
|
61
|
+
}).send({ from: admin, wait: waitOpts }),
|
|
62
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
|
|
63
|
+
from: admin,
|
|
64
|
+
wait: waitOpts,
|
|
65
|
+
}),
|
|
59
66
|
]);
|
|
60
67
|
|
|
61
68
|
log(`BananaCoin: ${bananaCoin.address}`);
|
|
62
69
|
log(`FPC: ${fpc.address}`);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
export async function
|
|
66
|
-
const initialAccounts = await
|
|
67
|
-
const bananaCoin = await
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return bananaCoin;
|
|
72
|
+
export async function registerDeployedBananaCoinInWalletAndGetAddress(wallet: Wallet) {
|
|
73
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
74
|
+
const bananaCoin = await getBananaCoinInstance(initialAccounts);
|
|
75
|
+
// The following is no-op if the contract is already registered
|
|
76
|
+
await wallet.registerContract(bananaCoin, TokenContract.artifact);
|
|
77
|
+
return bananaCoin.address;
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
export async function
|
|
76
|
-
const initialAccounts = await
|
|
80
|
+
export async function registerDeployedBananaFPCInWalletAndGetAddress(wallet: Wallet) {
|
|
81
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
77
82
|
const fpc = await getBananaFPCInstance(initialAccounts);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
throw new Error('BananaFPC not deployed.');
|
|
81
|
-
}
|
|
83
|
+
// The following is no-op if the contract is already registered
|
|
84
|
+
await wallet.registerContract(fpc, FPCContract.artifact);
|
|
82
85
|
return fpc.address;
|
|
83
86
|
}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings
|
|
2
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
|
+
import { AztecNodeService } from '@aztec/aztec-node';
|
|
4
|
+
import { type AztecNodeConfig, getConfigEnvVars } from '@aztec/aztec-node/config';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
7
|
+
import { type BlobClientInterface, createBlobClient } from '@aztec/blob-client/client';
|
|
8
|
+
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
10
|
+
import { waitForPublicClient } from '@aztec/ethereum/client';
|
|
11
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
12
|
+
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
13
|
+
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
14
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
15
|
+
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
16
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
17
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
18
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
19
|
+
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
20
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
21
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
22
|
+
import { SequencerState } from '@aztec/sequencer-client';
|
|
23
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
24
|
+
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
25
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
26
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
27
|
+
import {
|
|
28
|
+
type TelemetryClient,
|
|
29
|
+
getConfigEnvVars as getTelemetryClientConfig,
|
|
30
|
+
initTelemetryClient,
|
|
31
|
+
} from '@aztec/telemetry-client';
|
|
32
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
33
|
+
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
34
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
35
|
+
|
|
36
|
+
import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
37
|
+
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
38
|
+
import { foundry } from 'viem/chains';
|
|
39
|
+
|
|
40
|
+
import { createAccountLogs } from '../cli/util.js';
|
|
41
|
+
import { DefaultMnemonic } from '../mnemonic.js';
|
|
42
|
+
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
43
|
+
import { EpochTestSettler } from '../testing/epoch_test_settler.js';
|
|
44
|
+
import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
|
|
45
|
+
import { publishStandardAuthRegistry } from './auth_registry.js';
|
|
46
|
+
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
47
|
+
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
48
|
+
|
|
49
|
+
const logger = createLogger('local-network');
|
|
50
|
+
|
|
51
|
+
// The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
|
|
52
|
+
// proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
|
|
53
|
+
// pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
|
|
54
|
+
// P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
|
|
55
|
+
const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
|
|
56
|
+
|
|
57
|
+
const localAnvil = foundry;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Function to deploy our L1 contracts to the local network L1
|
|
61
|
+
* @param aztecNodeConfig - The Aztec Node Config
|
|
62
|
+
* @param hdAccount - Account for publishing L1 contracts
|
|
63
|
+
*/
|
|
64
|
+
export async function deployContractsToL1(
|
|
65
|
+
aztecNodeConfig: AztecNodeConfig,
|
|
66
|
+
privateKey: Hex,
|
|
67
|
+
opts: {
|
|
68
|
+
genesisArchiveRoot?: Fr;
|
|
69
|
+
feeJuicePortalInitialBalance?: bigint;
|
|
70
|
+
} = {},
|
|
71
|
+
): Promise<L1ContractAddresses> {
|
|
72
|
+
await waitForPublicClient(aztecNodeConfig);
|
|
73
|
+
|
|
74
|
+
const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
|
|
75
|
+
...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
|
|
76
|
+
...aztecNodeConfig,
|
|
77
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
78
|
+
protocolContractsHash,
|
|
79
|
+
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
80
|
+
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
81
|
+
aztecTargetCommitteeSize: 0, // no committee in local network
|
|
82
|
+
slasherEnabled: false, // no slashing in local network
|
|
83
|
+
realVerifier: false,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
|
|
87
|
+
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
88
|
+
|
|
89
|
+
return l1Contracts.l1ContractAddresses;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Local network settings. */
|
|
93
|
+
export type LocalNetworkConfig = AztecNodeConfig & {
|
|
94
|
+
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
95
|
+
l1Mnemonic: string;
|
|
96
|
+
/** Whether to deploy test accounts on local network start.*/
|
|
97
|
+
testAccounts: boolean;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
102
|
+
* Does not start any HTTP services nor populate any initial accounts.
|
|
103
|
+
* @param config - Optional local network settings.
|
|
104
|
+
*/
|
|
105
|
+
export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {}, userLog: LogFn) {
|
|
106
|
+
// local network is meant for test envs. We should only need one l1RpcUrl
|
|
107
|
+
const l1RpcUrl = config.l1RpcUrls?.[0];
|
|
108
|
+
if (!l1RpcUrl) {
|
|
109
|
+
throw new Error('An L1 RPC URL is required');
|
|
110
|
+
}
|
|
111
|
+
if ((config.l1RpcUrls?.length || 0) > 1) {
|
|
112
|
+
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
116
|
+
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
117
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
118
|
+
|
|
119
|
+
const aztecNodeConfig: AztecNodeConfig = {
|
|
120
|
+
...getConfigEnvVars(),
|
|
121
|
+
...config,
|
|
122
|
+
txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
|
|
123
|
+
};
|
|
124
|
+
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
125
|
+
if (
|
|
126
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys == undefined ||
|
|
127
|
+
!aztecNodeConfig.sequencerPublisherPrivateKeys.length ||
|
|
128
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY
|
|
129
|
+
) {
|
|
130
|
+
const privKey = hdAccount.getHdKey().privateKey;
|
|
131
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys = [
|
|
132
|
+
new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const),
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
|
|
136
|
+
const privKey = hdAccount.getHdKey().privateKey;
|
|
137
|
+
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${Buffer.from(privKey!).toString('hex')}`]);
|
|
138
|
+
}
|
|
139
|
+
aztecNodeConfig.coinbase = EthAddress.fromString(
|
|
140
|
+
privateKeyToAddress(aztecNodeConfig.validatorPrivateKeys.getValue()[0]),
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const initialAccounts = await (async () => {
|
|
144
|
+
if (config.testAccounts === true || config.testAccounts === undefined) {
|
|
145
|
+
if (aztecNodeConfig.p2pEnabled) {
|
|
146
|
+
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
147
|
+
} else {
|
|
148
|
+
userLog(`Setting up test accounts`);
|
|
149
|
+
return await getInitialTestAccountsData();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return [];
|
|
153
|
+
})();
|
|
154
|
+
|
|
155
|
+
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
156
|
+
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
157
|
+
const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a));
|
|
158
|
+
const fundedAddresses = [
|
|
159
|
+
...initialAccounts.map(a => a.address),
|
|
160
|
+
...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
|
|
161
|
+
...prefundAddresses,
|
|
162
|
+
];
|
|
163
|
+
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
164
|
+
|
|
165
|
+
const dateProvider = new TestDateProvider();
|
|
166
|
+
|
|
167
|
+
let cheatcodes: EthCheatCodes | undefined;
|
|
168
|
+
let rollupAddress: EthAddress | undefined;
|
|
169
|
+
let watcher: AnvilTestWatcher | undefined;
|
|
170
|
+
if (!aztecNodeConfig.p2pEnabled) {
|
|
171
|
+
({ rollupAddress } = await deployContractsToL1(
|
|
172
|
+
aztecNodeConfig,
|
|
173
|
+
aztecNodeConfig.validatorPrivateKeys.getValue()[0],
|
|
174
|
+
{
|
|
175
|
+
genesisArchiveRoot,
|
|
176
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
177
|
+
},
|
|
178
|
+
));
|
|
179
|
+
|
|
180
|
+
const chain =
|
|
181
|
+
aztecNodeConfig.l1RpcUrls.length > 0
|
|
182
|
+
? createEthereumChain([l1RpcUrl], aztecNodeConfig.l1ChainId)
|
|
183
|
+
: { chainInfo: localAnvil };
|
|
184
|
+
|
|
185
|
+
const publicClient = createPublicClient({
|
|
186
|
+
chain: chain.chainInfo,
|
|
187
|
+
transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
cheatcodes = new EthCheatCodes([l1RpcUrl], dateProvider);
|
|
191
|
+
|
|
192
|
+
watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
|
|
193
|
+
watcher.setisLocalNetwork(true);
|
|
194
|
+
watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
|
|
195
|
+
|
|
196
|
+
await watcher.start();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
200
|
+
// Create a local blob client client inside the local network, no http connectivity
|
|
201
|
+
const blobClient = createBlobClient();
|
|
202
|
+
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
|
|
203
|
+
|
|
204
|
+
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
205
|
+
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
206
|
+
// warping time out from under an in-progress block.
|
|
207
|
+
watcher?.setGetPendingTxCount(() => node.getPendingTxCount());
|
|
208
|
+
const sequencer = node.getSequencer()?.getSequencer();
|
|
209
|
+
if (sequencer) {
|
|
210
|
+
const idleStates: Set<string> = new Set([
|
|
211
|
+
SequencerState.STOPPED,
|
|
212
|
+
SequencerState.STOPPING,
|
|
213
|
+
SequencerState.IDLE,
|
|
214
|
+
SequencerState.SYNCHRONIZING,
|
|
215
|
+
]);
|
|
216
|
+
watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
|
|
217
|
+
// Under proposer pipelining the L1 publish for slot N happens during wall-clock slot N,
|
|
218
|
+
// but the proposer for slot N has already built the checkpoint during slot N-1 and is
|
|
219
|
+
// waiting for L1 to advance. We need to fast-forward L1 to wake that wait — and the wait
|
|
220
|
+
// we have to break first is `waitForValidParentCheckpointOnL1`, which blocks the
|
|
221
|
+
// checkpoint_proposal_job's background submission task until the archiver has synced past
|
|
222
|
+
// the build slot. That wait happens *before* `PUBLISHING_CHECKPOINT` is set, so a hook on
|
|
223
|
+
// that state transition would be circular (L1 has to advance before the state we'd use to
|
|
224
|
+
// advance L1 fires). The earliest pre-wait signal is `block-proposed`, which the sequencer
|
|
225
|
+
// emits once each block is built. In sandbox single-block-per-slot mode this is
|
|
226
|
+
// effectively "checkpoint built", and the watcher warp is harmless if a subsequent
|
|
227
|
+
// assembly/validation/parent-wait step aborts: L1 just sits one slot ahead, which the
|
|
228
|
+
// cascade absorbs.
|
|
229
|
+
if (watcher) {
|
|
230
|
+
sequencer.on('block-proposed', ({ slot }) => watcher!.setProposedTargetSlot(Number(slot)));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let epochTestSettler: EpochTestSettler | undefined;
|
|
235
|
+
if (!aztecNodeConfig.p2pEnabled) {
|
|
236
|
+
epochTestSettler = new EpochTestSettler(
|
|
237
|
+
cheatcodes!,
|
|
238
|
+
rollupAddress!,
|
|
239
|
+
node.getBlockSource(),
|
|
240
|
+
logger.createChild('epoch-settler'),
|
|
241
|
+
{ pollingIntervalMs: 200 },
|
|
242
|
+
);
|
|
243
|
+
await epochTestSettler.start();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (initialAccounts.length) {
|
|
247
|
+
const wallet = await EmbeddedWallet.create(node, {
|
|
248
|
+
pxeConfig: { proverEnabled: aztecNodeConfig.realProofs },
|
|
249
|
+
ephemeral: true,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
userLog('Setting up funded test accounts...');
|
|
253
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts, setupWaitOpts);
|
|
254
|
+
const accLogs = await createAccountLogs(accountManagers, wallet);
|
|
255
|
+
userLog(accLogs.join(''));
|
|
256
|
+
|
|
257
|
+
userLog('Publishing standard AuthRegistry contract...');
|
|
258
|
+
await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
|
|
259
|
+
|
|
260
|
+
await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
|
|
261
|
+
|
|
262
|
+
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
263
|
+
|
|
264
|
+
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
265
|
+
await wallet.stop();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const stop = async () => {
|
|
269
|
+
await node.stop();
|
|
270
|
+
await watcher?.stop();
|
|
271
|
+
await epochTestSettler?.stop();
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
return { node, stop };
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Create and start a new Aztec RPC HTTP Server
|
|
279
|
+
* @param config - Optional Aztec node settings.
|
|
280
|
+
*/
|
|
281
|
+
export async function createAztecNode(
|
|
282
|
+
config: Partial<AztecNodeConfig> = {},
|
|
283
|
+
deps: {
|
|
284
|
+
telemetry?: TelemetryClient;
|
|
285
|
+
blobClient?: BlobClientInterface;
|
|
286
|
+
dateProvider?: DateProvider;
|
|
287
|
+
proverBroker?: ProvingJobBroker;
|
|
288
|
+
} = {},
|
|
289
|
+
options: { genesis?: GenesisData } = {},
|
|
290
|
+
) {
|
|
291
|
+
// TODO(#12272): will clean this up. This is criminal.
|
|
292
|
+
// Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
|
|
293
|
+
const aztecNodeConfig: AztecNodeConfig = {
|
|
294
|
+
...getConfigEnvVars(),
|
|
295
|
+
...config,
|
|
296
|
+
};
|
|
297
|
+
const node = await AztecNodeService.createAndSync(
|
|
298
|
+
aztecNodeConfig,
|
|
299
|
+
{ ...deps, proverNodeDeps: { broker: deps.proverBroker } },
|
|
300
|
+
options,
|
|
301
|
+
);
|
|
302
|
+
return node;
|
|
303
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import {
|
|
3
|
+
type ContractInstanceWithAddress,
|
|
4
|
+
getContractInstanceFromInstantiationParams,
|
|
5
|
+
} from '@aztec/aztec.js/contracts';
|
|
6
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
9
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
10
|
+
|
|
11
|
+
async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
|
|
12
|
+
return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
13
|
+
salt: new Fr(SPONSORED_FPC_SALT),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function getSponsoredFPCAddress(): Promise<AztecAddress> {
|
|
18
|
+
return (await getSponsoredFPCInstance()).address;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet): Promise<AztecAddress> {
|
|
22
|
+
const fpc = await getSponsoredFPCInstance();
|
|
23
|
+
// The following is no-op if the contract is already registered
|
|
24
|
+
await wallet.registerContract(fpc, SponsoredFPCContract.artifact);
|
|
25
|
+
return fpc.address;
|
|
26
|
+
}
|