Skip to content

Commit

Permalink
VRF-1035: Add retrieval of VRF Wrapper Config in superscripts (#12977)
Browse files Browse the repository at this point in the history
  • Loading branch information
iljapavlovs committed May 5, 2024
1 parent a34a17a commit fe2e8fd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
13 changes: 10 additions & 3 deletions core/scripts/vrfv2/testnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (
"strings"
"sync"

"github.com/smartcontractkit/chainlink/core/scripts/vrfv2/testnet/v2scripts"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_owner_test_consumer"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/shopspring/decimal"

"github.com/smartcontractkit/chainlink/core/scripts/vrfv2/testnet/v2scripts"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_owner_test_consumer"

"github.com/jmoiron/sqlx"

helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
Expand Down Expand Up @@ -1294,6 +1294,13 @@ func main() {
*wrapperPremiumPercentage,
*keyHash,
*maxNumWords)
case "wrapper-get-config":
cmd := flag.NewFlagSet("wrapper-get-config", flag.ExitOnError)
wrapperAddress := cmd.String("wrapper-address", "", "wrapper address")
helpers.ParseArgs(cmd, os.Args[2:], "wrapper-address")
wrapper, err := vrfv2_wrapper.NewVRFV2Wrapper(common.HexToAddress(*wrapperAddress), e.Ec)
helpers.PanicErr(err)
v2scripts.PrintWrapperConfig(wrapper)
case "wrapper-get-fulfillment-tx-size":
cmd := flag.NewFlagSet("wrapper-get-fulfillment-tx-size", flag.ExitOnError)
wrapperAddress := cmd.String("wrapper-address", "", "address of the VRFV2Wrapper contract")
Expand Down
15 changes: 11 additions & 4 deletions core/scripts/vrfv2/testnet/v2scripts/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"fmt"
"math/big"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_test_v2"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_load_test_with_metrics"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_test_v2"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_load_test_with_metrics"

helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_blockhash_store"
Expand Down Expand Up @@ -208,6 +208,13 @@ func WrapperConfigure(
helpers.ConfirmTXMined(context.Background(), e.Ec, tx, e.ChainID)
}

func PrintWrapperConfig(wrapper *vrfv2_wrapper.VRFV2Wrapper) {
cfg, err := wrapper.GetConfig(nil)
helpers.PanicErr(err)
fmt.Printf("Wrapper config: %+v\n", cfg)
fmt.Printf("Wrapper Keyhash: %s\n", fmt.Sprintf("0x%x", cfg.KeyHash))
}

func WrapperConsumerDeploy(
e helpers.Environment,
link, wrapper common.Address,
Expand Down
11 changes: 9 additions & 2 deletions core/scripts/vrfv2plus/testnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (
"os"
"strings"

"github.com/ethereum/go-ethereum"

"github.com/smartcontractkit/chainlink/core/scripts/vrfv2plus/testnet/v2plusscripts"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/chain_specific_util_helper"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2plus_interface"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -1234,7 +1235,13 @@ func main() {
uint32(*stalenessSeconds),
uint32(*fulfillmentFlatFeeNativePPM),
uint32(*fulfillmentFlatFeeLinkDiscountPPM))

case "wrapper-get-config":
cmd := flag.NewFlagSet("wrapper-get-config", flag.ExitOnError)
wrapperAddress := cmd.String("wrapper-address", "", "wrapper address")
helpers.ParseArgs(cmd, os.Args[2:], "wrapper-address")
wrapper, err := vrfv2plus_wrapper.NewVRFV2PlusWrapper(common.HexToAddress(*wrapperAddress), e.Ec)
helpers.PanicErr(err)
v2plusscripts.PrintWrapperConfig(wrapper)
case "wrapper-get-fulfillment-tx-size":
cmd := flag.NewFlagSet("wrapper-get-fulfillment-tx-size", flag.ExitOnError)
wrapperAddress := cmd.String("wrapper-address", "", "address of the VRFV2Wrapper contract")
Expand Down
7 changes: 7 additions & 0 deletions core/scripts/vrfv2plus/testnet/v2plusscripts/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ func WrapperConfigure(
helpers.ConfirmTXMined(context.Background(), e.Ec, tx, e.ChainID)
}

func PrintWrapperConfig(wrapper *vrfv2plus_wrapper.VRFV2PlusWrapper) {
cfg, err := wrapper.GetConfig(nil)
helpers.PanicErr(err)
fmt.Printf("Wrapper config: %+v\n", cfg)
fmt.Printf("Wrapper Keyhash: %s\n", fmt.Sprintf("0x%x", cfg.KeyHash))
}

func WrapperConsumerDeploy(
e helpers.Environment,
link, wrapper common.Address,
Expand Down

0 comments on commit fe2e8fd

Please sign in to comment.