This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbuidler.config.js
227 lines (201 loc) · 8.11 KB
/
buidler.config.js
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
// ES6 module imports via require
require("@babel/register");
// Libraries
const assert = require("assert");
const { constants, errors, utils } = require("ethers");
// Disable ethers v4 warnings e.g. for solidity overloaded fns
errors.setLogLevel("error");
// Classes
const Action = require("./src/classes/gelato/Action").default;
const Condition = require("./src/classes/gelato/Condition").default;
const GelatoProvider = require("./src/classes/gelato/GelatoProvider").default;
const Task = require("./src/classes/gelato/Task").default;
const TaskSpec = require("./src/classes/gelato/TaskSpec").default;
const TaskReceipt = require("./src/classes/gelato/TaskReceipt").default;
// Objects
const gelatoSysAdminInitialState = require("./test/gelato_core/base/gelato_sys_admin/GelatoSysAdmin.initialState")
.default;
// Objects/Enums
const Operation = require("./src/enums/gelato/Operation").default;
const DataFlow = require("./src/enums/gelato/DataFlow").default;
// Helpers
// Async
const sleep = require("./src/helpers/async/sleep").default;
// Gelato
const convertTaskReceiptArrayToObj = require("./src/helpers/gelato/convertTaskReceiptArrayToObj")
.default;
const convertTaskReceiptObjToArray = require("./src/helpers/gelato/convertTaskReceiptObjToArray")
.default;
// Nested Arrays
const nestedArraysAreEqual = require("./src/helpers/nestedArrays/nestedArraysAreEqual")
.default;
// Nested Objects
const checkNestedObj = require("./src/helpers/nestedObjects/checkNestedObj")
.default;
const getNestedObj = require("./src/helpers/nestedObjects/getNestedObj")
.default;
// ================================= BRE extension ==================================
extendEnvironment((bre) => {
// Classes
bre.Action = Action;
bre.Condition = Condition;
bre.GelatoProvider = GelatoProvider;
bre.Task = Task;
bre.TaskSpec = TaskSpec;
bre.TaskReceipt = TaskReceipt;
// Objects
bre.gelatoSysAdminInitialState = gelatoSysAdminInitialState;
// Objects/Enums
bre.Operation = Operation;
bre.DataFlow = DataFlow;
// Functions
// Async
bre.sleep = sleep;
// Gelato
bre.convertTaskReceiptArrayToObj = convertTaskReceiptArrayToObj;
bre.convertTaskReceiptObjToArray = convertTaskReceiptObjToArray;
// Nested Arrays
bre.nestedArraysAreEqual = nestedArraysAreEqual;
// Nested Objects
bre.checkNestedObj = checkNestedObj;
bre.getNestedObj = getNestedObj;
// Libraries
bre.constants = constants;
bre.utils = utils;
bre.getUser = () => new ethers.Wallet(USER_PK, ethers.provider);
bre.getProvider = () => new ethers.Wallet(PROVIDER_PK, ethers.provider);
bre.getSysAdmin = () => new ethers.Wallet(SYS_ADMIN_PK, ethers.provider);
bre.getExecutor = () => new ethers.Wallet(EXECUTOR_PK, ethers.provider);
});
// ================================= CONFIG =========================================
// Process Env Variables
require("dotenv").config();
const DEV_MNEMONIC = process.env.DEV_MNEMONIC;
const MAINNET_MNEMONIC = process.env.MAINNET_MNEMONIC;
const INFURA_ID = process.env.INFURA_ID;
const DEFAULT_NETWORK = process.env.DEFAULT_NETWORK;
const USER_PK = process.env.USER_PK;
const PROVIDER_PK = process.env.PROVIDER_PK;
const SYS_ADMIN_PK = process.env.SYS_ADMIN_PK;
const EXECUTOR_PK = process.env.EXECUTOR_PK;
const ALCHEMY_ID = process.env.ALCHEMY_ID;
assert.ok(DEV_MNEMONIC, "no DEV_MNEMONIC in process.env");
assert.ok(MAINNET_MNEMONIC, "no MAINNET_MNEMONIC in process.env");
assert.ok(INFURA_ID, "no Infura ID in process.env");
assert.ok(USER_PK, "no user private key (USER_PK) found in .env");
assert.ok(PROVIDER_PK, "no provider private key (USER_PK) found in .env");
// assert.ok(ALCHEMY_ID, "no Alchemy ID in process.env");
// Config Files
const buidlerevmConfig = require("./buidler/config/networks/buidlerevmConfig");
const rinkebyConfig = require("./buidler/config/networks/rinkebyConfig");
const mainnetConfig = require("./buidler/config/networks/mainnetConfig");
module.exports = {
defaultNetwork: DEFAULT_NETWORK ? DEFAULT_NETWORK : "buidlerevm",
etherscan: {
// The url for the Etherscan API you want to use.
// For example, here we're using the one for the Rinkeby test network
url: "https://api.etherscan.io/api",
// Your API key for Etherscan (Obtain one at https://etherscan.io/)
apiKey: process.env.ETHERSCAN_KEY,
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
},
networks: {
buidlerevm: {
hardfork: "istanbul",
contracts: buidlerevmConfig.contracts,
allowUnlimitedContractSize: process.env.BUIDLER_DEBUG ? true : false,
// Custom
filters: { defaultFromBlock: 1, defaultToBlock: "latest" },
},
coverage: {
url: "http://127.0.0.1:8555",
// Custom
filters: { defaultFromBlock: 1, defaultToBlock: "latest" },
},
localhost: {
allowUnlimitedContractSize: process.env.BUIDLER_DEBUG ? true : false,
filters: { defaultFromBlock: 1, defaultToBlock: "latest" },
},
mainnet: {
// Standard
accounts: { mnemonic: MAINNET_MNEMONIC },
chainId: 1,
gas: "auto",
gasPrice: parseInt(utils.parseUnits("80", "gwei")),
gasMultiplier: 1.5,
url: `https://mainnet.infura.io/v3/${INFURA_ID}`,
// url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`,
// Custom
addressBook: mainnetConfig.addressBook,
contracts: mainnetConfig.contracts,
deployments: mainnetConfig.deployments,
filters: mainnetConfig.filters,
},
rinkeby: {
// Standard
accounts: { mnemonic: DEV_MNEMONIC },
chainId: 4,
gasPrice: parseInt(utils.parseUnits("8", "gwei")),
url: `https://rinkeby.infura.io/v3/${INFURA_ID}`,
// Custom
addressBook: rinkebyConfig.addressBook,
contracts: rinkebyConfig.contracts,
deployments: rinkebyConfig.deployments,
filters: rinkebyConfig.filters,
},
},
solc: {
version: "0.6.10",
optimizer: { enabled: true },
},
};
// ================================= PLUGINS =========================================
usePlugin("@nomiclabs/buidler-ethers");
usePlugin("@nomiclabs/buidler-etherscan");
usePlugin("@nomiclabs/buidler-waffle");
usePlugin("buidler-gas-reporter");
usePlugin("solidity-coverage");
// ================================= TASKS =========================================
// task action function receives the Buidler Runtime Environment as second argument
// ============== ABI
require("./buidler/tasks/abi/collection.tasks.abi");
// ============== BLOCK
require("./buidler/tasks/block/collection.tasks.block");
// ============== BRE
// BRE, BRE-CONFIG(:networks), BRE-NETWORK
require("./buidler/tasks/bre/collection.tasks.bre");
// ============== DAPPS
require("./buidler/tasks/dapps/collection.tasks.dapps");
// ============== DEBUGGING
require("./buidler/tasks/debugging/collection.tasks.debugging");
// ============== DEPLOY
require("./buidler/tasks/deploy/collection.tasks.deploy");
// ============== ERC20
require("./buidler/tasks/erc20/collection.tasks.erc20");
// ============== ETH
require("./buidler/tasks/eth/collection.tasks.eth");
// ============== ETHERS
require("./buidler/tasks/ethers/collection.tasks.ethers");
// ============== EVENTS
require("./buidler/tasks/events/collection.tasks.events");
// ============= GELATO
// _____ ACTIONS
require("./buidler/tasks/gelato/actions/collection.tasks.actions");
// _____ CORE
// GasAdmin, Executors, Providers, submitTask, ...
require("./buidler/tasks/gelato/core/collection.tasks.gelato-core");
// _____ CONDITIONS
require("./buidler/tasks/gelato/conditions/collection.tasks.conditions");
// _____ HELPERS
require("./buidler/tasks/gelato/helpers/collection.tasks.gelato-helpers.js");
// ============= USER PROXIES (GelatoUserProxy, GnosisSafeProxy,...)
require("./buidler/tasks/user_proxies/collection.tasks.gelato-user-proxies");
// ======================== INTERNAL HELPER TASKS ======================================
// encoding, naming ....
require("./buidler/tasks/internal/collection.internalTasks");
// ======================== VIEW FUNCS ======================================
require("./buidler/tasks/view/collection.viewTasks");
// ======================== DEMO ======================================
require("./src/demo/collection.tasks.demo");