11import { HardhatRuntimeEnvironment } from "hardhat/types" ;
2- import { BigNumber } from "ethers" ;
3- import { DeployFunction , DeployResult } from "hardhat-deploy/types" ;
4- import { SortitionModule , VRFSubscriptionManagerV2Mock , VRFSubscriptionManagerV2 } from "../typechain-types" ;
2+ import { DeployFunction } from "hardhat-deploy/types" ;
3+ import { SortitionModule } from "../typechain-types" ;
54import { HomeChains , isSkipped } from "./utils" ;
65import { deployUpgradable } from "./utils/deployUpgradable" ;
76
@@ -10,31 +9,11 @@ const pnkByChain = new Map<HomeChains, string>([
109 [ HomeChains . ARBITRUM_GOERLI , "0x3483FA1b87792cd5BE4100822C4eCEC8D3E531ee" ] ,
1110] ) ;
1211
13- // https://randomizer.ai/docs#addresses
1412const randomizerByChain = new Map < HomeChains , string > ( [
1513 [ HomeChains . ARBITRUM_ONE , "0x5b8bB80f2d72D0C85caB8fB169e8170A05C94bAF" ] ,
1614 [ HomeChains . ARBITRUM_GOERLI , "0x923096Da90a3b60eb7E12723fA2E1547BA9236Bc" ] ,
1715] ) ;
1816
19- // https://docs.chain.link/resources/link-token-contracts?parent=vrf#arbitrum
20- const linkByChain = new Map < HomeChains , string > ( [
21- [ HomeChains . ARBITRUM_ONE , "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4" ] ,
22- [ HomeChains . ARBITRUM_GOERLI , "0xd14838A68E8AFBAdE5efb411d5871ea0011AFd28" ] ,
23- ] ) ;
24-
25- // https://docs.chain.link/vrf/v2/subscription/supported-networks#arbitrum-mainnet
26- const keyHashByChain = new Map < HomeChains , string > ( [
27- [ HomeChains . ARBITRUM_ONE , "0x72d2b016bb5b62912afea355ebf33b91319f828738b111b723b78696b9847b63" ] , // 30 gwei key Hash
28- [ HomeChains . ARBITRUM_GOERLI , "0x83d1b6e3388bed3d76426974512bb0d270e9542a765cd667242ea26c0cc0b730" ] ,
29- [ HomeChains . HARDHAT , "0x0000000000000000000000000000000000000000000000000000000000000000" ] ,
30- ] ) ;
31-
32- // https://docs.chain.link/vrf/v2/subscription/supported-networks#arbitrum-mainnet
33- const vrfCoordinatorByChain = new Map < HomeChains , string > ( [
34- [ HomeChains . ARBITRUM_ONE , "0x41034678D6C633D8a95c75e1138A360a28bA15d1" ] ,
35- [ HomeChains . ARBITRUM_GOERLI , "0x6D80646bEAdd07cE68cab36c27c626790bBcf17f" ] ,
36- ] ) ;
37-
3817const deployArbitration : DeployFunction = async ( hre : HardhatRuntimeEnvironment ) => {
3918 const { deployments, getNamedAccounts, getChainId } = hre ;
4019 const { deploy, execute } = deployments ;
@@ -66,16 +45,6 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6645 } )
6746 ) . address
6847 ) ;
69- vrfCoordinatorByChain . set (
70- HomeChains . HARDHAT ,
71- (
72- await deploy ( "VRFCoordinatorV2Mock" , {
73- from : deployer ,
74- args : [ BigNumber . from ( 10 ) . pow ( 18 ) , 1000000000 ] , // base_fee: 1 LINK, gas_price_link: 0.000000001 LINK per gas, from chainlink mock scripts
75- log : true ,
76- } )
77- ) . address
78- ) ;
7948 }
8049
8150 const randomizer = randomizerByChain . get ( Number ( await getChainId ( ) ) ) ?? AddressZero ;
@@ -88,78 +57,6 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
8857
8958 const sortitionModule = ( await hre . ethers . getContract ( "SortitionModule" ) ) as SortitionModule ;
9059 await sortitionModule . changeRandomNumberGenerator ( rng . address , RNG_LOOKAHEAD ) ;
91-
92- const link = linkByChain . get ( Number ( await getChainId ( ) ) ) ?? AddressZero ; // LINK not needed on hardhat local node
93- const keyHash = keyHashByChain . get ( Number ( await getChainId ( ) ) ) ?? AddressZero ;
94- const requestConfirmations = 3 ; // Paramater to be fixed, range [1 ; 200] on Arbitrum
95- const callbackGasLimit = 100000 ; // Parameter to be fixed, 50000 on RandomizerRNG but no external call to sortitionModule.passPhase() in the callback
96- const numWords = 1 ;
97- const vrfCoordinator = vrfCoordinatorByChain . get ( Number ( await getChainId ( ) ) ) ?? AddressZero ;
98- // Deploy the VRF Subscription Manager contract on Arbitrum, a mock contract on Hardhat node or nothing on other networks.
99- let vrfSubscriptionManager : DeployResult | string ;
100- if ( vrfCoordinator ) {
101- vrfSubscriptionManager =
102- chainId === HomeChains . HARDHAT
103- ? await deploy ( "VRFSubscriptionManagerV2Mock" , {
104- from : deployer ,
105- args : [ deployer , vrfCoordinator ] ,
106- log : true ,
107- } )
108- : await deploy ( "VRFSubscriptionManagerV2" , {
109- from : deployer ,
110- args : [ deployer , vrfCoordinator , link ] ,
111- log : true ,
112- } ) ;
113- } else {
114- vrfSubscriptionManager = AddressZero ;
115- }
116-
117- // Execute the setup transactions for using VRF and deploy the Consumer contract on Hardhat node
118- // The Sortition Module rng source is not changed to the VRF Consumer.
119- if ( vrfSubscriptionManager ) {
120- if ( chainId === HomeChains . HARDHAT ) {
121- const vrfSubscriptionManagerContract = ( await hre . ethers . getContract (
122- "VRFSubscriptionManagerV2Mock"
123- ) ) as VRFSubscriptionManagerV2Mock ;
124- await vrfSubscriptionManagerContract . topUpSubscription ( BigNumber . from ( 10 ) . pow ( 20 ) ) ; // 100 LINK
125- const subscriptionId = await vrfSubscriptionManagerContract . subscriptionId ( ) ;
126- const vrfConsumer = await deploy ( "VRFConsumerV2" , {
127- from : deployer ,
128- args : [
129- deployer ,
130- vrfCoordinator ,
131- sortitionModule . address ,
132- keyHash ,
133- subscriptionId ,
134- requestConfirmations ,
135- callbackGasLimit ,
136- numWords ,
137- ] ,
138- log : true ,
139- } ) ;
140- await vrfSubscriptionManagerContract . addConsumer ( vrfConsumer . address ) ;
141- }
142- } else {
143- const vrfSubscriptionManagerContract = ( await hre . ethers . getContract (
144- "VRFSubscriptionManagerV2"
145- ) ) as VRFSubscriptionManagerV2 ;
146- const subscriptionId = await vrfSubscriptionManagerContract . subscriptionId ( ) ;
147- const vrfConsumer = await deploy ( "VRFConsumerV2" , {
148- from : deployer ,
149- args : [
150- deployer ,
151- vrfCoordinator ,
152- sortitionModule . address ,
153- keyHash ,
154- subscriptionId ,
155- requestConfirmations ,
156- callbackGasLimit ,
157- numWords ,
158- ] ,
159- log : true ,
160- } ) ;
161- await vrfSubscriptionManagerContract . addConsumer ( vrfConsumer . address ) ;
162- }
16360} ;
16461
16562deployArbitration . tags = [ "RNG" ] ;
0 commit comments