@aztec/aztec 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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 +11 -10
- 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 +9 -25
- package/dest/cli/aztec_start_options.d.ts +1 -1
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +22 -39
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +46 -1
- package/dest/cli/cmds/start_archiver.d.ts +1 -1
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +9 -9
- 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 +25 -14
- package/dest/cli/cmds/start_node.d.ts +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +13 -21
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.js +1 -1
- 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 +12 -3
- 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 +8 -3
- package/dest/cli/cmds/start_prover_node.d.ts +1 -1
- package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_node.js +16 -7
- package/dest/cli/cmds/start_txe.d.ts +1 -1
- package/dest/cli/index.d.ts +1 -1
- package/dest/cli/preload_crs.d.ts +1 -1
- package/dest/cli/release_version.d.ts +1 -1
- package/dest/cli/util.d.ts +12 -10
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +7 -7
- 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 +18 -16
- package/dest/examples/util.d.ts +3 -3
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/examples/util.js +1 -1
- 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/banana_fpc.d.ts +10 -0
- package/dest/local-network/banana_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/banana_fpc.js +15 -19
- 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 +72 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/{sandbox/sandbox.js → local-network/local-network.js} +43 -57
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/sponsored_fpc.js +7 -8
- package/dest/mnemonic.d.ts +1 -1
- package/dest/splash.d.ts +1 -1
- package/dest/testing/anvil_test_watcher.d.ts +4 -4
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +19 -18
- package/dest/testing/cheat_codes.d.ts +7 -10
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +9 -10
- package/dest/testing/index.d.ts +1 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +0 -1
- package/package.json +39 -37
- package/src/bin/index.ts +12 -10
- package/src/cli/aztec_start_action.ts +9 -22
- package/src/cli/aztec_start_options.ts +23 -40
- package/src/cli/cli.ts +46 -1
- package/src/cli/cmds/start_archiver.ts +9 -9
- package/src/cli/cmds/start_bot.ts +36 -13
- package/src/cli/cmds/start_node.ts +16 -17
- package/src/cli/cmds/start_p2p_bootstrap.ts +1 -1
- package/src/cli/cmds/start_prover_agent.ts +8 -11
- package/src/cli/cmds/start_prover_broker.ts +17 -3
- package/src/cli/cmds/start_prover_node.ts +13 -8
- package/src/cli/util.ts +12 -10
- package/src/cli/versioning.ts +3 -3
- package/src/examples/token.ts +20 -17
- package/src/examples/util.ts +2 -2
- package/src/index.ts +5 -5
- package/src/{sandbox → local-network}/banana_fpc.ts +16 -21
- package/src/local-network/index.ts +7 -0
- package/src/{sandbox/sandbox.ts → local-network/local-network.ts} +68 -99
- package/src/local-network/sponsored_fpc.ts +26 -0
- package/src/testing/anvil_test_watcher.ts +18 -19
- package/src/testing/cheat_codes.ts +13 -13
- package/src/testing/index.ts +0 -1
- package/dest/cli/chain_l2_config.d.ts +0 -31
- package/dest/cli/chain_l2_config.d.ts.map +0 -1
- package/dest/cli/chain_l2_config.js +0 -261
- 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 -33
- 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 -31
- 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 -4
- package/dest/sandbox/index.d.ts.map +0 -1
- package/dest/sandbox/index.js +0 -3
- package/dest/sandbox/sandbox.d.ts +0 -83
- package/dest/sandbox/sandbox.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fpc.d.ts +0 -4
- package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
- package/dest/testing/aztec_cheat_codes.d.ts +0 -59
- package/dest/testing/aztec_cheat_codes.d.ts.map +0 -1
- package/dest/testing/aztec_cheat_codes.js +0 -62
- package/src/cli/chain_l2_config.ts +0 -341
- package/src/cli/cmds/start_blob_sink.ts +0 -57
- package/src/cli/cmds/start_pxe.ts +0 -49
- package/src/cli/get_l1_config.ts +0 -19
- package/src/sandbox/index.ts +0 -4
- package/src/sandbox/sponsored_fpc.ts +0 -27
- package/src/testing/aztec_cheat_codes.ts +0 -77
|
@@ -45,23 +45,20 @@ export async function startProverAgent(
|
|
|
45
45
|
|
|
46
46
|
await preloadCrsDataForServerSideProving(config, userLog);
|
|
47
47
|
|
|
48
|
-
const fetch = makeTracedFetch(
|
|
48
|
+
const fetch = makeTracedFetch(
|
|
49
|
+
// retry connections every 3s, up to 30s before giving up
|
|
50
|
+
[1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
|
|
51
|
+
false,
|
|
52
|
+
makeUndiciFetch(new Agent({ connections: 10 })),
|
|
53
|
+
);
|
|
49
54
|
const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
|
|
50
55
|
|
|
51
|
-
const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
|
|
56
|
+
const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
|
|
52
57
|
const prover = await buildServerCircuitProver(config, telemetry);
|
|
53
58
|
const proofStore = new InlineProofStore();
|
|
54
59
|
const agents = times(
|
|
55
60
|
config.proverAgentCount,
|
|
56
|
-
() =>
|
|
57
|
-
new ProvingAgent(
|
|
58
|
-
broker,
|
|
59
|
-
proofStore,
|
|
60
|
-
prover,
|
|
61
|
-
config.proverAgentProofTypes,
|
|
62
|
-
config.proverAgentPollIntervalMs,
|
|
63
|
-
telemetry,
|
|
64
|
-
),
|
|
61
|
+
() => new ProvingAgent(broker, proofStore, prover, config.proverAgentProofTypes, config.proverAgentPollIntervalMs),
|
|
65
62
|
);
|
|
66
63
|
|
|
67
64
|
// expose all agents as individual services
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getL1Config } from '@aztec/cli/config';
|
|
2
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
1
3
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
2
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
5
|
import {
|
|
@@ -10,8 +12,7 @@ import { getProverNodeBrokerConfigFromEnv } from '@aztec/prover-node';
|
|
|
10
12
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
11
13
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
12
14
|
|
|
13
|
-
import {
|
|
14
|
-
import { extractRelevantOptions } from '../util.js';
|
|
15
|
+
import { extractRelevantOptions, setupUpdateMonitor } from '../util.js';
|
|
15
16
|
|
|
16
17
|
export async function startProverBroker(
|
|
17
18
|
options: any,
|
|
@@ -33,6 +34,7 @@ export async function startProverBroker(
|
|
|
33
34
|
throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
const followsCanonicalRollup = typeof config.rollupVersion !== 'number';
|
|
36
38
|
const { addresses, config: rollupConfig } = await getL1Config(
|
|
37
39
|
config.l1Contracts.registryAddress,
|
|
38
40
|
config.l1RpcUrls,
|
|
@@ -43,8 +45,20 @@ export async function startProverBroker(
|
|
|
43
45
|
config.l1Contracts = addresses;
|
|
44
46
|
config.rollupVersion = rollupConfig.rollupVersion;
|
|
45
47
|
|
|
46
|
-
const client = initTelemetryClient(getTelemetryClientConfig());
|
|
48
|
+
const client = await initTelemetryClient(getTelemetryClientConfig());
|
|
47
49
|
const broker = await createAndStartProvingBroker(config, client);
|
|
50
|
+
|
|
51
|
+
if (options.autoUpdate !== 'disabled' && options.autoUpdateUrl) {
|
|
52
|
+
await setupUpdateMonitor(
|
|
53
|
+
options.autoUpdate,
|
|
54
|
+
new URL(options.autoUpdateUrl),
|
|
55
|
+
followsCanonicalRollup,
|
|
56
|
+
getPublicClient(config),
|
|
57
|
+
config.l1Contracts.registryAddress,
|
|
58
|
+
signalHandlers,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
services.proverBroker = [broker, ProvingJobBrokerSchema];
|
|
49
63
|
signalHandlers.push(() => broker.stop());
|
|
50
64
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/aztec.js';
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
3
|
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
4
|
-
import {
|
|
4
|
+
import { getL1Config } from '@aztec/cli/config';
|
|
5
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
6
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
6
7
|
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
7
8
|
import type { LogFn } from '@aztec/foundation/log';
|
|
@@ -16,7 +17,6 @@ import { P2PApiSchema, ProverNodeApiSchema, type ProvingJobBroker } from '@aztec
|
|
|
16
17
|
import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
17
18
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
18
19
|
|
|
19
|
-
import { getL1Config } from '../get_l1_config.js';
|
|
20
20
|
import { extractRelevantOptions, preloadCrsDataForVerifying, setupUpdateMonitor } from '../util.js';
|
|
21
21
|
import { getVersions } from '../versioning.js';
|
|
22
22
|
import { startProverBroker } from './start_prover_broker.js';
|
|
@@ -52,7 +52,7 @@ export async function startProverNode(
|
|
|
52
52
|
proverConfig.l1Contracts = addresses;
|
|
53
53
|
proverConfig = { ...proverConfig, ...config };
|
|
54
54
|
|
|
55
|
-
const testAccounts = proverConfig.testAccounts ? (await
|
|
55
|
+
const testAccounts = proverConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
|
|
56
56
|
const sponsoredFPCAccounts = proverConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
|
|
57
57
|
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
|
|
58
58
|
|
|
@@ -67,13 +67,18 @@ export async function startProverNode(
|
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
|
|
70
|
+
const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
|
|
71
71
|
|
|
72
72
|
let broker: ProvingJobBroker;
|
|
73
73
|
if (proverConfig.proverBrokerUrl) {
|
|
74
|
-
// at 1TPS we'd enqueue ~1k
|
|
74
|
+
// at 1TPS we'd enqueue ~1k chonk verifier proofs and ~1k AVM proofs immediately
|
|
75
75
|
// set a lower connection limit such that we don't overload the server
|
|
76
|
-
|
|
76
|
+
// Keep retrying up to 30s
|
|
77
|
+
const fetch = makeTracedFetch(
|
|
78
|
+
[1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
|
|
79
|
+
false,
|
|
80
|
+
makeUndiciFetch(new Agent({ connections: 100 })),
|
|
81
|
+
);
|
|
77
82
|
broker = createProvingJobBrokerClient(proverConfig.proverBrokerUrl, getVersions(proverConfig), fetch);
|
|
78
83
|
} else if (options.proverBroker) {
|
|
79
84
|
({ broker } = await startProverBroker(options, signalHandlers, services, userLog));
|
package/src/cli/util.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { AztecNodeConfig } from '@aztec/aztec-node';
|
|
2
|
-
import type { AccountManager
|
|
3
|
-
import type { ViemClient } from '@aztec/ethereum';
|
|
2
|
+
import type { AccountManager } from '@aztec/aztec.js/wallet';
|
|
3
|
+
import type { ViemClient } from '@aztec/ethereum/types';
|
|
4
4
|
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
7
|
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
6
8
|
import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
7
|
-
import type { PXEService } from '@aztec/pxe/server';
|
|
8
9
|
import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { getTelemetryClient } from '@aztec/telemetry-client/start';
|
|
11
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
11
12
|
|
|
12
13
|
import chalk from 'chalk';
|
|
13
14
|
import type { Command } from 'commander';
|
|
@@ -67,7 +68,7 @@ export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<voi
|
|
|
67
68
|
/**
|
|
68
69
|
* Creates logs for the initial accounts
|
|
69
70
|
* @param accounts - The initial accounts
|
|
70
|
-
* @param
|
|
71
|
+
* @param wallet - A TestWallet instance to get the registered accounts
|
|
71
72
|
* @returns A string array containing the initial accounts details
|
|
72
73
|
*/
|
|
73
74
|
export async function createAccountLogs(
|
|
@@ -81,13 +82,13 @@ export async function createAccountLogs(
|
|
|
81
82
|
*/
|
|
82
83
|
secretKey: Fr;
|
|
83
84
|
}[],
|
|
84
|
-
|
|
85
|
+
wallet: TestWallet,
|
|
85
86
|
) {
|
|
86
|
-
const registeredAccounts = await
|
|
87
|
+
const registeredAccounts = await wallet.getAccounts();
|
|
87
88
|
const accountLogStrings = [`Initial Accounts:\n\n`];
|
|
88
89
|
for (const accountWithSecretKey of accountsWithSecretKeys) {
|
|
89
90
|
const completeAddress = await accountWithSecretKey.account.getCompleteAddress();
|
|
90
|
-
if (registeredAccounts.find(a => a.equals(completeAddress))) {
|
|
91
|
+
if (registeredAccounts.find(a => a.item.equals(completeAddress.address))) {
|
|
91
92
|
accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
|
|
92
93
|
accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
|
|
93
94
|
accountLogStrings.push(` Secret Key: ${accountWithSecretKey.secretKey.toString()}\n`);
|
|
@@ -271,7 +272,7 @@ export const extractRelevantOptions = <T>(
|
|
|
271
272
|
};
|
|
272
273
|
|
|
273
274
|
/**
|
|
274
|
-
* Downloads just enough points to be able to verify
|
|
275
|
+
* Downloads just enough points to be able to verify Chonk proofs.
|
|
275
276
|
* @param opts - Whether proof are to be verifier
|
|
276
277
|
* @param log - Logging function
|
|
277
278
|
*/
|
|
@@ -310,6 +311,7 @@ export async function setupUpdateMonitor(
|
|
|
310
311
|
updateNodeConfig?: (config: object) => Promise<void>,
|
|
311
312
|
) {
|
|
312
313
|
const logger = createLogger('update-check');
|
|
314
|
+
const { UpdateChecker } = await import('@aztec/stdlib/update-checker');
|
|
313
315
|
const checker = await UpdateChecker.new({
|
|
314
316
|
baseURL: updatesLocation,
|
|
315
317
|
publicClient,
|
package/src/cli/versioning.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
2
|
-
import {
|
|
2
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
3
3
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
4
4
|
import { type ComponentsVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
5
5
|
|
|
6
6
|
export function getVersions(config?: ChainConfig): Partial<ComponentsVersions> {
|
|
7
7
|
return config
|
|
8
|
-
? getComponentsVersionsFromConfig(config,
|
|
8
|
+
? getComponentsVersionsFromConfig(config, protocolContractsHash, getVKTreeRoot())
|
|
9
9
|
: {
|
|
10
10
|
l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
|
|
11
|
-
|
|
11
|
+
l2ProtocolContractsHash: protocolContractsHash.toString(),
|
|
12
12
|
};
|
|
13
13
|
}
|
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 { TestWallet } from '@aztec/test-wallet/server';
|
|
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,40 +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
|
-
|
|
23
|
-
|
|
22
|
+
const wallet = await TestWallet.create(node);
|
|
23
|
+
|
|
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;
|
|
24
31
|
|
|
25
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 token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18)
|
|
29
36
|
.send({ from: alice })
|
|
30
37
|
.deployed();
|
|
31
38
|
logger.info('Token deployed');
|
|
32
39
|
|
|
33
|
-
// Create the contract abstraction and link it to Alice's and Bob's wallet for future signing
|
|
34
|
-
const tokenAlice = await TokenContract.at(token.address, aliceWallet);
|
|
35
|
-
const tokenBob = await TokenContract.at(token.address, bobWallet);
|
|
36
|
-
|
|
37
40
|
// Mint tokens to Alice
|
|
38
41
|
logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
|
|
39
|
-
await
|
|
42
|
+
await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice }).wait();
|
|
40
43
|
|
|
41
44
|
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
42
45
|
|
|
43
|
-
const balanceAfterMint = await
|
|
46
|
+
const balanceAfterMint = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
44
47
|
logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
|
|
45
48
|
|
|
46
49
|
// We will now transfer tokens from Alice to Bob
|
|
47
50
|
logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
|
|
48
|
-
await
|
|
51
|
+
await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice }).wait();
|
|
49
52
|
|
|
50
53
|
// Check the new balances
|
|
51
|
-
const aliceBalance = await
|
|
54
|
+
const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
52
55
|
logger.info(`Alice's balance ${aliceBalance}`);
|
|
53
56
|
|
|
54
|
-
const bobBalance = await
|
|
57
|
+
const bobBalance = await token.methods.balance_of_private(bob).simulate({ from: bob });
|
|
55
58
|
logger.info(`Bob's balance ${bobBalance}`);
|
|
56
59
|
}
|
|
57
60
|
|
package/src/examples/util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EthAddress } from '@aztec/aztec.js';
|
|
2
|
-
import type { ExtendedViemWalletClient } from '@aztec/ethereum';
|
|
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';
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from './
|
|
2
|
+
createLocalNetwork,
|
|
3
|
+
registerDeployedBananaCoinInWalletAndGetAddress,
|
|
4
|
+
registerDeployedBananaFPCInWalletAndGetAddress,
|
|
5
|
+
registerDeployedSponsoredFPCInWalletAndGetAddress,
|
|
6
|
+
} from './local-network/index.js';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { type InitialAccountData,
|
|
2
|
-
import type { Wallet } from '@aztec/aztec.js';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
5
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
6
6
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
7
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
9
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
10
9
|
|
|
11
10
|
const BANANA_COIN_SALT = new Fr(0);
|
|
12
11
|
const bananaCoinArgs = {
|
|
@@ -46,14 +45,14 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
|
|
|
46
45
|
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
export async function setupBananaFPC(initialAccounts: InitialAccountData[],
|
|
48
|
+
export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
|
|
50
49
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
51
50
|
const admin = getBananaAdmin(initialAccounts);
|
|
52
51
|
const [bananaCoin, fpc] = await Promise.all([
|
|
53
|
-
TokenContract.deploy(
|
|
52
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal)
|
|
54
53
|
.send({ from: admin, contractAddressSalt: BANANA_COIN_SALT, universalDeploy: true })
|
|
55
54
|
.deployed(),
|
|
56
|
-
FPCContract.deploy(
|
|
55
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin)
|
|
57
56
|
.send({ from: admin, contractAddressSalt: BANANA_FPC_SALT, universalDeploy: true })
|
|
58
57
|
.deployed(),
|
|
59
58
|
]);
|
|
@@ -62,22 +61,18 @@ export async function setupBananaFPC(initialAccounts: InitialAccountData[], depl
|
|
|
62
61
|
log(`FPC: ${fpc.address}`);
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
export async function
|
|
66
|
-
const initialAccounts = await
|
|
67
|
-
const bananaCoin = await
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return bananaCoin;
|
|
64
|
+
export async function registerDeployedBananaCoinInWalletAndGetAddress(wallet: Wallet) {
|
|
65
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
66
|
+
const bananaCoin = await getBananaCoinInstance(initialAccounts);
|
|
67
|
+
// The following is no-op if the contract is already registered
|
|
68
|
+
await wallet.registerContract(bananaCoin, TokenContract.artifact);
|
|
69
|
+
return bananaCoin.address;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
export async function
|
|
76
|
-
const initialAccounts = await
|
|
72
|
+
export async function registerDeployedBananaFPCInWalletAndGetAddress(wallet: Wallet) {
|
|
73
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
77
74
|
const fpc = await getBananaFPCInstance(initialAccounts);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
throw new Error('BananaFPC not deployed.');
|
|
81
|
-
}
|
|
75
|
+
// The following is no-op if the contract is already registered
|
|
76
|
+
await wallet.registerContract(fpc, FPCContract.artifact);
|
|
82
77
|
return fpc.address;
|
|
83
78
|
}
|