Skip to content

Commit

Permalink
DEVSVCS-138: adding default test config for VRF CTF tests; adding abi… (
Browse files Browse the repository at this point in the history
#14184)

* DEVSVCS-138: adding default test config for VRF CTF tests; adding ability to deploy Test Coordinator, Arbitrum Coordinator for V2Plus, also Arbitrum Wrapper

* DEVSVCS-138: fixing lint solidity issues
  • Loading branch information
iljapavlovs authored Aug 26, 2024
1 parent 3d2efc3 commit 3257b8f
Show file tree
Hide file tree
Showing 15 changed files with 5,694 additions and 48 deletions.
1 change: 1 addition & 0 deletions contracts/scripts/native_solc_compile_all_vrf
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ compileContract vrf/dev/testhelpers/VRFV2PlusWrapperConsumerExample.sol
compileContract vrf/dev/testhelpers/VRFV2PlusRevertingExample.sol
compileContract vrf/dev/testhelpers/VRFConsumerV2PlusUpgradeableExample.sol
compileContract vrf/dev/testhelpers/VRFV2PlusMaliciousMigrator.sol
compileContractAltOpts vrf/dev/testhelpers/VRFCoordinatorTestV2_5.sol 500
compileContract vrf/dev/libraries/VRFV2PlusClient.sol
compileContract vrf/dev/testhelpers/VRFCoordinatorV2Plus_V2Example.sol
compileContract vrf/dev/TrustedBlockhashStore.sol
Expand Down
773 changes: 773 additions & 0 deletions contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorTestV2_5.sol

Large diffs are not rendered by default.

588 changes: 588 additions & 0 deletions contracts/src/v0.8/vrf/dev/testhelpers/VRFOld.sol

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ vrf_consumer_v2_plus_upgradeable_example: ../../contracts/solc/v0.8.19/VRFConsum
vrf_consumer_v2_upgradeable_example: ../../contracts/solc/v0.8.6/VRFConsumerV2UpgradeableExample/VRFConsumerV2UpgradeableExample.abi ../../contracts/solc/v0.8.6/VRFConsumerV2UpgradeableExample/VRFConsumerV2UpgradeableExample.bin f1790a9a2f2a04c730593e483459709cb89e897f8a19d7a3ac0cfe6a97265e6e
vrf_coordinator_mock: ../../contracts/solc/v0.8.6/VRFCoordinatorMock/VRFCoordinatorMock.abi ../../contracts/solc/v0.8.6/VRFCoordinatorMock/VRFCoordinatorMock.bin 5c495cf8df1f46d8736b9150cdf174cce358cb8352f60f0d5bb9581e23920501
vrf_coordinator_test_v2: ../../contracts/solc/v0.8.6/VRFCoordinatorTestV2/VRFCoordinatorTestV2.abi ../../contracts/solc/v0.8.6/VRFCoordinatorTestV2/VRFCoordinatorTestV2.bin ff6c0056c6181ea75f667beed21ff4610f417dd50ceabf2dec8fa42e84851f50
vrf_coordinator_test_v2_5: ../../contracts/solc/v0.8.19/VRFCoordinatorTestV2_5/VRFCoordinatorTestV2_5.abi ../../contracts/solc/v0.8.19/VRFCoordinatorTestV2_5/VRFCoordinatorTestV2_5.bin ab793e7d72b2d10d5c80b5358ca98caf5ff8a8686700735b198ed811272d7910
vrf_coordinator_v2: ../../contracts/solc/v0.8.6/VRFCoordinatorV2/VRFCoordinatorV2.abi ../../contracts/solc/v0.8.6/VRFCoordinatorV2/VRFCoordinatorV2.bin 156fbbc19489383901087c2076648ccd343bcd9a332f1ad25974da834c5be961
vrf_coordinator_v2_5: ../../contracts/solc/v0.8.19/VRFCoordinatorV2_5/VRFCoordinatorV2_5.abi ../../contracts/solc/v0.8.19/VRFCoordinatorV2_5/VRFCoordinatorV2_5.bin 3c766dbdefcc895ad475de96c65b6c48c868b8dc889ee750bba6711b1e5ec41d
vrf_coordinator_v2_5_arbitrum: ../../contracts/solc/v0.8.19/VRFCoordinatorV2_5_Arbitrum/VRFCoordinatorV2_5_Arbitrum.abi ../../contracts/solc/v0.8.19/VRFCoordinatorV2_5_Arbitrum/VRFCoordinatorV2_5_Arbitrum.bin 1a2431ee76e307b45f683c439d08b9096a08f08aaf9ca132ea5b36b409962abe
Expand Down
1 change: 1 addition & 0 deletions core/gethwrappers/go_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ package gethwrappers
//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/VRFCoordinatorV2_5_Optimism/VRFCoordinatorV2_5_Optimism.abi ../../contracts/solc/v0.8.19/VRFCoordinatorV2_5_Optimism/VRFCoordinatorV2_5_Optimism.bin VRFCoordinatorV2_5_Optimism vrf_coordinator_v2_5_optimism
//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/VRFV2PlusWrapper_Arbitrum/VRFV2PlusWrapper_Arbitrum.abi ../../contracts/solc/v0.8.19/VRFV2PlusWrapper_Arbitrum/VRFV2PlusWrapper_Arbitrum.bin VRFV2PlusWrapper_Arbitrum vrfv2plus_wrapper_arbitrum
//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/VRFV2PlusWrapper_Optimism/VRFV2PlusWrapper_Optimism.abi ../../contracts/solc/v0.8.19/VRFV2PlusWrapper_Optimism/VRFV2PlusWrapper_Optimism.bin VRFV2PlusWrapper_Optimism vrfv2plus_wrapper_optimism
//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/VRFCoordinatorTestV2_5/VRFCoordinatorTestV2_5.abi ../../contracts/solc/v0.8.19/VRFCoordinatorTestV2_5/VRFCoordinatorTestV2_5.bin VRFCoordinatorTestV2_5 vrf_coordinator_test_v2_5

// Aggregators
//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV2V3Interface.abi ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV2V3Interface.bin AggregatorV2V3Interface aggregator_v2v3_interface
Expand Down
5 changes: 5 additions & 0 deletions integration-tests/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,11 @@ func IsOPStackChain(chainID int64) bool {
chainID == 11155420 //OPTIMISM SEPOLIA
}

func IsArbitrumChain(chainID int64) bool {
return chainID == 42161 || //Arbitrum MAINNET
chainID == 421614 //Arbitrum Sepolia
}

func RandBool() bool {
return rand.Intn(2) == 1
}
Expand Down
40 changes: 21 additions & 19 deletions integration-tests/actions/vrf/vrfv2/setup_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func CreateVRFV2Job(
}
ost, err := os.String()
if err != nil {
return nil, fmt.Errorf("%s, err %w", vrfcommon.ErrParseJob, err)
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrParseJob, err)
}

