@aztec/aztec-faucet 0.0.0-test.1 → 0.0.1-commit.03f7ef2
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/bin/index.d.ts +1 -1
- package/dest/config.d.ts +5 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +7 -6
- package/dest/faucet.d.ts +2 -3
- package/dest/faucet.d.ts.map +1 -1
- package/dest/faucet.js +12 -20
- package/dest/http.d.ts +1 -2
- package/dest/http.d.ts.map +1 -1
- package/dest/index.d.ts +1 -1
- package/package.json +20 -17
- package/src/config.ts +14 -7
- package/src/faucet.ts +11 -23
package/dest/bin/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings
|
|
2
2
|
export {};
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iaW4vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
package/dest/config.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { type L1ReaderConfig } from '@aztec/ethereum';
|
|
2
|
-
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
1
|
+
import { type L1ReaderConfig } from '@aztec/ethereum/l1-reader';
|
|
2
|
+
import { type ConfigMappingsType, SecretValue } from '@aztec/foundation/config';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
export type L1AssetConfig = {
|
|
5
5
|
address: EthAddress;
|
|
6
6
|
amount: bigint;
|
|
7
7
|
};
|
|
8
8
|
export type FaucetConfig = L1ReaderConfig & {
|
|
9
|
-
l1Mnemonic
|
|
10
|
-
|
|
9
|
+
l1Mnemonic?: SecretValue<string>;
|
|
10
|
+
mnemonicAddressIndex: number;
|
|
11
11
|
interval: number;
|
|
12
12
|
ethAmount: string;
|
|
13
13
|
l1Assets: L1AssetConfig[];
|
|
14
14
|
};
|
|
15
15
|
export declare const faucetConfigMapping: ConfigMappingsType<FaucetConfig>;
|
|
16
16
|
export declare function getFaucetConfigFromEnv(): FaucetConfig;
|
|
17
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLGNBQWMsRUFBMEIsTUFBTSwyQkFBMkIsQ0FBQztBQUN4RixPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFDdkIsV0FBVyxFQUlaLE1BQU0sMEJBQTBCLENBQUM7QUFDbEMsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTNELE1BQU0sTUFBTSxhQUFhLEdBQUc7SUFDMUIsT0FBTyxFQUFFLFVBQVUsQ0FBQztJQUNwQixNQUFNLEVBQUUsTUFBTSxDQUFDO0NBQ2hCLENBQUM7QUFFRixNQUFNLE1BQU0sWUFBWSxHQUFHLGNBQWMsR0FBRztJQUMxQyxVQUFVLENBQUMsRUFBRSxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUM7SUFDakMsb0JBQW9CLEVBQUUsTUFBTSxDQUFDO0lBQzdCLFFBQVEsRUFBRSxNQUFNLENBQUM7SUFDakIsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUNsQixRQUFRLEVBQUUsYUFBYSxFQUFFLENBQUM7Q0FDM0IsQ0FBQztBQUVGLGVBQU8sTUFBTSxtQkFBbUIsRUFBRSxrQkFBa0IsQ0FBQyxZQUFZLENBcUNoRSxDQUFDO0FBRUYsd0JBQWdCLHNCQUFzQixJQUFJLFlBQVksQ0FFckQifQ==
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,EAIZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG;IAC1C,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,kBAAkB,CAAC,YAAY,CAqChE,CAAC;AAEF,wBAAgB,sBAAsB,IAAI,YAAY,CAErD"}
|
package/dest/config.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { l1ReaderConfigMappings } from '@aztec/ethereum';
|
|
2
|
-
import { getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
1
|
+
import { l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
2
|
+
import { getConfigFromMappings, numberConfigHelper, secretStringConfigHelper } from '@aztec/foundation/config';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
export const faucetConfigMapping = {
|
|
5
5
|
...l1ReaderConfigMappings,
|
|
6
6
|
l1Mnemonic: {
|
|
7
7
|
env: 'MNEMONIC',
|
|
8
|
-
description: 'The mnemonic for the faucet account'
|
|
8
|
+
description: 'The mnemonic for the faucet account',
|
|
9
|
+
...secretStringConfigHelper()
|
|
9
10
|
},
|
|
10
|
-
|
|
11
|
-
env: '
|
|
12
|
-
description: 'The
|
|
11
|
+
mnemonicAddressIndex: {
|
|
12
|
+
env: 'FAUCET_MNEMONIC_ADDRESS_INDEX',
|
|
13
|
+
description: 'The address to use',
|
|
13
14
|
...numberConfigHelper(0)
|
|
14
15
|
},
|
|
15
16
|
interval: {
|
package/dest/faucet.d.ts
CHANGED
|
@@ -6,8 +6,7 @@ export declare class Faucet {
|
|
|
6
6
|
private account;
|
|
7
7
|
private timeFn;
|
|
8
8
|
private log;
|
|
9
|
-
private
|
|
10
|
-
private publicClient;
|
|
9
|
+
private l1Client;
|
|
11
10
|
private dripHistory;
|
|
12
11
|
private l1Assets;
|
|
13
12
|
constructor(config: FaucetConfig, account: LocalAccount, timeFn?: () => number, log?: import("@aztec/foundation/log").Logger);
|
|
@@ -25,4 +24,4 @@ export declare class ThrottleError extends Error {
|
|
|
25
24
|
export declare class UnknownAsset extends Error {
|
|
26
25
|
constructor(asset: string);
|
|
27
26
|
}
|
|
28
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmF1Y2V0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZmF1Y2V0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBSWhFLE9BQU8sRUFLTCxLQUFLLFlBQVksRUFJbEIsTUFBTSxNQUFNLENBQUM7QUFHZCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsYUFBYSxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBTy9ELHFCQUFhLE1BQU07SUFPZixPQUFPLENBQUMsTUFBTTtJQUNkLE9BQU8sQ0FBQyxPQUFPO0lBQ2YsT0FBTyxDQUFDLE1BQU07SUFDZCxPQUFPLENBQUMsR0FBRztJQVRiLE9BQU8sQ0FBQyxRQUFRLENBQTJCO0lBRTNDLE9BQU8sQ0FBQyxXQUFXLENBQTBDO0lBQzdELE9BQU8sQ0FBQyxRQUFRLENBQThCO0lBRTlDLFlBQ1UsTUFBTSxFQUFFLFlBQVksRUFDcEIsT0FBTyxFQUFFLFlBQVksRUFDckIsTUFBTSxHQUFFLE1BQU0sTUFBaUIsRUFDL0IsR0FBRyx5Q0FBK0IsRUFLM0M7SUFFRCxPQUFvQixNQUFNLENBQUMsTUFBTSxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBYWhFO0lBRU0sSUFBSSxDQUFDLEVBQUUsRUFBRSxVQUFVLEVBQUUsU0FBUyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBTTVEO0lBRVksT0FBTyxDQUFDLEVBQUUsRUFBRSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQVlsRDtJQUVZLFNBQVMsQ0FBQyxFQUFFLEVBQUUsVUFBVSxFQUFFLFNBQVMsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQWN2RTtJQUVZLFVBQVUsQ0FBQyxhQUFhLEVBQUUsYUFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0F1Qm5FO0lBRUQsT0FBTyxDQUFDLGFBQWE7SUFhckIsT0FBTyxDQUFDLGNBQWM7Q0FTdkI7QUFFRCxxQkFBYSxhQUFjLFNBQVEsS0FBSztJQUN0QyxZQUFZLE9BQU8sRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFFekM7Q0FDRjtBQUVELHFCQUFhLFlBQWEsU0FBUSxLQUFLO0lBQ3JDLFlBQVksS0FBSyxFQUFFLE1BQU0sRUFFeEI7Q0FDRiJ9
|
package/dest/faucet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faucet.d.ts","sourceRoot":"","sources":["../src/faucet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"faucet.d.ts","sourceRoot":"","sources":["../src/faucet.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE,OAAO,EAKL,KAAK,YAAY,EAIlB,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO/D,qBAAa,MAAM;IAOf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,GAAG;IATb,OAAO,CAAC,QAAQ,CAA2B;IAE3C,OAAO,CAAC,WAAW,CAA0C;IAC7D,OAAO,CAAC,QAAQ,CAA8B;IAE9C,YACU,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,YAAY,EACrB,MAAM,GAAE,MAAM,MAAiB,EAC/B,GAAG,yCAA+B,EAK3C;IAED,OAAoB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAahE;IAEM,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM5D;IAEY,OAAO,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAYlD;IAEY,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAcvE;IAEY,UAAU,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBnE;IAED,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,cAAc;CASvB;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAEzC;CACF;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,KAAK,EAAE,MAAM,EAExB;CACF"}
|
package/dest/faucet.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createEthereumChain } from '@aztec/ethereum';
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
4
|
-
import {
|
|
5
|
+
import { getContract, parseEther } from 'viem';
|
|
5
6
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
6
7
|
export class Faucet {
|
|
7
8
|
config;
|
|
8
9
|
account;
|
|
9
10
|
timeFn;
|
|
10
11
|
log;
|
|
11
|
-
|
|
12
|
-
publicClient;
|
|
12
|
+
l1Client;
|
|
13
13
|
dripHistory;
|
|
14
14
|
l1Assets;
|
|
15
15
|
constructor(config, account, timeFn = Date.now, log = createLogger('aztec:faucet')){
|
|
@@ -20,22 +20,14 @@ export class Faucet {
|
|
|
20
20
|
this.dripHistory = new Map();
|
|
21
21
|
this.l1Assets = new Map();
|
|
22
22
|
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
23
|
-
this.
|
|
24
|
-
account: this.account,
|
|
25
|
-
chain: chain.chainInfo,
|
|
26
|
-
transport: fallback(chain.rpcUrls.map((url)=>viemHttp(url)))
|
|
27
|
-
});
|
|
28
|
-
this.publicClient = createPublicClient({
|
|
29
|
-
chain: chain.chainInfo,
|
|
30
|
-
transport: fallback(chain.rpcUrls.map((url)=>viemHttp(url)))
|
|
31
|
-
});
|
|
23
|
+
this.l1Client = createExtendedL1Client(config.l1RpcUrls, this.account, chain.chainInfo);
|
|
32
24
|
}
|
|
33
25
|
static async create(config) {
|
|
34
|
-
if (!config.l1Mnemonic) {
|
|
26
|
+
if (!config.l1Mnemonic || !config.l1Mnemonic.getValue()) {
|
|
35
27
|
throw new Error('Missing faucet mnemonic');
|
|
36
28
|
}
|
|
37
|
-
const account = mnemonicToAccount(config.l1Mnemonic, {
|
|
38
|
-
addressIndex: config.
|
|
29
|
+
const account = mnemonicToAccount(config.l1Mnemonic.getValue(), {
|
|
30
|
+
addressIndex: config.mnemonicAddressIndex
|
|
39
31
|
});
|
|
40
32
|
const faucet = new Faucet(config, account);
|
|
41
33
|
for (const asset of config.l1Assets){
|
|
@@ -52,12 +44,12 @@ export class Faucet {
|
|
|
52
44
|
}
|
|
53
45
|
async sendEth(to) {
|
|
54
46
|
this.checkThrottle(to, 'ETH');
|
|
55
|
-
const hash = await this.
|
|
47
|
+
const hash = await this.l1Client.sendTransaction({
|
|
56
48
|
account: this.account,
|
|
57
49
|
to: to.toString(),
|
|
58
50
|
value: parseEther(this.config.ethAmount)
|
|
59
51
|
});
|
|
60
|
-
await this.
|
|
52
|
+
await this.l1Client.waitForTransactionReceipt({
|
|
61
53
|
hash
|
|
62
54
|
});
|
|
63
55
|
this.updateThrottle(to, 'ETH');
|
|
@@ -73,7 +65,7 @@ export class Faucet {
|
|
|
73
65
|
to.toString(),
|
|
74
66
|
asset.amount
|
|
75
67
|
]);
|
|
76
|
-
await this.
|
|
68
|
+
await this.l1Client.waitForTransactionReceipt({
|
|
77
69
|
hash
|
|
78
70
|
});
|
|
79
71
|
this.updateThrottle(to, assetName);
|
|
@@ -83,7 +75,7 @@ export class Faucet {
|
|
|
83
75
|
const contract = getContract({
|
|
84
76
|
abi: TestERC20Abi,
|
|
85
77
|
address: l1AssetConfig.address.toString(),
|
|
86
|
-
client: this.
|
|
78
|
+
client: this.l1Client
|
|
87
79
|
});
|
|
88
80
|
const [name, owner] = await Promise.all([
|
|
89
81
|
contract.read.name(),
|
package/dest/http.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { type ApiSchemaFor } from '@aztec/foundation/schemas';
|
|
3
2
|
import { type Faucet } from './faucet.js';
|
|
4
3
|
export declare function createFaucetHttpServer(faucet: Faucet, apiPrefix?: string, logger?: import("@aztec/foundation/log").Logger): import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
5
4
|
export declare const FaucetSchema: ApiSchemaFor<Faucet>;
|
|
6
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2h0dHAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLEtBQUssWUFBWSxFQUFXLE1BQU0sMkJBQTJCLENBQUM7QUFTdkUsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFpQixNQUFNLGFBQWEsQ0FBQztBQUV6RCx3QkFBZ0Isc0JBQXNCLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxTQUFTLFNBQUssRUFBRSxNQUFNLHlDQUFvQyxzR0E2RGhIO0FBRUQsZUFBTyxNQUFNLFlBQVksRUFBRSxZQUFZLENBQUMsTUFBTSxDQVE3QyxDQUFDIn0=
|
package/dest/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAW,MAAM,2BAA2B,CAAC;AASvE,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,aAAa,CAAC;AAEzD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,SAAK,EAAE,MAAM,yCAAoC,sGA6DhH;AAED,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,MAAM,CAQ7C,CAAC"}
|
package/dest/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './faucet.js';
|
|
2
2
|
export * from './http.js';
|
|
3
3
|
export * from './config.js';
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLFdBQVcsQ0FBQztBQUMxQixjQUFjLGFBQWEsQ0FBQyJ9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec-faucet",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1-commit.03f7ef2",
|
|
4
4
|
"main": "dest/bin/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -17,11 +17,9 @@
|
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"start": "node --no-warnings ./dest/bin",
|
|
20
|
-
"build": "yarn clean && tsc
|
|
21
|
-
"build:dev": "tsc
|
|
20
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
21
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
22
22
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
23
|
-
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
24
|
-
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
25
23
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
26
24
|
},
|
|
27
25
|
"inherits": [
|
|
@@ -58,27 +56,32 @@
|
|
|
58
56
|
"testTimeout": 120000,
|
|
59
57
|
"setupFiles": [
|
|
60
58
|
"../../foundation/src/jest/setup.mjs"
|
|
59
|
+
],
|
|
60
|
+
"testEnvironment": "../../foundation/src/jest/env.mjs",
|
|
61
|
+
"setupFilesAfterEnv": [
|
|
62
|
+
"../../foundation/src/jest/setupAfterEnv.mjs"
|
|
61
63
|
]
|
|
62
64
|
},
|
|
63
65
|
"dependencies": {
|
|
64
|
-
"@aztec/ethereum": "0.0.
|
|
65
|
-
"@aztec/foundation": "0.0.
|
|
66
|
-
"@aztec/l1-artifacts": "0.0.
|
|
66
|
+
"@aztec/ethereum": "0.0.1-commit.03f7ef2",
|
|
67
|
+
"@aztec/foundation": "0.0.1-commit.03f7ef2",
|
|
68
|
+
"@aztec/l1-artifacts": "0.0.1-commit.03f7ef2",
|
|
67
69
|
"@koa/cors": "^5.0.0",
|
|
68
|
-
"koa": "^2.
|
|
70
|
+
"koa": "^2.16.1",
|
|
69
71
|
"koa-bodyparser": "^4.4.1",
|
|
70
|
-
"koa-router": "^
|
|
71
|
-
"viem": "2.
|
|
72
|
+
"koa-router": "^13.1.1",
|
|
73
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
72
74
|
"zod": "^3.23.8"
|
|
73
75
|
},
|
|
74
76
|
"devDependencies": {
|
|
75
|
-
"@jest/globals": "^
|
|
76
|
-
"@types/jest": "^
|
|
77
|
+
"@jest/globals": "^30.0.0",
|
|
78
|
+
"@types/jest": "^30.0.0",
|
|
77
79
|
"@types/koa-bodyparser": "^4.3.12",
|
|
78
|
-
"@types/node": "^
|
|
79
|
-
"
|
|
80
|
+
"@types/node": "^22.15.17",
|
|
81
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
82
|
+
"jest": "^30.0.0",
|
|
80
83
|
"ts-node": "^10.9.1",
|
|
81
|
-
"typescript": "^5.
|
|
84
|
+
"typescript": "^5.3.3"
|
|
82
85
|
},
|
|
83
86
|
"files": [
|
|
84
87
|
"dest",
|
|
@@ -87,6 +90,6 @@
|
|
|
87
90
|
],
|
|
88
91
|
"types": "./dest/index.d.ts",
|
|
89
92
|
"engines": {
|
|
90
|
-
"node": ">=
|
|
93
|
+
"node": ">=20.10"
|
|
91
94
|
}
|
|
92
95
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum';
|
|
2
|
-
import {
|
|
1
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
2
|
+
import {
|
|
3
|
+
type ConfigMappingsType,
|
|
4
|
+
SecretValue,
|
|
5
|
+
getConfigFromMappings,
|
|
6
|
+
numberConfigHelper,
|
|
7
|
+
secretStringConfigHelper,
|
|
8
|
+
} from '@aztec/foundation/config';
|
|
3
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
10
|
|
|
5
11
|
export type L1AssetConfig = {
|
|
@@ -8,8 +14,8 @@ export type L1AssetConfig = {
|
|
|
8
14
|
};
|
|
9
15
|
|
|
10
16
|
export type FaucetConfig = L1ReaderConfig & {
|
|
11
|
-
l1Mnemonic
|
|
12
|
-
|
|
17
|
+
l1Mnemonic?: SecretValue<string>;
|
|
18
|
+
mnemonicAddressIndex: number;
|
|
13
19
|
interval: number;
|
|
14
20
|
ethAmount: string;
|
|
15
21
|
l1Assets: L1AssetConfig[];
|
|
@@ -20,10 +26,11 @@ export const faucetConfigMapping: ConfigMappingsType<FaucetConfig> = {
|
|
|
20
26
|
l1Mnemonic: {
|
|
21
27
|
env: 'MNEMONIC',
|
|
22
28
|
description: 'The mnemonic for the faucet account',
|
|
29
|
+
...secretStringConfigHelper(),
|
|
23
30
|
},
|
|
24
|
-
|
|
25
|
-
env: '
|
|
26
|
-
description: 'The
|
|
31
|
+
mnemonicAddressIndex: {
|
|
32
|
+
env: 'FAUCET_MNEMONIC_ADDRESS_INDEX',
|
|
33
|
+
description: 'The address to use',
|
|
27
34
|
...numberConfigHelper(0),
|
|
28
35
|
},
|
|
29
36
|
interval: {
|
package/src/faucet.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
3
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
2
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
6
|
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
@@ -10,12 +12,8 @@ import {
|
|
|
10
12
|
type HttpTransport,
|
|
11
13
|
type LocalAccount,
|
|
12
14
|
type WalletClient,
|
|
13
|
-
createPublicClient,
|
|
14
|
-
createWalletClient,
|
|
15
|
-
fallback,
|
|
16
15
|
getContract,
|
|
17
16
|
parseEther,
|
|
18
|
-
http as viemHttp,
|
|
19
17
|
} from 'viem';
|
|
20
18
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
21
19
|
|
|
@@ -27,8 +25,7 @@ type L1Asset = {
|
|
|
27
25
|
};
|
|
28
26
|
|
|
29
27
|
export class Faucet {
|
|
30
|
-
private
|
|
31
|
-
private publicClient: ViemPublicClient;
|
|
28
|
+
private l1Client: ExtendedViemWalletClient;
|
|
32
29
|
|
|
33
30
|
private dripHistory = new Map<string, Map<string, number>>();
|
|
34
31
|
private l1Assets = new Map<string, L1Asset>();
|
|
@@ -41,24 +38,15 @@ export class Faucet {
|
|
|
41
38
|
) {
|
|
42
39
|
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
43
40
|
|
|
44
|
-
this.
|
|
45
|
-
account: this.account,
|
|
46
|
-
chain: chain.chainInfo,
|
|
47
|
-
transport: fallback(chain.rpcUrls.map(url => viemHttp(url))),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
this.publicClient = createPublicClient({
|
|
51
|
-
chain: chain.chainInfo,
|
|
52
|
-
transport: fallback(chain.rpcUrls.map(url => viemHttp(url))),
|
|
53
|
-
});
|
|
41
|
+
this.l1Client = createExtendedL1Client(config.l1RpcUrls, this.account, chain.chainInfo);
|
|
54
42
|
}
|
|
55
43
|
|
|
56
44
|
public static async create(config: FaucetConfig): Promise<Faucet> {
|
|
57
|
-
if (!config.l1Mnemonic) {
|
|
45
|
+
if (!config.l1Mnemonic || !config.l1Mnemonic.getValue()) {
|
|
58
46
|
throw new Error('Missing faucet mnemonic');
|
|
59
47
|
}
|
|
60
48
|
|
|
61
|
-
const account = mnemonicToAccount(config.l1Mnemonic, { addressIndex: config.
|
|
49
|
+
const account = mnemonicToAccount(config.l1Mnemonic.getValue(), { addressIndex: config.mnemonicAddressIndex });
|
|
62
50
|
const faucet = new Faucet(config, account);
|
|
63
51
|
|
|
64
52
|
for (const asset of config.l1Assets) {
|
|
@@ -79,12 +67,12 @@ export class Faucet {
|
|
|
79
67
|
public async sendEth(to: EthAddress): Promise<void> {
|
|
80
68
|
this.checkThrottle(to, 'ETH');
|
|
81
69
|
|
|
82
|
-
const hash = await this.
|
|
70
|
+
const hash = await this.l1Client.sendTransaction({
|
|
83
71
|
account: this.account,
|
|
84
72
|
to: to.toString(),
|
|
85
73
|
value: parseEther(this.config.ethAmount),
|
|
86
74
|
});
|
|
87
|
-
await this.
|
|
75
|
+
await this.l1Client.waitForTransactionReceipt({ hash });
|
|
88
76
|
|
|
89
77
|
this.updateThrottle(to, 'ETH');
|
|
90
78
|
this.log.info(`Sent ETH ${this.config.ethAmount} to ${to} in tx ${hash}`);
|
|
@@ -99,7 +87,7 @@ export class Faucet {
|
|
|
99
87
|
this.checkThrottle(to, assetName);
|
|
100
88
|
|
|
101
89
|
const hash = await asset.contract.write.mint([to.toString(), asset.amount]);
|
|
102
|
-
await this.
|
|
90
|
+
await this.l1Client.waitForTransactionReceipt({ hash });
|
|
103
91
|
|
|
104
92
|
this.updateThrottle(to, assetName);
|
|
105
93
|
|
|
@@ -110,7 +98,7 @@ export class Faucet {
|
|
|
110
98
|
const contract = getContract({
|
|
111
99
|
abi: TestERC20Abi,
|
|
112
100
|
address: l1AssetConfig.address.toString(),
|
|
113
|
-
client: this.
|
|
101
|
+
client: this.l1Client,
|
|
114
102
|
});
|
|
115
103
|
|
|
116
104
|
const [name, owner] = await Promise.all([contract.read.name(), contract.read.owner()]);
|