-
Notifications
You must be signed in to change notification settings - Fork 885
Expand file tree
/
Copy pathprepareMigrationAdminsCalldata.js
More file actions
53 lines (46 loc) · 1.18 KB
/
prepareMigrationAdminsCalldata.js
File metadata and controls
53 lines (46 loc) · 1.18 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Read migrationAdmins.csv
// In the format of:
// index,address
// 0,0x1234...
// 1,0x5678...
// ...
const fs = require('fs');
const file = 'migrationAdmins.csv';
const migrationAdmins = [];
// Read file line by line and save to the array
// Skip the first line
fs.readFileSync(file, 'utf-8')
.split(/\r?\n/)
.slice(1)
.forEach(function (line) {
// If line is empty, skip
if (!line) return;
const [index, address] = line.split(',');
migrationAdmins.push(address);
});
// Function setMigrationAdmins(address[] memory migrationAdmins, bool whitelisted)
// Construct the calldata using migrationAdmins and bool true, using ethers
const ethers = require('ethers');
const abi = [
{
inputs: [
{
internalType: 'address[]',
name: 'migrationAdmins',
type: 'address[]',
},
{
internalType: 'bool',
name: 'whitelisted',
type: 'bool',
},
],
name: 'setMigrationAdmins',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
];
const iface = new ethers.utils.Interface(abi);
const data = iface.encodeFunctionData('setMigrationAdmins', [migrationAdmins, true]);
console.log(data);