@aztec/aztec-faucet 0.85.0 → 0.86.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/dest/faucet.d.ts +1 -2
- package/dest/faucet.d.ts.map +1 -1
- package/dest/faucet.js +8 -17
- package/package.json +4 -6
- package/src/faucet.ts +7 -21
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);
|
package/dest/faucet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faucet.d.ts","sourceRoot":"","sources":["../src/faucet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE,OAAO,EAKL,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"faucet.d.ts","sourceRoot":"","sources":["../src/faucet.ts"],"names":[],"mappings":"AACA,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;gBAGpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,YAAY,EACrB,MAAM,GAAE,MAAM,MAAiB,EAC/B,GAAG,yCAA+B;WAOxB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAe1D,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhD,OAAO,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IActC,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB3D,UAAU,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBpE,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,cAAc;CASvB;AAED,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAG3C;AAED,qBAAa,YAAa,SAAQ,KAAK;gBACzB,KAAK,EAAE,MAAM;CAG1B"}
|
package/dest/faucet.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { createEthereumChain } from '@aztec/ethereum';
|
|
1
|
+
import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
4
|
-
import {
|
|
4
|
+
import { getContract, parseEther } from 'viem';
|
|
5
5
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
6
6
|
export class Faucet {
|
|
7
7
|
config;
|
|
8
8
|
account;
|
|
9
9
|
timeFn;
|
|
10
10
|
log;
|
|
11
|
-
|
|
12
|
-
publicClient;
|
|
11
|
+
l1Client;
|
|
13
12
|
dripHistory;
|
|
14
13
|
l1Assets;
|
|
15
14
|
constructor(config, account, timeFn = Date.now, log = createLogger('aztec:faucet')){
|
|
@@ -20,15 +19,7 @@ export class Faucet {
|
|
|
20
19
|
this.dripHistory = new Map();
|
|
21
20
|
this.l1Assets = new Map();
|
|
22
21
|
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
|
-
});
|
|
22
|
+
this.l1Client = createExtendedL1Client(config.l1RpcUrls, this.account, chain.chainInfo);
|
|
32
23
|
}
|
|
33
24
|
static async create(config) {
|
|
34
25
|
if (!config.l1Mnemonic) {
|
|
@@ -52,12 +43,12 @@ export class Faucet {
|
|
|
52
43
|
}
|
|
53
44
|
async sendEth(to) {
|
|
54
45
|
this.checkThrottle(to, 'ETH');
|
|
55
|
-
const hash = await this.
|
|
46
|
+
const hash = await this.l1Client.sendTransaction({
|
|
56
47
|
account: this.account,
|
|
57
48
|
to: to.toString(),
|
|
58
49
|
value: parseEther(this.config.ethAmount)
|
|
59
50
|
});
|
|
60
|
-
await this.
|
|
51
|
+
await this.l1Client.waitForTransactionReceipt({
|
|
61
52
|
hash
|
|
62
53
|
});
|
|
63
54
|
this.updateThrottle(to, 'ETH');
|
|
@@ -73,7 +64,7 @@ export class Faucet {
|
|
|
73
64
|
to.toString(),
|
|
74
65
|
asset.amount
|
|
75
66
|
]);
|
|
76
|
-
await this.
|
|
67
|
+
await this.l1Client.waitForTransactionReceipt({
|
|
77
68
|
hash
|
|
78
69
|
});
|
|
79
70
|
this.updateThrottle(to, assetName);
|
|
@@ -83,7 +74,7 @@ export class Faucet {
|
|
|
83
74
|
const contract = getContract({
|
|
84
75
|
abi: TestERC20Abi,
|
|
85
76
|
address: l1AssetConfig.address.toString(),
|
|
86
|
-
client: this.
|
|
77
|
+
client: this.l1Client
|
|
87
78
|
});
|
|
88
79
|
const [name, owner] = await Promise.all([
|
|
89
80
|
contract.read.name(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec-faucet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.0",
|
|
4
4
|
"main": "dest/bin/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -20,8 +20,6 @@
|
|
|
20
20
|
"build": "yarn clean && tsc -b",
|
|
21
21
|
"build:dev": "tsc -b --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": [
|
|
@@ -61,9 +59,9 @@
|
|
|
61
59
|
]
|
|
62
60
|
},
|
|
63
61
|
"dependencies": {
|
|
64
|
-
"@aztec/ethereum": "0.
|
|
65
|
-
"@aztec/foundation": "0.
|
|
66
|
-
"@aztec/l1-artifacts": "0.
|
|
62
|
+
"@aztec/ethereum": "0.86.0",
|
|
63
|
+
"@aztec/foundation": "0.86.0",
|
|
64
|
+
"@aztec/l1-artifacts": "0.86.0",
|
|
67
65
|
"@koa/cors": "^5.0.0",
|
|
68
66
|
"koa": "^2.16.1",
|
|
69
67
|
"koa-bodyparser": "^4.4.1",
|
package/src/faucet.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ExtendedViemWalletClient, createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
@@ -10,12 +10,8 @@ import {
|
|
|
10
10
|
type HttpTransport,
|
|
11
11
|
type LocalAccount,
|
|
12
12
|
type WalletClient,
|
|
13
|
-
createPublicClient,
|
|
14
|
-
createWalletClient,
|
|
15
|
-
fallback,
|
|
16
13
|
getContract,
|
|
17
14
|
parseEther,
|
|
18
|
-
http as viemHttp,
|
|
19
15
|
} from 'viem';
|
|
20
16
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
21
17
|
|
|
@@ -27,8 +23,7 @@ type L1Asset = {
|
|
|
27
23
|
};
|
|
28
24
|
|
|
29
25
|
export class Faucet {
|
|
30
|
-
private
|
|
31
|
-
private publicClient: ViemPublicClient;
|
|
26
|
+
private l1Client: ExtendedViemWalletClient;
|
|
32
27
|
|
|
33
28
|
private dripHistory = new Map<string, Map<string, number>>();
|
|
34
29
|
private l1Assets = new Map<string, L1Asset>();
|
|
@@ -41,16 +36,7 @@ export class Faucet {
|
|
|
41
36
|
) {
|
|
42
37
|
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
43
38
|
|
|
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
|
-
});
|
|
39
|
+
this.l1Client = createExtendedL1Client(config.l1RpcUrls, this.account, chain.chainInfo);
|
|
54
40
|
}
|
|
55
41
|
|
|
56
42
|
public static async create(config: FaucetConfig): Promise<Faucet> {
|
|
@@ -79,12 +65,12 @@ export class Faucet {
|
|
|
79
65
|
public async sendEth(to: EthAddress): Promise<void> {
|
|
80
66
|
this.checkThrottle(to, 'ETH');
|
|
81
67
|
|
|
82
|
-
const hash = await this.
|
|
68
|
+
const hash = await this.l1Client.sendTransaction({
|
|
83
69
|
account: this.account,
|
|
84
70
|
to: to.toString(),
|
|
85
71
|
value: parseEther(this.config.ethAmount),
|
|
86
72
|
});
|
|
87
|
-
await this.
|
|
73
|
+
await this.l1Client.waitForTransactionReceipt({ hash });
|
|
88
74
|
|
|
89
75
|
this.updateThrottle(to, 'ETH');
|
|
90
76
|
this.log.info(`Sent ETH ${this.config.ethAmount} to ${to} in tx ${hash}`);
|
|
@@ -99,7 +85,7 @@ export class Faucet {
|
|
|
99
85
|
this.checkThrottle(to, assetName);
|
|
100
86
|
|
|
101
87
|
const hash = await asset.contract.write.mint([to.toString(), asset.amount]);
|
|
102
|
-
await this.
|
|
88
|
+
await this.l1Client.waitForTransactionReceipt({ hash });
|
|
103
89
|
|
|
104
90
|
this.updateThrottle(to, assetName);
|
|
105
91
|
|
|
@@ -110,7 +96,7 @@ export class Faucet {
|
|
|
110
96
|
const contract = getContract({
|
|
111
97
|
abi: TestERC20Abi,
|
|
112
98
|
address: l1AssetConfig.address.toString(),
|
|
113
|
-
client: this.
|
|
99
|
+
client: this.l1Client,
|
|
114
100
|
});
|
|
115
101
|
|
|
116
102
|
const [name, owner] = await Promise.all([contract.read.name(), contract.read.owner()]);
|