-
Notifications
You must be signed in to change notification settings - Fork 1
/
copyDeploymentAddresses.js
124 lines (115 loc) · 3.77 KB
/
copyDeploymentAddresses.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
const deployments = require("@mangrovedao/mangrove-deployments");
const fs = require("fs");
const path = require("path");
const config = require("./config");
const script = path.basename(__filename);
if (!config.copyDeployments) {
console.group(
"Skipping copying deployments from the mangrove-deployments package.",
);
console.log("Set copyDeployments = true in config.js to enable copying.");
console.log("Using addresses/deployed/*.json files as-is instead.");
console.groupEnd();
process.exit(0);
}
console.group(`${script}:`);
// This is a hack to get the network names because the addresses
// file names use non-canonical network names from ethers.js
const networkNames = deployments.mangroveNetworkNames;
// Query deployments based on the configuration in config.js
console.log(
`Querying mangrove-deployments for core deployments of version ${
config.coreDeploymentVersionRangePattern
}, ${
config.coreDeploymentVersionReleasedFilter === undefined
? "released or unreleased"
: config.coreDeploymentVersionReleasedFilter
? "release"
: "unreleased"
}...`,
);
const coreDeploymentsFilter = {
version: config.coreDeploymentVersionRangePattern,
released: config.coreDeploymentVersionReleasedFilter,
};
const latestCoreDeployments = deployments.getLatestCoreContractsPerNetwork(
coreDeploymentsFilter,
);
console.group(`...found the following deployments of Mangrove:`);
for (const [networkName, namedAddresses] of Object.entries(
latestCoreDeployments,
)) {
console.log(
`${networkName}: ${namedAddresses.mangrove.version} at ${namedAddresses.mangrove.address}`,
);
}
console.groupEnd();
console.log();
console.log(
`Querying mangrove-deployments for matching strat deployments of version ${
config.stratsDeploymentVersionRangePattern
}, ${
config.stratsDeploymentVersionReleasedFilter === undefined
? "released or unreleased"
: config.stratsDeploymentVersionReleasedFilter
? "release"
: "unreleased"
}...`,
);
const stratsDeploymentsFilter = {
version: config.stratsDeploymentVersionRangePattern,
released: config.stratsDeploymentVersionReleasedFilter,
};
const latestStratsDeployments = deployments.getLatestStratContractsPerNetwork(
stratsDeploymentsFilter,
coreDeploymentsFilter,
);
console.group(`...found the following deployments of strats:`);
for (const [networkName, namedAddresses] of Object.entries(
latestStratsDeployments,
)) {
console.group(
`${networkName}, Mangrove v${namedAddresses.mangrove.version} at ${namedAddresses.mangrove.address}:`,
);
for (const [stratName, stratNetworkDeployment] of Object.entries(
namedAddresses,
)) {
if (stratName == "mangrove") {
continue;
}
if (stratNetworkDeployment === undefined) {
console.log(`${stratName}: not deployed`);
continue;
}
const name =
stratNetworkDeployment.deploymentName ??
stratNetworkDeployment.contractName;
console.log(
`${name}: v${stratNetworkDeployment.version} at ${stratNetworkDeployment.address}`,
);
}
console.groupEnd();
}
console.groupEnd();
console.log();
console.log(`Copying deployment addresses...`);
// NB: Test token deployments are included in the context-addresses package,
// so they are not queried from mangrove-deployments.
// Create the addresses files with the loaded deployment addresses
for (const [networkName, namedAddresses] of Object.entries(
deployments.toNamedAddressesPerNamedNetwork(
latestCoreDeployments,
latestStratsDeployments,
),
)) {
const networkAddressesFilePath = path.join(
__dirname,
`./addresses/deployed/${networkName}.json`,
);
fs.writeFileSync(
networkAddressesFilePath,
JSON.stringify(namedAddresses, null, 2),
);
}
console.log(`...done copying deployment addresses`);
console.groupEnd();