-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathcommon-contracts.js
63 lines (59 loc) · 2.64 KB
/
common-contracts.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
const { task } = require('hardhat/config');
const { TASK_TEST_SETUP_TEST_ENVIRONMENT } = require('hardhat/builtin-tasks/task-names');
const { setCode } = require('@nomicfoundation/hardhat-network-helpers');
const fs = require('fs');
const path = require('path');
const INSTANCES = {
// ERC-4337 Entrypoints
entrypoint: {
v07: {
address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',
abi: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/bin/EntryPoint070.abi'), 'utf-8')),
bytecode: fs.readFileSync(path.resolve(__dirname, '../test/bin/EntryPoint070.bytecode'), 'hex'),
},
v08: {
address: '0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108',
abi: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/bin/EntryPoint080.abi'), 'utf-8')),
bytecode: fs.readFileSync(path.resolve(__dirname, '../test/bin/EntryPoint080.bytecode'), 'hex'),
},
},
senderCreator: {
v07: {
address: '0xEFC2c1444eBCC4Db75e7613d20C6a62fF67A167C',
abi: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/bin/SenderCreator070.abi'), 'utf-8')),
bytecode: fs.readFileSync(path.resolve(__dirname, '../test/bin/SenderCreator070.bytecode'), 'hex'),
},
v08: {
address: '0x449ED7C3e6Fee6a97311d4b55475DF59C44AdD33',
abi: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/bin/SenderCreator080.abi'), 'utf-8')),
bytecode: fs.readFileSync(path.resolve(__dirname, '../test/bin/SenderCreator080.bytecode'), 'hex'),
},
},
deployer: {
// Arachnid's deterministic deployment proxy
// See: https://github.com/Arachnid/deterministic-deployment-proxy/tree/master
arachnid: {
address: '0x4e59b44847b379578588920cA78FbF26c0B4956C',
abi: [],
bytecode:
'0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3',
},
// Micah's deployer
micah: {
address: '0x7A0D94F55792C434d74a40883C6ed8545E406D12',
abi: [],
bytecode: '0x60003681823780368234f58015156014578182fd5b80825250506014600cf3',
},
},
};
const setup = (input, ethers) =>
input.address && input.abi && input.bytecode
? setCode(input.address, '0x' + input.bytecode.replace(/0x/, '')).then(() =>
ethers.getContractAt(input.abi, input.address),
)
: Promise.all(
Object.entries(input).map(([name, entry]) => setup(entry, ethers).then(result => [name, result])),
).then(Object.fromEntries);
task(TASK_TEST_SETUP_TEST_ENVIRONMENT).setAction((_, env, runSuper) =>
runSuper().then(() => setup(INSTANCES, env.ethers).then(result => Object.assign(env, result))),
);