@aztec/cli 0.0.0-test.1 → 0.0.1-fake-ceab37513c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
- package/dest/cmds/contracts/inspect_contract.js +9 -5
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +3 -3
- package/dest/cmds/infrastructure/sequencers.d.ts +2 -1
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +27 -15
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.js +14 -12
- package/dest/cmds/l1/advance_epoch.d.ts.map +1 -1
- package/dest/cmds/l1/advance_epoch.js +3 -2
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +3 -3
- package/dest/cmds/l1/bridge_erc20.d.ts +1 -1
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
- package/dest/cmds/l1/bridge_erc20.js +4 -4
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +2 -2
- package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_l1_contracts.js +22 -5
- package/dest/cmds/l1/deploy_new_rollup.d.ts +2 -1
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +16 -7
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.js +17 -17
- package/dest/cmds/l1/index.d.ts +1 -0
- package/dest/cmds/l1/index.d.ts.map +1 -1
- package/dest/cmds/l1/index.js +29 -39
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts +6 -0
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -0
- package/dest/cmds/l1/trigger_seed_snapshot.js +19 -0
- package/dest/cmds/l1/update_l1_validators.d.ts +17 -2
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +156 -101
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.js +2 -2
- package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.js +2 -2
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +3 -0
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts.map +1 -0
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.js +4 -0
- package/dest/cmds/misc/index.d.ts.map +1 -1
- package/dest/cmds/misc/index.js +7 -3
- package/dest/cmds/misc/update/github.d.ts +0 -1
- package/dest/cmds/misc/update/github.d.ts.map +1 -1
- package/dest/cmds/misc/update/github.js +0 -1
- package/dest/cmds/misc/update.d.ts.map +1 -1
- package/dest/cmds/misc/update.js +2 -3
- package/dest/cmds/pxe/get_contract_data.js +1 -1
- package/dest/cmds/pxe/get_node_info.d.ts.map +1 -1
- package/dest/cmds/pxe/get_node_info.js +11 -7
- package/dest/cmds/pxe/get_pxe_info.js +2 -2
- package/dest/config/cached_fetch.d.ts +18 -0
- package/dest/config/cached_fetch.d.ts.map +1 -0
- package/dest/config/cached_fetch.js +54 -0
- package/dest/config/chain_l2_config.d.ts +38 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -0
- package/dest/config/chain_l2_config.js +376 -0
- package/dest/config/enrich_env.d.ts +4 -0
- package/dest/config/enrich_env.d.ts.map +1 -0
- package/dest/config/enrich_env.js +12 -0
- package/dest/config/get_l1_config.d.ts +8 -0
- package/dest/config/get_l1_config.d.ts.map +1 -0
- package/dest/config/get_l1_config.js +22 -0
- package/dest/config/index.d.ts +5 -0
- package/dest/config/index.d.ts.map +1 -0
- package/dest/config/index.js +4 -0
- package/dest/config/network_config.d.ts +19 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +79 -0
- package/dest/utils/aztec.d.ts +12 -11
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +52 -22
- package/dest/utils/commands.d.ts +1 -1
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +5 -5
- package/dest/utils/encoding.js +1 -1
- package/dest/utils/github.d.ts +0 -1
- package/dest/utils/github.d.ts.map +1 -1
- package/dest/utils/github.js +0 -1
- package/dest/utils/index.d.ts +1 -0
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +1 -0
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +18 -26
- package/dest/utils/setup_contracts.d.ts +5 -0
- package/dest/utils/setup_contracts.d.ts.map +1 -0
- package/dest/utils/setup_contracts.js +36 -0
- package/package.json +38 -32
- package/src/cmds/contracts/inspect_contract.ts +16 -6
- package/src/cmds/infrastructure/index.ts +10 -2
- package/src/cmds/infrastructure/sequencers.ts +32 -15
- package/src/cmds/infrastructure/setup_l2_contract.ts +16 -11
- package/src/cmds/l1/advance_epoch.ts +3 -2
- package/src/cmds/l1/assume_proven_through.ts +3 -3
- package/src/cmds/l1/bridge_erc20.ts +4 -3
- package/src/cmds/l1/deploy_l1_contracts.ts +30 -6
- package/src/cmds/l1/deploy_new_rollup.ts +22 -8
- package/src/cmds/l1/governance_utils.ts +18 -17
- package/src/cmds/l1/index.ts +69 -96
- package/src/cmds/l1/trigger_seed_snapshot.ts +31 -0
- package/src/cmds/l1/update_l1_validators.ts +191 -92
- package/src/cmds/misc/generate_bootnode_enr.ts +3 -2
- package/src/cmds/misc/generate_secret_and_hash.ts +2 -2
- package/src/cmds/misc/get_canonical_sponsored_fpc_address.ts +7 -0
- package/src/cmds/misc/index.ts +13 -4
- package/src/cmds/misc/update/github.ts +0 -1
- package/src/cmds/misc/update.ts +1 -7
- package/src/cmds/pxe/get_contract_data.ts +1 -1
- package/src/cmds/pxe/get_node_info.ts +10 -7
- package/src/cmds/pxe/get_pxe_info.ts +2 -2
- package/src/config/cached_fetch.ts +67 -0
- package/src/config/chain_l2_config.ts +493 -0
- package/src/config/enrich_env.ts +15 -0
- package/src/config/get_l1_config.ts +28 -0
- package/src/config/index.ts +4 -0
- package/src/config/network_config.ts +102 -0
- package/src/utils/aztec.ts +76 -27
- package/src/utils/commands.ts +5 -5
- package/src/utils/encoding.ts +1 -1
- package/src/utils/github.ts +0 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/inspect.ts +18 -25
- package/src/utils/setup_contracts.ts +58 -0
- package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
- package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
- package/dest/cmds/devnet/bootstrap_network.js +0 -196
- package/dest/cmds/devnet/faucet.d.ts +0 -4
- package/dest/cmds/devnet/faucet.d.ts.map +0 -1
- package/dest/cmds/devnet/faucet.js +0 -26
- package/dest/cmds/devnet/index.d.ts +0 -4
- package/dest/cmds/devnet/index.d.ts.map +0 -1
- package/dest/cmds/devnet/index.js +0 -14
- package/dest/cmds/l1/deploy_l1_verifier.d.ts +0 -5
- package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +0 -1
- package/dest/cmds/l1/deploy_l1_verifier.js +0 -54
- package/dest/cmds/misc/setup_contracts.d.ts +0 -7
- package/dest/cmds/misc/setup_contracts.d.ts.map +0 -1
- package/dest/cmds/misc/setup_contracts.js +0 -27
- package/src/cmds/devnet/bootstrap_network.ts +0 -318
- package/src/cmds/devnet/faucet.ts +0 -33
- package/src/cmds/devnet/index.ts +0 -60
- package/src/cmds/l1/deploy_l1_verifier.ts +0 -105
- package/src/cmds/misc/setup_contracts.ts +0 -40
package/src/utils/aztec.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { EthAddress, type PXE } from '@aztec/aztec.js';
|
|
2
|
+
import {
|
|
3
|
+
type ContractArtifact,
|
|
4
|
+
type FunctionAbi,
|
|
5
|
+
FunctionType,
|
|
6
|
+
getAllFunctionAbis,
|
|
7
|
+
loadContractArtifact,
|
|
8
|
+
} from '@aztec/aztec.js/abi';
|
|
9
|
+
import {
|
|
10
|
+
type DeployL1ContractsReturnType,
|
|
11
|
+
type L1ContractsConfig,
|
|
12
|
+
type Operator,
|
|
13
|
+
RollupContract,
|
|
14
|
+
} from '@aztec/ethereum';
|
|
15
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
16
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
5
17
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
6
18
|
import type { NoirPackageConfig } from '@aztec/foundation/noir';
|
|
7
|
-
import {
|
|
8
|
-
import { FunctionType } from '@aztec/stdlib/abi';
|
|
19
|
+
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
9
20
|
|
|
10
21
|
import TOML from '@iarna/toml';
|
|
11
22
|
import { readFile } from 'fs/promises';
|
|
@@ -19,8 +30,8 @@ import { encodeArgs } from './encoding.js';
|
|
|
19
30
|
* @param fnName - Function name to be found.
|
|
20
31
|
* @returns The function's ABI.
|
|
21
32
|
*/
|
|
22
|
-
export function
|
|
23
|
-
const fn = artifact.
|
|
33
|
+
export function getFunctionAbi(artifact: ContractArtifact, fnName: string): FunctionAbi {
|
|
34
|
+
const fn = getAllFunctionAbis(artifact).find(({ name }) => name === fnName);
|
|
24
35
|
if (!fn) {
|
|
25
36
|
throw Error(`Function ${fnName} not found in contract ABI.`);
|
|
26
37
|
}
|
|
@@ -41,11 +52,14 @@ export async function deployAztecContracts(
|
|
|
41
52
|
mnemonic: string,
|
|
42
53
|
mnemonicIndex: number,
|
|
43
54
|
salt: number | undefined,
|
|
44
|
-
initialValidators:
|
|
55
|
+
initialValidators: Operator[],
|
|
45
56
|
genesisArchiveRoot: Fr,
|
|
46
|
-
|
|
57
|
+
feeJuicePortalInitialBalance: bigint,
|
|
47
58
|
acceleratedTestDeployments: boolean,
|
|
48
59
|
config: L1ContractsConfig,
|
|
60
|
+
existingToken: EthAddress | undefined,
|
|
61
|
+
realVerifier: boolean,
|
|
62
|
+
createVerificationJson: string | false,
|
|
49
63
|
debugLogger: Logger,
|
|
50
64
|
): Promise<DeployL1ContractsReturnType> {
|
|
51
65
|
const { createEthereumChain, deployL1Contracts } = await import('@aztec/ethereum');
|
|
@@ -53,29 +67,33 @@ export async function deployAztecContracts(
|
|
|
53
67
|
|
|
54
68
|
const account = !privateKey
|
|
55
69
|
? mnemonicToAccount(mnemonic!, { addressIndex: mnemonicIndex })
|
|
56
|
-
: privateKeyToAccount(
|
|
70
|
+
: privateKeyToAccount(addLeadingHex(privateKey));
|
|
57
71
|
const chain = createEthereumChain(rpcUrls, chainId);
|
|
58
72
|
|
|
59
73
|
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
60
74
|
|
|
61
|
-
|
|
75
|
+
const result = await deployL1Contracts(
|
|
62
76
|
chain.rpcUrls,
|
|
63
77
|
account,
|
|
64
78
|
chain.chainInfo,
|
|
65
79
|
debugLogger,
|
|
66
80
|
{
|
|
67
|
-
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
68
81
|
vkTreeRoot: getVKTreeRoot(),
|
|
69
82
|
protocolContractTreeRoot,
|
|
70
83
|
genesisArchiveRoot,
|
|
71
|
-
genesisBlockHash,
|
|
72
84
|
salt,
|
|
73
85
|
initialValidators,
|
|
74
86
|
acceleratedTestDeployments,
|
|
87
|
+
feeJuicePortalInitialBalance,
|
|
88
|
+
realVerifier,
|
|
89
|
+
existingTokenAddress: existingToken,
|
|
75
90
|
...config,
|
|
76
91
|
},
|
|
77
92
|
config,
|
|
93
|
+
createVerificationJson,
|
|
78
94
|
);
|
|
95
|
+
|
|
96
|
+
return result;
|
|
79
97
|
}
|
|
80
98
|
|
|
81
99
|
export async function deployNewRollupContracts(
|
|
@@ -86,40 +104,59 @@ export async function deployNewRollupContracts(
|
|
|
86
104
|
mnemonic: string,
|
|
87
105
|
mnemonicIndex: number,
|
|
88
106
|
salt: number | undefined,
|
|
89
|
-
initialValidators:
|
|
107
|
+
initialValidators: Operator[],
|
|
90
108
|
genesisArchiveRoot: Fr,
|
|
91
|
-
|
|
109
|
+
feeJuicePortalInitialBalance: bigint,
|
|
92
110
|
config: L1ContractsConfig,
|
|
111
|
+
realVerifier: boolean,
|
|
112
|
+
createVerificationJson: string | false,
|
|
93
113
|
logger: Logger,
|
|
94
|
-
): Promise<{
|
|
95
|
-
const { createEthereumChain,
|
|
114
|
+
): Promise<{ rollup: RollupContract; slashFactoryAddress: EthAddress }> {
|
|
115
|
+
const { createEthereumChain, deployRollupForUpgrade, createExtendedL1Client } = await import('@aztec/ethereum');
|
|
96
116
|
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
|
|
97
117
|
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
98
118
|
|
|
99
119
|
const account = !privateKey
|
|
100
120
|
? mnemonicToAccount(mnemonic!, { addressIndex: mnemonicIndex })
|
|
101
|
-
: privateKeyToAccount(
|
|
121
|
+
: privateKeyToAccount(addLeadingHex(privateKey));
|
|
102
122
|
const chain = createEthereumChain(rpcUrls, chainId);
|
|
103
|
-
const
|
|
123
|
+
const client = createExtendedL1Client(rpcUrls, account, chain.chainInfo, undefined, mnemonicIndex);
|
|
124
|
+
|
|
125
|
+
if (!initialValidators || initialValidators.length === 0) {
|
|
126
|
+
// initialize the new rollup with Amin's validator address.
|
|
127
|
+
const aminAddressString = '0x3b218d0F26d15B36C715cB06c949210a0d630637';
|
|
128
|
+
const amin = EthAddress.fromString(aminAddressString);
|
|
104
129
|
|
|
105
|
-
|
|
106
|
-
|
|
130
|
+
initialValidators = [
|
|
131
|
+
{
|
|
132
|
+
attester: amin,
|
|
133
|
+
withdrawer: amin,
|
|
134
|
+
// No secrets here. The actual keys are not currently used.
|
|
135
|
+
bn254SecretKey: new SecretValue(Fr.fromHexString(aminAddressString).toBigInt()),
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
logger.info('Initializing new rollup with old attesters', { initialValidators });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const { rollup, slashFactoryAddress } = await deployRollupForUpgrade(
|
|
142
|
+
client,
|
|
107
143
|
{
|
|
108
144
|
salt,
|
|
109
145
|
vkTreeRoot: getVKTreeRoot(),
|
|
110
146
|
protocolContractTreeRoot,
|
|
111
|
-
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
112
147
|
genesisArchiveRoot,
|
|
113
|
-
genesisBlockHash,
|
|
114
148
|
initialValidators,
|
|
149
|
+
feeJuicePortalInitialBalance,
|
|
150
|
+
realVerifier,
|
|
115
151
|
...config,
|
|
116
152
|
},
|
|
117
153
|
registryAddress,
|
|
118
154
|
logger,
|
|
119
155
|
config,
|
|
156
|
+
createVerificationJson,
|
|
120
157
|
);
|
|
121
158
|
|
|
122
|
-
return {
|
|
159
|
+
return { rollup, slashFactoryAddress };
|
|
123
160
|
}
|
|
124
161
|
|
|
125
162
|
/**
|
|
@@ -178,7 +215,7 @@ export async function getContractArtifact(fileDir: string, log: LogFn) {
|
|
|
178
215
|
*/
|
|
179
216
|
export async function prepTx(contractFile: string, functionName: string, _functionArgs: string[], log: LogFn) {
|
|
180
217
|
const contractArtifact = await getContractArtifact(contractFile, log);
|
|
181
|
-
const functionArtifact =
|
|
218
|
+
const functionArtifact = getFunctionAbi(contractArtifact, functionName);
|
|
182
219
|
const functionArgs = encodeArgs(_functionArgs, functionArtifact.parameters);
|
|
183
220
|
const isPrivate = functionArtifact.functionType === FunctionType.PRIVATE;
|
|
184
221
|
|
|
@@ -190,7 +227,7 @@ export async function prepTx(contractFile: string, functionName: string, _functi
|
|
|
190
227
|
* @param hex - A hex string
|
|
191
228
|
* @returns A new string with leading 0x removed
|
|
192
229
|
*/
|
|
193
|
-
export const stripLeadingHex = (hex: string) => {
|
|
230
|
+
export const stripLeadingHex = (hex: string): string => {
|
|
194
231
|
if (hex.length > 2 && hex.startsWith('0x')) {
|
|
195
232
|
return hex.substring(2);
|
|
196
233
|
}
|
|
@@ -198,6 +235,18 @@ export const stripLeadingHex = (hex: string) => {
|
|
|
198
235
|
};
|
|
199
236
|
|
|
200
237
|
/**
|
|
238
|
+
* Adds a leading 0x to a hex string. If a leading 0x is already present the string is returned unchanged.
|
|
239
|
+
* @param hex - A hex string
|
|
240
|
+
* @returns A new string with leading 0x added
|
|
241
|
+
*/
|
|
242
|
+
export const addLeadingHex = (hex: string): `0x${string}` => {
|
|
243
|
+
if (hex.length > 2 && hex.startsWith('0x')) {
|
|
244
|
+
return hex as `0x${string}`;
|
|
245
|
+
}
|
|
246
|
+
return `0x${hex}`;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/*
|
|
201
250
|
* Pretty prints Nargo.toml contents to a string
|
|
202
251
|
* @param config - Nargo.toml contents
|
|
203
252
|
* @returns The Nargo.toml contents as a string
|
package/src/utils/commands.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const getLocalhost = () =>
|
|
|
22
22
|
.catch(() => 'localhost');
|
|
23
23
|
|
|
24
24
|
export const LOCALHOST = await getLocalhost();
|
|
25
|
-
export const { ETHEREUM_HOSTS = `http://${LOCALHOST}:8545`, PRIVATE_KEY, API_KEY, CLI_VERSION } = process.env;
|
|
25
|
+
export const { ETHEREUM_HOSTS = `http://${LOCALHOST}:8545`, PRIVATE_KEY, MNEMONIC, API_KEY, CLI_VERSION } = process.env;
|
|
26
26
|
|
|
27
27
|
export function addOptions(program: Command, options: Option[]) {
|
|
28
28
|
options.forEach(option => program.addOption(option));
|
|
@@ -287,7 +287,7 @@ export function parsePublicKey(publicKey: string): PublicKeys | undefined {
|
|
|
287
287
|
}
|
|
288
288
|
try {
|
|
289
289
|
return PublicKeys.fromString(publicKey);
|
|
290
|
-
} catch
|
|
290
|
+
} catch {
|
|
291
291
|
throw new InvalidArgumentError(`Invalid public key: ${publicKey}`);
|
|
292
292
|
}
|
|
293
293
|
}
|
|
@@ -301,7 +301,7 @@ export function parsePublicKey(publicKey: string): PublicKeys | undefined {
|
|
|
301
301
|
export function parsePartialAddress(address: string): Fr {
|
|
302
302
|
try {
|
|
303
303
|
return Fr.fromHexString(address);
|
|
304
|
-
} catch
|
|
304
|
+
} catch {
|
|
305
305
|
throw new InvalidArgumentError(`Invalid partial address: ${address}`);
|
|
306
306
|
}
|
|
307
307
|
}
|
|
@@ -315,7 +315,7 @@ export function parsePartialAddress(address: string): Fr {
|
|
|
315
315
|
export function parseSecretKey(secretKey: string): Fr {
|
|
316
316
|
try {
|
|
317
317
|
return Fr.fromHexString(secretKey);
|
|
318
|
-
} catch
|
|
318
|
+
} catch {
|
|
319
319
|
throw new InvalidArgumentError(`Invalid encryption secret key: ${secretKey}`);
|
|
320
320
|
}
|
|
321
321
|
}
|
|
@@ -348,7 +348,7 @@ export function parseField(field: string): Fr {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
return new Fr(BigInt(field));
|
|
351
|
-
} catch
|
|
351
|
+
} catch {
|
|
352
352
|
throw new InvalidArgumentError(`Invalid field: ${field}`);
|
|
353
353
|
}
|
|
354
354
|
}
|
package/src/utils/encoding.ts
CHANGED
|
@@ -35,7 +35,7 @@ function encodeArg(arg: string, abiType: AbiType, name: string): any {
|
|
|
35
35
|
let res: bigint;
|
|
36
36
|
try {
|
|
37
37
|
res = BigInt(arg);
|
|
38
|
-
} catch
|
|
38
|
+
} catch {
|
|
39
39
|
throw new Error(
|
|
40
40
|
`Invalid value passed for ${name}. Could not parse ${arg} as a${kind === 'integer' ? 'n' : ''} ${kind}.`,
|
|
41
41
|
);
|
package/src/utils/github.ts
CHANGED
package/src/utils/index.ts
CHANGED
package/src/utils/inspect.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
3
3
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
4
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
5
5
|
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
6
|
-
import {
|
|
6
|
+
import type { ExtendedNote } from '@aztec/stdlib/note';
|
|
7
7
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
8
8
|
|
|
9
9
|
export async function inspectBlock(pxe: PXE, blockNumber: number, log: LogFn, opts: { showTxs?: boolean } = {}) {
|
|
@@ -18,11 +18,11 @@ export async function inspectBlock(pxe: PXE, blockNumber: number, log: LogFn, op
|
|
|
18
18
|
log(` Total fees: ${block.header.totalFees.toBigInt()}`);
|
|
19
19
|
log(` Total mana used: ${block.header.totalManaUsed.toBigInt()}`);
|
|
20
20
|
log(
|
|
21
|
-
` Fee per gas unit: DA=${block.header.globalVariables.gasFees.feePerDaGas
|
|
21
|
+
` Fee per gas unit: DA=${block.header.globalVariables.gasFees.feePerDaGas} L2=${block.header.globalVariables.gasFees.feePerL2Gas}`,
|
|
22
22
|
);
|
|
23
23
|
log(` Coinbase: ${block.header.globalVariables.coinbase}`);
|
|
24
24
|
log(` Fee recipient: ${block.header.globalVariables.feeRecipient}`);
|
|
25
|
-
log(` Timestamp: ${new Date(block.header.globalVariables.timestamp
|
|
25
|
+
log(` Timestamp: ${new Date(Number(block.header.globalVariables.timestamp) * 500)}`);
|
|
26
26
|
if (opts.showTxs) {
|
|
27
27
|
log(``);
|
|
28
28
|
const artifactMap = await getKnownArtifacts(pxe);
|
|
@@ -40,11 +40,7 @@ export async function inspectTx(
|
|
|
40
40
|
log: LogFn,
|
|
41
41
|
opts: { includeBlockInfo?: boolean; artifactMap?: ArtifactMap } = {},
|
|
42
42
|
) {
|
|
43
|
-
const [receipt, effectsInBlock
|
|
44
|
-
pxe.getTxReceipt(txHash),
|
|
45
|
-
pxe.getTxEffect(txHash),
|
|
46
|
-
pxe.getNotes({ txHash, status: NoteStatus.ACTIVE_OR_NULLIFIED }),
|
|
47
|
-
]);
|
|
43
|
+
const [receipt, effectsInBlock] = await Promise.all([pxe.getTxReceipt(txHash), pxe.getTxEffect(txHash)]);
|
|
48
44
|
// Base tx data
|
|
49
45
|
log(`Tx ${txHash.toString()}`);
|
|
50
46
|
log(` Status: ${receipt.status} ${effectsInBlock ? `(${effectsInBlock.data.revertCode.getDescription()})` : ''}`);
|
|
@@ -88,12 +84,9 @@ export async function inspectTx(
|
|
|
88
84
|
const notes = effects.noteHashes;
|
|
89
85
|
if (notes.length > 0) {
|
|
90
86
|
log(' Created notes:');
|
|
91
|
-
log(` Total: ${notes.length}
|
|
92
|
-
|
|
93
|
-
log(
|
|
94
|
-
for (const note of getNotes) {
|
|
95
|
-
inspectNote(note, artifactMap, log);
|
|
96
|
-
}
|
|
87
|
+
log(` Total: ${notes.length}`);
|
|
88
|
+
for (const note of notes) {
|
|
89
|
+
log(` Note hash: ${note.toShortString()}`);
|
|
97
90
|
}
|
|
98
91
|
}
|
|
99
92
|
|
|
@@ -103,8 +96,10 @@ export async function inspectTx(
|
|
|
103
96
|
if (nullifierCount > 0) {
|
|
104
97
|
log(' Nullifiers:');
|
|
105
98
|
for (const nullifier of effects.nullifiers) {
|
|
106
|
-
const [note] = await pxe.getNotes({ siloedNullifier: nullifier });
|
|
107
99
|
const deployed = deployNullifiers[nullifier.toString()];
|
|
100
|
+
const note = deployed
|
|
101
|
+
? (await pxe.getNotes({ siloedNullifier: nullifier, contractAddress: deployed }))[0]
|
|
102
|
+
: undefined;
|
|
108
103
|
const initialized = initNullifiers[nullifier.toString()];
|
|
109
104
|
const registered = classNullifiers[nullifier.toString()];
|
|
110
105
|
if (nullifier.toBuffer().equals(txHash.toBuffer())) {
|
|
@@ -142,9 +137,8 @@ export async function inspectTx(
|
|
|
142
137
|
function inspectNote(note: ExtendedNote, artifactMap: ArtifactMap, log: LogFn, text = 'Note') {
|
|
143
138
|
const artifact = artifactMap[note.contractAddress.toString()];
|
|
144
139
|
const contract = artifact?.name ?? note.contractAddress.toString();
|
|
145
|
-
|
|
146
|
-
log(`
|
|
147
|
-
log(` Owner: ${toFriendlyAddress(note.owner, artifactMap)}`);
|
|
140
|
+
log(` ${text} at ${contract}`);
|
|
141
|
+
log(` Recipient: ${toFriendlyAddress(note.recipient, artifactMap)}`);
|
|
148
142
|
for (const field of note.note.items) {
|
|
149
143
|
log(` ${field.toString()}`);
|
|
150
144
|
}
|
|
@@ -161,19 +155,18 @@ function toFriendlyAddress(address: AztecAddress, artifactMap: ArtifactMap) {
|
|
|
161
155
|
|
|
162
156
|
async function getKnownNullifiers(pxe: PXE, artifactMap: ArtifactMap) {
|
|
163
157
|
const knownContracts = await pxe.getContracts();
|
|
164
|
-
const deployerAddress = ProtocolContractAddress.
|
|
165
|
-
const
|
|
158
|
+
const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
|
|
159
|
+
const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
|
|
166
160
|
const initNullifiers: Record<string, AztecAddress> = {};
|
|
167
161
|
const deployNullifiers: Record<string, AztecAddress> = {};
|
|
168
162
|
const classNullifiers: Record<string, string> = {};
|
|
169
163
|
for (const contract of knownContracts) {
|
|
170
|
-
initNullifiers[siloNullifier(contract, contract.toField()).toString()] = contract;
|
|
171
|
-
deployNullifiers[siloNullifier(deployerAddress, contract.toField()).toString()] = contract;
|
|
164
|
+
initNullifiers[(await siloNullifier(contract, contract.toField())).toString()] = contract;
|
|
165
|
+
deployNullifiers[(await siloNullifier(deployerAddress, contract.toField())).toString()] = contract;
|
|
172
166
|
}
|
|
173
167
|
for (const artifact of Object.values(artifactMap)) {
|
|
174
|
-
classNullifiers[
|
|
175
|
-
|
|
176
|
-
] = `${artifact.name}Class<${artifact.classId}>`;
|
|
168
|
+
classNullifiers[(await siloNullifier(classRegistryAddress, artifact.classId)).toString()] =
|
|
169
|
+
`${artifact.name}Class<${artifact.classId}>`;
|
|
177
170
|
}
|
|
178
171
|
return { initNullifiers, deployNullifiers, classNullifiers };
|
|
179
172
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AztecAddress,
|
|
3
|
+
DefaultWaitOpts,
|
|
4
|
+
Fr,
|
|
5
|
+
type PXE,
|
|
6
|
+
SignerlessWallet,
|
|
7
|
+
SponsoredFeePaymentMethod,
|
|
8
|
+
type WaitForProvenOpts,
|
|
9
|
+
getContractInstanceFromInstantiationParams,
|
|
10
|
+
waitForProven,
|
|
11
|
+
} from '@aztec/aztec.js';
|
|
12
|
+
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
13
|
+
import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
|
|
14
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
15
|
+
|
|
16
|
+
async function getSponsoredFPCContract() {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
18
|
+
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
19
|
+
const { SponsoredFPCContract } = await import('@aztec/noir-contracts.js/SponsoredFPC');
|
|
20
|
+
return SponsoredFPCContract;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function getSponsoredFPCAddress() {
|
|
24
|
+
const SponsoredFPCContract = await getSponsoredFPCContract();
|
|
25
|
+
const sponsoredFPCInstance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
26
|
+
salt: new Fr(SPONSORED_FPC_SALT),
|
|
27
|
+
});
|
|
28
|
+
return sponsoredFPCInstance.address;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function setupSponsoredFPC(
|
|
32
|
+
pxe: PXE,
|
|
33
|
+
log: LogFn,
|
|
34
|
+
waitOpts = DefaultWaitOpts,
|
|
35
|
+
waitForProvenOptions?: WaitForProvenOpts,
|
|
36
|
+
) {
|
|
37
|
+
const SponsoredFPCContract = await getSponsoredFPCContract();
|
|
38
|
+
const address = await getSponsoredFPCAddress();
|
|
39
|
+
const paymentMethod = new SponsoredFeePaymentMethod(address);
|
|
40
|
+
const { l1ChainId: chainId, rollupVersion } = await pxe.getNodeInfo();
|
|
41
|
+
|
|
42
|
+
const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(chainId, rollupVersion));
|
|
43
|
+
|
|
44
|
+
const deployTx = SponsoredFPCContract.deploy(deployer).send({
|
|
45
|
+
from: AztecAddress.ZERO,
|
|
46
|
+
contractAddressSalt: new Fr(SPONSORED_FPC_SALT),
|
|
47
|
+
universalDeploy: true,
|
|
48
|
+
fee: { paymentMethod },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const deployed = await deployTx.deployed(waitOpts);
|
|
52
|
+
|
|
53
|
+
if (waitForProvenOptions !== undefined) {
|
|
54
|
+
await waitForProven(pxe, await deployTx.getReceipt(), waitForProvenOptions);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
log(`SponsoredFPC: ${deployed.address}`);
|
|
58
|
+
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
2
|
-
export declare function bootstrapNetwork(pxeUrl: string, l1Urls: string[], l1ChainId: string, l1PrivateKey: `0x${string}` | undefined, l1Mnemonic: string, addressIndex: number, json: boolean, log: LogFn, debugLog: Logger): Promise<void>;
|
|
3
|
-
//# sourceMappingURL=bootstrap_network.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap_network.d.ts","sourceRoot":"","sources":["../../../src/cmds/devnet/bootstrap_network.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAiB3D,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS,EACvC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,MAAM,iBA4EjB"}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { getDeployedTestAccountsWallets } from '@aztec/accounts/testing';
|
|
2
|
-
import { BatchCall, Fr, L1FeeJuicePortalManager, createCompatibleClient, retryUntil } from '@aztec/aztec.js';
|
|
3
|
-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
|
|
4
|
-
import { createEthereumChain, createL1Clients, deployL1Contract } from '@aztec/ethereum';
|
|
5
|
-
import { getContract } from 'viem';
|
|
6
|
-
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
7
|
-
const waitOpts = {
|
|
8
|
-
timeout: 120,
|
|
9
|
-
provenTimeout: 4800,
|
|
10
|
-
interval: 1
|
|
11
|
-
};
|
|
12
|
-
export async function bootstrapNetwork(pxeUrl, l1Urls, l1ChainId, l1PrivateKey, l1Mnemonic, addressIndex, json, log, debugLog) {
|
|
13
|
-
const pxe = await createCompatibleClient(pxeUrl, debugLog);
|
|
14
|
-
const [wallet] = await getDeployedTestAccountsWallets(pxe);
|
|
15
|
-
const l1Clients = createL1Clients(l1Urls, l1PrivateKey ? privateKeyToAccount(l1PrivateKey) : // Note that this account needs to be funded on L1 !
|
|
16
|
-
mnemonicToAccount(l1Mnemonic, {
|
|
17
|
-
addressIndex
|
|
18
|
-
}), createEthereumChain(l1Urls, +l1ChainId).chainInfo);
|
|
19
|
-
const { erc20Address, portalAddress } = await deployERC20(l1Clients);
|
|
20
|
-
const { token, bridge } = await deployToken(wallet, portalAddress);
|
|
21
|
-
await initPortal(pxe, l1Clients, erc20Address, portalAddress, bridge.address);
|
|
22
|
-
const fpcAdmin = wallet.getAddress();
|
|
23
|
-
const fpc = await deployFPC(wallet, token.address, fpcAdmin);
|
|
24
|
-
const counter = await deployCounter(wallet);
|
|
25
|
-
await fundFPC(counter.address, wallet, l1Clients, fpc.address, debugLog);
|
|
26
|
-
if (json) {
|
|
27
|
-
log(JSON.stringify({
|
|
28
|
-
devCoinL1: erc20Address.toString(),
|
|
29
|
-
devCoinPortalL1: portalAddress.toString(),
|
|
30
|
-
devCoin: {
|
|
31
|
-
address: token.address.toString(),
|
|
32
|
-
initHash: token.initHash.toString(),
|
|
33
|
-
salt: token.salt.toString()
|
|
34
|
-
},
|
|
35
|
-
devCoinBridge: {
|
|
36
|
-
address: bridge.address.toString(),
|
|
37
|
-
initHash: bridge.initHash.toString(),
|
|
38
|
-
salt: bridge.salt.toString()
|
|
39
|
-
},
|
|
40
|
-
devCoinFpc: {
|
|
41
|
-
address: fpc.address.toString(),
|
|
42
|
-
initHash: fpc.initHash.toString(),
|
|
43
|
-
salt: fpc.salt.toString()
|
|
44
|
-
},
|
|
45
|
-
counter: {
|
|
46
|
-
address: counter.address.toString(),
|
|
47
|
-
initHash: counter.initHash.toString(),
|
|
48
|
-
salt: counter.salt.toString()
|
|
49
|
-
}
|
|
50
|
-
}, null, 2));
|
|
51
|
-
} else {
|
|
52
|
-
log(`DevCoin L1: ${erc20Address}`);
|
|
53
|
-
log(`DevCoin L1 Portal: ${portalAddress}`);
|
|
54
|
-
log(`DevCoin L2: ${token.address}`);
|
|
55
|
-
log(`DevCoin L2 init hash: ${token.initHash}`);
|
|
56
|
-
log(`DevCoin L2 salt: ${token.salt}`);
|
|
57
|
-
log(`DevCoin L2 Bridge: ${bridge.address}`);
|
|
58
|
-
log(`DevCoin L2 Bridge init hash: ${bridge.initHash}`);
|
|
59
|
-
log(`DevCoin L2 Bridge salt: ${bridge.salt}`);
|
|
60
|
-
log(`DevCoin FPC: ${fpc.address}`);
|
|
61
|
-
log(`DevCoin FPC init hash: ${fpc.initHash}`);
|
|
62
|
-
log(`DevCoin FPC salt: ${fpc.salt}`);
|
|
63
|
-
log(`Counter: ${counter.address}`);
|
|
64
|
-
log(`Counter init hash: ${counter.initHash}`);
|
|
65
|
-
log(`Counter salt: ${counter.salt}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Step 1. Deploy the L1 contracts, but don't initialize
|
|
70
|
-
*/ async function deployERC20({ walletClient, publicClient }) {
|
|
71
|
-
const { TestERC20Abi, TestERC20Bytecode, TokenPortalAbi, TokenPortalBytecode } = await import('@aztec/l1-artifacts');
|
|
72
|
-
const erc20 = {
|
|
73
|
-
contractAbi: TestERC20Abi,
|
|
74
|
-
contractBytecode: TestERC20Bytecode
|
|
75
|
-
};
|
|
76
|
-
const portal = {
|
|
77
|
-
contractAbi: TokenPortalAbi,
|
|
78
|
-
contractBytecode: TokenPortalBytecode
|
|
79
|
-
};
|
|
80
|
-
const { address: erc20Address } = await deployL1Contract(walletClient, publicClient, erc20.contractAbi, erc20.contractBytecode, [
|
|
81
|
-
'DevCoin',
|
|
82
|
-
'DEV',
|
|
83
|
-
walletClient.account.address
|
|
84
|
-
]);
|
|
85
|
-
const { address: portalAddress } = await deployL1Contract(walletClient, publicClient, portal.contractAbi, portal.contractBytecode);
|
|
86
|
-
return {
|
|
87
|
-
erc20Address,
|
|
88
|
-
portalAddress
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Step 2. Deploy the L2 contracts
|
|
93
|
-
*/ async function deployToken(wallet, l1Portal) {
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
95
|
-
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
96
|
-
const { TokenContract } = await import('@aztec/noir-contracts.js/Token');
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
98
|
-
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
99
|
-
const { TokenBridgeContract } = await import('@aztec/noir-contracts.js/TokenBridge');
|
|
100
|
-
const devCoin = await TokenContract.deploy(wallet, wallet.getAddress(), 'DevCoin', 'DEV', 18).send({
|
|
101
|
-
universalDeploy: true
|
|
102
|
-
}).deployed(waitOpts);
|
|
103
|
-
const bridge = await TokenBridgeContract.deploy(wallet, devCoin.address, l1Portal).send({
|
|
104
|
-
universalDeploy: true
|
|
105
|
-
}).deployed(waitOpts);
|
|
106
|
-
await new BatchCall(wallet, [
|
|
107
|
-
await devCoin.methods.set_minter(bridge.address, true).request(),
|
|
108
|
-
await devCoin.methods.set_admin(bridge.address).request()
|
|
109
|
-
]).send().wait(waitOpts);
|
|
110
|
-
return {
|
|
111
|
-
token: {
|
|
112
|
-
address: devCoin.address,
|
|
113
|
-
initHash: devCoin.instance.initializationHash,
|
|
114
|
-
salt: devCoin.instance.salt
|
|
115
|
-
},
|
|
116
|
-
bridge: {
|
|
117
|
-
address: bridge.address,
|
|
118
|
-
initHash: bridge.instance.initializationHash,
|
|
119
|
-
salt: bridge.instance.salt
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Step 3. Initialize DevCoin's L1 portal
|
|
125
|
-
*/ async function initPortal(pxe, { walletClient, publicClient }, erc20, portal, bridge) {
|
|
126
|
-
const { TokenPortalAbi } = await import('@aztec/l1-artifacts');
|
|
127
|
-
const { l1ContractAddresses: { registryAddress } } = await pxe.getNodeInfo();
|
|
128
|
-
const contract = getContract({
|
|
129
|
-
abi: TokenPortalAbi,
|
|
130
|
-
address: portal.toString(),
|
|
131
|
-
client: walletClient
|
|
132
|
-
});
|
|
133
|
-
const hash = await contract.write.initialize([
|
|
134
|
-
registryAddress.toString(),
|
|
135
|
-
erc20.toString(),
|
|
136
|
-
bridge.toString()
|
|
137
|
-
]);
|
|
138
|
-
await publicClient.waitForTransactionReceipt({
|
|
139
|
-
hash
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
async function deployFPC(wallet, tokenAddress, admin) {
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
144
|
-
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
145
|
-
const { FPCContract } = await import('@aztec/noir-contracts.js/FPC');
|
|
146
|
-
const fpc = await FPCContract.deploy(wallet, tokenAddress, admin).send({
|
|
147
|
-
universalDeploy: true
|
|
148
|
-
}).deployed(waitOpts);
|
|
149
|
-
const info = {
|
|
150
|
-
address: fpc.address,
|
|
151
|
-
initHash: fpc.instance.initializationHash,
|
|
152
|
-
salt: fpc.instance.salt
|
|
153
|
-
};
|
|
154
|
-
return info;
|
|
155
|
-
}
|
|
156
|
-
async function deployCounter(wallet) {
|
|
157
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
158
|
-
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
159
|
-
const { CounterContract } = await import('@aztec/noir-contracts.js/Counter');
|
|
160
|
-
const counter = await CounterContract.deploy(wallet, 1, wallet.getAddress()).send({
|
|
161
|
-
universalDeploy: true
|
|
162
|
-
}).deployed(waitOpts);
|
|
163
|
-
const info = {
|
|
164
|
-
address: counter.address,
|
|
165
|
-
initHash: counter.instance.initializationHash,
|
|
166
|
-
salt: counter.instance.salt
|
|
167
|
-
};
|
|
168
|
-
return info;
|
|
169
|
-
}
|
|
170
|
-
// NOTE: Disabling for now in order to get devnet running
|
|
171
|
-
async function fundFPC(counterAddress, wallet, l1Clients, fpcAddress, debugLog) {
|
|
172
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
173
|
-
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
174
|
-
const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
176
|
-
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
|
|
177
|
-
const { CounterContract } = await import('@aztec/noir-contracts.js/Counter');
|
|
178
|
-
const { protocolContractAddresses: { feeJuice } } = await wallet.getPXEInfo();
|
|
179
|
-
const feeJuiceContract = await FeeJuiceContract.at(feeJuice, wallet);
|
|
180
|
-
const feeJuicePortal = await L1FeeJuicePortalManager.new(wallet, l1Clients.publicClient, l1Clients.walletClient, debugLog);
|
|
181
|
-
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
|
|
182
|
-
const { claimAmount, claimSecret, messageLeafIndex, messageHash } = await feeJuicePortal.bridgeTokensPublic(fpcAddress, amount, true);
|
|
183
|
-
await retryUntil(async ()=>await wallet.isL1ToL2MessageSynced(Fr.fromHexString(messageHash)), 'message sync', 600, 1);
|
|
184
|
-
const counter = await CounterContract.at(counterAddress, wallet);
|
|
185
|
-
debugLog.info('Incrementing Counter');
|
|
186
|
-
// TODO (alexg) remove this once sequencer builds blocks continuously
|
|
187
|
-
// advance the chain
|
|
188
|
-
await counter.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait(waitOpts);
|
|
189
|
-
await counter.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait(waitOpts);
|
|
190
|
-
debugLog.info('Claiming FPC');
|
|
191
|
-
await feeJuiceContract.methods.claim(fpcAddress, claimAmount, claimSecret, messageLeafIndex).send().wait({
|
|
192
|
-
...waitOpts,
|
|
193
|
-
proven: true
|
|
194
|
-
});
|
|
195
|
-
debugLog.info('Finished claiming FPC');
|
|
196
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
export declare function dripFaucet(faucetUrl: string, asset: string, account: EthAddress, json: boolean, log: LogFn): Promise<void>;
|
|
4
|
-
//# sourceMappingURL=faucet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"faucet.d.ts","sourceRoot":"","sources":["../../../src/cmds/devnet/faucet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { prettyPrintJSON } from '../../utils/commands.js';
|
|
2
|
-
export async function dripFaucet(faucetUrl, asset, account, json, log) {
|
|
3
|
-
const url = new URL(`/drip/${account.toString()}`, faucetUrl);
|
|
4
|
-
url.searchParams.set('asset', asset);
|
|
5
|
-
const res = await fetch(url);
|
|
6
|
-
if (res.status === 200) {
|
|
7
|
-
if (json) {
|
|
8
|
-
log(prettyPrintJSON({
|
|
9
|
-
ok: true
|
|
10
|
-
}));
|
|
11
|
-
} else {
|
|
12
|
-
log(`Dripped ${asset} for ${account.toString()}`);
|
|
13
|
-
}
|
|
14
|
-
} else {
|
|
15
|
-
if (json) {
|
|
16
|
-
log(prettyPrintJSON({
|
|
17
|
-
ok: false
|
|
18
|
-
}));
|
|
19
|
-
} else if (res.status === 429) {
|
|
20
|
-
log(`Rate limited when dripping ${asset} for ${account.toString()}`);
|
|
21
|
-
} else {
|
|
22
|
-
log(`Failed to drip ${asset} for ${account.toString()}`);
|
|
23
|
-
}
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
}
|