1
1
import { 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" ;
5
4
6
5
enum HomeChains {
7
6
ARBITRUM_ONE = 42161 ,
@@ -14,31 +13,11 @@ const pnkByChain = new Map<HomeChains, string>([
14
13
[ HomeChains . ARBITRUM_GOERLI , "0x4DEeeFD054434bf6721eF39Aa18EfB3fd0D12610" ] ,
15
14
] ) ;
16
15
17
- // https://randomizer.ai/docs#addresses
18
16
const randomizerByChain = new Map < HomeChains , string > ( [
19
17
[ HomeChains . ARBITRUM_ONE , "0x00" ] ,
20
18
[ HomeChains . ARBITRUM_GOERLI , "0x57F7a8aA8291A04B325F3f0d2c4d03353d3Ef25f" ] ,
21
19
] ) ;
22
20
23
- // https://docs.chain.link/resources/link-token-contracts?parent=vrf#arbitrum
24
- const linkByChain = new Map < HomeChains , string > ( [
25
- [ HomeChains . ARBITRUM_ONE , "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4" ] ,
26
- [ HomeChains . ARBITRUM_GOERLI , "0xd14838A68E8AFBAdE5efb411d5871ea0011AFd28" ] ,
27
- ] ) ;
28
-
29
- // https://docs.chain.link/vrf/v2/subscription/supported-networks#arbitrum-mainnet
30
- const keyHashByChain = new Map < HomeChains , string > ( [
31
- [ HomeChains . ARBITRUM_ONE , "0x72d2b016bb5b62912afea355ebf33b91319f828738b111b723b78696b9847b63" ] , // 30 gwei key Hash
32
- [ HomeChains . ARBITRUM_GOERLI , "0x83d1b6e3388bed3d76426974512bb0d270e9542a765cd667242ea26c0cc0b730" ] ,
33
- [ HomeChains . HARDHAT , "0x0000000000000000000000000000000000000000000000000000000000000000" ] ,
34
- ] ) ;
35
-
36
- // https://docs.chain.link/vrf/v2/subscription/supported-networks#arbitrum-mainnet
37
- const vrfCoordinatorByChain = new Map < HomeChains , string > ( [
38
- [ HomeChains . ARBITRUM_ONE , "0x41034678D6C633D8a95c75e1138A360a28bA15d1" ] ,
39
- [ HomeChains . ARBITRUM_GOERLI , "0x6D80646bEAdd07cE68cab36c27c626790bBcf17f" ] ,
40
- ] ) ;
41
-
42
21
const deployArbitration : DeployFunction = async ( hre : HardhatRuntimeEnvironment ) => {
43
22
const { deployments, getNamedAccounts, getChainId } = hre ;
44
23
const { deploy, execute } = deployments ;
@@ -70,16 +49,6 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
70
49
} )
71
50
) . address
72
51
) ;
73
- vrfCoordinatorByChain . set (
74
- HomeChains . HARDHAT ,
75
- (
76
- await deploy ( "VRFCoordinatorV2Mock" , {
77
- from : deployer ,
78
- args : [ BigNumber . from ( 10 ) . pow ( 18 ) , 1000000000 ] , // base_fee: 1 LINK, gas_price_link: 0.000000001 LINK per gas, from chainlink mock scripts
79
- log : true ,
80
- } )
81
- ) . address
82
- ) ;
83
52
}
84
53
85
54
const randomizer = randomizerByChain . get ( Number ( await getChainId ( ) ) ) ?? AddressZero ;
@@ -91,78 +60,6 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
91
60
92
61
const sortitionModule = ( await hre . ethers . getContract ( "SortitionModule" ) ) as SortitionModule ;
93
62
await sortitionModule . changeRandomNumberGenerator ( rng . address , RNG_LOOKAHEAD ) ;
94
-
95
- const link = linkByChain . get ( Number ( await getChainId ( ) ) ) ?? AddressZero ; // LINK not needed on hardhat local node
96
- const keyHash = keyHashByChain . get ( Number ( await getChainId ( ) ) ) ?? AddressZero ;
97
- const requestConfirmations = 3 ; // Paramater to be fixed, range [1 ; 200] on Arbitrum
98
- const callbackGasLimit = 100000 ; // Parameter to be fixed, 50000 on RandomizerRNG but no external call to sortitionModule.passPhase() in the callback
99
- const numWords = 1 ;
100
- const vrfCoordinator = vrfCoordinatorByChain . get ( Number ( await getChainId ( ) ) ) ?? AddressZero ;
101
- // Deploy the VRF Subscription Manager contract on Arbitrum, a mock contract on Hardhat node or nothing on other networks.
102
- let vrfSubscriptionManager : DeployResult | string ;
103
- if ( vrfCoordinator ) {
104
- vrfSubscriptionManager =
105
- chainId === HomeChains . HARDHAT
106
- ? await deploy ( "VRFSubscriptionManagerV2Mock" , {
107
- from : deployer ,
108
- args : [ deployer , vrfCoordinator ] ,
109
- log : true ,
110
- } )
111
- : await deploy ( "VRFSubscriptionManagerV2" , {
112
- from : deployer ,
113
- args : [ deployer , vrfCoordinator , link ] ,
114
- log : true ,
115
- } ) ;
116
- } else {
117
- vrfSubscriptionManager = AddressZero ;
118
- }
119
-
120
- // Execute the setup transactions for using VRF and deploy the Consumer contract on Hardhat node
121
- // The Sortition Module rng source is not changed to the VRF Consumer.
122
- if ( vrfSubscriptionManager ) {
123
- if ( chainId === HomeChains . HARDHAT ) {
124
- const vrfSubscriptionManagerContract = ( await hre . ethers . getContract (
125
- "VRFSubscriptionManagerV2Mock"
126
- ) ) as VRFSubscriptionManagerV2Mock ;
127
- await vrfSubscriptionManagerContract . topUpSubscription ( BigNumber . from ( 10 ) . pow ( 20 ) ) ; // 100 LINK
128
- const subscriptionId = await vrfSubscriptionManagerContract . subscriptionId ( ) ;
129
- const vrfConsumer = await deploy ( "VRFConsumerV2" , {
130
- from : deployer ,
131
- args : [
132
- deployer ,
133
- vrfCoordinator ,
134
- sortitionModule . address ,
135
- keyHash ,
136
- subscriptionId ,
137
- requestConfirmations ,
138
- callbackGasLimit ,
139
- numWords ,
140
- ] ,
141
- log : true ,
142
- } ) ;
143
- await vrfSubscriptionManagerContract . addConsumer ( vrfConsumer . address ) ;
144
- }
145
- } else {
146
- const vrfSubscriptionManagerContract = ( await hre . ethers . getContract (
147
- "VRFSubscriptionManagerV2"
148
- ) ) as VRFSubscriptionManagerV2 ;
149
- const subscriptionId = await vrfSubscriptionManagerContract . subscriptionId ( ) ;
150
- const vrfConsumer = await deploy ( "VRFConsumerV2" , {
151
- from : deployer ,
152
- args : [
153
- deployer ,
154
- vrfCoordinator ,
155
- sortitionModule . address ,
156
- keyHash ,
157
- subscriptionId ,
158
- requestConfirmations ,
159
- callbackGasLimit ,
160
- numWords ,
161
- ] ,
162
- log : true ,
163
- } ) ;
164
- await vrfSubscriptionManagerContract . addConsumer ( vrfConsumer . address ) ;
165
- }
166
63
} ;
167
64
168
65
deployArbitration . tags = [ "RNG" ] ;
0 commit comments