@aztec/aztec 0.0.0-test.0
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 +57 -0
- package/dest/bin/index.d.ts +3 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +46 -0
- package/dest/cli/aztec_start_action.d.ts +3 -0
- package/dest/cli/aztec_start_action.d.ts.map +1 -0
- package/dest/cli/aztec_start_action.js +108 -0
- package/dest/cli/aztec_start_options.d.ts +15 -0
- package/dest/cli/aztec_start_options.d.ts.map +1 -0
- package/dest/cli/aztec_start_options.js +348 -0
- package/dest/cli/chain_l2_config.d.ts +19 -0
- package/dest/cli/chain_l2_config.d.ts.map +1 -0
- package/dest/cli/chain_l2_config.js +56 -0
- package/dest/cli/cli.d.ts +9 -0
- package/dest/cli/cli.d.ts.map +1 -0
- package/dest/cli/cli.js +33 -0
- package/dest/cli/cmds/start_archiver.d.ts +9 -0
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -0
- package/dest/cli/cmds/start_archiver.js +42 -0
- package/dest/cli/cmds/start_blob_sink.d.ts +3 -0
- package/dest/cli/cmds/start_blob_sink.d.ts.map +1 -0
- package/dest/cli/cmds/start_blob_sink.js +17 -0
- package/dest/cli/cmds/start_bot.d.ts +11 -0
- package/dest/cli/cmds/start_bot.d.ts.map +1 -0
- package/dest/cli/cmds/start_bot.js +31 -0
- package/dest/cli/cmds/start_faucet.d.ts +4 -0
- package/dest/cli/cmds/start_faucet.d.ts.map +1 -0
- package/dest/cli/cmds/start_faucet.js +20 -0
- package/dest/cli/cmds/start_node.d.ts +7 -0
- package/dest/cli/cmds/start_node.d.ts.map +1 -0
- package/dest/cli/cmds/start_node.js +131 -0
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +6 -0
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -0
- package/dest/cli/cmds/start_p2p_bootstrap.js +26 -0
- package/dest/cli/cmds/start_prover_agent.d.ts +4 -0
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -0
- package/dest/cli/cmds/start_prover_agent.js +41 -0
- package/dest/cli/cmds/start_prover_broker.d.ts +9 -0
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -0
- package/dest/cli/cmds/start_prover_broker.js +31 -0
- package/dest/cli/cmds/start_prover_node.d.ts +7 -0
- package/dest/cli/cmds/start_prover_node.d.ts.map +1 -0
- package/dest/cli/cmds/start_prover_node.js +110 -0
- package/dest/cli/cmds/start_pxe.d.ts +16 -0
- package/dest/cli/cmds/start_pxe.d.ts.map +1 -0
- package/dest/cli/cmds/start_pxe.js +95 -0
- package/dest/cli/cmds/start_txe.d.ts +3 -0
- package/dest/cli/cmds/start_txe.d.ts.map +1 -0
- package/dest/cli/cmds/start_txe.js +11 -0
- package/dest/cli/get_l1_config.d.ts +7 -0
- package/dest/cli/get_l1_config.d.ts.map +1 -0
- package/dest/cli/get_l1_config.js +13 -0
- package/dest/cli/index.d.ts +2 -0
- package/dest/cli/index.d.ts.map +1 -0
- package/dest/cli/index.js +1 -0
- package/dest/cli/util.d.ts +46 -0
- package/dest/cli/util.d.ts.map +1 -0
- package/dest/cli/util.js +154 -0
- package/dest/cli/versioning.d.ts +4 -0
- package/dest/cli/versioning.d.ts.map +1 -0
- package/dest/cli/versioning.js +9 -0
- package/dest/examples/token.d.ts +2 -0
- package/dest/examples/token.d.ts.map +1 -0
- package/dest/examples/token.js +46 -0
- package/dest/examples/util.d.ts +20 -0
- package/dest/examples/util.d.ts.map +1 -0
- package/dest/examples/util.js +31 -0
- package/dest/index.d.ts +2 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +1 -0
- package/dest/mnemonic.d.ts +2 -0
- package/dest/mnemonic.d.ts.map +1 -0
- package/dest/mnemonic.js +1 -0
- package/dest/sandbox/banana_fpc.d.ts +11 -0
- package/dest/sandbox/banana_fpc.d.ts.map +1 -0
- package/dest/sandbox/banana_fpc.js +79 -0
- package/dest/sandbox/index.d.ts +5 -0
- package/dest/sandbox/index.d.ts.map +1 -0
- package/dest/sandbox/index.js +4 -0
- package/dest/sandbox/sandbox.d.ts +76 -0
- package/dest/sandbox/sandbox.d.ts.map +1 -0
- package/dest/sandbox/sandbox.js +181 -0
- package/dest/sandbox/sponsored_fee_payment_method.d.ts +23 -0
- package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +1 -0
- package/dest/sandbox/sponsored_fee_payment_method.js +36 -0
- package/dest/sandbox/sponsored_fpc.d.ts +6 -0
- package/dest/sandbox/sponsored_fpc.d.ts.map +1 -0
- package/dest/sandbox/sponsored_fpc.js +26 -0
- package/dest/splash.d.ts +3 -0
- package/dest/splash.d.ts.map +1 -0
- package/dest/splash.js +2 -0
- package/package.json +118 -0
- package/src/bin/index.ts +54 -0
- package/src/cli/aztec_start_action.ts +114 -0
- package/src/cli/aztec_start_options.ts +371 -0
- package/src/cli/chain_l2_config.ts +74 -0
- package/src/cli/cli.ts +48 -0
- package/src/cli/cmds/start_archiver.ts +55 -0
- package/src/cli/cmds/start_blob_sink.ts +31 -0
- package/src/cli/cmds/start_bot.ts +49 -0
- package/src/cli/cmds/start_faucet.ts +34 -0
- package/src/cli/cmds/start_node.ts +151 -0
- package/src/cli/cmds/start_p2p_bootstrap.ts +29 -0
- package/src/cli/cmds/start_prover_agent.ts +68 -0
- package/src/cli/cmds/start_prover_broker.ts +46 -0
- package/src/cli/cmds/start_prover_node.ts +121 -0
- package/src/cli/cmds/start_pxe.ts +129 -0
- package/src/cli/cmds/start_txe.ts +15 -0
- package/src/cli/get_l1_config.ts +18 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/util.ts +216 -0
- package/src/cli/versioning.ts +13 -0
- package/src/examples/token.ts +65 -0
- package/src/examples/util.ts +45 -0
- package/src/index.ts +7 -0
- package/src/mnemonic.ts +1 -0
- package/src/sandbox/banana_fpc.ts +83 -0
- package/src/sandbox/index.ts +5 -0
- package/src/sandbox/sandbox.ts +229 -0
- package/src/sandbox/sponsored_fee_payment_method.ts +46 -0
- package/src/sandbox/sponsored_fpc.ts +38 -0
- package/src/splash.ts +10 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start_pxe.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_pxe.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,EAGtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,SAAS,EAAoC,MAAM,iCAAiC,CAAC;AAOnG,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC;AAIhD,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAAA;CAAE,CAAC,CAExE;AAcD,wBAAsB,MAAM,CAC1B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,EACd,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,SAAS,CAAA;CAAO,GAC9B,OAAO,CAAC;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAAA;CAAE,CAAC,CAwExE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { AztecAddress, Fr, PublicKeys, getContractClassFromArtifact } from '@aztec/aztec.js';
|
|
2
|
+
import { getContractArtifact } from '@aztec/cli/cli-utils';
|
|
3
|
+
import { allPxeConfigMappings, createPXEService } from '@aztec/pxe/server';
|
|
4
|
+
import { PXESchema, createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import { L2BasicContractsMap, Network } from '@aztec/stdlib/network';
|
|
6
|
+
import { makeTracedFetch } from '@aztec/telemetry-client';
|
|
7
|
+
import { extractRelevantOptions } from '../util.js';
|
|
8
|
+
import { getVersions } from '../versioning.js';
|
|
9
|
+
const contractAddressesUrl = 'http://static.aztec.network';
|
|
10
|
+
export async function startPXE(options, signalHandlers, services, userLog) {
|
|
11
|
+
return await addPXE(options, signalHandlers, services, userLog, {});
|
|
12
|
+
}
|
|
13
|
+
function isValidNetwork(value) {
|
|
14
|
+
return Object.values(Network).includes(value);
|
|
15
|
+
}
|
|
16
|
+
async function fetchBasicContractAddresses(url) {
|
|
17
|
+
const response = await fetch(url);
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error(`Failed to fetch basic contract addresses from ${url}`);
|
|
20
|
+
}
|
|
21
|
+
return response.json();
|
|
22
|
+
}
|
|
23
|
+
export async function addPXE(options, signalHandlers, services, userLog, deps = {}) {
|
|
24
|
+
const pxeConfig = extractRelevantOptions(options, allPxeConfigMappings, 'pxe');
|
|
25
|
+
let nodeUrl;
|
|
26
|
+
if (pxeConfig.network) {
|
|
27
|
+
if (isValidNetwork(pxeConfig.network)) {
|
|
28
|
+
if (!pxeConfig.apiKey && !pxeConfig.nodeUrl) {
|
|
29
|
+
userLog(`API Key or Aztec Node URL is required to connect to ${pxeConfig.network}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
} else if (pxeConfig.apiKey) {
|
|
32
|
+
nodeUrl = `https://api.aztec.network/${pxeConfig.network}/aztec-node-1/${pxeConfig.apiKey}`;
|
|
33
|
+
} else if (pxeConfig.nodeUrl) {
|
|
34
|
+
nodeUrl = pxeConfig.nodeUrl;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
userLog(`Network ${pxeConfig.network} is not supported`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
nodeUrl = pxeConfig.nodeUrl;
|
|
42
|
+
}
|
|
43
|
+
if (!nodeUrl && !deps.node && !pxeConfig.network) {
|
|
44
|
+
userLog('Aztec Node URL (nodeUrl | AZTEC_NODE_URL) option is required to start PXE without --node option');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const node = deps.node ?? createAztecNodeClient(nodeUrl, getVersions(pxeConfig), makeTracedFetch([
|
|
48
|
+
1,
|
|
49
|
+
2,
|
|
50
|
+
3
|
|
51
|
+
], true));
|
|
52
|
+
const pxe = await createPXEService(node, pxeConfig);
|
|
53
|
+
// register basic contracts
|
|
54
|
+
if (pxeConfig.network) {
|
|
55
|
+
userLog(`Registering basic contracts for ${pxeConfig.network}`);
|
|
56
|
+
const basicContractsInfo = await fetchBasicContractAddresses(`${contractAddressesUrl}/${pxeConfig.network}/basic_contracts.json`);
|
|
57
|
+
const l2Contracts = {};
|
|
58
|
+
for (const [key, artifactName] of Object.entries(L2BasicContractsMap[pxeConfig.network])){
|
|
59
|
+
l2Contracts[key] = {
|
|
60
|
+
name: key,
|
|
61
|
+
address: AztecAddress.fromString(basicContractsInfo[key].address),
|
|
62
|
+
initHash: Fr.fromHexString(basicContractsInfo[key].initHash),
|
|
63
|
+
salt: Fr.fromHexString(basicContractsInfo[key].salt),
|
|
64
|
+
artifact: await getContractArtifact(artifactName, userLog)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
await Promise.all(Object.values(l2Contracts).map(async ({ name, address, artifact, initHash, salt })=>{
|
|
68
|
+
const contractClass = await getContractClassFromArtifact(artifact);
|
|
69
|
+
const instance = {
|
|
70
|
+
version: 1,
|
|
71
|
+
salt,
|
|
72
|
+
initializationHash: initHash,
|
|
73
|
+
address,
|
|
74
|
+
deployer: AztecAddress.ZERO,
|
|
75
|
+
currentContractClassId: contractClass.id,
|
|
76
|
+
originalContractClassId: contractClass.id,
|
|
77
|
+
publicKeys: PublicKeys.default()
|
|
78
|
+
};
|
|
79
|
+
userLog(`Registering ${name} at ${address.toString()}`);
|
|
80
|
+
await pxe.registerContract({
|
|
81
|
+
artifact,
|
|
82
|
+
instance
|
|
83
|
+
});
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
// Add PXE to services list
|
|
87
|
+
services.pxe = [
|
|
88
|
+
pxe,
|
|
89
|
+
PXESchema
|
|
90
|
+
];
|
|
91
|
+
return {
|
|
92
|
+
pxe,
|
|
93
|
+
config: pxeConfig
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start_txe.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_txe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,wBAAsB,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,iBAU/D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
2
|
+
import { createTXERpcServer } from '@aztec/txe';
|
|
3
|
+
export async function startTXE(options, debugLogger) {
|
|
4
|
+
debugLogger.info(`Setting up TXE...`);
|
|
5
|
+
const txeServer = createTXERpcServer(debugLogger);
|
|
6
|
+
const { port } = await startHttpRpcServer(txeServer, {
|
|
7
|
+
port: options.port,
|
|
8
|
+
timeoutMs: 1e3 * 60 * 5
|
|
9
|
+
});
|
|
10
|
+
debugLogger.info(`TXE listening on port ${port}`);
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type L1ContractAddresses, getL1ContractsConfig } from '@aztec/ethereum';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
export declare function getL1Config(registryAddress: EthAddress, l1RpcUrls: string[], l1ChainId: number): Promise<{
|
|
4
|
+
addresses: L1ContractAddresses;
|
|
5
|
+
config: Awaited<ReturnType<typeof getL1ContractsConfig>>;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=get_l1_config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_l1_config.d.ts","sourceRoot":"","sources":["../../src/cli/get_l1_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAoB,oBAAoB,EAAmB,MAAM,iBAAiB,CAAC;AACpH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,wBAAsB,WAAW,CAC/B,eAAe,EAAE,UAAU,EAC3B,SAAS,EAAE,MAAM,EAAE,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,SAAS,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAA;CAAE,CAAC,CAUvG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RegistryContract, getL1ContractsConfig, getPublicClient } from '@aztec/ethereum';
|
|
2
|
+
export async function getL1Config(registryAddress, l1RpcUrls, l1ChainId) {
|
|
3
|
+
const publicClient = getPublicClient({
|
|
4
|
+
l1RpcUrls,
|
|
5
|
+
l1ChainId
|
|
6
|
+
});
|
|
7
|
+
const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress, 'canonical');
|
|
8
|
+
const config = await getL1ContractsConfig(publicClient, addresses);
|
|
9
|
+
return {
|
|
10
|
+
addresses,
|
|
11
|
+
config
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cli.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AccountManager, Fr } from '@aztec/aztec.js';
|
|
2
|
+
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
+
import type { PXEService } from '@aztec/pxe/server';
|
|
5
|
+
import type { Command } from 'commander';
|
|
6
|
+
import { type AztecStartOption } from './aztec_start_options.js';
|
|
7
|
+
export declare const installSignalHandlers: (logFn: LogFn, cb?: Array<() => Promise<void>>) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Creates logs for the initial accounts
|
|
10
|
+
* @param accounts - The initial accounts
|
|
11
|
+
* @param pxe - A PXE instance to get the registered accounts
|
|
12
|
+
* @returns A string array containing the initial accounts details
|
|
13
|
+
*/
|
|
14
|
+
export declare function createAccountLogs(accountsWithSecretKeys: {
|
|
15
|
+
/**
|
|
16
|
+
* The account object
|
|
17
|
+
*/
|
|
18
|
+
account: AccountManager;
|
|
19
|
+
/**
|
|
20
|
+
* The secret key of the account
|
|
21
|
+
*/
|
|
22
|
+
secretKey: Fr;
|
|
23
|
+
}[], pxe: PXEService): Promise<string[]>;
|
|
24
|
+
export declare function getMaxLengths(sections: {
|
|
25
|
+
[key: string]: AztecStartOption[];
|
|
26
|
+
}): [number, number];
|
|
27
|
+
export declare function formatHelpLine(option: string, defaultValue: string, envVar: string, maxOptionLength: number, maxDefaultLength: number): string;
|
|
28
|
+
export declare const addOptions: (cmd: Command, options: AztecStartOption[]) => void;
|
|
29
|
+
export declare const printAztecStartHelpText: () => string;
|
|
30
|
+
/**
|
|
31
|
+
* Extracts namespaced options from a key-value map.
|
|
32
|
+
* @param options - Key-value map of options.
|
|
33
|
+
* @param namespace - The namespace to extract.
|
|
34
|
+
* @returns Key-value map of namespaced options.
|
|
35
|
+
*/
|
|
36
|
+
export declare const extractNamespacedOptions: (options: Record<string, any>, namespace: string) => Record<string, any>;
|
|
37
|
+
/**
|
|
38
|
+
* Extracts relevant options from a key-value map.
|
|
39
|
+
* @template T - The type of the relevant options.
|
|
40
|
+
* @param options - Key-value map of options.
|
|
41
|
+
* @param mappings - The mappings to extract.
|
|
42
|
+
* @param namespace - The namespace to extract for.
|
|
43
|
+
* @returns Key-value map of relevant options.
|
|
44
|
+
*/
|
|
45
|
+
export declare const extractRelevantOptions: <T>(options: Record<string, any>, mappings: ConfigMappingsType<T>, namespace: string) => T;
|
|
46
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/cli/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,0BAA0B,CAAC;AAEpF,eAAO,MAAM,qBAAqB,UAAW,KAAK,OAAO,MAAM,MAAM,QAAQ,IAAI,CAAC,CAAC,SAclF,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,sBAAsB,EAAE;IACtB;;OAEG;IACH,OAAO,EAAE,cAAc,CAAC;IACxB;;OAEG;IACH,SAAS,EAAE,EAAE,CAAC;CACf,EAAE,EACH,GAAG,EAAE,UAAU,qBAyBhB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;CAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAiB/F;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAKR;AAmBD,eAAO,MAAM,UAAU,QAAS,OAAO,WAAW,gBAAgB,EAAE,SASnE,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAwBnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,YAAa,OAAO,MAAM,EAAE,GAAG,CAAC,aAAa,MAAM,wBASvF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,eACxB,OAAO,MAAM,EAAE,GAAG,CAAC,YAClB,mBAAmB,CAAC,CAAC,aACpB,MAAM,KAChB,CA8BF,CAAC"}
|
package/dest/cli/util.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { aztecStartOptions } from './aztec_start_options.js';
|
|
3
|
+
export const installSignalHandlers = (logFn, cb)=>{
|
|
4
|
+
const shutdown = async ()=>{
|
|
5
|
+
logFn('Shutting down...');
|
|
6
|
+
if (cb) {
|
|
7
|
+
await Promise.all(cb);
|
|
8
|
+
}
|
|
9
|
+
process.exit(0);
|
|
10
|
+
};
|
|
11
|
+
process.removeAllListeners('SIGINT');
|
|
12
|
+
process.removeAllListeners('SIGTERM');
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
14
|
+
process.once('SIGINT', shutdown);
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
16
|
+
process.once('SIGTERM', shutdown);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Creates logs for the initial accounts
|
|
20
|
+
* @param accounts - The initial accounts
|
|
21
|
+
* @param pxe - A PXE instance to get the registered accounts
|
|
22
|
+
* @returns A string array containing the initial accounts details
|
|
23
|
+
*/ export async function createAccountLogs(accountsWithSecretKeys, pxe) {
|
|
24
|
+
const registeredAccounts = await pxe.getRegisteredAccounts();
|
|
25
|
+
const accountLogStrings = [
|
|
26
|
+
`Initial Accounts:\n\n`
|
|
27
|
+
];
|
|
28
|
+
for (const accountWithSecretKey of accountsWithSecretKeys){
|
|
29
|
+
const completeAddress = await accountWithSecretKey.account.getCompleteAddress();
|
|
30
|
+
if (registeredAccounts.find((a)=>a.equals(completeAddress))) {
|
|
31
|
+
accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
|
|
32
|
+
accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
|
|
33
|
+
accountLogStrings.push(` Secret Key: ${accountWithSecretKey.secretKey.toString()}\n`);
|
|
34
|
+
accountLogStrings.push(` Master nullifier public key: ${completeAddress.publicKeys.masterNullifierPublicKey.toString()}\n`);
|
|
35
|
+
accountLogStrings.push(` Master incoming viewing public key: ${completeAddress.publicKeys.masterIncomingViewingPublicKey.toString()}\n\n`);
|
|
36
|
+
accountLogStrings.push(` Master outgoing viewing public key: ${completeAddress.publicKeys.masterOutgoingViewingPublicKey.toString()}\n\n`);
|
|
37
|
+
accountLogStrings.push(` Master tagging public key: ${completeAddress.publicKeys.masterTaggingPublicKey.toString()}\n\n`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return accountLogStrings;
|
|
41
|
+
}
|
|
42
|
+
export function getMaxLengths(sections) {
|
|
43
|
+
let maxFlagLength = 0;
|
|
44
|
+
let maxDefaultLength = 0;
|
|
45
|
+
Object.values(sections).forEach((options)=>{
|
|
46
|
+
options.forEach((option)=>{
|
|
47
|
+
if (option.flag.length > maxFlagLength) {
|
|
48
|
+
maxFlagLength = option.flag.length;
|
|
49
|
+
}
|
|
50
|
+
const defaultLength = option.defaultValue ? option.defaultValue.length : 0;
|
|
51
|
+
if (defaultLength > maxDefaultLength) {
|
|
52
|
+
maxDefaultLength = defaultLength;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
return [
|
|
57
|
+
maxFlagLength + 1,
|
|
58
|
+
maxDefaultLength + 1
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
export function formatHelpLine(option, defaultValue, envVar, maxOptionLength, maxDefaultLength) {
|
|
62
|
+
const paddedOption = option.padEnd(maxOptionLength + 2, ' ');
|
|
63
|
+
const paddedDefault = defaultValue.padEnd(maxDefaultLength + 2, ' ');
|
|
64
|
+
return `${chalk.cyan(paddedOption)}${chalk.yellow(paddedDefault)}${chalk.green(envVar)}`;
|
|
65
|
+
}
|
|
66
|
+
const getDefaultOrEnvValue = (opt)=>{
|
|
67
|
+
let val;
|
|
68
|
+
// if the option is set in the environment, use that & parse it
|
|
69
|
+
if (opt.envVar && process.env[opt.envVar]) {
|
|
70
|
+
val = process.env[opt.envVar];
|
|
71
|
+
if (val && opt.parseVal) {
|
|
72
|
+
return opt.parseVal(val);
|
|
73
|
+
}
|
|
74
|
+
// if no env variable, use the default value
|
|
75
|
+
} else if (opt.defaultValue) {
|
|
76
|
+
val = opt.defaultValue;
|
|
77
|
+
}
|
|
78
|
+
return val;
|
|
79
|
+
};
|
|
80
|
+
// Function to add options dynamically
|
|
81
|
+
export const addOptions = (cmd, options)=>{
|
|
82
|
+
options.forEach((opt)=>{
|
|
83
|
+
cmd.option(opt.flag, `${opt.description} (default: ${opt.defaultValue}) ($${opt.envVar})`, opt.parseVal ? opt.parseVal : (val)=>val, getDefaultOrEnvValue(opt));
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export const printAztecStartHelpText = ()=>{
|
|
87
|
+
const helpTextLines = [
|
|
88
|
+
''
|
|
89
|
+
];
|
|
90
|
+
const [maxFlagLength, maxDefaultLength] = getMaxLengths(aztecStartOptions);
|
|
91
|
+
Object.keys(aztecStartOptions).forEach((category)=>{
|
|
92
|
+
helpTextLines.push(chalk.bold.blue(` ${category}`));
|
|
93
|
+
helpTextLines.push('');
|
|
94
|
+
aztecStartOptions[category].forEach((opt)=>{
|
|
95
|
+
const defaultValueText = opt.defaultValue ? `(default: ${opt.printDefault ? opt.printDefault(opt.defaultValue) : opt.defaultValue})` : '';
|
|
96
|
+
const envVarText = opt.envVar ? `($${opt.envVar})` : '';
|
|
97
|
+
const flagText = `${opt.flag}`;
|
|
98
|
+
const paddedText = formatHelpLine(flagText, defaultValueText, envVarText, maxFlagLength, maxDefaultLength);
|
|
99
|
+
helpTextLines.push(` ${paddedText}`);
|
|
100
|
+
helpTextLines.push(` ${chalk.white(opt.description)}`);
|
|
101
|
+
helpTextLines.push('');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
return helpTextLines.join('\n');
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Extracts namespaced options from a key-value map.
|
|
108
|
+
* @param options - Key-value map of options.
|
|
109
|
+
* @param namespace - The namespace to extract.
|
|
110
|
+
* @returns Key-value map of namespaced options.
|
|
111
|
+
*/ export const extractNamespacedOptions = (options, namespace)=>{
|
|
112
|
+
const extract = `${namespace}.`;
|
|
113
|
+
const namespacedOptions = {};
|
|
114
|
+
for(const key in options){
|
|
115
|
+
if (key.startsWith(extract)) {
|
|
116
|
+
namespacedOptions[key.replace(extract, '')] = options[key];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return namespacedOptions;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Extracts relevant options from a key-value map.
|
|
123
|
+
* @template T - The type of the relevant options.
|
|
124
|
+
* @param options - Key-value map of options.
|
|
125
|
+
* @param mappings - The mappings to extract.
|
|
126
|
+
* @param namespace - The namespace to extract for.
|
|
127
|
+
* @returns Key-value map of relevant options.
|
|
128
|
+
*/ export const extractRelevantOptions = (options, mappings, namespace)=>{
|
|
129
|
+
const relevantOptions = {};
|
|
130
|
+
// Iterate over each key in the options
|
|
131
|
+
Object.keys(options).forEach((optionKey)=>{
|
|
132
|
+
const keyParts = optionKey.split('.');
|
|
133
|
+
const optionNamespace = keyParts.length > 1 ? keyParts[0] : '';
|
|
134
|
+
const mainKey = keyParts.length > 1 ? keyParts[1] : keyParts[0];
|
|
135
|
+
// Check if the key exists in the mappings
|
|
136
|
+
if (mainKey in mappings) {
|
|
137
|
+
// Check for duplicates in the options
|
|
138
|
+
const duplicates = Object.keys(options).filter((optKey)=>{
|
|
139
|
+
const optKeyParts = optKey.split('.');
|
|
140
|
+
return optKeyParts[1] === mainKey || optKeyParts[0] === mainKey;
|
|
141
|
+
});
|
|
142
|
+
// If duplicates are found, use the namespace to differentiate
|
|
143
|
+
if (duplicates.length > 1) {
|
|
144
|
+
if (namespace === optionNamespace) {
|
|
145
|
+
relevantOptions[mainKey] = options[optionKey];
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
// If no duplicates, extract the value without considering the namespace
|
|
149
|
+
relevantOptions[mainKey] = options[optionKey];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return relevantOptions;
|
|
154
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../../src/cli/versioning.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,kBAAkB,EAAmC,MAAM,0BAA0B,CAAC;AAEpG,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAO7E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
2
|
+
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
3
|
+
import { getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
4
|
+
export function getVersions(config) {
|
|
5
|
+
return config ? getComponentsVersionsFromConfig(config, protocolContractTreeRoot, getVKTreeRoot()) : {
|
|
6
|
+
l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
|
|
7
|
+
l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString()
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/examples/token.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getDeployedTestAccountsWallets } from '@aztec/accounts/testing';
|
|
2
|
+
import { createPXEClient } from '@aztec/aztec.js';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
|
+
const logger = createLogger('example:token');
|
|
6
|
+
const url = 'http://localhost:8080';
|
|
7
|
+
const pxe = createPXEClient(url);
|
|
8
|
+
const ALICE_MINT_BALANCE = 333n;
|
|
9
|
+
const TRANSFER_AMOUNT = 33n;
|
|
10
|
+
/**
|
|
11
|
+
* Main function.
|
|
12
|
+
*/ async function main() {
|
|
13
|
+
logger.info('Running token contract test on HTTP interface.');
|
|
14
|
+
const [aliceWallet, bobWallet] = await getDeployedTestAccountsWallets(pxe);
|
|
15
|
+
const alice = aliceWallet.getCompleteAddress();
|
|
16
|
+
const bob = bobWallet.getCompleteAddress();
|
|
17
|
+
logger.info(`Fetched Alice and Bob accounts: ${alice.address.toString()}, ${bob.address.toString()}`);
|
|
18
|
+
logger.info('Deploying Token...');
|
|
19
|
+
const token = await TokenContract.deploy(aliceWallet, alice, 'TokenName', 'TokenSymbol', 18).send().deployed();
|
|
20
|
+
logger.info('Token deployed');
|
|
21
|
+
// Create the contract abstraction and link it to Alice's and Bob's wallet for future signing
|
|
22
|
+
const tokenAlice = await TokenContract.at(token.address, aliceWallet);
|
|
23
|
+
const tokenBob = await TokenContract.at(token.address, bobWallet);
|
|
24
|
+
// Mint tokens to Alice
|
|
25
|
+
logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
|
|
26
|
+
const from = aliceWallet.getAddress(); // we are setting from to Alice here because we need a sender to calculate the tag
|
|
27
|
+
await tokenAlice.methods.mint_to_private(from, aliceWallet.getAddress(), ALICE_MINT_BALANCE).send().wait();
|
|
28
|
+
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
29
|
+
const balanceAfterMint = await tokenAlice.methods.balance_of_private(alice).simulate();
|
|
30
|
+
logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
|
|
31
|
+
// We will now transfer tokens from Alice to Bob
|
|
32
|
+
logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
|
|
33
|
+
await tokenAlice.methods.transfer(bob, TRANSFER_AMOUNT).send().wait();
|
|
34
|
+
// Check the new balances
|
|
35
|
+
const aliceBalance = await tokenAlice.methods.balance_of_private(alice).simulate();
|
|
36
|
+
logger.info(`Alice's balance ${aliceBalance}`);
|
|
37
|
+
const bobBalance = await tokenBob.methods.balance_of_private(bob).simulate();
|
|
38
|
+
logger.info(`Bob's balance ${bobBalance}`);
|
|
39
|
+
}
|
|
40
|
+
main().then(()=>{
|
|
41
|
+
logger.info('Finished running successfully.');
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}).catch((err)=>{
|
|
44
|
+
logger.error('Error in main fn: ', err);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js';
|
|
2
|
+
import type { ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
|
|
3
|
+
import type { Abi, Narrow } from 'abitype';
|
|
4
|
+
import type { Hex } from 'viem';
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to deploy ETH contracts.
|
|
7
|
+
* @param walletClient - A viem WalletClient.
|
|
8
|
+
* @param publicClient - A viem PublicClient.
|
|
9
|
+
* @param abi - The ETH contract's ABI (as abitype's Abi).
|
|
10
|
+
* @param bytecode - The ETH contract's bytecode.
|
|
11
|
+
* @param args - Constructor arguments for the contract.
|
|
12
|
+
* @returns The ETH address the contract was deployed to.
|
|
13
|
+
*/
|
|
14
|
+
export declare function deployL1Contract(walletClient: ViemWalletClient, publicClient: ViemPublicClient, abi: Narrow<Abi | readonly unknown[]>, bytecode: Hex, args?: readonly unknown[]): Promise<EthAddress>;
|
|
15
|
+
/**
|
|
16
|
+
* Sleep for a given number of milliseconds.
|
|
17
|
+
* @param ms - the number of milliseconds to sleep for
|
|
18
|
+
*/
|
|
19
|
+
export declare function delay(ms: number): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/examples/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG1E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,SAAS,OAAO,EAAE,CAAC,EACrC,QAAQ,EAAE,GAAG,EACb,IAAI,GAAE,SAAS,OAAO,EAAO,GAC5B,OAAO,CAAC,UAAU,CAAC,CAcrB;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js';
|
|
2
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to deploy ETH contracts.
|
|
5
|
+
* @param walletClient - A viem WalletClient.
|
|
6
|
+
* @param publicClient - A viem PublicClient.
|
|
7
|
+
* @param abi - The ETH contract's ABI (as abitype's Abi).
|
|
8
|
+
* @param bytecode - The ETH contract's bytecode.
|
|
9
|
+
* @param args - Constructor arguments for the contract.
|
|
10
|
+
* @returns The ETH address the contract was deployed to.
|
|
11
|
+
*/ export async function deployL1Contract(walletClient, publicClient, abi, bytecode, args = []) {
|
|
12
|
+
const hash = await walletClient.deployContract({
|
|
13
|
+
abi,
|
|
14
|
+
bytecode,
|
|
15
|
+
args
|
|
16
|
+
});
|
|
17
|
+
const receipt = await publicClient.waitForTransactionReceipt({
|
|
18
|
+
hash
|
|
19
|
+
});
|
|
20
|
+
const contractAddress = receipt.contractAddress;
|
|
21
|
+
if (!contractAddress) {
|
|
22
|
+
throw new Error(`No contract address found in receipt: ${jsonStringify(receipt)}`);
|
|
23
|
+
}
|
|
24
|
+
return EthAddress.fromString(receipt.contractAddress);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sleep for a given number of milliseconds.
|
|
28
|
+
* @param ms - the number of milliseconds to sleep for
|
|
29
|
+
*/ export function delay(ms) {
|
|
30
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
31
|
+
}
|
package/dest/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC"}
|
package/dest/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSandbox, getDeployedBananaCoinAddress, getDeployedBananaFPCAddress, getDeployedSponsoredFPCAddress, SponsoredFeePaymentMethod } from './sandbox/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mnemonic.d.ts","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,gEAAgE,CAAC"}
|
package/dest/mnemonic.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DefaultMnemonic = 'test test test test test test test test test test test junk';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { Wallet } from '@aztec/aztec.js';
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
6
|
+
export declare function getBananaCoinAddress(initialAccounts: InitialAccountData[]): Promise<AztecAddress>;
|
|
7
|
+
export declare function getBananaFPCAddress(initialAccounts: InitialAccountData[]): Promise<AztecAddress>;
|
|
8
|
+
export declare function setupBananaFPC(initialAccounts: InitialAccountData[], deployer: Wallet, log: LogFn): Promise<void>;
|
|
9
|
+
export declare function getDeployedBananaCoinAddress(pxe: PXE): Promise<AztecAddress>;
|
|
10
|
+
export declare function getDeployedBananaFPCAddress(pxe: PXE): Promise<AztecAddress>;
|
|
11
|
+
//# sourceMappingURL=banana_fpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banana_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/banana_fpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,yBAAyB,CAAC;AAC1F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAuB3D,wBAAsB,oBAAoB,CAAC,eAAe,EAAE,kBAAkB,EAAE,yBAE/E;AAWD,wBAAsB,mBAAmB,CAAC,eAAe,EAAE,kBAAkB,EAAE,yBAE9E;AAED,wBAAsB,cAAc,CAAC,eAAe,EAAE,kBAAkB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAcvG;AAED,wBAAsB,4BAA4B,CAAC,GAAG,EAAE,GAAG,yBAQ1D;AAED,wBAAsB,2BAA2B,CAAC,GAAG,EAAE,GAAG,yBAQzD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { getInitialTestAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
4
|
+
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
|
|
7
|
+
const BANANA_COIN_SALT = new Fr(0);
|
|
8
|
+
const bananaCoinArgs = {
|
|
9
|
+
name: 'BC',
|
|
10
|
+
symbol: 'BC',
|
|
11
|
+
decimal: 18n
|
|
12
|
+
};
|
|
13
|
+
const BANANA_FPC_SALT = new Fr(0);
|
|
14
|
+
function getBananaAdmin(initialAccounts) {
|
|
15
|
+
return initialAccounts[0]?.address ?? AztecAddress.ZERO;
|
|
16
|
+
}
|
|
17
|
+
async function getBananaCoinInstance(initialAccounts) {
|
|
18
|
+
const admin = getBananaAdmin(initialAccounts);
|
|
19
|
+
return await getContractInstanceFromDeployParams(TokenContract.artifact, {
|
|
20
|
+
constructorArgs: [
|
|
21
|
+
admin,
|
|
22
|
+
bananaCoinArgs.name,
|
|
23
|
+
bananaCoinArgs.symbol,
|
|
24
|
+
bananaCoinArgs.decimal
|
|
25
|
+
],
|
|
26
|
+
salt: BANANA_COIN_SALT
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export async function getBananaCoinAddress(initialAccounts) {
|
|
30
|
+
return (await getBananaCoinInstance(initialAccounts)).address;
|
|
31
|
+
}
|
|
32
|
+
async function getBananaFPCInstance(initialAccounts) {
|
|
33
|
+
const bananaCoin = await getBananaCoinAddress(initialAccounts);
|
|
34
|
+
const admin = getBananaAdmin(initialAccounts);
|
|
35
|
+
return await getContractInstanceFromDeployParams(FPCContract.artifact, {
|
|
36
|
+
constructorArgs: [
|
|
37
|
+
bananaCoin,
|
|
38
|
+
admin
|
|
39
|
+
],
|
|
40
|
+
salt: BANANA_FPC_SALT
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export async function getBananaFPCAddress(initialAccounts) {
|
|
44
|
+
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
45
|
+
}
|
|
46
|
+
export async function setupBananaFPC(initialAccounts, deployer, log) {
|
|
47
|
+
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
48
|
+
const admin = getBananaAdmin(initialAccounts);
|
|
49
|
+
const [bananaCoin, fpc] = await Promise.all([
|
|
50
|
+
TokenContract.deploy(deployer, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
|
|
51
|
+
contractAddressSalt: BANANA_COIN_SALT,
|
|
52
|
+
universalDeploy: true
|
|
53
|
+
}).deployed(),
|
|
54
|
+
FPCContract.deploy(deployer, bananaCoinAddress, admin).send({
|
|
55
|
+
contractAddressSalt: BANANA_FPC_SALT,
|
|
56
|
+
universalDeploy: true
|
|
57
|
+
}).deployed()
|
|
58
|
+
]);
|
|
59
|
+
log(`BananaCoin: ${bananaCoin.address}`);
|
|
60
|
+
log(`FPC: ${fpc.address}`);
|
|
61
|
+
}
|
|
62
|
+
export async function getDeployedBananaCoinAddress(pxe) {
|
|
63
|
+
const initialAccounts = await getInitialTestAccounts();
|
|
64
|
+
const bananaCoin = await getBananaCoinAddress(initialAccounts);
|
|
65
|
+
const contracts = await pxe.getContracts();
|
|
66
|
+
if (!contracts.find((c)=>c.equals(bananaCoin))) {
|
|
67
|
+
throw new Error('BananaCoin not deployed.');
|
|
68
|
+
}
|
|
69
|
+
return bananaCoin;
|
|
70
|
+
}
|
|
71
|
+
export async function getDeployedBananaFPCAddress(pxe) {
|
|
72
|
+
const initialAccounts = await getInitialTestAccounts();
|
|
73
|
+
const fpc = await getBananaFPCInstance(initialAccounts);
|
|
74
|
+
const contracts = await pxe.getContracts();
|
|
75
|
+
if (!contracts.find((c)=>c.equals(fpc.address))) {
|
|
76
|
+
throw new Error('BananaFPC not deployed.');
|
|
77
|
+
}
|
|
78
|
+
return fpc.address;
|
|
79
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './sandbox.js';
|
|
2
|
+
export { getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './banana_fpc.js';
|
|
3
|
+
export { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
4
|
+
export { SponsoredFeePaymentMethod } from './sponsored_fee_payment_method.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './sandbox.js';
|
|
2
|
+
export { getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './banana_fpc.js';
|
|
3
|
+
export { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
4
|
+
export { SponsoredFeePaymentMethod } from './sponsored_fee_payment_method.js';
|