spec := &client.VRFV2JobSpec{
Expand All @@ -69,7 +69,7 @@ func CreateVRFV2Job(
}
job, err := chainlinkNode.MustCreateJob(spec)
if err != nil {
return nil, fmt.Errorf("%s, err %w", ErrCreatingVRFv2Job, err)
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrCreatingVRFv2Job, err)
}
return job, nil
}
Expand Down Expand Up @@ -113,15 +113,14 @@ func SetupVRFV2Environment(
if err != nil {
return nil, nil, nil, err
}

l.Info().Str("Coordinator", vrfContracts.CoordinatorV2.Address()).Msg("Registering Proving Key")
provingKey, err := VRFV2RegisterProvingKey(vrfKey, registerProvingKeyAgainstAddress, vrfContracts.CoordinatorV2)
if err != nil {
return nil, nil, nil, fmt.Errorf("%s, err %w", vrfcommon.ErrRegisteringProvingKey, err)
return nil, nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrRegisteringProvingKey, err)
}
keyHash, err := vrfContracts.CoordinatorV2.HashOfKey(ctx, provingKey)
if err != nil {
return nil, nil, nil, fmt.Errorf("%s, err %w", vrfcommon.ErrCreatingProvingKeyHash, err)
return nil, nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrCreatingProvingKeyHash, err)
}

