-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcopyDeploymentAddresses.js
66 lines (59 loc) · 2.07 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
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}:`);
// 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 latestCoreDeployments = deployments.getLatestCoreContractsPerNetwork({
version: config.coreDeploymentVersionRangePattern,
released: config.coreDeploymentVersionReleasedFilter,
});
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(`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),
)) {
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();