@@ -2,7 +2,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
22import { DeployFunction } from "hardhat-deploy/types" ;
33import { BigNumber } from "ethers" ;
44import getContractAddress from "../deploy-helpers/getContractAddress" ;
5- import { SortitionModule , VRFSubscriptionManagerV2Mock } from "../typechain-types" ;
5+ import { SortitionModule , VRFSubscriptionManagerV2 , VRFSubscriptionManagerV2Mock } from "../typechain-types" ;
66
77enum HomeChains {
88 ARBITRUM_ONE = 42161 ,
@@ -166,8 +166,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
166166 : AddressZero ;
167167
168168 // Execute the setup transactions for using VRF and deploy the Consumer contract on Hardhat node
169+ // The Sortition Module rng source is not changed to the VRF Consumer.
169170 if ( vrfSubscriptionManager ) {
170- // The Sortition Module is not changed to the VRF Consumer, it must be done in the test.
171171 if ( chainId === HomeChains . HARDHAT ) {
172172 const vrfSubscriptionManagerContract = ( await hre . ethers . getContract (
173173 "VRFSubscriptionManagerV2Mock"
@@ -190,6 +190,26 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
190190 } ) ;
191191 await vrfSubscriptionManagerContract . addConsumer ( vrfConsumer . address ) ;
192192 }
193+ } else {
194+ const vrfSubscriptionManagerContract = ( await hre . ethers . getContract (
195+ "VRFSubscriptionManagerV2"
196+ ) ) as VRFSubscriptionManagerV2 ;
197+ const subscriptionId = await vrfSubscriptionManagerContract . subscriptionId ( ) ;
198+ const vrfConsumer = await deploy ( "VRFConsumerV2" , {
199+ from : deployer ,
200+ args : [
201+ deployer ,
202+ vrfCoordinator ,
203+ sortitionModule . address ,
204+ keyHash ,
205+ subscriptionId ,
206+ requestConfirmations ,
207+ callbackGasLimit ,
208+ numWords ,
209+ ] ,
210+ log : true ,
211+ } ) ;
212+ await vrfSubscriptionManagerContract . addConsumer ( vrfConsumer . address ) ;
193213 }
194214} ;
195215
0 commit comments