vrfTXKeyAddressStrings, vrfTXKeyAddresses, err := vrfcommon.CreateFundAndGetSendingKeys(
Expand Down Expand Up @@ -189,44 +188,47 @@ func SetupVRFV2Environment(
return vrfContracts, &vrfKeyData, nodeTypeToNodeMap, nil
}

func setupVRFNode(contracts *vrfcommon.VRFContracts, chainID *big.Int, vrfv2Config *testconfig.General, pubKeyCompressed string, vrfOwnerConfig *vrfcommon.VRFOwnerConfig, l zerolog.Logger, vrfNode *vrfcommon.VRFNode) error {
func setupVRFNode(contracts *vrfcommon.VRFContracts, chainID *big.Int, config *testconfig.General, pubKeyCompressed string, vrfOwnerConfig *vrfcommon.VRFOwnerConfig, l zerolog.Logger, vrfNode *vrfcommon.VRFNode) error {
vrfJobSpecConfig := vrfcommon.VRFJobSpecConfig{
ForwardingAllowed: *vrfv2Config.VRFJobForwardingAllowed,
ForwardingAllowed: *config.VRFJobForwardingAllowed,
CoordinatorAddress: contracts.CoordinatorV2.Address(),
BatchCoordinatorAddress: contracts.BatchCoordinatorV2.Address(),
FromAddresses: vrfNode.TXKeyAddressStrings,
EVMChainID: chainID.String(),
MinIncomingConfirmations: int(*vrfv2Config.MinimumConfirmations),
MinIncomingConfirmations: int(*config.MinimumConfirmations),
PublicKey: pubKeyCompressed,
EstimateGasMultiplier: *vrfv2Config.VRFJobEstimateGasMultiplier,
BatchFulfillmentEnabled: *vrfv2Config.VRFJobBatchFulfillmentEnabled,
BatchFulfillmentGasMultiplier: *vrfv2Config.VRFJobBatchFulfillmentGasMultiplier,
PollPeriod: vrfv2Config.VRFJobPollPeriod.Duration,
RequestTimeout: vrfv2Config.VRFJobRequestTimeout.Duration,
SimulationBlock: vrfv2Config.VRFJobSimulationBlock,
EstimateGasMultiplier: *config.VRFJobEstimateGasMultiplier,
BatchFulfillmentEnabled: *config.VRFJobBatchFulfillmentEnabled,
BatchFulfillmentGasMultiplier: *config.VRFJobBatchFulfillmentGasMultiplier,
PollPeriod: config.VRFJobPollPeriod.Duration,
RequestTimeout: config.VRFJobRequestTimeout.Duration,
SimulationBlock: config.VRFJobSimulationBlock,
VRFOwnerConfig: vrfOwnerConfig,
}

l.Info().Msg("Creating VRFV2 Job")
vrfV2job, err := CreateVRFV2Job(
job, err := CreateVRFV2Job(
vrfNode.CLNode.API,
vrfJobSpecConfig,
)
if err != nil {
return fmt.Errorf("%s, err %w", ErrCreateVRFV2Jobs, err)
}
vrfNode.Job = vrfV2job
vrfNode.Job = job

// this part is here because VRFv2 can work with only a specific key
// [[EVM.KeySpecific]]
// Key = '...'
nodeConfig := node.NewConfig(vrfNode.CLNode.NodeConfig,
node.WithKeySpecificMaxGasPrice(vrfNode.TXKeyAddressStrings, *vrfv2Config.CLNodeMaxGasPriceGWei),
node.WithKeySpecificMaxGasPrice(vrfNode.TXKeyAddressStrings, *config.CLNodeMaxGasPriceGWei),
)
l.Info().Msg("Restarting Node with new sending key PriceMax configuration")
l.Info().
Strs("Sending Keys", vrfNode.TXKeyAddressStrings).
Int64("Price Max Setting", *config.CLNodeMaxGasPriceGWei).
Msg("Restarting Node with new sending key PriceMax configuration")
err = vrfNode.CLNode.Restart(nodeConfig)
if err != nil {
return fmt.Errorf("%s, err %w", vrfcommon.ErrRestartCLNode, err)
return fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrRestartCLNode, err)
}
return nil
}
Expand Down
27 changes: 27 additions & 0 deletions integration-tests/actions/vrf/vrfv2plus/contract_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ func DeployVRFV2_5Contracts(
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrLoadingCoordinator, err)
}
} else if actions.IsArbitrumChain(chainClient.ChainID) {
arbitrumCoordinator, err := contracts.DeployVRFCoordinatorV2_5_Arbitrum(chainClient, bhs.Address())
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployCoordinatorV2Plus, err)
}
coordinator, err = contracts.LoadVRFCoordinatorV2_5(chainClient, arbitrumCoordinator.Address.String())
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrLoadingCoordinator, err)
}
} else if *configGeneral.UseTestCoordinator {
testCoordinator, err := contracts.DeployVRFCoordinatorTestV2_5(chainClient, bhs.Address())
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployCoordinatorV2Plus, err)
}
coordinator, err = contracts.LoadVRFCoordinatorV2_5(chainClient, testCoordinator.Address.String())
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrLoadingCoordinator, err)
}
} else {
coordinator, err = contracts.DeployVRFCoordinatorV2_5(chainClient, bhs.Address())
if err != nil {
Expand Down Expand Up @@ -426,6 +444,15 @@ func DeployVRFV2PlusDirectFundingContracts(
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrLoadingCoordinator, err)
}
} else if actions.IsArbitrumChain(sethClient.ChainID) {
arbitrumWrapper, err := contracts.DeployVRFV2PlusWrapperArbitrum(sethClient, linkTokenAddress, linkEthFeedAddress, coordinator.Address(), wrapperSubId)
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployCoordinatorV2Plus, err)
}
vrfv2PlusWrapper, err = contracts.LoadVRFV2PlusWrapper(sethClient, arbitrumWrapper.Address.String())
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrLoadingCoordinator, err)
}
} else {
vrfv2PlusWrapper, err = contracts.DeployVRFV2PlusWrapper(sethClient, linkTokenAddress, linkEthFeedAddress, coordinator.Address(), wrapperSubId)
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions integration-tests/actions/vrf/vrfv2plus/setup_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ func CreateVRFV2PlusJob(
if vrfJobSpecConfig.BatchFulfillmentEnabled {
jobSpec.BatchCoordinatorAddress = vrfJobSpecConfig.BatchCoordinatorAddress
}

job, err := chainlinkNode.MustCreateJob(&jobSpec)
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrCreatingVRFv2PlusJob, err)
}

