This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathconstants.ts
More file actions
36 lines (28 loc) · 1.35 KB
/
constants.ts
File metadata and controls
36 lines (28 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { HDNode } from "@ethersproject/hdnode";
import { Wallet } from "@ethersproject/wallet";
import { JsonRpcProvider } from "@ethersproject/providers";
import { ChainRpcProvider } from "@connext/vector-types";
import { network, ethers } from "hardhat";
import pino from "pino";
// Get defaults from env
const chainProviders = JSON.parse(process.env.CHAIN_PROVIDERS ?? "{}");
const chainId = Object.keys(chainProviders)[0];
const urls = Object.values(chainProviders)[0];
const mnemonic = process.env.SUGAR_DADDY ?? "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
export const defaultLogLevel = process.env.LOG_LEVEL || "info";
export const logger = pino({ level: defaultLogLevel });
export const networkName = network.name;
export const provider = urls
? new ChainRpcProvider(parseInt(chainId), (urls as string).split(","))
: new ChainRpcProvider(parseInt(chainId), [ethers.provider as JsonRpcProvider]);
const hdNode = HDNode.fromMnemonic(mnemonic).derivePath("m/44'/60'/0'/0");
export const wallets: Wallet[] = Array(20)
.fill(0)
.map((_, idx) => {
const wallet = new Wallet(hdNode.derivePath(idx.toString()).privateKey, provider);
return wallet;
});
export const chainIdReq = provider.getNetwork().then(net => net.chainId);
export const alice = wallets[0];
export const bob = wallets[1];
export const rando = wallets[2];