-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdeployDogethereum.ts
122 lines (106 loc) · 3.2 KB
/
deployDogethereum.ts
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
import hre from "hardhat";
import fs from "fs-extra";
import path from "path";
import {
deployDogethereum,
DEPLOYMENT_JSON_NAME,
DogecoinNetworkId,
getDefaultDeploymentPath,
getScryptChecker,
deployScryptCheckerDummy,
storeDeployment,
ScryptCheckerDeployment,
SuperblockchainOptions,
SUPERBLOCK_OPTIONS_LOCAL,
SUPERBLOCK_OPTIONS_INTEGRATION_FAST_SYNC,
// SUPERBLOCK_OPTIONS_INTEGRATION_SLOW_SYNC,
// SUPERBLOCK_OPTIONS_PRODUCTION,
} from "../deploy";
interface PriceOracles {
/**
* Doge - Usd Chainlink price oracle.
*/
dogeUsdPriceOracle?: string,
/**
* Eth - Usd Chainlink price oracle.
*/
ethUsdPriceOracle?: string,
}
const mainnetOracles: PriceOracles = {
dogeUsdPriceOracle: "0x2465CefD3b488BE410b941b1d4b2767088e2A028",
ethUsdPriceOracle: "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419",
}
const localOracles: PriceOracles = {};
/**
* This script always deploys the production token.
*/
async function main() {
const deploymentDir = getDefaultDeploymentPath(hre);
const deploymentExists = await fs.pathExists(
path.join(deploymentDir, DEPLOYMENT_JSON_NAME)
);
if (deploymentExists && hre.network.name !== "hardhat") {
// We support only one deployment for each network for now.
throw new Error(`A deployment for ${hre.network.name} already exists.`);
}
// TODO: parametrize these when we write this as a Hardhat task.
const dogecoinNetworkId = DogecoinNetworkId.Regtest;
const superblockOptions = getSuperblockchainOptions(hre.network.name);
const { scryptChecker } = await deployOrGetScryptChecker();
// TODO: add testnet oracles when they are available.
let oracles: PriceOracles;
if (hre.network.name === "mainnet") {
oracles = mainnetOracles;
} else {
oracles = localOracles;
}
const deployment = await deployDogethereum(hre, {
confirmations: 1,
dogecoinNetworkId,
superblockOptions,
scryptChecker,
dogeTokenContractName: "DogeToken",
useProxy: true,
...oracles,
});
return storeDeployment(hre, deployment, deploymentDir);
}
function deployOrGetScryptChecker(): Promise<ScryptCheckerDeployment> {
const scryptCheckerAddress = process.env.SCRYPT_CHECKER;
if (scryptCheckerAddress === undefined) {
throw new Error(
`Scrypt checker contract address is missing.
Please specify the address by setting the SCRYPT_CHECKER environment variable.`
);
}
if (scryptCheckerAddress === "deploy_dummy") {
return deployScryptCheckerDummy(hre);
}
return getScryptChecker(hre, scryptCheckerAddress);
}
function getSuperblockchainOptions(ethereumNetworkName: string): SuperblockchainOptions {
if (
ethereumNetworkName === "hardhat" ||
ethereumNetworkName === "development" ||
ethereumNetworkName === "integrationDogeRegtest"
) {
return SUPERBLOCK_OPTIONS_LOCAL;
}
if (
ethereumNetworkName === "rinkeby" ||
ethereumNetworkName === "ropsten" ||
ethereumNetworkName === "integrationDogeMain" ||
ethereumNetworkName === "integrationDogeScrypt"
) {
return SUPERBLOCK_OPTIONS_INTEGRATION_FAST_SYNC;
}
throw new Error("Unknown network.");
}
main()
.then(() => {
process.exit(0);
})
.catch((error) => {
console.error(error);
process.exit(1);
});