return job, nil
}

Expand All @@ -87,7 +85,6 @@ func SetupVRFV2_5Environment(
) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode, error) {
l.Info().Msg("Starting VRFV2 Plus environment setup")
configGeneral := vrfv2PlusTestConfig.GetVRFv2PlusConfig().General

vrfContracts, err := SetupVRFV2PlusContracts(
sethClient,
linkToken,
Expand Down Expand Up @@ -361,7 +358,7 @@ func SetupVRFV2PlusWrapperForNewEnv(
vrfv2PlusConfig,
)
if err != nil {
return nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err)
return nil, nil, err
}
// once the wrapper is deployed, wrapper address will become consumer of external EOA subscription
err = vrfContracts.CoordinatorV2Plus.AddConsumer(wrapperSubId, wrapperContracts.VRFV2PlusWrapper.Address())
Expand Down
105 changes: 101 additions & 4 deletions integration-tests/contracts/ethereum_vrfv2plus_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ import (
"github.com/smartcontractkit/chainlink/integration-tests/wrappers"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_blockhash_store"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_vrf_coordinator_v2plus"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_test_v2_5"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5_arbitrum"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5_optimism"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_upgraded_version"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper_arbitrum"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper_load_test_consumer"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper_optimism"
)
Expand All @@ -37,6 +40,18 @@ type EthereumVRFCoordinatorV2_5_Optimism struct {
coordinator vrf_coordinator_v2_5_optimism.VRFCoordinatorV25Optimism
}

type EthereumVRFCoordinatorV2_5_Arbitrum struct {
Address common.Address
client *seth.Client
coordinator vrf_coordinator_v2_5_arbitrum.VRFCoordinatorV25Arbitrum
}

type EthereumVRFCoordinatorTestV2_5 struct {
Address common.Address
client *seth.Client
coordinator vrf_coordinator_test_v2_5.VRFCoordinatorTestV25
}

type EthereumBatchVRFCoordinatorV2Plus struct {
address common.Address
client *seth.Client
Expand Down Expand Up @@ -74,6 +89,12 @@ type EthereumVRFV2PlusWrapperOptimism struct {
wrapper *vrfv2plus_wrapper_optimism.VRFV2PlusWrapperOptimism
}

type EthereumVRFV2PlusWrapperArbitrum struct {
Address common.Address
client *seth.Client
wrapper *vrfv2plus_wrapper_arbitrum.VRFV2PlusWrapperArbitrum
}

func (v *EthereumVRFV2PlusWrapper) Address() string {
return v.address.Hex()
}
Expand Down Expand Up @@ -178,6 +199,56 @@ func DeployVRFCoordinatorV2_5_Optimism(seth *seth.Client, bhsAddr string) (*Ethe
}, err
}

func DeployVRFCoordinatorV2_5_Arbitrum(seth *seth.Client, bhsAddr string) (*EthereumVRFCoordinatorV2_5_Arbitrum, error) {
abi, err := vrf_coordinator_v2_5_arbitrum.VRFCoordinatorV25ArbitrumMetaData.GetAbi()
if err != nil {
return nil, fmt.Errorf("failed to get VRFCoordinatorV2_5_Arbitrum ABI: %w", err)
}
coordinatorDeploymentData, err := seth.DeployContract(
seth.NewTXOpts(),
"VRFCoordinatorV2_5_Arbitrum",
*abi,
common.FromHex(vrf_coordinator_v2_5_arbitrum.VRFCoordinatorV25ArbitrumMetaData.Bin),
common.HexToAddress(bhsAddr))
if err != nil {
return nil, fmt.Errorf("VRFCoordinatorV2_5_Arbitrum instance deployment have failed: %w", err)
}
contract, err := vrf_coordinator_v2_5_arbitrum.NewVRFCoordinatorV25Arbitrum(coordinatorDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth))
if err != nil {
return nil, fmt.Errorf("failed to instantiate VRFCoordinatorV2_5_Arbitrum instance: %w", err)
}
return &EthereumVRFCoordinatorV2_5_Arbitrum{
client: seth,
coordinator: *contract,
Address: coordinatorDeploymentData.Address,
}, err
}

