-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy path00-rng.ts
66 lines (57 loc) · 2.25 KB
/
00-rng.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
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { SortitionModule } from "../typechain-types";
import { HomeChains, isSkipped } from "./utils";
import { deployUpgradable } from "./utils/deployUpgradable";
const pnkByChain = new Map<HomeChains, string>([
[HomeChains.ARBITRUM_ONE, "0x330bD769382cFc6d50175903434CCC8D206DCAE5"],
[HomeChains.ARBITRUM_GOERLI, "0x3483FA1b87792cd5BE4100822C4eCEC8D3E531ee"],
]);
const randomizerByChain = new Map<HomeChains, string>([
[HomeChains.ARBITRUM_ONE, "0x5b8bB80f2d72D0C85caB8fB169e8170A05C94bAF"],
[HomeChains.ARBITRUM_GOERLI, "0x923096Da90a3b60eb7E12723fA2E1547BA9236Bc"],
]);
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy, execute } = deployments;
const { AddressZero } = hre.ethers.constants;
// fallback to hardhat node signers on local network
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
const chainId = Number(await getChainId());
console.log("Deploying to %s with deployer %s", HomeChains[chainId], deployer);
if (chainId === HomeChains.HARDHAT) {
pnkByChain.set(
HomeChains.HARDHAT,
(
await deploy("PNK", {
from: deployer,
log: true,
})
).address
);
randomizerByChain.set(
HomeChains.HARDHAT,
(
await deploy("RandomizerMock", {
from: deployer,
args: [],
log: true,
})
).address
);
}
const randomizer = randomizerByChain.get(Number(await getChainId())) ?? AddressZero;
await deployUpgradable(deployments, "RandomizerRNG", { from: deployer, args: [randomizer, deployer], log: true });
const rng = await deploy("BlockHashRNG", {
from: deployer,
args: [],
log: true,
});
const sortitionModule = (await hre.ethers.getContract("SortitionModule")) as SortitionModule;
await sortitionModule.changeRandomNumberGenerator(rng.address);
};
deployArbitration.tags = ["RNG"];
deployArbitration.skip = async ({ network }) => {
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
};
export default deployArbitration;