-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathhardhat.config.ts
151 lines (141 loc) · 5 KB
/
hardhat.config.ts
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { task } from "hardhat/config";
import "@nomiclabs/hardhat-waffle";
import "./misc/typechain-ethers-v5-mcdex"
import "hardhat-contract-sizer";
// import "hardhat-gas-reporter";
// import "hardhat-abi-exporter";
import "solidity-coverage"
const pk = process.env["PK"]
task("accounts", "Prints the list of accounts", async (args, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
task("encode", "Encode calldata")
.addPositionalParam("sig", "Signature of contract to deploy")
.addOptionalPositionalParam("args", "Args of function call, seprated by common ','")
.setAction(async (args, hre) => {
if (typeof args.args != 'undefined') {
args.args = args.args.split(',')
}
args.sig = args.sig.replace('function ', '')
var iface = new hre.ethers.utils.Interface(["function " + args.sig])
var selector = args.sig.slice(0, args.sig.indexOf('('))
// console.log(args.sig, args.args, selector)
var calldata = iface.encodeFunctionData(selector, args.args)
console.log("encoded calldata", calldata)
})
task("deploy", "Deploy a single contract")
.addPositionalParam("name", "Name of contract to deploy")
.addOptionalPositionalParam("args", "Args of contract constructor, seprated by common ','")
.setAction(async (args, hre) => {
if (typeof args.args != 'undefined') {
args.args = args.args.split('|')
}
const factory = await hre.ethers.getContractFactory(args.name);
const contract = await factory.deploy(...args.args);
console.log(args.name, "has been deployed to", contract.address);
})
task("send", "Call contract function")
.addPositionalParam("address", "Address of contract")
.addPositionalParam("sig", "Signature of contract")
.addOptionalPositionalParam("args", "Args of function call, seprated by common ','")
.setAction(async (args, hre) => {
if (typeof args.args != 'undefined') {
args.args = args.args.split('|')
}
args.sig = args.sig.replace('function ', '')
var iface = new hre.ethers.utils.Interface(["function " + args.sig])
var selector = args.sig.slice(0, args.sig.indexOf('('))
// console.log(args.sig, args.args, selector)
var calldata = iface.encodeFunctionData(selector, args.args)
// console.log("encoded calldata", calldata)
const signer = hre.ethers.provider.getSigner(0);
const tx = await signer.sendTransaction({
to: args.address,
from: signer._address,
data: calldata,
});
console.log(tx);
console.log(await tx.wait());
})
task("call", "Call contract function")
.addPositionalParam("address", "Address of contract")
.addPositionalParam("sig", "Signature of contract")
.addOptionalPositionalParam("args", "Args of function call, seprated by common ','")
.setAction(async (args, hre) => {
if (typeof args.args != 'undefined') {
args.args = args.args.split('|')
}
args.sig = args.sig.replace('function ', '')
var iface = new hre.ethers.utils.Interface(["function " + args.sig])
var selector = args.sig.slice(0, args.sig.indexOf('('))
console.log(args.sig, args.args, selector)
var calldata = iface.encodeFunctionData(selector, args.args)
// console.log("encoded calldata", calldata)
const signer = hre.ethers.provider.getSigner(0);
const result = await signer.call({
to: args.address,
data: calldata,
})
console.log("result", result);
})
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
allowUnlimitedContractSize: true
},
kovan: {
url: "https://kovan.infura.io/v3/",
gasPrice: 1e9,
// accounts: [""],
timeout: 300000,
confirmations: 1,
},
bscTestnet: {
url: "https://data-seed-prebsc-2-s1.binance.org:8545/",
gasPrice: 20e9,
// accounts: [""],
timeout: 300000,
confirmations: 1,
},
arb: {
url: "https://kovan5.arbitrum.io/rpc",
gasPrice: 3e8,
accounts: [pk],
timeout: 300000,
confirmations: 1,
},
},
solidity: {
version: "0.7.4",
settings: {
optimizer: {
enabled: true,
runs: 1
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
contractSizer: {
alphaSort: true,
runOnCompile: false,
disambiguatePaths: false,
},
abiExporter: {
path: './abi',
clear: false,
flat: true,
only: ['PoolCreator', 'LiquidityPool'],
},
mocha: {
timeout: 60000
}
};