func DeployVRFCoordinatorTestV2_5(seth *seth.Client, bhsAddr string) (*EthereumVRFCoordinatorTestV2_5, error) {
abi, err := vrf_coordinator_test_v2_5.VRFCoordinatorTestV25MetaData.GetAbi()
if err != nil {
return nil, fmt.Errorf("failed to get VRFCoordinatorTestV2_5 ABI: %w", err)
}
coordinatorDeploymentData, err := seth.DeployContract(
seth.NewTXOpts(),
"VRFCoordinatorTestV2_5",
*abi,
common.FromHex(vrf_coordinator_test_v2_5.VRFCoordinatorTestV25MetaData.Bin),
common.HexToAddress(bhsAddr))
if err != nil {
return nil, fmt.Errorf("VRFCoordinatorTestV2_5 instance deployment have failed: %w", err)
}
contract, err := vrf_coordinator_test_v2_5.NewVRFCoordinatorTestV25(coordinatorDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth))
if err != nil {
return nil, fmt.Errorf("failed to instantiate VRFCoordinatorTestV2_5 instance: %w", err)
}
return &EthereumVRFCoordinatorTestV2_5{
client: seth,
coordinator: *contract,
Address: coordinatorDeploymentData.Address,
}, err
}

func DeployBatchVRFCoordinatorV2Plus(seth *seth.Client, coordinatorAddress string) (BatchVRFCoordinatorV2Plus, error) {
abi, err := batch_vrf_coordinator_v2plus.BatchVRFCoordinatorV2PlusMetaData.GetAbi()
if err != nil {
Expand Down Expand Up @@ -1185,24 +1256,50 @@ func DeployVRFV2PlusWrapper(seth *seth.Client, linkAddr string, linkEthFeedAddr
}, err
}

func DeployVRFV2PlusWrapperArbitrum(seth *seth.Client, linkAddr string, linkEthFeedAddr string, coordinatorAddr string, subId *big.Int) (*EthereumVRFV2PlusWrapperArbitrum, error) {
abi, err := vrfv2plus_wrapper_arbitrum.VRFV2PlusWrapperArbitrumMetaData.GetAbi()
if err != nil {
return nil, fmt.Errorf("failed to get VRFV2PlusWrapper_Arbitrum ABI: %w", err)
}
data, err := seth.DeployContract(
seth.NewTXOpts(),
"VRFV2PlusWrapper_Arbitrum",
*abi,
common.FromHex(vrfv2plus_wrapper_arbitrum.VRFV2PlusWrapperArbitrumMetaData.Bin),
common.HexToAddress(linkAddr), common.HexToAddress(linkEthFeedAddr),
common.HexToAddress(coordinatorAddr), subId)
if err != nil {
return nil, fmt.Errorf("VRFV2PlusWrapper_Arbitrum instance deployment have failed: %w", err)
}
contract, err := vrfv2plus_wrapper_arbitrum.NewVRFV2PlusWrapperArbitrum(data.Address, wrappers.MustNewWrappedContractBackend(nil, seth))
if err != nil {
return nil, fmt.Errorf("failed to instantiate VRFV2PlusWrapper_Arbitrum instance: %w", err)
}
return &EthereumVRFV2PlusWrapperArbitrum{
client: seth,
wrapper: contract,
Address: data.Address,
}, err
}

func DeployVRFV2PlusWrapperOptimism(seth *seth.Client, linkAddr string, linkEthFeedAddr string, coordinatorAddr string, subId *big.Int) (*EthereumVRFV2PlusWrapperOptimism, error) {
abi, err := vrfv2plus_wrapper_optimism.VRFV2PlusWrapperOptimismMetaData.GetAbi()
if err != nil {
return nil, fmt.Errorf("failed to get VRFV2PlusWrapperOptimism ABI: %w", err)
return nil, fmt.Errorf("failed to get VRFV2PlusWrapper_Optimism ABI: %w", err)
}
data, err := seth.DeployContract(
seth.NewTXOpts(),
"VRFV2PlusWrapperOptimism",
"VRFV2PlusWrapper_Optimism",
*abi,
common.FromHex(vrfv2plus_wrapper_optimism.VRFV2PlusWrapperOptimismMetaData.Bin),
common.HexToAddress(linkAddr), common.HexToAddress(linkEthFeedAddr),
common.HexToAddress(coordinatorAddr), subId)
if err != nil {
return nil, fmt.Errorf("VRFV2PlusWrapperOptimism instance deployment have failed: %w", err)
return nil, fmt.Errorf("VRFV2PlusWrapper_Optimism instance deployment have failed: %w", err)
}
contract, err := vrfv2plus_wrapper_optimism.NewVRFV2PlusWrapperOptimism(data.Address, wrappers.MustNewWrappedContractBackend(nil, seth))
if err != nil {
return nil, fmt.Errorf("failed to instantiate VRFV2PlusWrapperOptimism instance: %w", err)
return nil, fmt.Errorf("failed to instantiate VRFV2PlusWrapper_Optimism instance: %w", err)
}
return &EthereumVRFV2PlusWrapperOptimism{
client: seth,
Expand Down
Loading

0 comments on commit 3257b8f

Please sign in to comment.