From 70d2482b0e9df6c0d08805cbc7f3019192cf41b5 Mon Sep 17 00:00:00 2001 From: lei shi Date: Mon, 17 Jun 2024 09:32:49 +0800 Subject: [PATCH] try adding test for v23 --- .../native_solc_compile_all_automation | 5 +- .../testhelpers/MockETHUSDAggregator.sol | 53 + .../mock_ethusd_aggregator_wrapper.go | 377 ++ .../generated/weth9_wrapper/weth9_wrapper.go | 1010 ++++++ ...rapper-dependency-versions-do-not-edit.txt | 3 + core/gethwrappers/go_generate.go | 2 + .../actions/automationv2/actions.go | 125 +- integration-tests/actions/keeper_helpers.go | 1 + .../contracts/contract_models.go | 18 + .../ethereum/KeeperRegistryVersions.go | 1 + .../contracts/ethereum_contracts.go | 3022 +++++++++++------ .../ethereum_contracts_automation.go | 325 +- .../contracts/ethereum_keeper_contracts.go | 2257 +++++++++++- integration-tests/go.mod | 18 +- integration-tests/go.sum | 30 +- integration-tests/smoke/automation_test.go | 1 + 16 files changed, 6178 insertions(+), 1070 deletions(-) create mode 100644 contracts/src/v0.8/automation/testhelpers/MockETHUSDAggregator.sol create mode 100644 core/gethwrappers/generated/mock_ethusd_aggregator_wrapper/mock_ethusd_aggregator_wrapper.go create mode 100644 core/gethwrappers/generated/weth9_wrapper/weth9_wrapper.go diff --git a/contracts/scripts/native_solc_compile_all_automation b/contracts/scripts/native_solc_compile_all_automation index 84656917d8f..dc75d18e4cb 100755 --- a/contracts/scripts/native_solc_compile_all_automation +++ b/contracts/scripts/native_solc_compile_all_automation @@ -12,7 +12,7 @@ OPTIMIZE_RUNS=1000000 SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; cd ../../ && pwd -P )" -python3 -m pip install --require-hashes -r "$SCRIPTPATH"/requirements.txt +python3 -m pip install --require-hashes --break-system-packages -r "$SCRIPTPATH"/requirements.txt solc-select install $SOLC_VERSION solc-select use $SOLC_VERSION @@ -106,3 +106,6 @@ compileContract automation/v2_3/AutomationRegistryLogicB2_3.sol compileContract automation/v2_3/AutomationRegistryLogicC2_3.sol compileContract automation/v2_3/AutomationUtils2_3.sol compileContract automation/interfaces/v2_3/IAutomationRegistryMaster2_3.sol + +compileContract automation/testhelpers/MockETHUSDAggregator.sol +compileContract automation/test/v2_3/WETH9.sol diff --git a/contracts/src/v0.8/automation/testhelpers/MockETHUSDAggregator.sol b/contracts/src/v0.8/automation/testhelpers/MockETHUSDAggregator.sol new file mode 100644 index 00000000000..10f6732c998 --- /dev/null +++ b/contracts/src/v0.8/automation/testhelpers/MockETHUSDAggregator.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.19; + +import "../../shared/interfaces/AggregatorV3Interface.sol"; + +contract MockETHUSDAggregator is AggregatorV3Interface { + int256 public answer; + uint256 private blockTimestampDeduction = 0; + + constructor(int256 _answer) { + answer = _answer; + } + + function decimals() external pure override returns (uint8) { + return 8; + } + + function description() external pure override returns (string memory) { + return "MockETHUSDAggregator"; + } + + function version() external pure override returns (uint256) { + return 1; + } + + function getRoundData( + uint80 /*_roundId*/ + ) + external + view + override + returns (uint80 roundId, int256 ans, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) + { + return (1, answer, getDeductedBlockTimestamp(), getDeductedBlockTimestamp(), 1); + } + + function latestRoundData() + external + view + override + returns (uint80 roundId, int256 ans, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) + { + return (1, answer, getDeductedBlockTimestamp(), getDeductedBlockTimestamp(), 1); + } + + function getDeductedBlockTimestamp() internal view returns (uint256) { + return block.timestamp - blockTimestampDeduction; + } + + function setBlockTimestampDeduction(uint256 _blockTimestampDeduction) external { + blockTimestampDeduction = _blockTimestampDeduction; + } +} diff --git a/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper/mock_ethusd_aggregator_wrapper.go b/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper/mock_ethusd_aggregator_wrapper.go new file mode 100644 index 00000000000..c10f916c5e7 --- /dev/null +++ b/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper/mock_ethusd_aggregator_wrapper.go @@ -0,0 +1,377 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package mock_ethusd_aggregator_wrapper + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "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/event" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +var MockETHUSDAggregatorMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"_answer\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"answer\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"description\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint80\",\"name\":\"\",\"type\":\"uint80\"}],\"name\":\"getRoundData\",\"outputs\":[{\"internalType\":\"uint80\",\"name\":\"roundId\",\"type\":\"uint80\"},{\"internalType\":\"int256\",\"name\":\"ans\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"startedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"updatedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint80\",\"name\":\"answeredInRound\",\"type\":\"uint80\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestRoundData\",\"outputs\":[{\"internalType\":\"uint80\",\"name\":\"roundId\",\"type\":\"uint80\"},{\"internalType\":\"int256\",\"name\":\"ans\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"startedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"updatedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint80\",\"name\":\"answeredInRound\",\"type\":\"uint80\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_blockTimestampDeduction\",\"type\":\"uint256\"}],\"name\":\"setBlockTimestampDeduction\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}]", + Bin: "0x6080604052600060015534801561001557600080fd5b506040516103333803806103338339810160408190526100349161003c565b600055610055565b60006020828403121561004e57600080fd5b5051919050565b6102cf806100646000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c806385bb7d691161005b57806385bb7d69146100e65780639a6fc8f5146100ef578063f0ad37df14610139578063feaf968c1461014e57600080fd5b8063313ce5671461008257806354fd4d50146100965780637284e416146100a7575b600080fd5b604051600881526020015b60405180910390f35b60015b60405190815260200161008d565b604080518082018252601481527f4d6f636b45544855534441676772656761746f720000000000000000000000006020820152905161008d91906101ca565b61009960005481565b6101026100fd366004610236565b610156565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a00161008d565b61014c610147366004610269565b600155565b005b610102610186565b6000806000806000600160005461016b6101b5565b6101736101b5565b9299919850965090945060019350915050565b6000806000806000600160005461019b6101b5565b6101a36101b5565b92989197509550909350600192509050565b6000600154426101c59190610282565b905090565b600060208083528351808285015260005b818110156101f7578581018301518582016040015282016101db565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60006020828403121561024857600080fd5b813569ffffffffffffffffffff8116811461026257600080fd5b9392505050565b60006020828403121561027b57600080fd5b5035919050565b818103818111156102bc577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b9291505056fea164736f6c6343000813000a", +} + +var MockETHUSDAggregatorABI = MockETHUSDAggregatorMetaData.ABI + +var MockETHUSDAggregatorBin = MockETHUSDAggregatorMetaData.Bin + +func DeployMockETHUSDAggregator(auth *bind.TransactOpts, backend bind.ContractBackend, _answer *big.Int) (common.Address, *types.Transaction, *MockETHUSDAggregator, error) { + parsed, err := MockETHUSDAggregatorMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(MockETHUSDAggregatorBin), backend, _answer) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &MockETHUSDAggregator{address: address, abi: *parsed, MockETHUSDAggregatorCaller: MockETHUSDAggregatorCaller{contract: contract}, MockETHUSDAggregatorTransactor: MockETHUSDAggregatorTransactor{contract: contract}, MockETHUSDAggregatorFilterer: MockETHUSDAggregatorFilterer{contract: contract}}, nil +} + +type MockETHUSDAggregator struct { + address common.Address + abi abi.ABI + MockETHUSDAggregatorCaller + MockETHUSDAggregatorTransactor + MockETHUSDAggregatorFilterer +} + +type MockETHUSDAggregatorCaller struct { + contract *bind.BoundContract +} + +type MockETHUSDAggregatorTransactor struct { + contract *bind.BoundContract +} + +type MockETHUSDAggregatorFilterer struct { + contract *bind.BoundContract +} + +type MockETHUSDAggregatorSession struct { + Contract *MockETHUSDAggregator + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type MockETHUSDAggregatorCallerSession struct { + Contract *MockETHUSDAggregatorCaller + CallOpts bind.CallOpts +} + +type MockETHUSDAggregatorTransactorSession struct { + Contract *MockETHUSDAggregatorTransactor + TransactOpts bind.TransactOpts +} + +type MockETHUSDAggregatorRaw struct { + Contract *MockETHUSDAggregator +} + +type MockETHUSDAggregatorCallerRaw struct { + Contract *MockETHUSDAggregatorCaller +} + +type MockETHUSDAggregatorTransactorRaw struct { + Contract *MockETHUSDAggregatorTransactor +} + +func NewMockETHUSDAggregator(address common.Address, backend bind.ContractBackend) (*MockETHUSDAggregator, error) { + abi, err := abi.JSON(strings.NewReader(MockETHUSDAggregatorABI)) + if err != nil { + return nil, err + } + contract, err := bindMockETHUSDAggregator(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &MockETHUSDAggregator{address: address, abi: abi, MockETHUSDAggregatorCaller: MockETHUSDAggregatorCaller{contract: contract}, MockETHUSDAggregatorTransactor: MockETHUSDAggregatorTransactor{contract: contract}, MockETHUSDAggregatorFilterer: MockETHUSDAggregatorFilterer{contract: contract}}, nil +} + +func NewMockETHUSDAggregatorCaller(address common.Address, caller bind.ContractCaller) (*MockETHUSDAggregatorCaller, error) { + contract, err := bindMockETHUSDAggregator(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &MockETHUSDAggregatorCaller{contract: contract}, nil +} + +func NewMockETHUSDAggregatorTransactor(address common.Address, transactor bind.ContractTransactor) (*MockETHUSDAggregatorTransactor, error) { + contract, err := bindMockETHUSDAggregator(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &MockETHUSDAggregatorTransactor{contract: contract}, nil +} + +func NewMockETHUSDAggregatorFilterer(address common.Address, filterer bind.ContractFilterer) (*MockETHUSDAggregatorFilterer, error) { + contract, err := bindMockETHUSDAggregator(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &MockETHUSDAggregatorFilterer{contract: contract}, nil +} + +func bindMockETHUSDAggregator(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := MockETHUSDAggregatorMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MockETHUSDAggregator.Contract.MockETHUSDAggregatorCaller.contract.Call(opts, result, method, params...) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MockETHUSDAggregator.Contract.MockETHUSDAggregatorTransactor.contract.Transfer(opts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MockETHUSDAggregator.Contract.MockETHUSDAggregatorTransactor.contract.Transact(opts, method, params...) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MockETHUSDAggregator.Contract.contract.Call(opts, result, method, params...) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MockETHUSDAggregator.Contract.contract.Transfer(opts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MockETHUSDAggregator.Contract.contract.Transact(opts, method, params...) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCaller) Answer(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _MockETHUSDAggregator.contract.Call(opts, &out, "answer") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorSession) Answer() (*big.Int, error) { + return _MockETHUSDAggregator.Contract.Answer(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCallerSession) Answer() (*big.Int, error) { + return _MockETHUSDAggregator.Contract.Answer(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCaller) Decimals(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _MockETHUSDAggregator.contract.Call(opts, &out, "decimals") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorSession) Decimals() (uint8, error) { + return _MockETHUSDAggregator.Contract.Decimals(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCallerSession) Decimals() (uint8, error) { + return _MockETHUSDAggregator.Contract.Decimals(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCaller) Description(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _MockETHUSDAggregator.contract.Call(opts, &out, "description") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorSession) Description() (string, error) { + return _MockETHUSDAggregator.Contract.Description(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCallerSession) Description() (string, error) { + return _MockETHUSDAggregator.Contract.Description(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCaller) GetRoundData(opts *bind.CallOpts, arg0 *big.Int) (GetRoundData, + + error) { + var out []interface{} + err := _MockETHUSDAggregator.contract.Call(opts, &out, "getRoundData", arg0) + + outstruct := new(GetRoundData) + if err != nil { + return *outstruct, err + } + + outstruct.RoundId = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.Ans = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.StartedAt = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.UpdatedAt = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) + outstruct.AnsweredInRound = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorSession) GetRoundData(arg0 *big.Int) (GetRoundData, + + error) { + return _MockETHUSDAggregator.Contract.GetRoundData(&_MockETHUSDAggregator.CallOpts, arg0) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCallerSession) GetRoundData(arg0 *big.Int) (GetRoundData, + + error) { + return _MockETHUSDAggregator.Contract.GetRoundData(&_MockETHUSDAggregator.CallOpts, arg0) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCaller) LatestRoundData(opts *bind.CallOpts) (LatestRoundData, + + error) { + var out []interface{} + err := _MockETHUSDAggregator.contract.Call(opts, &out, "latestRoundData") + + outstruct := new(LatestRoundData) + if err != nil { + return *outstruct, err + } + + outstruct.RoundId = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.Ans = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.StartedAt = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.UpdatedAt = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) + outstruct.AnsweredInRound = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorSession) LatestRoundData() (LatestRoundData, + + error) { + return _MockETHUSDAggregator.Contract.LatestRoundData(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCallerSession) LatestRoundData() (LatestRoundData, + + error) { + return _MockETHUSDAggregator.Contract.LatestRoundData(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCaller) Version(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _MockETHUSDAggregator.contract.Call(opts, &out, "version") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorSession) Version() (*big.Int, error) { + return _MockETHUSDAggregator.Contract.Version(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorCallerSession) Version() (*big.Int, error) { + return _MockETHUSDAggregator.Contract.Version(&_MockETHUSDAggregator.CallOpts) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorTransactor) SetBlockTimestampDeduction(opts *bind.TransactOpts, _blockTimestampDeduction *big.Int) (*types.Transaction, error) { + return _MockETHUSDAggregator.contract.Transact(opts, "setBlockTimestampDeduction", _blockTimestampDeduction) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorSession) SetBlockTimestampDeduction(_blockTimestampDeduction *big.Int) (*types.Transaction, error) { + return _MockETHUSDAggregator.Contract.SetBlockTimestampDeduction(&_MockETHUSDAggregator.TransactOpts, _blockTimestampDeduction) +} + +func (_MockETHUSDAggregator *MockETHUSDAggregatorTransactorSession) SetBlockTimestampDeduction(_blockTimestampDeduction *big.Int) (*types.Transaction, error) { + return _MockETHUSDAggregator.Contract.SetBlockTimestampDeduction(&_MockETHUSDAggregator.TransactOpts, _blockTimestampDeduction) +} + +type GetRoundData struct { + RoundId *big.Int + Ans *big.Int + StartedAt *big.Int + UpdatedAt *big.Int + AnsweredInRound *big.Int +} +type LatestRoundData struct { + RoundId *big.Int + Ans *big.Int + StartedAt *big.Int + UpdatedAt *big.Int + AnsweredInRound *big.Int +} + +func (_MockETHUSDAggregator *MockETHUSDAggregator) Address() common.Address { + return _MockETHUSDAggregator.address +} + +type MockETHUSDAggregatorInterface interface { + Answer(opts *bind.CallOpts) (*big.Int, error) + + Decimals(opts *bind.CallOpts) (uint8, error) + + Description(opts *bind.CallOpts) (string, error) + + GetRoundData(opts *bind.CallOpts, arg0 *big.Int) (GetRoundData, + + error) + + LatestRoundData(opts *bind.CallOpts) (LatestRoundData, + + error) + + Version(opts *bind.CallOpts) (*big.Int, error) + + SetBlockTimestampDeduction(opts *bind.TransactOpts, _blockTimestampDeduction *big.Int) (*types.Transaction, error) + + Address() common.Address +} diff --git a/core/gethwrappers/generated/weth9_wrapper/weth9_wrapper.go b/core/gethwrappers/generated/weth9_wrapper/weth9_wrapper.go new file mode 100644 index 00000000000..f38435143b9 --- /dev/null +++ b/core/gethwrappers/generated/weth9_wrapper/weth9_wrapper.go @@ -0,0 +1,1010 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package weth9_wrapper + +import ( + "errors" + "fmt" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "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/event" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +var WETH9MetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"InsufficientBalance\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"src\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guy\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"dst\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"src\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"dst\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"src\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Withdrawal\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"guy\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"dst\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"src\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"dst\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x60c0604052600d60809081526c2bb930b83832b21022ba3432b960991b60a05260009061002c9082610114565b506040805180820190915260048152630ae8aa8960e31b60208201526001906100559082610114565b506002805460ff1916601217905534801561006f57600080fd5b506101d3565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061009f57607f821691505b6020821081036100bf57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561010f57600081815260208120601f850160051c810160208610156100ec5750805b601f850160051c820191505b8181101561010b578281556001016100f8565b5050505b505050565b81516001600160401b0381111561012d5761012d610075565b6101418161013b845461008b565b846100c5565b602080601f831160018114610176576000841561015e5750858301515b600019600386901b1c1916600185901b17855561010b565b600085815260208120601f198616915b828110156101a557888601518255948401946001909101908401610186565b50858210156101c35787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61099c80620001e36000396000f3fe6080604052600436106100cb5760003560e01c806340c10f1911610074578063a9059cbb1161004e578063a9059cbb14610225578063d0e30db014610245578063dd62ed3e1461024d57600080fd5b806340c10f19146101c357806370a08231146101e357806395d89b411461021057600080fd5b806323b872dd116100a557806323b872dd146101575780632e1a7d4d14610177578063313ce5671461019757600080fd5b806306fdde03146100df578063095ea7b31461010a57806318160ddd1461013a57600080fd5b366100da576100d8610285565b005b600080fd5b3480156100eb57600080fd5b506100f46102e0565b6040516101019190610785565b60405180910390f35b34801561011657600080fd5b5061012a61012536600461081a565b61036e565b6040519015158152602001610101565b34801561014657600080fd5b50475b604051908152602001610101565b34801561016357600080fd5b5061012a610172366004610844565b6103e8565b34801561018357600080fd5b506100d8610192366004610880565b610649565b3480156101a357600080fd5b506002546101b19060ff1681565b60405160ff9091168152602001610101565b3480156101cf57600080fd5b506100d86101de36600461081a565b61071c565b3480156101ef57600080fd5b506101496101fe366004610899565b60036020526000908152604090205481565b34801561021c57600080fd5b506100f461075a565b34801561023157600080fd5b5061012a61024036600461081a565b610767565b6100d861077b565b34801561025957600080fd5b506101496102683660046108b4565b600460209081526000928352604080842090915290825290205481565b33600090815260036020526040812080543492906102a4908490610916565b909155505060405134815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200160405180910390a2565b600080546102ed90610929565b80601f016020809104026020016040519081016040528092919081815260200182805461031990610929565b80156103665780601f1061033b57610100808354040283529160200191610366565b820191906000526020600020905b81548152906001019060200180831161034957829003601f168201915b505050505081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906103d69086815260200190565b60405180910390a35060015b92915050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260036020526040812054821115610447576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff841633148015906104ad575073ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020546fffffffffffffffffffffffffffffffff14155b156105625773ffffffffffffffffffffffffffffffffffffffff8416600090815260046020908152604080832033845290915290205482111561051c576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091528120805484929061055c90849061097c565b90915550505b73ffffffffffffffffffffffffffffffffffffffff84166000908152600360205260408120805484929061059790849061097c565b909155505073ffffffffffffffffffffffffffffffffffffffff8316600090815260036020526040812080548492906105d1908490610916565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161063791815260200190565b60405180910390a35060019392505050565b33600090815260036020526040902054811115610692576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260036020526040812080548392906106b190849061097c565b9091555050604051339082156108fc029083906000818181858888f193505050501580156106e3573d6000803e3d6000fd5b5060405181815233907f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b659060200160405180910390a250565b73ffffffffffffffffffffffffffffffffffffffff821660009081526003602052604081208054839290610751908490610916565b90915550505050565b600180546102ed90610929565b60006107743384846103e8565b9392505050565b610783610285565b565b600060208083528351808285015260005b818110156107b257858101830151858201604001528201610796565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461081557600080fd5b919050565b6000806040838503121561082d57600080fd5b610836836107f1565b946020939093013593505050565b60008060006060848603121561085957600080fd5b610862846107f1565b9250610870602085016107f1565b9150604084013590509250925092565b60006020828403121561089257600080fd5b5035919050565b6000602082840312156108ab57600080fd5b610774826107f1565b600080604083850312156108c757600080fd5b6108d0836107f1565b91506108de602084016107f1565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156103e2576103e26108e7565b600181811c9082168061093d57607f821691505b602082108103610976577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b818103818111156103e2576103e26108e756fea164736f6c6343000813000a", +} + +var WETH9ABI = WETH9MetaData.ABI + +var WETH9Bin = WETH9MetaData.Bin + +func DeployWETH9(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *WETH9, error) { + parsed, err := WETH9MetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(WETH9Bin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &WETH9{address: address, abi: *parsed, WETH9Caller: WETH9Caller{contract: contract}, WETH9Transactor: WETH9Transactor{contract: contract}, WETH9Filterer: WETH9Filterer{contract: contract}}, nil +} + +type WETH9 struct { + address common.Address + abi abi.ABI + WETH9Caller + WETH9Transactor + WETH9Filterer +} + +type WETH9Caller struct { + contract *bind.BoundContract +} + +type WETH9Transactor struct { + contract *bind.BoundContract +} + +type WETH9Filterer struct { + contract *bind.BoundContract +} + +type WETH9Session struct { + Contract *WETH9 + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type WETH9CallerSession struct { + Contract *WETH9Caller + CallOpts bind.CallOpts +} + +type WETH9TransactorSession struct { + Contract *WETH9Transactor + TransactOpts bind.TransactOpts +} + +type WETH9Raw struct { + Contract *WETH9 +} + +type WETH9CallerRaw struct { + Contract *WETH9Caller +} + +type WETH9TransactorRaw struct { + Contract *WETH9Transactor +} + +func NewWETH9(address common.Address, backend bind.ContractBackend) (*WETH9, error) { + abi, err := abi.JSON(strings.NewReader(WETH9ABI)) + if err != nil { + return nil, err + } + contract, err := bindWETH9(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &WETH9{address: address, abi: abi, WETH9Caller: WETH9Caller{contract: contract}, WETH9Transactor: WETH9Transactor{contract: contract}, WETH9Filterer: WETH9Filterer{contract: contract}}, nil +} + +func NewWETH9Caller(address common.Address, caller bind.ContractCaller) (*WETH9Caller, error) { + contract, err := bindWETH9(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &WETH9Caller{contract: contract}, nil +} + +func NewWETH9Transactor(address common.Address, transactor bind.ContractTransactor) (*WETH9Transactor, error) { + contract, err := bindWETH9(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &WETH9Transactor{contract: contract}, nil +} + +func NewWETH9Filterer(address common.Address, filterer bind.ContractFilterer) (*WETH9Filterer, error) { + contract, err := bindWETH9(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &WETH9Filterer{contract: contract}, nil +} + +func bindWETH9(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := WETH9MetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_WETH9 *WETH9Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _WETH9.Contract.WETH9Caller.contract.Call(opts, result, method, params...) +} + +func (_WETH9 *WETH9Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WETH9.Contract.WETH9Transactor.contract.Transfer(opts) +} + +func (_WETH9 *WETH9Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _WETH9.Contract.WETH9Transactor.contract.Transact(opts, method, params...) +} + +func (_WETH9 *WETH9CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _WETH9.Contract.contract.Call(opts, result, method, params...) +} + +func (_WETH9 *WETH9TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WETH9.Contract.contract.Transfer(opts) +} + +func (_WETH9 *WETH9TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _WETH9.Contract.contract.Transact(opts, method, params...) +} + +func (_WETH9 *WETH9Caller) Allowance(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) { + var out []interface{} + err := _WETH9.contract.Call(opts, &out, "allowance", arg0, arg1) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_WETH9 *WETH9Session) Allowance(arg0 common.Address, arg1 common.Address) (*big.Int, error) { + return _WETH9.Contract.Allowance(&_WETH9.CallOpts, arg0, arg1) +} + +func (_WETH9 *WETH9CallerSession) Allowance(arg0 common.Address, arg1 common.Address) (*big.Int, error) { + return _WETH9.Contract.Allowance(&_WETH9.CallOpts, arg0, arg1) +} + +func (_WETH9 *WETH9Caller) BalanceOf(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { + var out []interface{} + err := _WETH9.contract.Call(opts, &out, "balanceOf", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_WETH9 *WETH9Session) BalanceOf(arg0 common.Address) (*big.Int, error) { + return _WETH9.Contract.BalanceOf(&_WETH9.CallOpts, arg0) +} + +func (_WETH9 *WETH9CallerSession) BalanceOf(arg0 common.Address) (*big.Int, error) { + return _WETH9.Contract.BalanceOf(&_WETH9.CallOpts, arg0) +} + +func (_WETH9 *WETH9Caller) Decimals(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _WETH9.contract.Call(opts, &out, "decimals") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +func (_WETH9 *WETH9Session) Decimals() (uint8, error) { + return _WETH9.Contract.Decimals(&_WETH9.CallOpts) +} + +func (_WETH9 *WETH9CallerSession) Decimals() (uint8, error) { + return _WETH9.Contract.Decimals(&_WETH9.CallOpts) +} + +func (_WETH9 *WETH9Caller) Name(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _WETH9.contract.Call(opts, &out, "name") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +func (_WETH9 *WETH9Session) Name() (string, error) { + return _WETH9.Contract.Name(&_WETH9.CallOpts) +} + +func (_WETH9 *WETH9CallerSession) Name() (string, error) { + return _WETH9.Contract.Name(&_WETH9.CallOpts) +} + +func (_WETH9 *WETH9Caller) Symbol(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _WETH9.contract.Call(opts, &out, "symbol") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +func (_WETH9 *WETH9Session) Symbol() (string, error) { + return _WETH9.Contract.Symbol(&_WETH9.CallOpts) +} + +func (_WETH9 *WETH9CallerSession) Symbol() (string, error) { + return _WETH9.Contract.Symbol(&_WETH9.CallOpts) +} + +func (_WETH9 *WETH9Caller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _WETH9.contract.Call(opts, &out, "totalSupply") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_WETH9 *WETH9Session) TotalSupply() (*big.Int, error) { + return _WETH9.Contract.TotalSupply(&_WETH9.CallOpts) +} + +func (_WETH9 *WETH9CallerSession) TotalSupply() (*big.Int, error) { + return _WETH9.Contract.TotalSupply(&_WETH9.CallOpts) +} + +func (_WETH9 *WETH9Transactor) Approve(opts *bind.TransactOpts, guy common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.contract.Transact(opts, "approve", guy, wad) +} + +func (_WETH9 *WETH9Session) Approve(guy common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.Approve(&_WETH9.TransactOpts, guy, wad) +} + +func (_WETH9 *WETH9TransactorSession) Approve(guy common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.Approve(&_WETH9.TransactOpts, guy, wad) +} + +func (_WETH9 *WETH9Transactor) Deposit(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WETH9.contract.Transact(opts, "deposit") +} + +func (_WETH9 *WETH9Session) Deposit() (*types.Transaction, error) { + return _WETH9.Contract.Deposit(&_WETH9.TransactOpts) +} + +func (_WETH9 *WETH9TransactorSession) Deposit() (*types.Transaction, error) { + return _WETH9.Contract.Deposit(&_WETH9.TransactOpts) +} + +func (_WETH9 *WETH9Transactor) Mint(opts *bind.TransactOpts, account common.Address, amount *big.Int) (*types.Transaction, error) { + return _WETH9.contract.Transact(opts, "mint", account, amount) +} + +func (_WETH9 *WETH9Session) Mint(account common.Address, amount *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.Mint(&_WETH9.TransactOpts, account, amount) +} + +func (_WETH9 *WETH9TransactorSession) Mint(account common.Address, amount *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.Mint(&_WETH9.TransactOpts, account, amount) +} + +func (_WETH9 *WETH9Transactor) Transfer(opts *bind.TransactOpts, dst common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.contract.Transact(opts, "transfer", dst, wad) +} + +func (_WETH9 *WETH9Session) Transfer(dst common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.Transfer(&_WETH9.TransactOpts, dst, wad) +} + +func (_WETH9 *WETH9TransactorSession) Transfer(dst common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.Transfer(&_WETH9.TransactOpts, dst, wad) +} + +func (_WETH9 *WETH9Transactor) TransferFrom(opts *bind.TransactOpts, src common.Address, dst common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.contract.Transact(opts, "transferFrom", src, dst, wad) +} + +func (_WETH9 *WETH9Session) TransferFrom(src common.Address, dst common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.TransferFrom(&_WETH9.TransactOpts, src, dst, wad) +} + +func (_WETH9 *WETH9TransactorSession) TransferFrom(src common.Address, dst common.Address, wad *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.TransferFrom(&_WETH9.TransactOpts, src, dst, wad) +} + +func (_WETH9 *WETH9Transactor) Withdraw(opts *bind.TransactOpts, wad *big.Int) (*types.Transaction, error) { + return _WETH9.contract.Transact(opts, "withdraw", wad) +} + +func (_WETH9 *WETH9Session) Withdraw(wad *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.Withdraw(&_WETH9.TransactOpts, wad) +} + +func (_WETH9 *WETH9TransactorSession) Withdraw(wad *big.Int) (*types.Transaction, error) { + return _WETH9.Contract.Withdraw(&_WETH9.TransactOpts, wad) +} + +func (_WETH9 *WETH9Transactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WETH9.contract.RawTransact(opts, nil) +} + +func (_WETH9 *WETH9Session) Receive() (*types.Transaction, error) { + return _WETH9.Contract.Receive(&_WETH9.TransactOpts) +} + +func (_WETH9 *WETH9TransactorSession) Receive() (*types.Transaction, error) { + return _WETH9.Contract.Receive(&_WETH9.TransactOpts) +} + +type WETH9ApprovalIterator struct { + Event *WETH9Approval + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WETH9ApprovalIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WETH9Approval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WETH9Approval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WETH9ApprovalIterator) Error() error { + return it.fail +} + +func (it *WETH9ApprovalIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WETH9Approval struct { + Src common.Address + Guy common.Address + Wad *big.Int + Raw types.Log +} + +func (_WETH9 *WETH9Filterer) FilterApproval(opts *bind.FilterOpts, src []common.Address, guy []common.Address) (*WETH9ApprovalIterator, error) { + + var srcRule []interface{} + for _, srcItem := range src { + srcRule = append(srcRule, srcItem) + } + var guyRule []interface{} + for _, guyItem := range guy { + guyRule = append(guyRule, guyItem) + } + + logs, sub, err := _WETH9.contract.FilterLogs(opts, "Approval", srcRule, guyRule) + if err != nil { + return nil, err + } + return &WETH9ApprovalIterator{contract: _WETH9.contract, event: "Approval", logs: logs, sub: sub}, nil +} + +func (_WETH9 *WETH9Filterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *WETH9Approval, src []common.Address, guy []common.Address) (event.Subscription, error) { + + var srcRule []interface{} + for _, srcItem := range src { + srcRule = append(srcRule, srcItem) + } + var guyRule []interface{} + for _, guyItem := range guy { + guyRule = append(guyRule, guyItem) + } + + logs, sub, err := _WETH9.contract.WatchLogs(opts, "Approval", srcRule, guyRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WETH9Approval) + if err := _WETH9.contract.UnpackLog(event, "Approval", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WETH9 *WETH9Filterer) ParseApproval(log types.Log) (*WETH9Approval, error) { + event := new(WETH9Approval) + if err := _WETH9.contract.UnpackLog(event, "Approval", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WETH9DepositIterator struct { + Event *WETH9Deposit + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WETH9DepositIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WETH9Deposit) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WETH9Deposit) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WETH9DepositIterator) Error() error { + return it.fail +} + +func (it *WETH9DepositIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WETH9Deposit struct { + Dst common.Address + Wad *big.Int + Raw types.Log +} + +func (_WETH9 *WETH9Filterer) FilterDeposit(opts *bind.FilterOpts, dst []common.Address) (*WETH9DepositIterator, error) { + + var dstRule []interface{} + for _, dstItem := range dst { + dstRule = append(dstRule, dstItem) + } + + logs, sub, err := _WETH9.contract.FilterLogs(opts, "Deposit", dstRule) + if err != nil { + return nil, err + } + return &WETH9DepositIterator{contract: _WETH9.contract, event: "Deposit", logs: logs, sub: sub}, nil +} + +func (_WETH9 *WETH9Filterer) WatchDeposit(opts *bind.WatchOpts, sink chan<- *WETH9Deposit, dst []common.Address) (event.Subscription, error) { + + var dstRule []interface{} + for _, dstItem := range dst { + dstRule = append(dstRule, dstItem) + } + + logs, sub, err := _WETH9.contract.WatchLogs(opts, "Deposit", dstRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WETH9Deposit) + if err := _WETH9.contract.UnpackLog(event, "Deposit", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WETH9 *WETH9Filterer) ParseDeposit(log types.Log) (*WETH9Deposit, error) { + event := new(WETH9Deposit) + if err := _WETH9.contract.UnpackLog(event, "Deposit", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WETH9TransferIterator struct { + Event *WETH9Transfer + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WETH9TransferIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WETH9Transfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WETH9Transfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WETH9TransferIterator) Error() error { + return it.fail +} + +func (it *WETH9TransferIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WETH9Transfer struct { + Src common.Address + Dst common.Address + Wad *big.Int + Raw types.Log +} + +func (_WETH9 *WETH9Filterer) FilterTransfer(opts *bind.FilterOpts, src []common.Address, dst []common.Address) (*WETH9TransferIterator, error) { + + var srcRule []interface{} + for _, srcItem := range src { + srcRule = append(srcRule, srcItem) + } + var dstRule []interface{} + for _, dstItem := range dst { + dstRule = append(dstRule, dstItem) + } + + logs, sub, err := _WETH9.contract.FilterLogs(opts, "Transfer", srcRule, dstRule) + if err != nil { + return nil, err + } + return &WETH9TransferIterator{contract: _WETH9.contract, event: "Transfer", logs: logs, sub: sub}, nil +} + +func (_WETH9 *WETH9Filterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *WETH9Transfer, src []common.Address, dst []common.Address) (event.Subscription, error) { + + var srcRule []interface{} + for _, srcItem := range src { + srcRule = append(srcRule, srcItem) + } + var dstRule []interface{} + for _, dstItem := range dst { + dstRule = append(dstRule, dstItem) + } + + logs, sub, err := _WETH9.contract.WatchLogs(opts, "Transfer", srcRule, dstRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WETH9Transfer) + if err := _WETH9.contract.UnpackLog(event, "Transfer", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WETH9 *WETH9Filterer) ParseTransfer(log types.Log) (*WETH9Transfer, error) { + event := new(WETH9Transfer) + if err := _WETH9.contract.UnpackLog(event, "Transfer", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WETH9WithdrawalIterator struct { + Event *WETH9Withdrawal + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WETH9WithdrawalIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WETH9Withdrawal) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WETH9Withdrawal) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WETH9WithdrawalIterator) Error() error { + return it.fail +} + +func (it *WETH9WithdrawalIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WETH9Withdrawal struct { + Src common.Address + Wad *big.Int + Raw types.Log +} + +func (_WETH9 *WETH9Filterer) FilterWithdrawal(opts *bind.FilterOpts, src []common.Address) (*WETH9WithdrawalIterator, error) { + + var srcRule []interface{} + for _, srcItem := range src { + srcRule = append(srcRule, srcItem) + } + + logs, sub, err := _WETH9.contract.FilterLogs(opts, "Withdrawal", srcRule) + if err != nil { + return nil, err + } + return &WETH9WithdrawalIterator{contract: _WETH9.contract, event: "Withdrawal", logs: logs, sub: sub}, nil +} + +func (_WETH9 *WETH9Filterer) WatchWithdrawal(opts *bind.WatchOpts, sink chan<- *WETH9Withdrawal, src []common.Address) (event.Subscription, error) { + + var srcRule []interface{} + for _, srcItem := range src { + srcRule = append(srcRule, srcItem) + } + + logs, sub, err := _WETH9.contract.WatchLogs(opts, "Withdrawal", srcRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WETH9Withdrawal) + if err := _WETH9.contract.UnpackLog(event, "Withdrawal", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WETH9 *WETH9Filterer) ParseWithdrawal(log types.Log) (*WETH9Withdrawal, error) { + event := new(WETH9Withdrawal) + if err := _WETH9.contract.UnpackLog(event, "Withdrawal", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +func (_WETH9 *WETH9) ParseLog(log types.Log) (generated.AbigenLog, error) { + switch log.Topics[0] { + case _WETH9.abi.Events["Approval"].ID: + return _WETH9.ParseApproval(log) + case _WETH9.abi.Events["Deposit"].ID: + return _WETH9.ParseDeposit(log) + case _WETH9.abi.Events["Transfer"].ID: + return _WETH9.ParseTransfer(log) + case _WETH9.abi.Events["Withdrawal"].ID: + return _WETH9.ParseWithdrawal(log) + + default: + return nil, fmt.Errorf("abigen wrapper received unknown log topic: %v", log.Topics[0]) + } +} + +func (WETH9Approval) Topic() common.Hash { + return common.HexToHash("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925") +} + +func (WETH9Deposit) Topic() common.Hash { + return common.HexToHash("0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c") +} + +func (WETH9Transfer) Topic() common.Hash { + return common.HexToHash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") +} + +func (WETH9Withdrawal) Topic() common.Hash { + return common.HexToHash("0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65") +} + +func (_WETH9 *WETH9) Address() common.Address { + return _WETH9.address +} + +type WETH9Interface interface { + Allowance(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) + + BalanceOf(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) + + Decimals(opts *bind.CallOpts) (uint8, error) + + Name(opts *bind.CallOpts) (string, error) + + Symbol(opts *bind.CallOpts) (string, error) + + TotalSupply(opts *bind.CallOpts) (*big.Int, error) + + Approve(opts *bind.TransactOpts, guy common.Address, wad *big.Int) (*types.Transaction, error) + + Deposit(opts *bind.TransactOpts) (*types.Transaction, error) + + Mint(opts *bind.TransactOpts, account common.Address, amount *big.Int) (*types.Transaction, error) + + Transfer(opts *bind.TransactOpts, dst common.Address, wad *big.Int) (*types.Transaction, error) + + TransferFrom(opts *bind.TransactOpts, src common.Address, dst common.Address, wad *big.Int) (*types.Transaction, error) + + Withdraw(opts *bind.TransactOpts, wad *big.Int) (*types.Transaction, error) + + Receive(opts *bind.TransactOpts) (*types.Transaction, error) + + FilterApproval(opts *bind.FilterOpts, src []common.Address, guy []common.Address) (*WETH9ApprovalIterator, error) + + WatchApproval(opts *bind.WatchOpts, sink chan<- *WETH9Approval, src []common.Address, guy []common.Address) (event.Subscription, error) + + ParseApproval(log types.Log) (*WETH9Approval, error) + + FilterDeposit(opts *bind.FilterOpts, dst []common.Address) (*WETH9DepositIterator, error) + + WatchDeposit(opts *bind.WatchOpts, sink chan<- *WETH9Deposit, dst []common.Address) (event.Subscription, error) + + ParseDeposit(log types.Log) (*WETH9Deposit, error) + + FilterTransfer(opts *bind.FilterOpts, src []common.Address, dst []common.Address) (*WETH9TransferIterator, error) + + WatchTransfer(opts *bind.WatchOpts, sink chan<- *WETH9Transfer, src []common.Address, dst []common.Address) (event.Subscription, error) + + ParseTransfer(log types.Log) (*WETH9Transfer, error) + + FilterWithdrawal(opts *bind.FilterOpts, src []common.Address) (*WETH9WithdrawalIterator, error) + + WatchWithdrawal(opts *bind.WatchOpts, sink chan<- *WETH9Withdrawal, src []common.Address) (event.Subscription, error) + + ParseWithdrawal(log types.Log) (*WETH9Withdrawal, error) + + ParseLog(log types.Log) (generated.AbigenLog, error) + + Address() common.Address +} diff --git a/core/gethwrappers/generation/generated-wrapper-dependency-versions-do-not-edit.txt b/core/gethwrappers/generation/generated-wrapper-dependency-versions-do-not-edit.txt index e46f86ba591..dfe0449bac5 100644 --- a/core/gethwrappers/generation/generated-wrapper-dependency-versions-do-not-edit.txt +++ b/core/gethwrappers/generation/generated-wrapper-dependency-versions-do-not-edit.txt @@ -7,6 +7,7 @@ authorized_receiver: ../../contracts/solc/v0.8.19/AuthorizedReceiver/AuthorizedR automation_compatible_utils: ../../contracts/solc/v0.8.19/AutomationCompatibleUtils/AutomationCompatibleUtils.abi ../../contracts/solc/v0.8.19/AutomationCompatibleUtils/AutomationCompatibleUtils.bin dfe88f4f40d124b8cb5f36a7e9f9328008ca57f7ec5d07a28d949d569d5f2834 automation_consumer_benchmark: ../../contracts/solc/v0.8.16/AutomationConsumerBenchmark/AutomationConsumerBenchmark.abi ../../contracts/solc/v0.8.16/AutomationConsumerBenchmark/AutomationConsumerBenchmark.bin f52c76f1aaed4be541d82d97189d70f5aa027fc9838037dd7a7d21910c8c488e automation_forwarder_logic: ../../contracts/solc/v0.8.16/AutomationForwarderLogic/AutomationForwarderLogic.abi ../../contracts/solc/v0.8.16/AutomationForwarderLogic/AutomationForwarderLogic.bin 15ae0c367297955fdab4b552dbb10e1f2be80a8fde0efec4a4d398693e9d72b5 +automation_mock_ethusd_aggregator: ../../contracts/solc/v0.8.19/AutomationMockETHUSDAggregator/AutomationMockETHUSDAggregator.abi ../../contracts/solc/v0.8.19/AutomationMockETHUSDAggregator/AutomationMockETHUSDAggregator.bin 76322d6157c16580412ac820468509fcffc0352cba10e017b37b0453d531af36 automation_registrar_wrapper2_1: ../../contracts/solc/v0.8.16/AutomationRegistrar2_1/AutomationRegistrar2_1.abi ../../contracts/solc/v0.8.16/AutomationRegistrar2_1/AutomationRegistrar2_1.bin eb06d853aab39d3196c593b03e555851cbe8386e0fe54a74c2479f62d14b3c42 automation_registrar_wrapper2_3: ../../contracts/solc/v0.8.19/AutomationRegistrar2_3/AutomationRegistrar2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistrar2_3/AutomationRegistrar2_3.bin 41f4b045cb783a8ad6e786b54216cc3666101abe75851784252e71aae3b00a99 automation_registry_logic_a_wrapper_2_2: ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_2/AutomationRegistryLogicA2_2.abi ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_2/AutomationRegistryLogicA2_2.bin 2f267fb8467a15c587ce4586ac56069f7229344ad3936430d7c7624c0528a171 @@ -55,6 +56,7 @@ log_emitter: ../../contracts/solc/v0.8.19/LogEmitter/LogEmitter.abi ../../contra log_triggered_streams_lookup_wrapper: ../../contracts/solc/v0.8.16/LogTriggeredStreamsLookup/LogTriggeredStreamsLookup.abi ../../contracts/solc/v0.8.16/LogTriggeredStreamsLookup/LogTriggeredStreamsLookup.bin 920fff3b662909f12ed11b47d168036ffa74ad52070a94e2fa26cdad5e428b4e log_upkeep_counter_wrapper: ../../contracts/solc/v0.8.6/LogUpkeepCounter/LogUpkeepCounter.abi ../../contracts/solc/v0.8.6/LogUpkeepCounter/LogUpkeepCounter.bin 42426bbb83f96dfbe55fc576d6c65020eaeed690e2289cf99b0c4aa810a5f4ec mock_aggregator_proxy: ../../contracts/solc/v0.8.6/MockAggregatorProxy/MockAggregatorProxy.abi ../../contracts/solc/v0.8.6/MockAggregatorProxy/MockAggregatorProxy.bin b16c108f3dd384c342ddff5e94da7c0a8d39d1be5e3d8f2cf61ecc7f0e50ff42 +mock_ethusd_aggregator_wrapper: ../../contracts/solc/v0.8.19/MockETHUSDAggregator/MockETHUSDAggregator.abi ../../contracts/solc/v0.8.19/MockETHUSDAggregator/MockETHUSDAggregator.bin b9b361f502d2aad32311c60ca86b071de93a024ac488bcfa19725d368cd05d61 offchain_aggregator_wrapper: OffchainAggregator/OffchainAggregator.abi - 5c8d6562e94166d4790f1ee6e4321d359d9f7262e6c5452a712b1f1c896f45cf operator_factory: ../../contracts/solc/v0.8.19/OperatorFactory/OperatorFactory.abi ../../contracts/solc/v0.8.19/OperatorFactory/OperatorFactory.bin 88e6baa5d9b255eea02616fbcb2cbe21a25ab46adeb6395f6289d169dec949ae operator_wrapper: ../../contracts/solc/v0.8.19/Operator/Operator.abi ../../contracts/solc/v0.8.19/Operator/Operator.bin 23c3888eaa7259e6adf2153d09abae8f4b1987dc44200363faab1e65483f32d5 @@ -115,3 +117,4 @@ vrfv2plus_reverting_example: ../../contracts/solc/v0.8.19/VRFV2PlusRevertingExam vrfv2plus_wrapper: ../../contracts/solc/v0.8.19/VRFV2PlusWrapper/VRFV2PlusWrapper.abi ../../contracts/solc/v0.8.19/VRFV2PlusWrapper/VRFV2PlusWrapper.bin 004733665a250081153e8878c0621461fea65a2d3b4905269cbd79a0966f211e vrfv2plus_wrapper_consumer_example: ../../contracts/solc/v0.8.19/VRFV2PlusWrapperConsumerExample/VRFV2PlusWrapperConsumerExample.abi ../../contracts/solc/v0.8.19/VRFV2PlusWrapperConsumerExample/VRFV2PlusWrapperConsumerExample.bin aeb0c681fa264f90971f65cba1e8d41064948070b217c8204a80ac95e1fa2294 vrfv2plus_wrapper_load_test_consumer: ../../contracts/solc/v0.8.19/VRFV2PlusWrapperLoadTestConsumer/VRFV2PlusWrapperLoadTestConsumer.abi ../../contracts/solc/v0.8.19/VRFV2PlusWrapperLoadTestConsumer/VRFV2PlusWrapperLoadTestConsumer.bin 5ca0223d3f6f6073ddfee4f9ddca13ea5f87297eb5f800359d7a1c41d04b6776 +weth9_wrapper: ../../contracts/solc/v0.8.19/WETH9/WETH9.abi ../../contracts/solc/v0.8.19/WETH9/WETH9.bin 7f600a1de0c02a071cb13bcf9eb1dbf11c3e3eccd1e78ed4b4ecb2960f2bb020 diff --git a/core/gethwrappers/go_generate.go b/core/gethwrappers/go_generate.go index 1ab61563bf7..25afd446484 100644 --- a/core/gethwrappers/go_generate.go +++ b/core/gethwrappers/go_generate.go @@ -57,6 +57,8 @@ package gethwrappers //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/ScrollModule/ScrollModule.abi ../../contracts/solc/v0.8.19/ScrollModule/ScrollModule.bin ScrollModule scroll_module //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/IChainModule/IChainModule.abi ../../contracts/solc/v0.8.19/IChainModule/IChainModule.bin IChainModule i_chain_module //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/IAutomationV21PlusCommon/IAutomationV21PlusCommon.abi ../../contracts/solc/v0.8.19/IAutomationV21PlusCommon/IAutomationV21PlusCommon.bin IAutomationV21PlusCommon i_automation_v21_plus_common +//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/MockETHUSDAggregator/MockETHUSDAggregator.abi ../../contracts/solc/v0.8.19/MockETHUSDAggregator/MockETHUSDAggregator.bin MockETHUSDAggregator mock_ethusd_aggregator_wrapper +//go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.19/WETH9/WETH9.abi ../../contracts/solc/v0.8.19/WETH9/WETH9.bin WETH9 weth9_wrapper //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/ILogAutomation/ILogAutomation.abi ../../contracts/solc/v0.8.16/ILogAutomation/ILogAutomation.bin ILogAutomation i_log_automation //go:generate go run ./generation/generate/wrap.go ../../contracts/solc/v0.8.16/AutomationForwarderLogic/AutomationForwarderLogic.abi ../../contracts/solc/v0.8.16/AutomationForwarderLogic/AutomationForwarderLogic.bin AutomationForwarderLogic automation_forwarder_logic diff --git a/integration-tests/actions/automationv2/actions.go b/integration-tests/actions/automationv2/actions.go index ced41dfb427..1ba0a0eee5f 100644 --- a/integration-tests/actions/automationv2/actions.go +++ b/integration-tests/actions/automationv2/actions.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/lib/pq" "github.com/rs/zerolog" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3" "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" ocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" @@ -55,12 +56,16 @@ type NodeDetails struct { OCR2Id string } +// TODO add wrapped native address etc type AutomationTest struct { ChainClient *seth.Client - LinkToken contracts.LinkToken + LinkToken contracts.LinkToken + //WETHToken contracts.WETHToken Transcoder contracts.UpkeepTranscoder EthLinkFeed contracts.MockETHLINKFeed + EthUSDFeed contracts.MockETHUSDFeed // TODO new add + WETHToken contracts.WETHToken // TODO new add GasFeed contracts.MockGasFeed Registry contracts.KeeperRegistry Registrar contracts.KeeperRegistrar @@ -177,6 +182,8 @@ func (a *AutomationTest) LoadLINK(address string) error { return nil } +// TODO deploy WETH Token + func (a *AutomationTest) DeployTranscoder() error { transcoder, err := contracts.DeployUpkeepTranscoder(a.ChainClient) if err != nil { @@ -213,6 +220,44 @@ func (a *AutomationTest) LoadEthLinkFeed(address string) error { return nil } +func (a *AutomationTest) DeployEthUSDFeed() error { + // TODO change the fallback price, just hardcode it should be fine + ethUSDFeed, err := contracts.DeployMockETHUSDFeed(a.ChainClient, a.RegistrySettings.FallbackLinkPrice) + if err != nil { + return err + } + a.EthUSDFeed = ethUSDFeed + return nil +} + +func (a *AutomationTest) LoadEthUSDFeed(address string) error { + ethUSDFeed, err := contracts.LoadMockETHUSDFeed(a.ChainClient, common.HexToAddress(address)) + if err != nil { + return err + } + a.EthUSDFeed = ethUSDFeed + return nil +} + +// var linkToken *contracts.EthereumLinkToken +func (a *AutomationTest) DeployWETH() error { + wethToken, err := contracts.DeployWETHTokenContract(a.Logger, a.ChainClient) + if err != nil { + return err + } + a.WETHToken = wethToken + return nil +} + +func (a *AutomationTest) LoadWETH(address string) error { + wethToken, err := contracts.LoadWETHTokenContract(a.Logger, a.ChainClient, common.HexToAddress(address)) + if err != nil { + return err + } + a.WETHToken = wethToken + return nil +} + func (a *AutomationTest) DeployGasFeed() error { gasFeed, err := contracts.DeployMockGASFeed(a.ChainClient, a.RegistrySettings.FallbackGasPrice) if err != nil { @@ -232,15 +277,21 @@ func (a *AutomationTest) LoadEthGasFeed(address string) error { } func (a *AutomationTest) DeployRegistry() error { + // TODO add wrapped native address etc registryOpts := &contracts.KeeperRegistryOpts{ RegistryVersion: a.RegistrySettings.RegistryVersion, LinkAddr: a.LinkToken.Address(), - ETHFeedAddr: a.EthLinkFeed.Address(), - GasFeedAddr: a.GasFeed.Address(), - TranscoderAddr: a.Transcoder.Address(), - RegistrarAddr: utils.ZeroAddress.Hex(), - Settings: a.RegistrySettings, - } + //WETHAddr: a.WETHToken.Address(), + ETHFeedAddr: a.EthLinkFeed.Address(), + GasFeedAddr: a.GasFeed.Address(), + TranscoderAddr: a.Transcoder.Address(), + RegistrarAddr: utils.ZeroAddress.Hex(), + Settings: a.RegistrySettings, + LinkUSDFeedAddr: a.EthUSDFeed.Address(), + NativeUSDFeedAddr: a.EthUSDFeed.Address(), + WrappedNativeAddr: a.WETHToken.Address(), + } + a.Logger.Info().Msgf("========hello = actions, %v, %v, %v", a.RegistrySettings.RegistryVersion, registryOpts.LinkUSDFeedAddr, registryOpts.WrappedNativeAddr) registry, err := contracts.DeployKeeperRegistry(a.ChainClient, registryOpts) if err != nil { return err @@ -263,6 +314,7 @@ func (a *AutomationTest) DeployRegistrar() error { return fmt.Errorf("registry must be deployed or loaded before registrar") } a.RegistrarSettings.RegistryAddr = a.Registry.Address() + a.RegistrarSettings.WETHTokenAddr = a.WETHToken.Address() registrar, err := contracts.DeployKeeperRegistrar(a.ChainClient, a.RegistrySettings.RegistryVersion, a.LinkToken.Address(), a.RegistrarSettings) if err != nil { return err @@ -361,14 +413,18 @@ func (a *AutomationTest) AddBootstrapJob() error { func (a *AutomationTest) AddAutomationJobs() error { var contractVersion string - if a.RegistrySettings.RegistryVersion == ethereum.RegistryVersion_2_2 { + // TODO what is the diff btw v2.1+ and v2.3 + //if a.RegistrySettings.RegistryVersion == ethereum.RegistryVersion_2_3 { + // contractVersion = "v2.3" + //} else + if a.RegistrySettings.RegistryVersion == ethereum.RegistryVersion_2_2 || a.RegistrySettings.RegistryVersion == ethereum.RegistryVersion_2_3 { contractVersion = "v2.1+" } else if a.RegistrySettings.RegistryVersion == ethereum.RegistryVersion_2_1 { contractVersion = "v2.1" } else if a.RegistrySettings.RegistryVersion == ethereum.RegistryVersion_2_0 { contractVersion = "v2.0" } else { - return fmt.Errorf("v2.0, v2.1, and v2.2 are the only supported versions") + return fmt.Errorf("v2.0, v2.1, v2.2 and v2.3 are the only supported versions") } pluginCfg := map[string]interface{}{ "contractVersion": "\"" + contractVersion + "\"", @@ -473,13 +529,13 @@ func (a *AutomationTest) SetConfigOnRegistry() error { if err != nil { return errors.Join(err, fmt.Errorf("failed to build config args")) } - case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2: + case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2, ethereum.RegistryVersion_2_3: signerOnchainPublicKeys, transmitterAccounts, f, _, offchainConfigVersion, offchainConfig, err = calculateOCR3ConfigArgs(a, S, oracleIdentities) if err != nil { return errors.Join(err, fmt.Errorf("failed to build config args")) } default: - return fmt.Errorf("v2.0, v2.1, and v2.2 are the only supported versions") + return fmt.Errorf("v2.0, v2.1, v2.2 and v2.3 are the only supported versions") } var signers []common.Address @@ -517,7 +573,46 @@ func (a *AutomationTest) SetConfigOnRegistry() error { ocrConfig.TypedOnchainConfig21 = a.RegistrySettings.Create21OnchainConfig(a.Registrar.Address(), a.UpkeepPrivilegeManager) } else if a.RegistrySettings.RegistryVersion == ethereum.RegistryVersion_2_2 { ocrConfig.TypedOnchainConfig22 = a.RegistrySettings.Create22OnchainConfig(a.Registrar.Address(), a.UpkeepPrivilegeManager, a.Registry.ChainModuleAddress(), a.Registry.ReorgProtectionEnabled()) + } else if a.RegistrySettings.RegistryVersion == ethereum.RegistryVersion_2_3 { + ocrConfig.TypedOnchainConfig23 = a.RegistrySettings.Create23OnchainConfig(a.Registrar.Address(), a.UpkeepPrivilegeManager, a.Registry.ChainModuleAddress(), a.Registry.ReorgProtectionEnabled()) + ocrConfig.BillingTokens = []common.Address{ + common.HexToAddress(a.LinkToken.Address()), + } + + ocrConfig.BillingConfigs = []i_automation_registry_master_wrapper_2_3.AutomationRegistryBase23BillingConfig{ + { + GasFeePPB: 100, + FlatFeeMilliCents: big.NewInt(500), + PriceFeed: common.HexToAddress(a.EthUSDFeed.Address()), + Decimals: 18, + FallbackPrice: big.NewInt(1000), + MinSpend: big.NewInt(200), + }, + } } + //function setConfigTypeSafe( + // address[] memory signers, + // address[] memory transmitters, + // uint8 f, + // OnchainConfig memory onchainConfig, // No this + // uint64 offchainConfigVersion, + // bytes memory offchainConfig, + // IERC20[] memory billingTokens, // not this + // BillingConfig[] memory billingConfigs // not this + //) + + //ocrConfig := contracts.OCRv2Config{ + // Signers: signers, + // Transmitters: transmitters, + // F: f, + // OffchainConfigVersion: offchainConfigVersion, + // OffchainConfig: offchainConfig, + //} + + // TODO log here to see what is ocrConfig + a.Logger.Info().Msgf("=====ocrConfig.BillingTokens: %v", ocrConfig.BillingTokens) + a.Logger.Info().Msgf("=====ocrConfig.BillingConfigs: %v", ocrConfig.BillingConfigs) + a.Logger.Info().Msgf("=====ocrConfig: %v", ocrConfig) err = a.Registry.SetConfigTypeSafe(ocrConfig) if err != nil { return errors.Join(err, fmt.Errorf("failed to set config on registry")) @@ -790,11 +885,18 @@ func (a *AutomationTest) SetupAutomationDeployment(t *testing.T) { err = a.DeployLINK() require.NoError(t, err, "Error deploying link token contract") + err = a.DeployWETH() + require.NoError(t, err, "Error deploying weth token contract") + err = a.DeployEthLinkFeed() require.NoError(t, err, "Error deploying eth link feed contract") err = a.DeployGasFeed() require.NoError(t, err, "Error deploying gas feed contract") + err = a.DeployEthUSDFeed() + require.NoError(t, err, "Error deploying eth usd feed contract") + // TODO deploy more + err = a.DeployTranscoder() require.NoError(t, err, "Error deploying transcoder contract") @@ -803,6 +905,7 @@ func (a *AutomationTest) SetupAutomationDeployment(t *testing.T) { err = a.DeployRegistrar() require.NoError(t, err, "Error deploying registrar contract") + l.Info().Msgf("===================version in actions.go in SetupAutomationDeployment: %v", a.RegistrySettings.RegistryVersion) a.AddJobsAndSetConfig(t) } diff --git a/integration-tests/actions/keeper_helpers.go b/integration-tests/actions/keeper_helpers.go index 882544e858a..7f02f54c751 100644 --- a/integration-tests/actions/keeper_helpers.go +++ b/integration-tests/actions/keeper_helpers.go @@ -313,6 +313,7 @@ func RegisterUpkeepContractsWithCheckData(t *testing.T, client *seth.Client, lin client.Addresses[keyNum].Hex(), isLogTrigger, isMercury, + linkToken.Address(), ) if err != nil { diff --git a/integration-tests/contracts/contract_models.go b/integration-tests/contracts/contract_models.go index b548ec1427a..94b07b19ab8 100644 --- a/integration-tests/contracts/contract_models.go +++ b/integration-tests/contracts/contract_models.go @@ -73,6 +73,7 @@ type FluxAggregator interface { WatchSubmissionReceived(ctx context.Context, eventChan chan<- *SubmissionEvent) error } +// TODO add Decimals type LinkToken interface { Address() string Approve(to string, amount *big.Int) error @@ -81,6 +82,16 @@ type LinkToken interface { TransferAndCall(to string, amount *big.Int, data []byte) (*types.Transaction, error) TransferAndCallFromKey(to string, amount *big.Int, data []byte, keyNum int) (*types.Transaction, error) Name(context.Context) (string, error) + Decimals() uint +} + +type WETHToken interface { + Address() string + Approve(to string, amount *big.Int) error + Transfer(to string, amount *big.Int) error + BalanceOf(ctx context.Context, addr string) (*big.Int, error) + Name(context.Context) (string, error) + Decimals() uint } type OffchainOptions struct { @@ -220,6 +231,13 @@ type MockETHLINKFeed interface { LatestRoundDataUpdatedAt() (*big.Int, error) } +type MockETHUSDFeed interface { + Address() string + LatestRoundData() (*big.Int, error) + LatestRoundDataUpdatedAt() (*big.Int, error) + Decimals() uint +} + type MockGasFeed interface { Address() string } diff --git a/integration-tests/contracts/ethereum/KeeperRegistryVersions.go b/integration-tests/contracts/ethereum/KeeperRegistryVersions.go index 4aee8d75d21..d5d0c2edeae 100644 --- a/integration-tests/contracts/ethereum/KeeperRegistryVersions.go +++ b/integration-tests/contracts/ethereum/KeeperRegistryVersions.go @@ -19,4 +19,5 @@ const ( RegistryVersion_2_0 RegistryVersion_2_1 RegistryVersion_2_2 + RegistryVersion_2_3 ) diff --git a/integration-tests/contracts/ethereum_contracts.go b/integration-tests/contracts/ethereum_contracts.go index 6d6c9108a4f..2310b4cf1ff 100644 --- a/integration-tests/contracts/ethereum_contracts.go +++ b/integration-tests/contracts/ethereum_contracts.go @@ -3,7 +3,6 @@ package contracts import ( "context" "encoding/hex" - "errors" "fmt" "math/big" "strings" @@ -12,258 +11,1318 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3" "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" "github.com/smartcontractkit/libocr/gethwrappers2/ocr2aggregator" ocrConfigHelper "github.com/smartcontractkit/libocr/offchainreporting/confighelper" ocrTypes "github.com/smartcontractkit/libocr/offchainreporting/types" - "github.com/smartcontractkit/seth" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" contractsethereum "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_coordinator" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_load_test_client" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_router" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flux_aggregator_wrapper" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethlink_aggregator_wrapper" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_gas_aggregator_wrapper" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_wrapper" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/oracle_wrapper" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/test_api_consumer_wrapper" - - "github.com/ethereum/go-ethereum/core/types" - - "github.com/smartcontractkit/chainlink/integration-tests/client" - "github.com/smartcontractkit/chainlink/integration-tests/wrappers" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_v1_events_mock" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/authorized_forwarder" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flags_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flux_aggregator_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/functions_billing_registry_events_mock" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/functions_oracle_events_mock" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/gas_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/gas_wrapper_mock" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_2" iregistry22 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_2" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" iregistry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registrar_wrapper1_2_mock" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_1" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_1_mock" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_2" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_3" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper2_0" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/link_token_interface" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_aggregator_proxy" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethlink_aggregator_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_gas_aggregator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_factory" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/oracle_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/test_api_consumer_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/llo-feeds/generated/fee_manager" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/llo-feeds/generated/reward_manager" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/llo-feeds/generated/verifier" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/llo-feeds/generated/verifier_proxy" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/werc20_mock" + + "github.com/smartcontractkit/chainlink/integration-tests/client" + eth_contracts "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" ) -// OCRv2Config represents the config for the OCRv2 contract -type OCRv2Config struct { - Signers []common.Address - Transmitters []common.Address - F uint8 - OnchainConfig []byte - TypedOnchainConfig21 i_keeper_registry_master_wrapper_2_1.IAutomationV21PlusCommonOnchainConfigLegacy - TypedOnchainConfig22 i_automation_registry_master_wrapper_2_2.AutomationRegistryBase22OnchainConfig - OffchainConfigVersion uint64 - OffchainConfig []byte +// LegacyEthereumOracle oracle for "directrequest" job tests +type LegacyEthereumOracle struct { + address *common.Address + client blockchain.EVMClient + oracle *oracle_wrapper.Oracle } -type EthereumFunctionsLoadStats struct { - LastRequestID string - LastResponse string - LastError string - Total uint32 - Succeeded uint32 - Errored uint32 - Empty uint32 +func (e *LegacyEthereumOracle) Address() string { + return e.address.Hex() } -func Bytes32ToSlice(a [32]byte) (r []byte) { - r = append(r, a[:]...) - return +func (e *LegacyEthereumOracle) Fund(ethAmount *big.Float) error { + gasEstimates, err := e.client.EstimateGas(ethereum.CallMsg{ + To: e.address, + }) + if err != nil { + return err + } + return e.client.Fund(e.address.Hex(), ethAmount, gasEstimates) } -// DefaultOffChainAggregatorOptions returns some base defaults for deploying an OCR contract -func DefaultOffChainAggregatorOptions() OffchainOptions { - return OffchainOptions{ - MaximumGasPrice: uint32(3000), - ReasonableGasPrice: uint32(10), - MicroLinkPerEth: uint32(500), - LinkGweiPerObservation: uint32(500), - LinkGweiPerTransmission: uint32(500), - MinimumAnswer: big.NewInt(1), - MaximumAnswer: big.NewInt(50000000000000000), - Decimals: 8, - Description: "Test OCR", - } -} - -// DefaultOffChainAggregatorConfig returns some base defaults for configuring an OCR contract -func DefaultOffChainAggregatorConfig(numberNodes int) OffChainAggregatorConfig { - if numberNodes <= 4 { - log.Err(fmt.Errorf("insufficient number of nodes (%d) supplied for OCR, need at least 5", numberNodes)). - Int("Number Chainlink Nodes", numberNodes). - Msg("You likely need more chainlink nodes to properly configure OCR, try 5 or more.") - } - s := []int{1} - // First node's stage already inputted as a 1 in line above, so numberNodes-1. - for i := 0; i < numberNodes-1; i++ { - s = append(s, 2) - } - return OffChainAggregatorConfig{ - AlphaPPB: 1, - DeltaC: time.Minute * 60, - DeltaGrace: time.Second * 12, - DeltaProgress: time.Second * 35, - DeltaStage: time.Second * 60, - DeltaResend: time.Second * 17, - DeltaRound: time.Second * 30, - RMax: 6, - S: s, - N: numberNodes, - F: 1, - OracleIdentities: []ocrConfigHelper.OracleIdentityExtra{}, +// SetFulfillmentPermission sets fulfillment permission for particular address +func (e *LegacyEthereumOracle) SetFulfillmentPermission(address string, allowed bool) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := e.oracle.SetFulfillmentPermission(opts, common.HexToAddress(address), allowed) + if err != nil { + return err } + return e.client.ProcessTransaction(tx) } -func ChainlinkK8sClientToChainlinkNodeWithKeysAndAddress(k8sNodes []*client.ChainlinkK8sClient) []ChainlinkNodeWithKeysAndAddress { - var nodesAsInterface = make([]ChainlinkNodeWithKeysAndAddress, len(k8sNodes)) - for i, node := range k8sNodes { - nodesAsInterface[i] = node +// LegacyEthereumAPIConsumer API consumer for job type "directrequest" tests +type LegacyEthereumAPIConsumer struct { + address *common.Address + client blockchain.EVMClient + consumer *test_api_consumer_wrapper.TestAPIConsumer +} + +func (e *LegacyEthereumAPIConsumer) Address() string { + return e.address.Hex() +} + +func (e *LegacyEthereumAPIConsumer) RoundID(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: ctx, } + return e.consumer.CurrentRoundID(opts) +} - return nodesAsInterface +func (e *LegacyEthereumAPIConsumer) Fund(ethAmount *big.Float) error { + gasEstimates, err := e.client.EstimateGas(ethereum.CallMsg{ + To: e.address, + }) + if err != nil { + return err + } + return e.client.Fund(e.address.Hex(), ethAmount, gasEstimates) } -func ChainlinkClientToChainlinkNodeWithKeysAndAddress(k8sNodes []*client.ChainlinkClient) []ChainlinkNodeWithKeysAndAddress { - var nodesAsInterface = make([]ChainlinkNodeWithKeysAndAddress, len(k8sNodes)) - for i, node := range k8sNodes { - nodesAsInterface[i] = node +func (e *LegacyEthereumAPIConsumer) Data(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: ctx, + } + data, err := e.consumer.Data(opts) + if err != nil { + return nil, err } + return data, nil +} - return nodesAsInterface +// CreateRequestTo creates request to an oracle for particular jobID with params +func (e *LegacyEthereumAPIConsumer) CreateRequestTo( + oracleAddr string, + jobID [32]byte, + payment *big.Int, + url string, + path string, + times *big.Int, +) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := e.consumer.CreateRequestTo(opts, common.HexToAddress(oracleAddr), jobID, payment, url, path, times) + if err != nil { + return err + } + return e.client.ProcessTransaction(tx) } -func V2OffChainAgrregatorToOffChainAggregatorWithRounds(contracts []OffchainAggregatorV2) []OffChainAggregatorWithRounds { - var contractsAsInterface = make([]OffChainAggregatorWithRounds, len(contracts)) - for i, contract := range contracts { - contractsAsInterface[i] = contract +// EthereumStaking +type EthereumStaking struct { + client blockchain.EVMClient + staking *eth_contracts.Staking + address *common.Address +} + +func (f *EthereumStaking) Address() string { + return f.address.Hex() +} + +// Fund sends specified currencies to the contract +func (f *EthereumStaking) Fund(ethAmount *big.Float) error { + gasEstimates, err := f.client.EstimateGas(ethereum.CallMsg{ + To: f.address, + }) + if err != nil { + return err } + return f.client.Fund(f.address.Hex(), ethAmount, gasEstimates) +} - return contractsAsInterface +func (f *EthereumStaking) AddOperators(operators []common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.staking.AddOperators(opts, operators) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) } -func V1OffChainAgrregatorToOffChainAggregatorWithRounds(contracts []OffchainAggregator) []OffChainAggregatorWithRounds { - var contractsAsInterface = make([]OffChainAggregatorWithRounds, len(contracts)) - for i, contract := range contracts { - contractsAsInterface[i] = contract +func (f *EthereumStaking) RemoveOperators(operators []common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.staking.RemoveOperators(opts, operators) + if err != nil { + return err } + return f.client.ProcessTransaction(tx) +} - return contractsAsInterface +func (f *EthereumStaking) SetFeedOperators(operators []common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.staking.SetFeedOperators(opts, operators) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) } -func GetRegistryContractABI(version contractsethereum.KeeperRegistryVersion) (*abi.ABI, error) { - var ( - contractABI *abi.ABI - err error - ) - switch version { - case contractsethereum.RegistryVersion_1_0, contractsethereum.RegistryVersion_1_1: - contractABI, err = keeper_registry_wrapper1_1.KeeperRegistryMetaData.GetAbi() - case contractsethereum.RegistryVersion_1_2: - contractABI, err = keeper_registry_wrapper1_2.KeeperRegistryMetaData.GetAbi() - case contractsethereum.RegistryVersion_1_3: - contractABI, err = keeper_registry_wrapper1_3.KeeperRegistryMetaData.GetAbi() - case contractsethereum.RegistryVersion_2_0: - contractABI, err = keeper_registry_wrapper2_0.KeeperRegistryMetaData.GetAbi() - case contractsethereum.RegistryVersion_2_1: - contractABI, err = iregistry21.IKeeperRegistryMasterMetaData.GetAbi() - case contractsethereum.RegistryVersion_2_2: - contractABI, err = iregistry22.IAutomationRegistryMasterMetaData.GetAbi() - default: - contractABI, err = keeper_registry_wrapper2_0.KeeperRegistryMetaData.GetAbi() +func (f *EthereumStaking) RaiseAlert() error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.staking.RaiseAlert(opts) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *EthereumStaking) Start(amount *big.Int, initialRewardRate *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.staking.Start(opts, amount, initialRewardRate) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *EthereumStaking) SetMerkleRoot(newMerkleRoot [32]byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.staking.SetMerkleRoot(opts, newMerkleRoot) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// EthereumFunctionsOracleEventsMock represents the basic events mock contract +type EthereumFunctionsOracleEventsMock struct { + client blockchain.EVMClient + eventsMock *functions_oracle_events_mock.FunctionsOracleEventsMock + address *common.Address +} + +func (f *EthereumFunctionsOracleEventsMock) Address() string { + return f.address.Hex() +} + +func (f *EthereumFunctionsOracleEventsMock) OracleResponse(requestId [32]byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitOracleResponse(opts, requestId) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *EthereumFunctionsOracleEventsMock) OracleRequest(requestId [32]byte, requestingContract common.Address, requestInitiator common.Address, subscriptionId uint64, subscriptionOwner common.Address, data []byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitOracleRequest(opts, requestId, requestingContract, requestInitiator, subscriptionId, subscriptionOwner, data) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *EthereumFunctionsOracleEventsMock) UserCallbackError(requestId [32]byte, reason string) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitUserCallbackError(opts, requestId, reason) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *EthereumFunctionsOracleEventsMock) UserCallbackRawError(requestId [32]byte, lowLevelData []byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitUserCallbackRawError(opts, requestId, lowLevelData) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// EthereumFunctionsBillingRegistryEventsMock represents the basic events mock contract +type EthereumFunctionsBillingRegistryEventsMock struct { + client blockchain.EVMClient + eventsMock *functions_billing_registry_events_mock.FunctionsBillingRegistryEventsMock + address *common.Address +} + +func (f *EthereumFunctionsBillingRegistryEventsMock) Address() string { + return f.address.Hex() +} + +func (f *EthereumFunctionsBillingRegistryEventsMock) SubscriptionFunded(subscriptionId uint64, oldBalance *big.Int, newBalance *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitSubscriptionFunded(opts, subscriptionId, oldBalance, newBalance) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *EthereumFunctionsBillingRegistryEventsMock) BillingStart(requestId [32]byte, commitment functions_billing_registry_events_mock.FunctionsBillingRegistryEventsMockCommitment) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitBillingStart(opts, requestId, commitment) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *EthereumFunctionsBillingRegistryEventsMock) BillingEnd(requestId [32]byte, subscriptionId uint64, signerPayment *big.Int, transmitterPayment *big.Int, totalCost *big.Int, success bool) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitBillingEnd(opts, requestId, subscriptionId, signerPayment, transmitterPayment, totalCost, success) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// LegacyEthereumStakingEventsMock represents the basic events mock contract +type LegacyEthereumStakingEventsMock struct { + client blockchain.EVMClient + eventsMock *eth_contracts.StakingEventsMock + address *common.Address +} + +func (f *LegacyEthereumStakingEventsMock) Address() string { + return f.address.Hex() +} + +func (f *LegacyEthereumStakingEventsMock) MaxCommunityStakeAmountIncreased(maxStakeAmount *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitMaxCommunityStakeAmountIncreased(opts, maxStakeAmount) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumStakingEventsMock) PoolSizeIncreased(maxPoolSize *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitPoolSizeIncreased(opts, maxPoolSize) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumStakingEventsMock) MaxOperatorStakeAmountIncreased(maxStakeAmount *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitMaxOperatorStakeAmountIncreased(opts, maxStakeAmount) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumStakingEventsMock) RewardInitialized(rate *big.Int, available *big.Int, startTimestamp *big.Int, endTimestamp *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitRewardInitialized(opts, rate, available, startTimestamp, endTimestamp) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumStakingEventsMock) AlertRaised(alerter common.Address, roundId *big.Int, rewardAmount *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitAlertRaised(opts, alerter, roundId, rewardAmount) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumStakingEventsMock) Staked(staker common.Address, newStake *big.Int, totalStake *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitStaked(opts, staker, newStake, totalStake) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumStakingEventsMock) OperatorAdded(operator common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitOperatorAdded(opts, operator) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumStakingEventsMock) OperatorRemoved(operator common.Address, amount *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitOperatorRemoved(opts, operator, amount) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumStakingEventsMock) FeedOperatorsSet(feedOperators []common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitFeedOperatorsSet(opts, feedOperators) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// EthereumOffchainAggregatorEventsMock represents the basic events mock contract +type EthereumOffchainAggregatorEventsMock struct { + client blockchain.EVMClient + eventsMock *eth_contracts.OffchainAggregatorEventsMock + address *common.Address +} + +func (f *EthereumOffchainAggregatorEventsMock) Address() string { + return f.address.Hex() +} + +func (f *EthereumOffchainAggregatorEventsMock) ConfigSet(previousConfigBlockNumber uint32, configCount uint64, signers []common.Address, transmitters []common.Address, threshold uint8, encodedConfigVersion uint64, encoded []byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitConfigSet(opts, previousConfigBlockNumber, configCount, signers, transmitters, threshold, encodedConfigVersion, encoded) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *EthereumOffchainAggregatorEventsMock) NewTransmission(aggregatorRoundId uint32, answer *big.Int, transmitter common.Address, observations []*big.Int, observers []byte, rawReportContext [32]byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitNewTransmission(opts, aggregatorRoundId, answer, transmitter, observations, observers, rawReportContext) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// LegacyEthereumKeeperRegistry11Mock represents the basic keeper registry 1.1 mock contract +type LegacyEthereumKeeperRegistry11Mock struct { + client blockchain.EVMClient + registryMock *keeper_registry_wrapper1_1_mock.KeeperRegistryMock + address *common.Address +} + +func (f *LegacyEthereumKeeperRegistry11Mock) Address() string { + return f.address.Hex() +} + +func (f *LegacyEthereumKeeperRegistry11Mock) EmitUpkeepPerformed(id *big.Int, success bool, from common.Address, payment *big.Int, performData []byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.EmitUpkeepPerformed(opts, id, success, from, payment, performData) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) EmitUpkeepCanceled(id *big.Int, atBlockHeight uint64) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.EmitUpkeepCanceled(opts, id, atBlockHeight) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) EmitFundsWithdrawn(id *big.Int, amount *big.Int, to common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.EmitFundsWithdrawn(opts, id, amount, to) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) EmitKeepersUpdated(keepers []common.Address, payees []common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.EmitKeepersUpdated(opts, keepers, payees) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) EmitUpkeepRegistered(id *big.Int, executeGas uint32, admin common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.EmitUpkeepRegistered(opts, id, executeGas, admin) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) EmitFundsAdded(id *big.Int, from common.Address, amount *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.EmitFundsAdded(opts, id, from, amount) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) SetUpkeepCount(_upkeepCount *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.SetUpkeepCount(opts, _upkeepCount) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) SetCanceledUpkeepList(_canceledUpkeepList []*big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.SetCanceledUpkeepList(opts, _canceledUpkeepList) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) SetKeeperList(_keepers []common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.SetKeeperList(opts, _keepers) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) SetConfig(_paymentPremiumPPB uint32, _flatFeeMicroLink uint32, _blockCountPerTurn *big.Int, _checkGasLimit uint32, _stalenessSeconds *big.Int, _gasCeilingMultiplier uint16, _fallbackGasPrice *big.Int, _fallbackLinkPrice *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.SetConfig(opts, _paymentPremiumPPB, _flatFeeMicroLink, _blockCountPerTurn, _checkGasLimit, _stalenessSeconds, _gasCeilingMultiplier, _fallbackGasPrice, _fallbackLinkPrice) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) SetUpkeep(id *big.Int, _target common.Address, _executeGas uint32, _balance *big.Int, _admin common.Address, _maxValidBlocknumber uint64, _lastKeeper common.Address, _checkData []byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.SetUpkeep(opts, id, _target, _executeGas, _balance, _admin, _maxValidBlocknumber, _lastKeeper, _checkData) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) SetMinBalance(id *big.Int, minBalance *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.SetMinBalance(opts, id, minBalance) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) SetCheckUpkeepData(id *big.Int, performData []byte, maxLinkPayment *big.Int, gasLimit *big.Int, adjustedGasWei *big.Int, linkEth *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.SetCheckUpkeepData(opts, id, performData, maxLinkPayment, gasLimit, adjustedGasWei, linkEth) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistry11Mock) SetPerformUpkeepSuccess(id *big.Int, success bool) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registryMock.SetPerformUpkeepSuccess(opts, id, success) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// LegacyEthereumKeeperRegistrar12Mock represents the basic keeper registrar 1.2 mock contract +type LegacyEthereumKeeperRegistrar12Mock struct { + client blockchain.EVMClient + registrarMock *keeper_registrar_wrapper1_2_mock.KeeperRegistrarMock + address *common.Address +} + +func (f *LegacyEthereumKeeperRegistrar12Mock) Address() string { + return f.address.Hex() +} + +func (f *LegacyEthereumKeeperRegistrar12Mock) EmitRegistrationRequested(hash [32]byte, name string, encryptedEmail []byte, upkeepContract common.Address, gasLimit uint32, adminAddress common.Address, checkData []byte, amount *big.Int, source uint8) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registrarMock.EmitRegistrationRequested(opts, hash, name, encryptedEmail, upkeepContract, gasLimit, adminAddress, checkData, amount, source) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistrar12Mock) EmitRegistrationApproved(hash [32]byte, displayName string, upkeepId *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registrarMock.EmitRegistrationApproved(opts, hash, displayName, upkeepId) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumKeeperRegistrar12Mock) SetRegistrationConfig(_autoApproveConfigType uint8, _autoApproveMaxAllowed uint32, _approvedCount uint32, _keeperRegistry common.Address, _minLINKJuels *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.registrarMock.SetRegistrationConfig(opts, _autoApproveConfigType, _autoApproveMaxAllowed, _approvedCount, _keeperRegistry, _minLINKJuels) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// LegacyEthereumKeeperGasWrapperMock represents the basic keeper gas wrapper mock contract +type LegacyEthereumKeeperGasWrapperMock struct { + client blockchain.EVMClient + gasWrapperMock *gas_wrapper_mock.KeeperRegistryCheckUpkeepGasUsageWrapperMock + address *common.Address +} + +func (f *LegacyEthereumKeeperGasWrapperMock) Address() string { + return f.address.Hex() +} + +func (f *LegacyEthereumKeeperGasWrapperMock) SetMeasureCheckGasResult(result bool, payload []byte, gas *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.gasWrapperMock.SetMeasureCheckGasResult(opts, result, payload, gas) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// LegacyEthereumFunctionsV1EventsMock represents the basic functions v1 events mock contract +type LegacyEthereumFunctionsV1EventsMock struct { + client blockchain.EVMClient + eventsMock *functions_v1_events_mock.FunctionsV1EventsMock + address *common.Address +} + +func (f *LegacyEthereumFunctionsV1EventsMock) Address() string { + return f.address.Hex() +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitRequestProcessed(requestId [32]byte, subscriptionId uint64, totalCostJuels *big.Int, transmitter common.Address, resultCode uint8, response []byte, errByte []byte, callbackReturnData []byte) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitRequestProcessed(opts, requestId, subscriptionId, totalCostJuels, transmitter, resultCode, response, errByte, callbackReturnData) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitRequestStart(requestId [32]byte, donId [32]byte, subscriptionId uint64, subscriptionOwner common.Address, requestingContract common.Address, requestInitiator common.Address, data []byte, dataVersion uint16, callbackGasLimit uint32, estimatedTotalCostJuels *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitRequestStart(opts, requestId, donId, subscriptionId, subscriptionOwner, requestingContract, requestInitiator, data, dataVersion, callbackGasLimit, estimatedTotalCostJuels) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitSubscriptionCanceled(subscriptionId uint64, fundsRecipient common.Address, fundsAmount *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitSubscriptionCanceled(opts, subscriptionId, fundsRecipient, fundsAmount) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitSubscriptionConsumerAdded(subscriptionId uint64, consumer common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitSubscriptionConsumerAdded(opts, subscriptionId, consumer) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitSubscriptionConsumerRemoved(subscriptionId uint64, consumer common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitSubscriptionConsumerRemoved(opts, subscriptionId, consumer) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitSubscriptionCreated(subscriptionId uint64, owner common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitSubscriptionCreated(opts, subscriptionId, owner) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitSubscriptionFunded(subscriptionId uint64, oldBalance *big.Int, newBalance *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitSubscriptionFunded(opts, subscriptionId, oldBalance, newBalance) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitSubscriptionOwnerTransferred(subscriptionId uint64, from common.Address, to common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitSubscriptionOwnerTransferred(opts, subscriptionId, from, to) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitSubscriptionOwnerTransferRequested(subscriptionId uint64, from common.Address, to common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitSubscriptionOwnerTransferRequested(opts, subscriptionId, from, to) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitRequestNotProcessed(requestId [32]byte, coordinator common.Address, transmitter common.Address, resultCode uint8) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitRequestNotProcessed(opts, requestId, coordinator, transmitter, resultCode) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFunctionsV1EventsMock) EmitContractUpdated(id [32]byte, from common.Address, to common.Address) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.eventsMock.EmitContractUpdated(opts, id, from, to) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// LegacyEthereumFluxAggregator represents the basic flux aggregation contract +type LegacyEthereumFluxAggregator struct { + client blockchain.EVMClient + fluxAggregator *flux_aggregator_wrapper.FluxAggregator + address *common.Address +} + +func (f *LegacyEthereumFluxAggregator) Address() string { + return f.address.Hex() +} + +// Fund sends specified currencies to the contract +func (f *LegacyEthereumFluxAggregator) Fund(ethAmount *big.Float) error { + gasEstimates, err := f.client.EstimateGas(ethereum.CallMsg{ + To: f.address, + }) + if err != nil { + return err + } + return f.client.Fund(f.address.Hex(), ethAmount, gasEstimates) +} + +func (f *LegacyEthereumFluxAggregator) UpdateAvailableFunds() error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.fluxAggregator.UpdateAvailableFunds(opts) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFluxAggregator) PaymentAmount(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(f.client.GetDefaultWallet().Address()), + Context: ctx, + } + payment, err := f.fluxAggregator.PaymentAmount(opts) + if err != nil { + return nil, err + } + return payment, nil +} + +func (f *LegacyEthereumFluxAggregator) RequestNewRound(_ context.Context) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.fluxAggregator.RequestNewRound(opts) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// WatchSubmissionReceived subscribes to any submissions on a flux feed +func (f *LegacyEthereumFluxAggregator) WatchSubmissionReceived(ctx context.Context, eventChan chan<- *SubmissionEvent) error { + ethEventChan := make(chan *flux_aggregator_wrapper.FluxAggregatorSubmissionReceived) + sub, err := f.fluxAggregator.WatchSubmissionReceived(&bind.WatchOpts{}, ethEventChan, nil, nil, nil) + if err != nil { + return err + } + defer sub.Unsubscribe() + + for { + select { + case event := <-ethEventChan: + eventChan <- &SubmissionEvent{ + Contract: event.Raw.Address, + Submission: event.Submission, + Round: event.Round, + BlockNumber: event.Raw.BlockNumber, + Oracle: event.Oracle, + } + case err := <-sub.Err(): + return err + case <-ctx.Done(): + return nil + } + } +} + +func (f *LegacyEthereumFluxAggregator) SetRequesterPermissions(_ context.Context, addr common.Address, authorized bool, roundsDelay uint32) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.fluxAggregator.SetRequesterPermissions(opts, addr, authorized, roundsDelay) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFluxAggregator) GetOracles(ctx context.Context) ([]string, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(f.client.GetDefaultWallet().Address()), + Context: ctx, + } + addresses, err := f.fluxAggregator.GetOracles(opts) + if err != nil { + return nil, err + } + var oracleAddrs []string + for _, o := range addresses { + oracleAddrs = append(oracleAddrs, o.Hex()) + } + return oracleAddrs, nil +} + +func (f *LegacyEthereumFluxAggregator) LatestRoundID(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(f.client.GetDefaultWallet().Address()), + Context: ctx, + } + rID, err := f.fluxAggregator.LatestRound(opts) + if err != nil { + return nil, err + } + return rID, nil +} + +func (f *LegacyEthereumFluxAggregator) WithdrawPayment( + _ context.Context, + from common.Address, + to common.Address, + amount *big.Int) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := f.fluxAggregator.WithdrawPayment(opts, from, to, amount) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +func (f *LegacyEthereumFluxAggregator) WithdrawablePayment(ctx context.Context, addr common.Address) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(f.client.GetDefaultWallet().Address()), + Context: ctx, + } + balance, err := f.fluxAggregator.WithdrawablePayment(opts, addr) + if err != nil { + return nil, err + } + return balance, nil +} + +func (f *LegacyEthereumFluxAggregator) LatestRoundData(ctx context.Context) (flux_aggregator_wrapper.LatestRoundData, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(f.client.GetDefaultWallet().Address()), + Context: ctx, + } + lr, err := f.fluxAggregator.LatestRoundData(opts) + if err != nil { + return flux_aggregator_wrapper.LatestRoundData{}, err + } + return lr, nil +} + +// GetContractData retrieves basic data for the flux aggregator contract +func (f *LegacyEthereumFluxAggregator) GetContractData(ctx context.Context) (*FluxAggregatorData, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(f.client.GetDefaultWallet().Address()), + Context: ctx, + } + + allocated, err := f.fluxAggregator.AllocatedFunds(opts) + if err != nil { + return &FluxAggregatorData{}, err + } + + available, err := f.fluxAggregator.AvailableFunds(opts) + if err != nil { + return &FluxAggregatorData{}, err + } + + lr, err := f.fluxAggregator.LatestRoundData(opts) + if err != nil { + return &FluxAggregatorData{}, err + } + latestRound := RoundData(lr) + + oracles, err := f.fluxAggregator.GetOracles(opts) + if err != nil { + return &FluxAggregatorData{}, err + } + + return &FluxAggregatorData{ + AllocatedFunds: allocated, + AvailableFunds: available, + LatestRoundData: latestRound, + Oracles: oracles, + }, nil +} + +// SetOracles allows the ability to add and/or remove oracles from the contract, and to set admins +func (f *LegacyEthereumFluxAggregator) SetOracles(o FluxAggregatorSetOraclesOptions) error { + opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := f.fluxAggregator.ChangeOracles(opts, o.RemoveList, o.AddList, o.AdminList, o.MinSubmissions, o.MaxSubmissions, o.RestartDelayRounds) + if err != nil { + return err + } + return f.client.ProcessTransaction(tx) +} + +// Description returns the description of the flux aggregator contract +func (f *LegacyEthereumFluxAggregator) Description(ctxt context.Context) (string, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(f.client.GetDefaultWallet().Address()), + Context: ctxt, + } + return f.fluxAggregator.Description(opts) +} + +// FluxAggregatorRoundConfirmer is a header subscription that awaits for a certain flux round to be completed +type FluxAggregatorRoundConfirmer struct { + fluxInstance FluxAggregator + roundID *big.Int + doneChan chan struct{} + context context.Context + cancel context.CancelFunc + complete bool + l zerolog.Logger +} + +// NewFluxAggregatorRoundConfirmer provides a new instance of a FluxAggregatorRoundConfirmer +func NewFluxAggregatorRoundConfirmer( + contract FluxAggregator, + roundID *big.Int, + timeout time.Duration, + logger zerolog.Logger, +) *FluxAggregatorRoundConfirmer { + ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) + return &FluxAggregatorRoundConfirmer{ + fluxInstance: contract, + roundID: roundID, + doneChan: make(chan struct{}), + context: ctx, + cancel: ctxCancel, + l: logger, + } +} + +// ReceiveHeader will query the latest FluxAggregator round and check to see whether the round has confirmed +func (f *FluxAggregatorRoundConfirmer) ReceiveHeader(header blockchain.NodeHeader) error { + if f.complete { + return nil + } + lr, err := f.fluxInstance.LatestRoundID(context.Background()) + if err != nil { + return err + } + logFields := map[string]any{ + "Contract Address": f.fluxInstance.Address(), + "Current Round": lr.Int64(), + "Waiting for Round": f.roundID.Int64(), + "Header Number": header.Number.Uint64(), + } + if lr.Cmp(f.roundID) >= 0 { + f.l.Info().Fields(logFields).Msg("FluxAggregator round completed") + f.complete = true + f.doneChan <- struct{}{} + } else { + f.l.Debug().Fields(logFields).Msg("Waiting for FluxAggregator round") + } + return nil +} + +// Wait is a blocking function that will wait until the round has confirmed, and timeout if the deadline has passed +func (f *FluxAggregatorRoundConfirmer) Wait() error { + defer func() { f.complete = true }() + for { + select { + case <-f.doneChan: + f.cancel() + return nil + case <-f.context.Done(): + return fmt.Errorf("timeout waiting for flux round to confirm: %d", f.roundID) + } + } +} + +func (f *FluxAggregatorRoundConfirmer) Complete() bool { + return f.complete +} + +// LegacyEthereumLinkToken represents a LinkToken address +type LegacyEthereumLinkToken struct { + client blockchain.EVMClient + instance *link_token_interface.LinkToken + address common.Address + l zerolog.Logger +} + +// Fund the LINK Token contract with ETH to distribute the token +func (l *LegacyEthereumLinkToken) Fund(ethAmount *big.Float) error { + gasEstimates, err := l.client.EstimateGas(ethereum.CallMsg{ + To: &l.address, + }) + if err != nil { + return err + } + return l.client.Fund(l.address.Hex(), ethAmount, gasEstimates) +} + +func (l *LegacyEthereumLinkToken) Decimals() uint { + return 18 +} + +func (l *LegacyEthereumLinkToken) BalanceOf(ctx context.Context, addr string) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(l.client.GetDefaultWallet().Address()), + Context: ctx, } - - return contractABI, err + balance, err := l.instance.BalanceOf(opts, common.HexToAddress(addr)) + if err != nil { + return nil, err + } + return balance, nil } -// DefaultFluxAggregatorOptions produces some basic defaults for a flux aggregator contract -func DefaultFluxAggregatorOptions() FluxAggregatorOptions { - return FluxAggregatorOptions{ - PaymentAmount: big.NewInt(1), - Timeout: uint32(30), - MinSubValue: big.NewInt(0), - MaxSubValue: big.NewInt(1000000000000), - Decimals: uint8(0), - Description: "Test Flux Aggregator", +// Name returns the name of the link token +func (l *LegacyEthereumLinkToken) Name(ctxt context.Context) (string, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(l.client.GetDefaultWallet().Address()), + Context: ctxt, } + return l.instance.Name(opts) } -// EthereumOffchainAggregator represents the offchain aggregation contract -type EthereumOffchainAggregator struct { - client *seth.Client - ocr *offchainaggregator.OffchainAggregator - address *common.Address - l zerolog.Logger +func (l *LegacyEthereumLinkToken) Address() string { + return l.address.Hex() } -func LoadOffchainAggregator(l zerolog.Logger, seth *seth.Client, contractAddress common.Address) (EthereumOffchainAggregator, error) { - abi, err := offchainaggregator.OffchainAggregatorMetaData.GetAbi() +func (l *LegacyEthereumLinkToken) Approve(to string, amount *big.Int) error { + opts, err := l.client.TransactionOpts(l.client.GetDefaultWallet()) if err != nil { - return EthereumOffchainAggregator{}, fmt.Errorf("failed to get OffChain Aggregator ABI: %w", err) + return err } - seth.ContractStore.AddABI("OffChainAggregator", *abi) - seth.ContractStore.AddBIN("OffChainAggregator", common.FromHex(offchainaggregator.OffchainAggregatorMetaData.Bin)) - - ocr, err := offchainaggregator.NewOffchainAggregator(contractAddress, wrappers.MustNewWrappedContractBackend(nil, seth)) + l.l.Info(). + Str("From", l.client.GetDefaultWallet().Address()). + Str("To", to). + Str("Amount", amount.String()). + Uint64("Nonce", opts.Nonce.Uint64()). + Msg("Approving LINK Transfer") + tx, err := l.instance.Approve(opts, common.HexToAddress(to), amount) if err != nil { - return EthereumOffchainAggregator{}, fmt.Errorf("failed to instantiate OCR instance: %w", err) + return err } - - return EthereumOffchainAggregator{ - client: seth, - ocr: ocr, - address: &contractAddress, - l: l, - }, nil + return l.client.ProcessTransaction(tx) } -func DeployOffchainAggregator(l zerolog.Logger, seth *seth.Client, linkTokenAddress common.Address, offchainOptions OffchainOptions) (EthereumOffchainAggregator, error) { - abi, err := offchainaggregator.OffchainAggregatorMetaData.GetAbi() +func (l *LegacyEthereumLinkToken) Transfer(to string, amount *big.Int) error { + opts, err := l.client.TransactionOpts(l.client.GetDefaultWallet()) if err != nil { - return EthereumOffchainAggregator{}, fmt.Errorf("failed to get OffChain Aggregator ABI: %w", err) + return err } - - ocrDeploymentData, err := seth.DeployContract( - seth.NewTXOpts(), - "OffChainAggregator", - *abi, - common.FromHex(offchainaggregator.OffchainAggregatorMetaData.Bin), - offchainOptions.MaximumGasPrice, - offchainOptions.ReasonableGasPrice, - offchainOptions.MicroLinkPerEth, - offchainOptions.LinkGweiPerObservation, - offchainOptions.LinkGweiPerTransmission, - linkTokenAddress, - offchainOptions.MinimumAnswer, - offchainOptions.MaximumAnswer, - offchainOptions.BillingAccessController, - offchainOptions.RequesterAccessController, - offchainOptions.Decimals, - offchainOptions.Description) + l.l.Info(). + Str("From", l.client.GetDefaultWallet().Address()). + Str("To", to). + Str("Amount", amount.String()). + Uint64("Nonce", opts.Nonce.Uint64()). + Msg("Transferring LINK") + tx, err := l.instance.Transfer(opts, common.HexToAddress(to), amount) if err != nil { - return EthereumOffchainAggregator{}, fmt.Errorf("OCR instance deployment have failed: %w", err) + return err } + return l.client.ProcessTransaction(tx) +} - ocr, err := offchainaggregator.NewOffchainAggregator(ocrDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) +func (l *LegacyEthereumLinkToken) TransferAndCall(to string, amount *big.Int, data []byte) (*types.Transaction, error) { + opts, err := l.client.TransactionOpts(l.client.GetDefaultWallet()) + if err != nil { + return nil, err + } + tx, err := l.instance.TransferAndCall(opts, common.HexToAddress(to), amount, data) if err != nil { - return EthereumOffchainAggregator{}, fmt.Errorf("failed to instantiate OCR instance: %w", err) + return nil, err } + l.l.Info(). + Str("From", l.client.GetDefaultWallet().Address()). + Str("To", to). + Str("Amount", amount.String()). + Uint64("Nonce", opts.Nonce.Uint64()). + Str("TxHash", tx.Hash().String()). + Msg("Transferring and Calling LINK") + return tx, l.client.ProcessTransaction(tx) +} - return EthereumOffchainAggregator{ - client: seth, - ocr: ocr, - address: &ocrDeploymentData.Address, - l: l, - }, nil +func (l *LegacyEthereumLinkToken) TransferAndCallFromKey(_ string, _ *big.Int, _ []byte, _ int) (*types.Transaction, error) { + panic("supported only with Seth") +} + +// LegacyEthereumOffchainAggregator represents the offchain aggregation contract +// Deprecated: we are moving away from blockchain.EVMClient, use EthereumOffchainAggregator instead +type LegacyEthereumOffchainAggregator struct { + client blockchain.EVMClient + ocr *offchainaggregator.OffchainAggregator + address *common.Address + l zerolog.Logger } // SetPayees sets wallets for the contract to pay out to? -func (o *EthereumOffchainAggregator) SetPayees( +func (o *LegacyEthereumOffchainAggregator) SetPayees( transmitters, payees []string, ) error { + opts, err := o.client.TransactionOpts(o.client.GetDefaultWallet()) + if err != nil { + return err + } var transmittersAddr, payeesAddr []common.Address for _, tr := range transmitters { transmittersAddr = append(transmittersAddr, common.HexToAddress(tr)) @@ -278,12 +1337,15 @@ func (o *EthereumOffchainAggregator) SetPayees( Str("OCR Address", o.Address()). Msg("Setting OCR Payees") - _, err := o.client.Decode(o.ocr.SetPayees(o.client.NewTXOpts(), transmittersAddr, payeesAddr)) - return err + tx, err := o.ocr.SetPayees(opts, transmittersAddr, payeesAddr) + if err != nil { + return err + } + return o.client.ProcessTransaction(tx) } // SetConfig sets the payees and the offchain reporting protocol configuration -func (o *EthereumOffchainAggregator) SetConfig( +func (o *LegacyEthereumOffchainAggregator) SetConfig( chainlinkNodes []ChainlinkNodeWithKeysAndAddress, ocrConfig OffChainAggregatorConfig, transmitters []common.Address, @@ -352,39 +1414,54 @@ func (o *EthereumOffchainAggregator) SetConfig( return err } - // fails with error setting OCR config for contract '0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82': both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified - // but we only have gasPrice set... It also fails with the same error when we enable EIP-1559 - // fails when we wait for it to be minted, inside the wrapper there's no error when we call it, so it must be something inside smart contract - // that's reverting it and maybe the error message is completely off - _, err = o.client.Decode(o.ocr.SetConfig(o.client.NewTXOpts(), signers, transmitters, threshold, encodedConfigVersion, encodedConfig)) - return err + // Set Config + opts, err := o.client.TransactionOpts(o.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := o.ocr.SetConfig(opts, signers, transmitters, threshold, encodedConfigVersion, encodedConfig) + if err != nil { + return err + } + return o.client.ProcessTransaction(tx) } // RequestNewRound requests the OCR contract to create a new round -func (o *EthereumOffchainAggregator) RequestNewRound() error { +func (o *LegacyEthereumOffchainAggregator) RequestNewRound() error { + opts, err := o.client.TransactionOpts(o.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := o.ocr.RequestNewRound(opts) + if err != nil { + return err + } o.l.Info().Str("Contract Address", o.address.Hex()).Msg("New OCR round requested") - _, err := o.client.Decode(o.ocr.RequestNewRound(o.client.NewTXOpts())) - return err + + return o.client.ProcessTransaction(tx) } // GetLatestAnswer returns the latest answer from the OCR contract -func (o *EthereumOffchainAggregator) GetLatestAnswer(ctx context.Context) (*big.Int, error) { - return o.ocr.LatestAnswer(&bind.CallOpts{ - From: o.client.Addresses[0], - Context: ctx, - }) +func (o *LegacyEthereumOffchainAggregator) GetLatestAnswer(ctxt context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(o.client.GetDefaultWallet().Address()), + Context: ctxt, + } + return o.ocr.LatestAnswer(opts) } -func (o *EthereumOffchainAggregator) Address() string { +func (o *LegacyEthereumOffchainAggregator) Address() string { return o.address.Hex() } // GetLatestRound returns data from the latest round -func (o *EthereumOffchainAggregator) GetLatestRound(ctx context.Context) (*RoundData, error) { - roundData, err := o.ocr.LatestRoundData(&bind.CallOpts{ - From: o.client.Addresses[0], +func (o *LegacyEthereumOffchainAggregator) GetLatestRound(ctx context.Context) (*RoundData, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(o.client.GetDefaultWallet().Address()), Context: ctx, - }) + } + + roundData, err := o.ocr.LatestRoundData(opts) if err != nil { return nil, err } @@ -398,8 +1475,11 @@ func (o *EthereumOffchainAggregator) GetLatestRound(ctx context.Context) (*Round }, err } -func (o *EthereumOffchainAggregator) LatestRoundDataUpdatedAt() (*big.Int, error) { - data, err := o.ocr.LatestRoundData(o.client.NewCallOpts()) +func (o *LegacyEthereumOffchainAggregator) LatestRoundDataUpdatedAt() (*big.Int, error) { + data, err := o.ocr.LatestRoundData(&bind.CallOpts{ + From: common.HexToAddress(o.client.GetDefaultWallet().Address()), + Context: context.Background(), + }) if err != nil { return nil, err } @@ -407,11 +1487,12 @@ func (o *EthereumOffchainAggregator) LatestRoundDataUpdatedAt() (*big.Int, error } // GetRound retrieves an OCR round by the round ID -func (o *EthereumOffchainAggregator) GetRound(ctx context.Context, roundID *big.Int) (*RoundData, error) { - roundData, err := o.ocr.GetRoundData(&bind.CallOpts{ - From: o.client.Addresses[0], +func (o *LegacyEthereumOffchainAggregator) GetRound(ctx context.Context, roundID *big.Int) (*RoundData, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(o.client.GetDefaultWallet().Address()), Context: ctx, - }, roundID) + } + roundData, err := o.ocr.GetRoundData(opts, roundID) if err != nil { return nil, err } @@ -426,1060 +1507,1049 @@ func (o *EthereumOffchainAggregator) GetRound(ctx context.Context, roundID *big. } // ParseEventAnswerUpdated parses the log for event AnswerUpdated -func (o *EthereumOffchainAggregator) ParseEventAnswerUpdated(eventLog types.Log) (*offchainaggregator.OffchainAggregatorAnswerUpdated, error) { +func (o *LegacyEthereumOffchainAggregator) ParseEventAnswerUpdated(eventLog types.Log) (*offchainaggregator.OffchainAggregatorAnswerUpdated, error) { return o.ocr.ParseAnswerUpdated(eventLog) } -// LegacyEthereumOperatorFactory represents operator factory contract -type EthereumOperatorFactory struct { - address *common.Address - client *seth.Client - operatorFactory *operator_factory.OperatorFactory -} - -func DeployEthereumOperatorFactory(seth *seth.Client, linkTokenAddress common.Address) (EthereumOperatorFactory, error) { - abi, err := operator_factory.OperatorFactoryMetaData.GetAbi() - if err != nil { - return EthereumOperatorFactory{}, fmt.Errorf("failed to get OperatorFactory ABI: %w", err) - } - operatorData, err := seth.DeployContract(seth.NewTXOpts(), "OperatorFactory", *abi, common.FromHex(operator_factory.OperatorFactoryMetaData.Bin), linkTokenAddress) - if err != nil { - return EthereumOperatorFactory{}, fmt.Errorf("OperatorFactory instance deployment have failed: %w", err) - } - - operatorFactory, err := operator_factory.NewOperatorFactory(operatorData.Address, seth.Client) - if err != nil { - return EthereumOperatorFactory{}, fmt.Errorf("failed to instantiate OperatorFactory instance: %w", err) - } - - return EthereumOperatorFactory{ - address: &operatorData.Address, - client: seth, - operatorFactory: operatorFactory, - }, nil -} - -func (e *EthereumOperatorFactory) ParseAuthorizedForwarderCreated(eventLog types.Log) (*operator_factory.OperatorFactoryAuthorizedForwarderCreated, error) { - return e.operatorFactory.ParseAuthorizedForwarderCreated(eventLog) -} - -func (e *EthereumOperatorFactory) ParseOperatorCreated(eventLog types.Log) (*operator_factory.OperatorFactoryOperatorCreated, error) { - return e.operatorFactory.ParseOperatorCreated(eventLog) -} - -func (e *EthereumOperatorFactory) Address() string { - return e.address.Hex() -} - -func (e *EthereumOperatorFactory) DeployNewOperatorAndForwarder() (*types.Transaction, error) { - return e.operatorFactory.DeployNewOperatorAndForwarder(e.client.NewTXOpts()) -} - -// EthereumOperator represents operator contract -type EthereumOperator struct { - address *common.Address - client *seth.Client - operator *operator_wrapper.Operator +// RunlogRoundConfirmer is a header subscription that awaits for a certain Runlog round to be completed +type RunlogRoundConfirmer struct { + consumer APIConsumer + roundID *big.Int + doneChan chan struct{} + context context.Context + cancel context.CancelFunc l zerolog.Logger } -func LoadEthereumOperator(logger zerolog.Logger, seth *seth.Client, contractAddress common.Address) (EthereumOperator, error) { - - abi, err := operator_wrapper.OperatorMetaData.GetAbi() - if err != nil { - return EthereumOperator{}, err - } - seth.ContractStore.AddABI("EthereumOperator", *abi) - seth.ContractStore.AddBIN("EthereumOperator", common.FromHex(operator_wrapper.OperatorMetaData.Bin)) - - operator, err := operator_wrapper.NewOperator(contractAddress, seth.Client) - if err != nil { - return EthereumOperator{}, err - } - - return EthereumOperator{ - address: &contractAddress, - client: seth, - operator: operator, +// NewRunlogRoundConfirmer provides a new instance of a RunlogRoundConfirmer +func NewRunlogRoundConfirmer( + contract APIConsumer, + roundID *big.Int, + timeout time.Duration, + logger zerolog.Logger, +) *RunlogRoundConfirmer { + ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) + return &RunlogRoundConfirmer{ + consumer: contract, + roundID: roundID, + doneChan: make(chan struct{}), + context: ctx, + cancel: ctxCancel, l: logger, - }, nil -} - -func (e *EthereumOperator) Address() string { - return e.address.Hex() -} - -func (e *EthereumOperator) AcceptAuthorizedReceivers(forwarders []common.Address, eoa []common.Address) error { - e.l.Info(). - Str("ForwardersAddresses", fmt.Sprint(forwarders)). - Str("EoaAddresses", fmt.Sprint(eoa)). - Msg("Accepting Authorized Receivers") - _, err := e.client.Decode(e.operator.AcceptAuthorizedReceivers(e.client.NewTXOpts(), forwarders, eoa)) - return err -} - -// EthereumAuthorizedForwarder represents authorized forwarder contract -type EthereumAuthorizedForwarder struct { - address *common.Address - client *seth.Client - authorizedForwarder *authorized_forwarder.AuthorizedForwarder -} - -func LoadEthereumAuthorizedForwarder(seth *seth.Client, contractAddress common.Address) (EthereumAuthorizedForwarder, error) { - abi, err := authorized_forwarder.AuthorizedForwarderMetaData.GetAbi() - if err != nil { - return EthereumAuthorizedForwarder{}, err - } - seth.ContractStore.AddABI("AuthorizedForwarder", *abi) - seth.ContractStore.AddBIN("AuthorizedForwarder", common.FromHex(authorized_forwarder.AuthorizedForwarderMetaData.Bin)) - - authorizedForwarder, err := authorized_forwarder.NewAuthorizedForwarder(contractAddress, seth.Client) - if err != nil { - return EthereumAuthorizedForwarder{}, fmt.Errorf("failed to instantiate AuthorizedForwarder instance: %w", err) } - - return EthereumAuthorizedForwarder{ - address: &contractAddress, - client: seth, - authorizedForwarder: authorizedForwarder, - }, nil -} - -// Owner return authorized forwarder owner address -func (e *EthereumAuthorizedForwarder) Owner(_ context.Context) (string, error) { - owner, err := e.authorizedForwarder.Owner(e.client.NewCallOpts()) - - return owner.Hex(), err } -func (e *EthereumAuthorizedForwarder) GetAuthorizedSenders(ctx context.Context) ([]string, error) { - opts := &bind.CallOpts{ - From: e.client.Addresses[0], - Context: ctx, - } - authorizedSenders, err := e.authorizedForwarder.GetAuthorizedSenders(opts) +// ReceiveHeader will query the latest Runlog round and check to see whether the round has confirmed +func (o *RunlogRoundConfirmer) ReceiveHeader(_ blockchain.NodeHeader) error { + currentRoundID, err := o.consumer.RoundID(context.Background()) if err != nil { - return nil, err + return err } - var sendersAddrs []string - for _, o := range authorizedSenders { - sendersAddrs = append(sendersAddrs, o.Hex()) + logFields := map[string]any{ + "Contract Address": o.consumer.Address(), + "Current Round": currentRoundID.Int64(), + "Waiting for Round": o.roundID.Int64(), + } + if currentRoundID.Cmp(o.roundID) >= 0 { + o.l.Info().Fields(logFields).Msg("Runlog round completed") + o.doneChan <- struct{}{} + } else { + o.l.Debug().Fields(logFields).Msg("Waiting for Runlog round") + } + return nil +} + +// Wait is a blocking function that will wait until the round has confirmed, and timeout if the deadline has passed +func (o *RunlogRoundConfirmer) Wait() error { + for { + select { + case <-o.doneChan: + o.cancel() + return nil + case <-o.context.Done(): + return fmt.Errorf("timeout waiting for OCR round to confirm: %d", o.roundID) + } } - return sendersAddrs, nil -} - -func (e *EthereumAuthorizedForwarder) Address() string { - return e.address.Hex() } -type EthereumOffchainAggregatorV2 struct { - address *common.Address - client *seth.Client - contract *ocr2aggregator.OCR2Aggregator - l zerolog.Logger +// OffchainAggregatorRoundConfirmer is a header subscription that awaits for a certain OCR round to be completed +type OffchainAggregatorRoundConfirmer struct { + ocrInstance OffchainAggregator + roundID *big.Int + doneChan chan struct{} + context context.Context + cancel context.CancelFunc + blocksSinceAnswer uint + complete bool + l zerolog.Logger } -func LoadOffChainAggregatorV2(l zerolog.Logger, seth *seth.Client, contractAddress common.Address) (EthereumOffchainAggregatorV2, error) { - oAbi, err := ocr2aggregator.OCR2AggregatorMetaData.GetAbi() - if err != nil { - return EthereumOffchainAggregatorV2{}, fmt.Errorf("failed to get OffChain Aggregator ABI: %w", err) - } - seth.ContractStore.AddABI("OffChainAggregatorV2", *oAbi) - seth.ContractStore.AddBIN("OffChainAggregatorV2", common.FromHex(ocr2aggregator.OCR2AggregatorMetaData.Bin)) - - ocr2, err := ocr2aggregator.NewOCR2Aggregator(contractAddress, seth.Client) - if err != nil { - return EthereumOffchainAggregatorV2{}, fmt.Errorf("failed to instantiate OCR instance: %w", err) +// NewOffchainAggregatorRoundConfirmer provides a new instance of a OffchainAggregatorRoundConfirmer +func NewOffchainAggregatorRoundConfirmer( + contract OffchainAggregator, + roundID *big.Int, + timeout time.Duration, + logger zerolog.Logger, +) *OffchainAggregatorRoundConfirmer { + ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) + return &OffchainAggregatorRoundConfirmer{ + ocrInstance: contract, + roundID: roundID, + doneChan: make(chan struct{}), + context: ctx, + cancel: ctxCancel, + complete: false, + l: logger, } - - return EthereumOffchainAggregatorV2{ - client: seth, - contract: ocr2, - address: &contractAddress, - l: l, - }, nil } -func DeployOffchainAggregatorV2(l zerolog.Logger, seth *seth.Client, linkTokenAddress common.Address, offchainOptions OffchainOptions) (EthereumOffchainAggregatorV2, error) { - oAbi, err := ocr2aggregator.OCR2AggregatorMetaData.GetAbi() - if err != nil { - return EthereumOffchainAggregatorV2{}, fmt.Errorf("failed to get OffChain Aggregator ABI: %w", err) +// ReceiveHeader will query the latest OffchainAggregator round and check to see whether the round has confirmed +func (o *OffchainAggregatorRoundConfirmer) ReceiveHeader(_ blockchain.NodeHeader) error { + if channelClosed(o.doneChan) { + return nil } - seth.ContractStore.AddABI("OffChainAggregatorV2", *oAbi) - seth.ContractStore.AddBIN("OffChainAggregatorV2", common.FromHex(ocr2aggregator.OCR2AggregatorMetaData.Bin)) - - ocrDeploymentData2, err := seth.DeployContract(seth.NewTXOpts(), "OffChainAggregatorV2", *oAbi, common.FromHex(ocr2aggregator.OCR2AggregatorMetaData.Bin), - linkTokenAddress, - offchainOptions.MinimumAnswer, - offchainOptions.MaximumAnswer, - offchainOptions.BillingAccessController, - offchainOptions.RequesterAccessController, - offchainOptions.Decimals, - offchainOptions.Description, - ) + lr, err := o.ocrInstance.GetLatestRound(context.Background()) if err != nil { - return EthereumOffchainAggregatorV2{}, fmt.Errorf("OCR instance deployment have failed: %w", err) + return err } - - ocr2, err := ocr2aggregator.NewOCR2Aggregator(ocrDeploymentData2.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) - if err != nil { - return EthereumOffchainAggregatorV2{}, fmt.Errorf("failed to instantiate OCR instance: %w", err) + o.blocksSinceAnswer++ + currRound := lr.RoundId + logFields := map[string]any{ + "Contract Address": o.ocrInstance.Address(), + "Current Round": currRound.Int64(), + "Waiting for Round": o.roundID.Int64(), + } + if currRound.Cmp(o.roundID) >= 0 { + o.l.Info().Fields(logFields).Msg("OCR round completed") + o.doneChan <- struct{}{} + o.complete = true + } else { + o.l.Debug().Fields(logFields).Msg("Waiting on OCR Round") + } + return nil +} + +// Wait is a blocking function that will wait until the round has confirmed, and timeout if the deadline has passed +func (o *OffchainAggregatorRoundConfirmer) Wait() error { + defer func() { o.complete = true }() + for { + select { + case <-o.doneChan: + o.cancel() + close(o.doneChan) + return nil + case <-o.context.Done(): + return fmt.Errorf("timeout waiting for OCR round to confirm: %d", o.roundID) + } } - - return EthereumOffchainAggregatorV2{ - client: seth, - contract: ocr2, - address: &ocrDeploymentData2.Address, - l: l, - }, nil } -func (e *EthereumOffchainAggregatorV2) Address() string { - return e.address.Hex() -} - -func (e *EthereumOffchainAggregatorV2) RequestNewRound() error { - _, err := e.client.Decode(e.contract.RequestNewRound(e.client.NewTXOpts())) - return err +func (o *OffchainAggregatorRoundConfirmer) Complete() bool { + return o.complete } -func (e *EthereumOffchainAggregatorV2) GetLatestAnswer(ctx context.Context) (*big.Int, error) { - return e.contract.LatestAnswer(&bind.CallOpts{ - From: e.client.Addresses[0], - Context: ctx, - }) +// OffchainAggregatorRoundConfirmer is a header subscription that awaits for a certain OCR round to be completed +type OffchainAggregatorV2RoundConfirmer struct { + ocrInstance OffchainAggregatorV2 + roundID *big.Int + doneChan chan struct{} + context context.Context + cancel context.CancelFunc + blocksSinceAnswer uint + complete bool + l zerolog.Logger } -func (e *EthereumOffchainAggregatorV2) GetLatestRound(ctx context.Context) (*RoundData, error) { - data, err := e.contract.LatestRoundData(&bind.CallOpts{ - From: e.client.Addresses[0], - Context: ctx, - }) - if err != nil { - return nil, err +// NewOffchainAggregatorRoundConfirmer provides a new instance of a OffchainAggregatorRoundConfirmer +func NewOffchainAggregatorV2RoundConfirmer( + contract OffchainAggregatorV2, + roundID *big.Int, + timeout time.Duration, + logger zerolog.Logger, +) *OffchainAggregatorV2RoundConfirmer { + ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) + return &OffchainAggregatorV2RoundConfirmer{ + ocrInstance: contract, + roundID: roundID, + doneChan: make(chan struct{}), + context: ctx, + cancel: ctxCancel, + complete: false, + l: logger, } - return &RoundData{ - RoundId: data.RoundId, - StartedAt: data.StartedAt, - UpdatedAt: data.UpdatedAt, - AnsweredInRound: data.AnsweredInRound, - Answer: data.Answer, - }, nil } -func (e *EthereumOffchainAggregatorV2) GetRound(ctx context.Context, roundID *big.Int) (*RoundData, error) { - data, err := e.contract.GetRoundData(&bind.CallOpts{ - From: e.client.Addresses[0], - Context: ctx, - }, roundID) - if err != nil { - return nil, err +// ReceiveHeader will query the latest OffchainAggregator round and check to see whether the round has confirmed +func (o *OffchainAggregatorV2RoundConfirmer) ReceiveHeader(_ blockchain.NodeHeader) error { + if channelClosed(o.doneChan) { + return nil } - return &RoundData{ - RoundId: data.RoundId, - StartedAt: data.StartedAt, - UpdatedAt: data.UpdatedAt, - AnsweredInRound: data.AnsweredInRound, - Answer: data.Answer, - }, nil -} - -func (e *EthereumOffchainAggregatorV2) SetPayees(transmitters, payees []string) error { - e.l.Info(). - Str("Transmitters", fmt.Sprintf("%v", transmitters)). - Str("Payees", fmt.Sprintf("%v", payees)). - Str("OCRv2 Address", e.Address()). - Msg("Setting OCRv2 Payees") - var addTransmitters, addrPayees []common.Address - for _, t := range transmitters { - addTransmitters = append(addTransmitters, common.HexToAddress(t)) + lr, err := o.ocrInstance.GetLatestRound(context.Background()) + if err != nil { + return err } - for _, p := range payees { - addrPayees = append(addrPayees, common.HexToAddress(p)) + o.blocksSinceAnswer++ + currRound := lr.RoundId + logFields := map[string]any{ + "Contract Address": o.ocrInstance.Address(), + "Current Round": currRound.Int64(), + "Waiting for Round": o.roundID.Int64(), + } + if currRound.Cmp(o.roundID) >= 0 { + o.l.Info().Fields(logFields).Msg("OCR round completed") + o.doneChan <- struct{}{} + o.complete = true + } else { + o.l.Debug().Fields(logFields).Msg("Waiting on OCR Round") + } + return nil +} + +// Wait is a blocking function that will wait until the round has confirmed, and timeout if the deadline has passed +func (o *OffchainAggregatorV2RoundConfirmer) Wait() error { + defer func() { o.complete = true }() + for { + select { + case <-o.doneChan: + o.cancel() + close(o.doneChan) + return nil + case <-o.context.Done(): + return fmt.Errorf("timeout waiting for OCR round to confirm: %d", o.roundID) + } } - - _, err := e.client.Decode(e.contract.SetPayees(e.client.NewTXOpts(), addTransmitters, addrPayees)) - return err } -func (e *EthereumOffchainAggregatorV2) SetConfig(ocrConfig *OCRv2Config) error { - e.l.Info(). - Str("Address", e.Address()). - Interface("Signers", ocrConfig.Signers). - Interface("Transmitters", ocrConfig.Transmitters). - Uint8("F", ocrConfig.F). - Bytes("OnchainConfig", ocrConfig.OnchainConfig). - Uint64("OffchainConfigVersion", ocrConfig.OffchainConfigVersion). - Bytes("OffchainConfig", ocrConfig.OffchainConfig). - Msg("Setting OCRv2 Config") - - _, err := e.client.Decode(e.contract.SetConfig( - e.client.NewTXOpts(), - ocrConfig.Signers, - ocrConfig.Transmitters, - ocrConfig.F, - ocrConfig.OnchainConfig, - ocrConfig.OffchainConfigVersion, - ocrConfig.OffchainConfig, - )) - return err +func (o *OffchainAggregatorV2RoundConfirmer) Complete() bool { + return o.complete } -func (e *EthereumOffchainAggregatorV2) ParseEventAnswerUpdated(log types.Log) (*ocr2aggregator.OCR2AggregatorAnswerUpdated, error) { - return e.contract.ParseAnswerUpdated(log) +// LegacyEthereumMockETHLINKFeed represents mocked ETH/LINK feed contract +type LegacyEthereumMockETHLINKFeed struct { + client blockchain.EVMClient + feed *mock_ethlink_aggregator_wrapper.MockETHLINKAggregator + address *common.Address } -// EthereumLinkToken represents a LinkToken address -type EthereumLinkToken struct { - client *seth.Client - instance *link_token_interface.LinkToken - address common.Address - l zerolog.Logger +func (v *LegacyEthereumMockETHLINKFeed) Address() string { + return v.address.Hex() } -func DeployLinkTokenContract(l zerolog.Logger, client *seth.Client) (*EthereumLinkToken, error) { - linkTokenAbi, err := link_token_interface.LinkTokenMetaData.GetAbi() - if err != nil { - return &EthereumLinkToken{}, fmt.Errorf("failed to get LinkToken ABI: %w", err) - } - linkDeploymentData, err := client.DeployContract(client.NewTXOpts(), "LinkToken", *linkTokenAbi, common.FromHex(link_token_interface.LinkTokenMetaData.Bin)) - if err != nil { - return &EthereumLinkToken{}, fmt.Errorf("LinkToken instance deployment have failed: %w", err) - } - - linkToken, err := link_token_interface.NewLinkToken(linkDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, client)) +func (v *LegacyEthereumMockETHLINKFeed) LatestRoundData() (*big.Int, error) { + data, err := v.feed.LatestRoundData(&bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: context.Background(), + }) if err != nil { - return &EthereumLinkToken{}, fmt.Errorf("failed to instantiate LinkToken instance: %w", err) + return nil, err } - - return &EthereumLinkToken{ - client: client, - instance: linkToken, - address: linkDeploymentData.Address, - l: l, - }, nil + return data.Ans, nil } -func LoadLinkTokenContract(l zerolog.Logger, client *seth.Client, address common.Address) (*EthereumLinkToken, error) { - abi, err := link_token_interface.LinkTokenMetaData.GetAbi() - if err != nil { - return &EthereumLinkToken{}, fmt.Errorf("failed to get LinkToken ABI: %w", err) - } - - client.ContractStore.AddABI("LinkToken", *abi) - client.ContractStore.AddBIN("LinkToken", common.FromHex(link_token_interface.LinkTokenMetaData.Bin)) - - linkToken, err := link_token_interface.NewLinkToken(address, wrappers.MustNewWrappedContractBackend(nil, client)) +func (v *LegacyEthereumMockETHLINKFeed) LatestRoundDataUpdatedAt() (*big.Int, error) { + data, err := v.feed.LatestRoundData(&bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: context.Background(), + }) if err != nil { - return &EthereumLinkToken{}, fmt.Errorf("failed to instantiate LinkToken instance: %w", err) + return nil, err } + return data.UpdatedAt, nil +} - return &EthereumLinkToken{ - client: client, - instance: linkToken, - address: address, - l: l, - }, nil +// LegacyEthereumMockGASFeed represents mocked Gas feed contract +type LegacyEthereumMockGASFeed struct { + client blockchain.EVMClient + feed *mock_gas_aggregator_wrapper.MockGASAggregator + address *common.Address } -// Fund the LINK Token contract with ETH to distribute the token -func (l *EthereumLinkToken) Fund(_ *big.Float) error { - panic("do not use this function, use actions.SendFunds instead") +func (v *LegacyEthereumMockGASFeed) Address() string { + return v.address.Hex() } -func (l *EthereumLinkToken) BalanceOf(ctx context.Context, addr string) (*big.Int, error) { - return l.instance.BalanceOf(&bind.CallOpts{ - From: l.client.Addresses[0], - Context: ctx, - }, common.HexToAddress(addr)) +// EthereumFlags represents flags contract +type EthereumFlags struct { + client blockchain.EVMClient + flags *flags_wrapper.Flags + address *common.Address +} +func (e *EthereumFlags) Address() string { + return e.address.Hex() } -// Name returns the name of the link token -func (l *EthereumLinkToken) Name(ctx context.Context) (string, error) { - return l.instance.Name(&bind.CallOpts{ - From: l.client.Addresses[0], +// GetFlag returns boolean if a flag was set for particular address +func (e *EthereumFlags) GetFlag(ctx context.Context, addr string) (bool, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), Context: ctx, - }) + } + flag, err := e.flags.GetFlag(opts, common.HexToAddress(addr)) + if err != nil { + return false, err + } + return flag, nil } -func (l *EthereumLinkToken) Address() string { - return l.address.Hex() +// LegacyEthereumOperatorFactory represents operator factory contract +// Deprecated: we are moving away from blockchain.EVMClient, use EthereumOperatorFactory instead +type LegacyEthereumOperatorFactory struct { + address *common.Address + client blockchain.EVMClient + operatorFactory *operator_factory.OperatorFactory } -func (l *EthereumLinkToken) Approve(to string, amount *big.Int) error { - l.l.Info(). - Str("From", l.client.Addresses[0].Hex()). - Str("To", to). - Str("Amount", amount.String()). - Msg("Approving LINK Transfer") - _, err := l.client.Decode(l.instance.Approve(l.client.NewTXOpts(), common.HexToAddress(to), amount)) - return err +func (e *LegacyEthereumOperatorFactory) ParseAuthorizedForwarderCreated(eventLog types.Log) (*operator_factory.OperatorFactoryAuthorizedForwarderCreated, error) { + return e.operatorFactory.ParseAuthorizedForwarderCreated(eventLog) } -func (l *EthereumLinkToken) Transfer(to string, amount *big.Int) error { - l.l.Info(). - Str("From", l.client.Addresses[0].Hex()). - Str("To", to). - Str("Amount", amount.String()). - Msg("Transferring LINK") - _, err := l.client.Decode(l.instance.Transfer(l.client.NewTXOpts(), common.HexToAddress(to), amount)) - return err +func (e *LegacyEthereumOperatorFactory) ParseOperatorCreated(eventLog types.Log) (*operator_factory.OperatorFactoryOperatorCreated, error) { + return e.operatorFactory.ParseOperatorCreated(eventLog) } -func (l *EthereumLinkToken) TransferAndCall(to string, amount *big.Int, data []byte) (*types.Transaction, error) { - l.l.Info(). - Str("From", l.client.Addresses[0].Hex()). - Str("To", to). - Str("Amount", amount.String()). - Msg("Transferring and Calling LINK") - decodedTx, err := l.client.Decode(l.instance.TransferAndCall(l.client.NewTXOpts(), common.HexToAddress(to), amount, data)) +func (e *LegacyEthereumOperatorFactory) Address() string { + return e.address.Hex() +} + +func (e *LegacyEthereumOperatorFactory) DeployNewOperatorAndForwarder() (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { return nil, err } - return decodedTx.Transaction, nil -} - -func (l *EthereumLinkToken) TransferAndCallFromKey(to string, amount *big.Int, data []byte, keyNum int) (*types.Transaction, error) { - l.l.Info(). - Str("From", l.client.Addresses[keyNum].Hex()). - Str("To", to). - Str("Amount", amount.String()). - Msg("Transferring and Calling LINK") - decodedTx, err := l.client.Decode(l.instance.TransferAndCall(l.client.NewTXKeyOpts(keyNum), common.HexToAddress(to), amount, data)) + tx, err := e.operatorFactory.DeployNewOperatorAndForwarder(opts) if err != nil { return nil, err } - return decodedTx.Transaction, nil + return tx, nil } -// DeployFluxAggregatorContract deploys the Flux Aggregator Contract on an EVM chain -func DeployFluxAggregatorContract( - seth *seth.Client, - linkAddr string, - fluxOptions FluxAggregatorOptions, -) (FluxAggregator, error) { - abi, err := flux_aggregator_wrapper.FluxAggregatorMetaData.GetAbi() - if err != nil { - return &EthereumFluxAggregator{}, fmt.Errorf("failed to get FluxAggregator ABI: %w", err) - } - seth.ContractStore.AddABI("FluxAggregator", *abi) - seth.ContractStore.AddBIN("FluxAggregator", common.FromHex(flux_aggregator_wrapper.FluxAggregatorMetaData.Bin)) +// LegacyEthereumOperator represents operator contract +// Deprecated: we are moving away from blockchain.EVMClient, use EthereumOperator instead +type LegacyEthereumOperator struct { + address common.Address + client blockchain.EVMClient + operator *operator_wrapper.Operator + l zerolog.Logger +} - fluxDeploymentData, err := seth.DeployContract(seth.NewTXOpts(), "FluxAggregator", *abi, common.FromHex(flux_aggregator_wrapper.FluxAggregatorMetaData.Bin), - common.HexToAddress(linkAddr), - fluxOptions.PaymentAmount, - fluxOptions.Timeout, - fluxOptions.Validator, - fluxOptions.MinSubValue, - fluxOptions.MaxSubValue, - fluxOptions.Decimals, - fluxOptions.Description, - ) +func (e *LegacyEthereumOperator) Address() string { + return e.address.Hex() +} +func (e *LegacyEthereumOperator) AcceptAuthorizedReceivers(forwarders []common.Address, eoa []common.Address) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumFluxAggregator{}, fmt.Errorf("FluxAggregator instance deployment have failed: %w", err) + return err } - - flux, err := flux_aggregator_wrapper.NewFluxAggregator(fluxDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) + e.l.Info(). + Str("ForwardersAddresses", fmt.Sprint(forwarders)). + Str("EoaAddresses", fmt.Sprint(eoa)). + Msg("Accepting Authorized Receivers") + tx, err := e.operator.AcceptAuthorizedReceivers(opts, forwarders, eoa) if err != nil { - return &EthereumFluxAggregator{}, fmt.Errorf("failed to instantiate FluxAggregator instance: %w", err) + return err } - - return &EthereumFluxAggregator{ - client: seth, - address: &fluxDeploymentData.Address, - fluxAggregator: flux, - }, nil + return e.client.ProcessTransaction(tx) } -// EthereumFluxAggregator represents the basic flux aggregation contract -type EthereumFluxAggregator struct { - client *seth.Client - fluxAggregator *flux_aggregator_wrapper.FluxAggregator - address *common.Address +// LegacyEthereumAuthorizedForwarder represents authorized forwarder contract +// Deprecated: we are moving away from blockchain.EVMClient, use EthereumAuthorizedForwarder instead +type LegacyEthereumAuthorizedForwarder struct { + address common.Address + client blockchain.EVMClient + authorizedForwarder *authorized_forwarder.AuthorizedForwarder } -func (f *EthereumFluxAggregator) Address() string { - return f.address.Hex() -} +// Owner return authorized forwarder owner address +func (e *LegacyEthereumAuthorizedForwarder) Owner(ctx context.Context) (string, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: ctx, + } + owner, err := e.authorizedForwarder.Owner(opts) -// Fund sends specified currencies to the contract -func (f *EthereumFluxAggregator) Fund(_ *big.Float) error { - panic("do not use this function, use actions.SendFunds() instead, otherwise we will have to deal with circular dependencies") + return owner.Hex(), err } -func (f *EthereumFluxAggregator) UpdateAvailableFunds() error { - _, err := f.client.Decode(f.fluxAggregator.UpdateAvailableFunds(f.client.NewTXOpts())) - return err +func (e *LegacyEthereumAuthorizedForwarder) GetAuthorizedSenders(ctx context.Context) ([]string, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: ctx, + } + authorizedSenders, err := e.authorizedForwarder.GetAuthorizedSenders(opts) + if err != nil { + return nil, err + } + var sendersAddrs []string + for _, o := range authorizedSenders { + sendersAddrs = append(sendersAddrs, o.Hex()) + } + return sendersAddrs, nil } -func (f *EthereumFluxAggregator) PaymentAmount(ctx context.Context) (*big.Int, error) { - return f.fluxAggregator.PaymentAmount(&bind.CallOpts{ - From: f.client.Addresses[0], - Context: ctx, - }) +func (e *LegacyEthereumAuthorizedForwarder) Address() string { + return e.address.Hex() } -func (f *EthereumFluxAggregator) RequestNewRound(context.Context) error { - _, err := f.client.Decode(f.fluxAggregator.RequestNewRound(f.client.NewTXOpts())) - return err +// EthereumMockAggregatorProxy represents mock aggregator proxy contract +type EthereumMockAggregatorProxy struct { + address *common.Address + client blockchain.EVMClient + mockAggregatorProxy *mock_aggregator_proxy.MockAggregatorProxy } -// WatchSubmissionReceived subscribes to any submissions on a flux feed -func (f *EthereumFluxAggregator) WatchSubmissionReceived(_ context.Context, _ chan<- *SubmissionEvent) error { - panic("do not use this method, instead use XXXX") +func (e *EthereumMockAggregatorProxy) Address() string { + return e.address.Hex() } -func (f *EthereumFluxAggregator) SetRequesterPermissions(_ context.Context, addr common.Address, authorized bool, roundsDelay uint32) error { - _, err := f.client.Decode(f.fluxAggregator.SetRequesterPermissions(f.client.NewTXOpts(), addr, authorized, roundsDelay)) - return err +func (e *EthereumMockAggregatorProxy) UpdateAggregator(aggregator common.Address) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := e.mockAggregatorProxy.UpdateAggregator(opts, aggregator) + if err != nil { + return err + } + return e.client.ProcessTransaction(tx) } -func (f *EthereumFluxAggregator) GetOracles(ctx context.Context) ([]string, error) { - addresses, err := f.fluxAggregator.GetOracles(&bind.CallOpts{ - From: f.client.Addresses[0], - Context: ctx, +func (e *EthereumMockAggregatorProxy) Aggregator() (common.Address, error) { + addr, err := e.mockAggregatorProxy.Aggregator(&bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: context.Background(), }) if err != nil { - return nil, err + return common.Address{}, err } - var oracleAddrs []string - for _, o := range addresses { - oracleAddrs = append(oracleAddrs, o.Hex()) + return addr, nil +} + +func channelClosed(ch <-chan struct{}) bool { + select { + case <-ch: + return true + default: } - return oracleAddrs, nil + + return false } -func (f *EthereumFluxAggregator) LatestRoundID(ctx context.Context) (*big.Int, error) { - return f.fluxAggregator.LatestRound(&bind.CallOpts{ - From: f.client.Addresses[0], - Context: ctx, - }) +// Deprecated: we are moving away from blockchain.EVMClient, use EthereumOffchainAggregatorV2 instead +type LegacyEthereumOffchainAggregatorV2 struct { + address *common.Address + client blockchain.EVMClient + contract *ocr2aggregator.OCR2Aggregator + l zerolog.Logger } -func (f *EthereumFluxAggregator) WithdrawPayment( - _ context.Context, - from common.Address, - to common.Address, - amount *big.Int) error { - _, err := f.client.Decode(f.fluxAggregator.WithdrawPayment(f.client.NewTXOpts(), from, to, amount)) - return err +// OCRv2Config represents the config for the OCRv2 contract +type OCRv2Config struct { + Signers []common.Address + Transmitters []common.Address + F uint8 + OnchainConfig []byte + TypedOnchainConfig21 i_keeper_registry_master_wrapper_2_1.IAutomationV21PlusCommonOnchainConfigLegacy + TypedOnchainConfig22 i_automation_registry_master_wrapper_2_2.AutomationRegistryBase22OnchainConfig + TypedOnchainConfig23 i_automation_registry_master_wrapper_2_3.AutomationRegistryBase23OnchainConfig + OffchainConfigVersion uint64 + OffchainConfig []byte + BillingTokens []common.Address + BillingConfigs []i_automation_registry_master_wrapper_2_3.AutomationRegistryBase23BillingConfig } -func (f *EthereumFluxAggregator) WithdrawablePayment(ctx context.Context, addr common.Address) (*big.Int, error) { - return f.fluxAggregator.WithdrawablePayment(&bind.CallOpts{ - From: f.client.Addresses[0], - Context: ctx, - }, addr) +func (e *LegacyEthereumOffchainAggregatorV2) Address() string { + return e.address.Hex() } -func (f *EthereumFluxAggregator) LatestRoundData(ctx context.Context) (flux_aggregator_wrapper.LatestRoundData, error) { - return f.fluxAggregator.LatestRoundData(&bind.CallOpts{ - From: f.client.Addresses[0], - Context: ctx, - }) +func (e *LegacyEthereumOffchainAggregatorV2) RequestNewRound() error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := e.contract.RequestNewRound(opts) + if err != nil { + return err + } + return e.client.ProcessTransaction(tx) } -// GetContractData retrieves basic data for the flux aggregator contract -func (f *EthereumFluxAggregator) GetContractData(ctx context.Context) (*FluxAggregatorData, error) { +func (e *LegacyEthereumOffchainAggregatorV2) GetLatestAnswer(ctx context.Context) (*big.Int, error) { opts := &bind.CallOpts{ - From: f.client.Addresses[0], + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), Context: ctx, } + return e.contract.LatestAnswer(opts) +} - allocated, err := f.fluxAggregator.AllocatedFunds(opts) - if err != nil { - return &FluxAggregatorData{}, err +func (e *LegacyEthereumOffchainAggregatorV2) GetLatestRound(ctx context.Context) (*RoundData, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: ctx, } - - available, err := f.fluxAggregator.AvailableFunds(opts) + data, err := e.contract.LatestRoundData(opts) if err != nil { - return &FluxAggregatorData{}, err + return nil, err } + return &RoundData{ + RoundId: data.RoundId, + StartedAt: data.StartedAt, + UpdatedAt: data.UpdatedAt, + AnsweredInRound: data.AnsweredInRound, + Answer: data.Answer, + }, nil +} - lr, err := f.fluxAggregator.LatestRoundData(opts) - if err != nil { - return &FluxAggregatorData{}, err +func (e *LegacyEthereumOffchainAggregatorV2) GetRound(ctx context.Context, roundID *big.Int) (*RoundData, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: ctx, } - latestRound := RoundData(lr) - - oracles, err := f.fluxAggregator.GetOracles(opts) + data, err := e.contract.GetRoundData(opts, roundID) if err != nil { - return &FluxAggregatorData{}, err + return nil, err } - - return &FluxAggregatorData{ - AllocatedFunds: allocated, - AvailableFunds: available, - LatestRoundData: latestRound, - Oracles: oracles, + return &RoundData{ + RoundId: data.RoundId, + StartedAt: data.StartedAt, + UpdatedAt: data.UpdatedAt, + AnsweredInRound: data.AnsweredInRound, + Answer: data.Answer, }, nil } -// SetOracles allows the ability to add and/or remove oracles from the contract, and to set admins -func (f *EthereumFluxAggregator) SetOracles(o FluxAggregatorSetOraclesOptions) error { - _, err := f.client.Decode(f.fluxAggregator.ChangeOracles(f.client.NewTXOpts(), o.RemoveList, o.AddList, o.AdminList, o.MinSubmissions, o.MaxSubmissions, o.RestartDelayRounds)) +func (e *LegacyEthereumOffchainAggregatorV2) SetPayees(transmitters, payees []string) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { return err } - return err -} + e.l.Info(). + Str("Transmitters", fmt.Sprintf("%v", transmitters)). + Str("Payees", fmt.Sprintf("%v", payees)). + Str("OCRv2 Address", e.Address()). + Msg("Setting OCRv2 Payees") -// Description returns the description of the flux aggregator contract -func (f *EthereumFluxAggregator) Description(ctxt context.Context) (string, error) { - return f.fluxAggregator.Description(&bind.CallOpts{ - From: f.client.Addresses[0], - Context: ctxt, - }) -} + var addTransmitters, addrPayees []common.Address + for _, t := range transmitters { + addTransmitters = append(addTransmitters, common.HexToAddress(t)) + } + for _, p := range payees { + addrPayees = append(addrPayees, common.HexToAddress(p)) + } -func DeployOracle(seth *seth.Client, linkAddr string) (Oracle, error) { - abi, err := oracle_wrapper.OracleMetaData.GetAbi() + tx, err := e.contract.SetPayees(opts, addTransmitters, addrPayees) if err != nil { - return &EthereumOracle{}, fmt.Errorf("failed to get Oracle ABI: %w", err) + return err } - seth.ContractStore.AddABI("Oracle", *abi) - seth.ContractStore.AddBIN("Oracle", common.FromHex(oracle_wrapper.OracleMetaData.Bin)) - - oracleDeploymentData, err := seth.DeployContract(seth.NewTXOpts(), "Oracle", *abi, common.FromHex(oracle_wrapper.OracleMetaData.Bin), - common.HexToAddress(linkAddr), - ) + return e.client.ProcessTransaction(tx) +} +func (e *LegacyEthereumOffchainAggregatorV2) SetConfig(ocrConfig *OCRv2Config) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumOracle{}, fmt.Errorf("Oracle instance deployment have failed: %w", err) + return err } - - oracle, err := oracle_wrapper.NewOracle(oracleDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) + e.l.Info(). + Str("Address", e.Address()). + Interface("Signers", ocrConfig.Signers). + Interface("Transmitters", ocrConfig.Transmitters). + Uint8("F", ocrConfig.F). + Bytes("OnchainConfig", ocrConfig.OnchainConfig). + Uint64("OffchainConfigVersion", ocrConfig.OffchainConfigVersion). + Bytes("OffchainConfig", ocrConfig.OffchainConfig). + Msg("Setting OCRv2 Config") + tx, err := e.contract.SetConfig( + opts, + ocrConfig.Signers, + ocrConfig.Transmitters, + ocrConfig.F, + ocrConfig.OnchainConfig, + ocrConfig.OffchainConfigVersion, + ocrConfig.OffchainConfig, + ) if err != nil { - return &EthereumOracle{}, fmt.Errorf("Oracle to instantiate FluxAggregator instance: %w", err) + return err } + return e.client.ProcessTransaction(tx) +} - return &EthereumOracle{ - client: seth, - address: &oracleDeploymentData.Address, - oracle: oracle, - }, nil +func (e *LegacyEthereumOffchainAggregatorV2) ParseEventAnswerUpdated(log types.Log) (*ocr2aggregator.OCR2AggregatorAnswerUpdated, error) { + return e.contract.ParseAnswerUpdated(log) } -// EthereumOracle oracle for "directrequest" job tests -type EthereumOracle struct { - address *common.Address - client *seth.Client - oracle *oracle_wrapper.Oracle +// EthereumKeeperRegistryCheckUpkeepGasUsageWrapper represents a gas wrapper for keeper registry +type EthereumKeeperRegistryCheckUpkeepGasUsageWrapper struct { + address *common.Address + client blockchain.EVMClient + gasUsageWrapper *gas_wrapper.KeeperRegistryCheckUpkeepGasUsageWrapper } -func (e *EthereumOracle) Address() string { +func (e *EthereumKeeperRegistryCheckUpkeepGasUsageWrapper) Address() string { return e.address.Hex() } -func (e *EthereumOracle) Fund(_ *big.Float) error { - panic("do not use this function, use actions.SendFunds() instead, otherwise we will have to deal with circular dependencies") +/* Functions 1_0_0 */ + +type LegacyEthereumFunctionsRouter struct { + address common.Address + client blockchain.EVMClient + instance *functions_router.FunctionsRouter + l zerolog.Logger } -// SetFulfillmentPermission sets fulfillment permission for particular address -func (e *EthereumOracle) SetFulfillmentPermission(address string, allowed bool) error { - _, err := e.client.Decode(e.oracle.SetFulfillmentPermission(e.client.NewTXOpts(), common.HexToAddress(address), allowed)) - return err +func (e *LegacyEthereumFunctionsRouter) Address() string { + return e.address.Hex() } -func DeployAPIConsumer(seth *seth.Client, linkAddr string) (APIConsumer, error) { - abi, err := test_api_consumer_wrapper.TestAPIConsumerMetaData.GetAbi() +func (e *LegacyEthereumFunctionsRouter) CreateSubscriptionWithConsumer(consumer string) (uint64, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumAPIConsumer{}, fmt.Errorf("failed to get TestAPIConsumer ABI: %w", err) + return 0, err } - seth.ContractStore.AddABI("TestAPIConsumer", *abi) - seth.ContractStore.AddBIN("TestAPIConsumer", common.FromHex(test_api_consumer_wrapper.TestAPIConsumerMetaData.Bin)) - - consumerDeploymentData, err := seth.DeployContract(seth.NewTXOpts(), "TestAPIConsumer", *abi, common.FromHex(test_api_consumer_wrapper.TestAPIConsumerMetaData.Bin), - common.HexToAddress(linkAddr), - ) + tx, err := e.instance.CreateSubscriptionWithConsumer(opts, common.HexToAddress(consumer)) + if err != nil { + return 0, err + } + if err := e.client.ProcessTransaction(tx); err != nil { + return 0, err + } + r, err := e.client.GetTxReceipt(tx.Hash()) + if err != nil { + return 0, err + } + for _, l := range r.Logs { + e.l.Info().Interface("Log", common.Bytes2Hex(l.Data)).Send() + } + topicsMap := map[string]interface{}{} + fabi, err := abi.JSON(strings.NewReader(functions_router.FunctionsRouterABI)) if err != nil { - return &EthereumAPIConsumer{}, fmt.Errorf("TestAPIConsumer instance deployment have failed: %w", err) + return 0, err + } + for _, ev := range fabi.Events { + e.l.Info().Str("EventName", ev.Name).Send() + } + topicOneInputs := abi.Arguments{fabi.Events["SubscriptionCreated"].Inputs[0]} + topicOneHash := []common.Hash{r.Logs[0].Topics[1:][0]} + if err := abi.ParseTopicsIntoMap(topicsMap, topicOneInputs, topicOneHash); err != nil { + return 0, fmt.Errorf("failed to decode topic value, err: %w", err) } - - consumer, err := test_api_consumer_wrapper.NewTestAPIConsumer(consumerDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) - if err != nil { - return &EthereumAPIConsumer{}, fmt.Errorf("failed to instantiate TestAPIConsumer instance: %w", err) + e.l.Info().Interface("NewTopicsDecoded", topicsMap).Send() + if topicsMap["subscriptionId"] == 0 { + return 0, fmt.Errorf("failed to decode subscription ID after creation") } - - return &EthereumAPIConsumer{ - client: seth, - address: &consumerDeploymentData.Address, - consumer: consumer, - }, nil + return topicsMap["subscriptionId"].(uint64), nil } -// EthereumAPIConsumer API consumer for job type "directrequest" tests -type EthereumAPIConsumer struct { - address *common.Address - client *seth.Client - consumer *test_api_consumer_wrapper.TestAPIConsumer +type LegacyEthereumFunctionsCoordinator struct { + address common.Address + client blockchain.EVMClient + instance *functions_coordinator.FunctionsCoordinator } -func (e *EthereumAPIConsumer) Address() string { - return e.address.Hex() +func (e *LegacyEthereumFunctionsCoordinator) GetThresholdPublicKey() ([]byte, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: context.Background(), + } + return e.instance.GetThresholdPublicKey(opts) } -func (e *EthereumAPIConsumer) RoundID(ctx context.Context) (*big.Int, error) { - return e.consumer.CurrentRoundID(&bind.CallOpts{ - From: e.client.Addresses[0], - Context: ctx, - }) +func (e *LegacyEthereumFunctionsCoordinator) GetDONPublicKey() ([]byte, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: context.Background(), + } + return e.instance.GetDONPublicKey(opts) } -func (e *EthereumAPIConsumer) Fund(_ *big.Float) error { - panic("do not use this function, use actions.SendFunds() instead, otherwise we will have to deal with circular dependencies") +func (e *LegacyEthereumFunctionsCoordinator) Address() string { + return e.address.Hex() } -func (e *EthereumAPIConsumer) Data(ctx context.Context) (*big.Int, error) { - return e.consumer.Data(&bind.CallOpts{ - From: e.client.Addresses[0], - Context: ctx, - }) +type LegacyEthereumFunctionsLoadTestClient struct { + address common.Address + client blockchain.EVMClient + instance *functions_load_test_client.FunctionsLoadTestClient } -// CreateRequestTo creates request to an oracle for particular jobID with params -func (e *EthereumAPIConsumer) CreateRequestTo( - oracleAddr string, - jobID [32]byte, - payment *big.Int, - url string, - path string, - times *big.Int, -) error { - _, err := e.client.Decode(e.consumer.CreateRequestTo(e.client.NewTXOpts(), common.HexToAddress(oracleAddr), jobID, payment, url, path, times)) - return err +func (e *LegacyEthereumFunctionsLoadTestClient) Address() string { + return e.address.Hex() } -// EthereumMockETHLINKFeed represents mocked ETH/LINK feed contract -type EthereumMockETHLINKFeed struct { - client *seth.Client - feed *mock_ethlink_aggregator_wrapper.MockETHLINKAggregator - address *common.Address +type EthereumFunctionsLoadStats struct { + LastRequestID string + LastResponse string + LastError string + Total uint32 + Succeeded uint32 + Errored uint32 + Empty uint32 } -func (v *EthereumMockETHLINKFeed) Address() string { - return v.address.Hex() +func Bytes32ToSlice(a [32]byte) (r []byte) { + r = append(r, a[:]...) + return } -func (v *EthereumMockETHLINKFeed) LatestRoundData() (*big.Int, error) { - data, err := v.feed.LatestRoundData(&bind.CallOpts{ - From: v.client.Addresses[0], +func (e *LegacyEthereumFunctionsLoadTestClient) GetStats() (*EthereumFunctionsLoadStats, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), Context: context.Background(), - }) - if err != nil { - return nil, err } - return data.Ans, nil -} - -func (v *EthereumMockETHLINKFeed) LatestRoundDataUpdatedAt() (*big.Int, error) { - data, err := v.feed.LatestRoundData(&bind.CallOpts{ - From: v.client.Addresses[0], - Context: context.Background(), - }) + lr, lbody, lerr, total, succeeded, errored, empty, err := e.instance.GetStats(opts) if err != nil { return nil, err } - return data.UpdatedAt, nil + return &EthereumFunctionsLoadStats{ + LastRequestID: string(Bytes32ToSlice(lr)), + LastResponse: string(lbody), + LastError: string(lerr), + Total: total, + Succeeded: succeeded, + Errored: errored, + Empty: empty, + }, nil } -func DeployMockETHLINKFeed(client *seth.Client, answer *big.Int) (MockETHLINKFeed, error) { - abi, err := mock_ethlink_aggregator_wrapper.MockETHLINKAggregatorMetaData.GetAbi() +func (e *LegacyEthereumFunctionsLoadTestClient) ResetStats() error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumMockETHLINKFeed{}, fmt.Errorf("failed to get MockETHLINKFeed ABI: %w", err) + return err } - data, err := client.DeployContract(client.NewTXOpts(), "MockETHLINKFeed", *abi, common.FromHex(mock_ethlink_aggregator_wrapper.MockETHLINKAggregatorMetaData.Bin), answer) + tx, err := e.instance.ResetStats(opts) if err != nil { - return &EthereumMockETHLINKFeed{}, fmt.Errorf("MockETHLINKFeed instance deployment have failed: %w", err) + return err } + return e.client.ProcessTransaction(tx) +} - instance, err := mock_ethlink_aggregator_wrapper.NewMockETHLINKAggregator(data.Address, wrappers.MustNewWrappedContractBackend(nil, client)) +func (e *LegacyEthereumFunctionsLoadTestClient) SendRequest(times uint32, source string, encryptedSecretsReferences []byte, args []string, subscriptionId uint64, jobId [32]byte) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumMockETHLINKFeed{}, fmt.Errorf("failed to instantiate MockETHLINKFeed instance: %w", err) + return err } - - return &EthereumMockETHLINKFeed{ - address: &data.Address, - client: client, - feed: instance, - }, nil + tx, err := e.instance.SendRequest(opts, times, source, encryptedSecretsReferences, args, subscriptionId, jobId) + if err != nil { + return err + } + return e.client.ProcessTransaction(tx) } -func LoadMockETHLINKFeed(client *seth.Client, address common.Address) (MockETHLINKFeed, error) { - abi, err := mock_ethlink_aggregator_wrapper.MockETHLINKAggregatorMetaData.GetAbi() +func (e *LegacyEthereumFunctionsLoadTestClient) SendRequestWithDONHostedSecrets(times uint32, source string, slotID uint8, slotVersion uint64, args []string, subscriptionId uint64, donID [32]byte) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumMockETHLINKFeed{}, fmt.Errorf("failed to get MockETHLINKFeed ABI: %w", err) + return err } - client.ContractStore.AddABI("MockETHLINKFeed", *abi) - client.ContractStore.AddBIN("MockETHLINKFeed", common.FromHex(mock_ethlink_aggregator_wrapper.MockETHLINKAggregatorMetaData.Bin)) - - instance, err := mock_ethlink_aggregator_wrapper.NewMockETHLINKAggregator(address, wrappers.MustNewWrappedContractBackend(nil, client)) + tx, err := e.instance.SendRequestWithDONHostedSecrets(opts, times, source, slotID, slotVersion, args, subscriptionId, donID) if err != nil { - return &EthereumMockETHLINKFeed{}, fmt.Errorf("failed to instantiate MockETHLINKFeed instance: %w", err) + return err } + return e.client.ProcessTransaction(tx) +} - return &EthereumMockETHLINKFeed{ - address: &address, - client: client, - feed: instance, - }, nil +type EthereumMercuryVerifier struct { + address common.Address + client blockchain.EVMClient + instance *verifier.Verifier + l zerolog.Logger } -// EthereumMockGASFeed represents mocked Gas feed contract -type EthereumMockGASFeed struct { - client *seth.Client - feed *mock_gas_aggregator_wrapper.MockGASAggregator - address *common.Address +func (e *EthereumMercuryVerifier) Address() common.Address { + return e.address } -func (v *EthereumMockGASFeed) Address() string { - return v.address.Hex() +func (e *EthereumMercuryVerifier) Verify(signedReport []byte, sender common.Address) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := e.instance.Verify(opts, signedReport, sender) + if err != nil { + return err + } + return e.client.ProcessTransaction(tx) } -func DeployMockGASFeed(client *seth.Client, answer *big.Int) (MockGasFeed, error) { - abi, err := mock_gas_aggregator_wrapper.MockGASAggregatorMetaData.GetAbi() +func (e *EthereumMercuryVerifier) SetConfig(feedId [32]byte, signers []common.Address, offchainTransmitters [][32]byte, f uint8, onchainConfig []byte, offchainConfigVersion uint64, offchainConfig []byte, recipientAddressesAndWeights []verifier.CommonAddressAndWeight) (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumMockGASFeed{}, fmt.Errorf("failed to get MockGasFeed ABI: %w", err) + return nil, err } - data, err := client.DeployContract(client.NewTXOpts(), "MockGasFeed", *abi, common.FromHex(mock_gas_aggregator_wrapper.MockGASAggregatorMetaData.Bin), answer) + tx, err := e.instance.SetConfig(opts, feedId, signers, offchainTransmitters, f, onchainConfig, offchainConfigVersion, offchainConfig, recipientAddressesAndWeights) + e.l.Info().Err(err).Str("contractAddress", e.address.Hex()).Hex("feedId", feedId[:]).Msg("Called EthereumMercuryVerifier.SetConfig()") if err != nil { - return &EthereumMockGASFeed{}, fmt.Errorf("MockGasFeed instance deployment have failed: %w", err) + return nil, err } + return tx, e.client.ProcessTransaction(tx) +} - instance, err := mock_gas_aggregator_wrapper.NewMockGASAggregator(data.Address, wrappers.MustNewWrappedContractBackend(nil, client)) +func (e *EthereumMercuryVerifier) LatestConfigDetails(ctx context.Context, feedId [32]byte) (verifier.LatestConfigDetails, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: ctx, + } + d, err := e.instance.LatestConfigDetails(opts, feedId) + e.l.Info().Err(err).Str("contractAddress", e.address.Hex()).Hex("feedId", feedId[:]). + Interface("details", d). + Msg("Called EthereumMercuryVerifier.LatestConfigDetails()") if err != nil { - return &EthereumMockGASFeed{}, fmt.Errorf("failed to instantiate MockGasFeed instance: %w", err) + return verifier.LatestConfigDetails{}, err } + return d, nil +} - return &EthereumMockGASFeed{ - address: &data.Address, - client: client, - feed: instance, - }, nil +type EthereumMercuryVerifierProxy struct { + address common.Address + client blockchain.EVMClient + instance *verifier_proxy.VerifierProxy + l zerolog.Logger +} + +func (e *EthereumMercuryVerifierProxy) Address() common.Address { + return e.address } -func LoadMockGASFeed(client *seth.Client, address common.Address) (MockGasFeed, error) { - abi, err := mock_gas_aggregator_wrapper.MockGASAggregatorMetaData.GetAbi() +func (e *EthereumMercuryVerifierProxy) InitializeVerifier(verifierAddress common.Address) (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumMockGASFeed{}, fmt.Errorf("failed to get MockGasFeed ABI: %w", err) + return nil, err } - client.ContractStore.AddABI("MockGasFeed", *abi) - client.ContractStore.AddBIN("MockGasFeed", common.FromHex(mock_gas_aggregator_wrapper.MockGASAggregatorMetaData.Bin)) - - instance, err := mock_gas_aggregator_wrapper.NewMockGASAggregator(address, wrappers.MustNewWrappedContractBackend(nil, client)) + tx, err := e.instance.InitializeVerifier(opts, verifierAddress) + e.l.Info().Err(err).Str("contractAddress", e.address.Hex()).Str("verifierAddress", verifierAddress.Hex()). + Msg("Called EthereumMercuryVerifierProxy.InitializeVerifier()") if err != nil { - return &EthereumMockGASFeed{}, fmt.Errorf("failed to instantiate MockGasFeed instance: %w", err) + return nil, err } - - return &EthereumMockGASFeed{ - address: &address, - client: client, - feed: instance, - }, nil + return tx, e.client.ProcessTransaction(tx) } -func DeployMultiCallContract(client *seth.Client) (common.Address, error) { - abi, err := abi.JSON(strings.NewReader(MultiCallABI)) +func (e *EthereumMercuryVerifierProxy) Verify(signedReport []byte, parameterPayload []byte, value *big.Int) (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) + if value != nil { + opts.Value = value + } if err != nil { - return common.Address{}, err + return nil, err } - - data, err := client.DeployContract(client.NewTXOpts(), "MultiCall", abi, common.FromHex(MultiCallBIN)) + tx, err := e.instance.Verify(opts, signedReport, parameterPayload) if err != nil { - return common.Address{}, fmt.Errorf("MultiCall instance deployment have failed: %w", err) + return nil, err } - - return data.Address, nil + return tx, e.client.ProcessTransaction(tx) } -func LoadFunctionsCoordinator(seth *seth.Client, addr string) (FunctionsCoordinator, error) { - abi, err := functions_coordinator.FunctionsCoordinatorMetaData.GetAbi() +func (e *EthereumMercuryVerifierProxy) VerifyBulk(signedReports [][]byte, parameterPayload []byte, value *big.Int) (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) + if value != nil { + opts.Value = value + } + if err != nil { + return nil, err + } + tx, err := e.instance.VerifyBulk(opts, signedReports, parameterPayload) if err != nil { - return &EthereumFunctionsCoordinator{}, fmt.Errorf("failed to get FunctionsCoordinator ABI: %w", err) + return nil, err } - seth.ContractStore.AddABI("FunctionsCoordinator", *abi) - seth.ContractStore.AddBIN("FunctionsCoordinator", common.FromHex(functions_coordinator.FunctionsCoordinatorMetaData.Bin)) + return tx, e.client.ProcessTransaction(tx) +} - instance, err := functions_coordinator.NewFunctionsCoordinator(common.HexToAddress(addr), seth.Client) +func (e *EthereumMercuryVerifierProxy) SetFeeManager(feeManager common.Address) (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumFunctionsCoordinator{}, fmt.Errorf("failed to instantiate FunctionsCoordinator instance: %w", err) + return nil, err } - - return &EthereumFunctionsCoordinator{ - client: seth, - instance: instance, - address: common.HexToAddress(addr), - }, err + tx, err := e.instance.SetFeeManager(opts, feeManager) + e.l.Info().Err(err).Str("feeManager", feeManager.Hex()).Msg("Called MercuryVerifierProxy.SetFeeManager()") + if err != nil { + return nil, err + } + return tx, e.client.ProcessTransaction(tx) } -type EthereumFunctionsCoordinator struct { +type EthereumMercuryFeeManager struct { address common.Address - client *seth.Client - instance *functions_coordinator.FunctionsCoordinator + client blockchain.EVMClient + instance *fee_manager.FeeManager + l zerolog.Logger } -func (e *EthereumFunctionsCoordinator) GetThresholdPublicKey() ([]byte, error) { - return e.instance.GetThresholdPublicKey(e.client.NewCallOpts()) +func (e *EthereumMercuryFeeManager) Address() common.Address { + return e.address +} + +func (e *EthereumMercuryFeeManager) UpdateSubscriberDiscount(subscriber common.Address, feedId [32]byte, token common.Address, discount uint64) (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) + if err != nil { + return nil, err + } + tx, err := e.instance.UpdateSubscriberDiscount(opts, subscriber, feedId, token, discount) + e.l.Info().Err(err).Msg("Called EthereumMercuryFeeManager.UpdateSubscriberDiscount()") + if err != nil { + return nil, err + } + return tx, e.client.ProcessTransaction(tx) } -func (e *EthereumFunctionsCoordinator) GetDONPublicKey() ([]byte, error) { - return e.instance.GetDONPublicKey(e.client.NewCallOpts()) +type EthereumMercuryRewardManager struct { + address common.Address + client blockchain.EVMClient + instance *reward_manager.RewardManager + l zerolog.Logger } -func (e *EthereumFunctionsCoordinator) Address() string { - return e.address.Hex() +func (e *EthereumMercuryRewardManager) Address() common.Address { + return e.address } -func LoadFunctionsRouter(l zerolog.Logger, seth *seth.Client, addr string) (FunctionsRouter, error) { - abi, err := functions_router.FunctionsRouterMetaData.GetAbi() +func (e *EthereumMercuryRewardManager) SetFeeManager(feeManager common.Address) (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumFunctionsRouter{}, fmt.Errorf("failed to get FunctionsRouter ABI: %w", err) + return nil, err } - seth.ContractStore.AddABI("FunctionsRouter", *abi) - seth.ContractStore.AddBIN("FunctionsRouter", common.FromHex(functions_router.FunctionsRouterMetaData.Bin)) - - instance, err := functions_router.NewFunctionsRouter(common.HexToAddress(addr), seth.Client) + tx, err := e.instance.SetFeeManager(opts, feeManager) + e.l.Info().Err(err).Str("feeManager", feeManager.Hex()).Msg("Called EthereumMercuryRewardManager.SetFeeManager()") if err != nil { - return &EthereumFunctionsRouter{}, fmt.Errorf("failed to instantiate FunctionsRouter instance: %w", err) + return nil, err } - - return &EthereumFunctionsRouter{ - client: seth, - instance: instance, - address: common.HexToAddress(addr), - l: l, - }, err + return tx, e.client.ProcessTransaction(tx) } -type EthereumFunctionsRouter struct { +type EthereumWERC20Mock struct { address common.Address - client *seth.Client - instance *functions_router.FunctionsRouter + client blockchain.EVMClient + instance *werc20_mock.WERC20Mock l zerolog.Logger } -func (e *EthereumFunctionsRouter) Address() string { - return e.address.Hex() +func (e *EthereumWERC20Mock) Address() common.Address { + return e.address } -func (e *EthereumFunctionsRouter) CreateSubscriptionWithConsumer(consumer string) (uint64, error) { - tx, err := e.client.Decode(e.instance.CreateSubscriptionWithConsumer(e.client.NewTXOpts(), common.HexToAddress(consumer))) +func (e *EthereumWERC20Mock) Approve(to string, amount *big.Int) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return 0, err + return err } + e.l.Info(). + Str("From", e.client.GetDefaultWallet().Address()). + Str("To", to). + Str("Amount", amount.String()). + Uint64("Nonce", opts.Nonce.Uint64()). + Msg("Approving LINK Transfer") + tx, err := e.instance.Approve(opts, common.HexToAddress(to), amount) + if err != nil { + return err + } + return e.client.ProcessTransaction(tx) +} - if tx.Receipt == nil { - return 0, errors.New("transaction did not err, but the receipt is nil") +func (e *EthereumWERC20Mock) BalanceOf(ctx context.Context, addr string) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(e.client.GetDefaultWallet().Address()), + Context: ctx, } - for _, l := range tx.Receipt.Logs { - e.l.Info().Interface("Log", common.Bytes2Hex(l.Data)).Send() + balance, err := e.instance.BalanceOf(opts, common.HexToAddress(addr)) + if err != nil { + return nil, err } - topicsMap := map[string]interface{}{} + return balance, nil +} - fabi, err := abi.JSON(strings.NewReader(functions_router.FunctionsRouterABI)) +func (e *EthereumWERC20Mock) Transfer(to string, amount *big.Int) error { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return 0, err - } - for _, ev := range fabi.Events { - e.l.Info().Str("EventName", ev.Name).Send() - } - topicOneInputs := abi.Arguments{fabi.Events["SubscriptionCreated"].Inputs[0]} - topicOneHash := []common.Hash{tx.Receipt.Logs[0].Topics[1:][0]} - if err := abi.ParseTopicsIntoMap(topicsMap, topicOneInputs, topicOneHash); err != nil { - return 0, fmt.Errorf("failed to decode topic value, err: %w", err) + return err } - e.l.Info().Interface("NewTopicsDecoded", topicsMap).Send() - if topicsMap["subscriptionId"] == 0 { - return 0, fmt.Errorf("failed to decode subscription ID after creation") + e.l.Info(). + Str("From", e.client.GetDefaultWallet().Address()). + Str("To", to). + Str("Amount", amount.String()). + Uint64("Nonce", opts.Nonce.Uint64()). + Msg("EthereumWERC20Mock.Transfer()") + tx, err := e.instance.Transfer(opts, common.HexToAddress(to), amount) + if err != nil { + return err } - return topicsMap["subscriptionId"].(uint64), nil + return e.client.ProcessTransaction(tx) } -func DeployFunctionsLoadTestClient(seth *seth.Client, router string) (FunctionsLoadTestClient, error) { - operatorAbi, err := functions_load_test_client.FunctionsLoadTestClientMetaData.GetAbi() +func (e *EthereumWERC20Mock) Mint(account common.Address, amount *big.Int) (*types.Transaction, error) { + opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet()) if err != nil { - return &EthereumFunctionsLoadTestClient{}, fmt.Errorf("failed to get FunctionsLoadTestClient ABI: %w", err) + return nil, err } - data, err := seth.DeployContract(seth.NewTXOpts(), "FunctionsLoadTestClient", *operatorAbi, common.FromHex(functions_load_test_client.FunctionsLoadTestClientMetaData.Bin), common.HexToAddress(router)) + e.l.Info(). + Str("account", account.Hex()). + Str("amount", amount.String()). + Msg("EthereumWERC20Mock.Mint()") + tx, err := e.instance.Mint(opts, account, amount) if err != nil { - return &EthereumFunctionsLoadTestClient{}, fmt.Errorf("FunctionsLoadTestClient instance deployment have failed: %w", err) + return tx, err } + return tx, e.client.ProcessTransaction(tx) +} - instance, err := functions_load_test_client.NewFunctionsLoadTestClient(data.Address, seth.Client) - if err != nil { - return &EthereumFunctionsLoadTestClient{}, fmt.Errorf("failed to instantiate FunctionsLoadTestClient instance: %w", err) +func ChainlinkK8sClientToChainlinkNodeWithKeysAndAddress(k8sNodes []*client.ChainlinkK8sClient) []ChainlinkNodeWithKeysAndAddress { + var nodesAsInterface = make([]ChainlinkNodeWithKeysAndAddress, len(k8sNodes)) + for i, node := range k8sNodes { + nodesAsInterface[i] = node } - return &EthereumFunctionsLoadTestClient{ - client: seth, - instance: instance, - address: data.Address, - }, nil + return nodesAsInterface } -// LoadFunctionsLoadTestClient returns deployed on given address FunctionsLoadTestClient contract instance -func LoadFunctionsLoadTestClient(seth *seth.Client, addr string) (FunctionsLoadTestClient, error) { - abi, err := functions_load_test_client.FunctionsLoadTestClientMetaData.GetAbi() - if err != nil { - return &EthereumFunctionsLoadTestClient{}, fmt.Errorf("failed to get FunctionsLoadTestClient ABI: %w", err) - } - seth.ContractStore.AddABI("FunctionsLoadTestClient", *abi) - seth.ContractStore.AddBIN("FunctionsLoadTestClient", common.FromHex(functions_load_test_client.FunctionsLoadTestClientMetaData.Bin)) - - instance, err := functions_load_test_client.NewFunctionsLoadTestClient(common.HexToAddress(addr), seth.Client) - if err != nil { - return &EthereumFunctionsLoadTestClient{}, fmt.Errorf("failed to instantiate FunctionsLoadTestClient instance: %w", err) +func ChainlinkClientToChainlinkNodeWithKeysAndAddress(k8sNodes []*client.ChainlinkClient) []ChainlinkNodeWithKeysAndAddress { + var nodesAsInterface = make([]ChainlinkNodeWithKeysAndAddress, len(k8sNodes)) + for i, node := range k8sNodes { + nodesAsInterface[i] = node } - return &EthereumFunctionsLoadTestClient{ - client: seth, - instance: instance, - address: common.HexToAddress(addr), - }, err + return nodesAsInterface } -type EthereumFunctionsLoadTestClient struct { - address common.Address - client *seth.Client - instance *functions_load_test_client.FunctionsLoadTestClient -} +func V2OffChainAgrregatorToOffChainAggregatorWithRounds(contracts []OffchainAggregatorV2) []OffChainAggregatorWithRounds { + var contractsAsInterface = make([]OffChainAggregatorWithRounds, len(contracts)) + for i, contract := range contracts { + contractsAsInterface[i] = contract + } -func (e *EthereumFunctionsLoadTestClient) Address() string { - return e.address.Hex() + return contractsAsInterface } -func (e *EthereumFunctionsLoadTestClient) GetStats() (*EthereumFunctionsLoadStats, error) { - lr, lbody, lerr, total, succeeded, errored, empty, err := e.instance.GetStats(e.client.NewCallOpts()) - if err != nil { - return nil, err +func V1OffChainAgrregatorToOffChainAggregatorWithRounds(contracts []OffchainAggregator) []OffChainAggregatorWithRounds { + var contractsAsInterface = make([]OffChainAggregatorWithRounds, len(contracts)) + for i, contract := range contracts { + contractsAsInterface[i] = contract } - return &EthereumFunctionsLoadStats{ - LastRequestID: string(Bytes32ToSlice(lr)), - LastResponse: string(lbody), - LastError: string(lerr), - Total: total, - Succeeded: succeeded, - Errored: errored, - Empty: empty, - }, nil -} -func (e *EthereumFunctionsLoadTestClient) ResetStats() error { - _, err := e.client.Decode(e.instance.ResetStats(e.client.NewTXOpts())) - return err + return contractsAsInterface } -func (e *EthereumFunctionsLoadTestClient) SendRequest(times uint32, source string, encryptedSecretsReferences []byte, args []string, subscriptionId uint64, jobId [32]byte) error { - _, err := e.client.Decode(e.instance.SendRequest(e.client.NewTXOpts(), times, source, encryptedSecretsReferences, args, subscriptionId, jobId)) - return err -} +func GetRegistryContractABI(version contractsethereum.KeeperRegistryVersion) (*abi.ABI, error) { + var ( + contractABI *abi.ABI + err error + ) + switch version { + case contractsethereum.RegistryVersion_1_0, contractsethereum.RegistryVersion_1_1: + contractABI, err = keeper_registry_wrapper1_1.KeeperRegistryMetaData.GetAbi() + case contractsethereum.RegistryVersion_1_2: + contractABI, err = keeper_registry_wrapper1_2.KeeperRegistryMetaData.GetAbi() + case contractsethereum.RegistryVersion_1_3: + contractABI, err = keeper_registry_wrapper1_3.KeeperRegistryMetaData.GetAbi() + case contractsethereum.RegistryVersion_2_0: + contractABI, err = keeper_registry_wrapper2_0.KeeperRegistryMetaData.GetAbi() + case contractsethereum.RegistryVersion_2_1: + contractABI, err = iregistry21.IKeeperRegistryMasterMetaData.GetAbi() + case contractsethereum.RegistryVersion_2_2: + contractABI, err = iregistry22.IAutomationRegistryMasterMetaData.GetAbi() + default: + contractABI, err = keeper_registry_wrapper2_0.KeeperRegistryMetaData.GetAbi() + } -func (e *EthereumFunctionsLoadTestClient) SendRequestWithDONHostedSecrets(times uint32, source string, slotID uint8, slotVersion uint64, args []string, subscriptionId uint64, donID [32]byte) error { - _, err := e.client.Decode(e.instance.SendRequestWithDONHostedSecrets(e.client.NewTXOpts(), times, source, slotID, slotVersion, args, subscriptionId, donID)) - return err + return contractABI, err } diff --git a/integration-tests/contracts/ethereum_contracts_automation.go b/integration-tests/contracts/ethereum_contracts_automation.go index 13cad7ffefb..486f19e679f 100644 --- a/integration-tests/contracts/ethereum_contracts_automation.go +++ b/integration-tests/contracts/ethereum_contracts_automation.go @@ -14,6 +14,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/rs/zerolog" + cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" + registrylogicc23 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registry_logic_c_wrapper_2_3" "github.com/smartcontractkit/seth" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" @@ -28,12 +30,20 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_consumer_benchmark" automationForwarderLogic "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_forwarder_logic" registrar21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registrar_wrapper2_1" + registrar23 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registrar_wrapper2_3" registrylogica22 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registry_logic_a_wrapper_2_2" registrylogicb22 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registry_logic_b_wrapper_2_2" registry22 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registry_wrapper_2_2" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/chain_module_base" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_2" iregistry22 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_2" + + registrylogica23 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registry_logic_a_wrapper_2_3" + registrylogicb23 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registry_logic_b_wrapper_2_3" + registry23 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registry_wrapper_2_3" + iregistry23 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3" + + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3" ac "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_v21_plus_common" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_chain_module" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" @@ -127,6 +137,7 @@ type EthereumKeeperRegistry struct { registry2_0 *keeper_registry_wrapper2_0.KeeperRegistry registry2_1 *i_keeper_registry_master_wrapper_2_1.IKeeperRegistryMaster registry2_2 *i_automation_registry_master_wrapper_2_2.IAutomationRegistryMaster + registry2_3 *i_automation_registry_master_wrapper_2_3.IAutomationRegistryMaster23 chainModule *i_chain_module.IChainModule address *common.Address l zerolog.Logger @@ -139,7 +150,7 @@ func (v *EthereumKeeperRegistry) ReorgProtectionEnabled() bool { } func (v *EthereumKeeperRegistry) ChainModuleAddress() common.Address { - if v.version == ethereum.RegistryVersion_2_2 { + if v.version >= ethereum.RegistryVersion_2_2 { return v.chainModule.Address() } return common.Address{} @@ -179,6 +190,8 @@ func (v *EthereumKeeperRegistry) SetConfigTypeSafe(ocrConfig OCRv2Config) error txOpts := v.client.NewTXOpts() var err error + v.l.Error().Msg("===============Setting config for registry") + //v.l.Info().Msgf("=======Setting config for registry %s", v.version) switch v.version { case ethereum.RegistryVersion_2_1: _, err = v.client.Decode(v.registry2_1.SetConfigTypeSafe(txOpts, @@ -198,6 +211,18 @@ func (v *EthereumKeeperRegistry) SetConfigTypeSafe(ocrConfig OCRv2Config) error ocrConfig.OffchainConfigVersion, ocrConfig.OffchainConfig, )) + case ethereum.RegistryVersion_2_3: + // TODO need to change to real LINK address + _, err = v.client.Decode(v.registry2_3.SetConfigTypeSafe(txOpts, + ocrConfig.Signers, + ocrConfig.Transmitters, + ocrConfig.F, + ocrConfig.TypedOnchainConfig23, + ocrConfig.OffchainConfigVersion, + ocrConfig.OffchainConfig, + ocrConfig.BillingTokens, + ocrConfig.BillingConfigs, + )) default: return fmt.Errorf("SetConfigTypeSafe is not supported in keeper registry version %d", v.version) } @@ -660,6 +685,8 @@ func (v *EthereumKeeperRegistry) CancelUpkeep(id *big.Int) error { tx, err = v.client.Decode(v.registry2_1.CancelUpkeep(opts, id)) case ethereum.RegistryVersion_2_2: tx, err = v.client.Decode(v.registry2_2.CancelUpkeep(opts, id)) + case ethereum.RegistryVersion_2_3: + tx, err = v.client.Decode(v.registry2_3.CancelUpkeep(opts, id)) } txHash := "none" @@ -978,6 +1005,12 @@ func (v *EthereumKeeperRegistry) ParseUpkeepIdFromRegisteredLog(log *types.Log) return nil, err } return parsedLog.Id, nil + case ethereum.RegistryVersion_2_3: + parsedLog, err := v.registry2_3.ParseUpkeepRegistered(*log) + if err != nil { + return nil, err + } + return parsedLog.Id, nil } return nil, fmt.Errorf("keeper registry version %d is not supported", v.version) @@ -1015,6 +1048,8 @@ func DeployKeeperRegistry( return deployRegistry21(client, opts, mode) case eth_contracts.RegistryVersion_2_2: return deployRegistry22(client, opts) + case eth_contracts.RegistryVersion_2_3: + return deployRegistry23(client, opts) default: return nil, fmt.Errorf("keeper registry version %d is not supported", opts.RegistryVersion) } @@ -1339,6 +1374,110 @@ func deployRegistry22(client *seth.Client, opts *KeeperRegistryOpts) (KeeperRegi }, err } +func deployRegistry23(client *seth.Client, opts *KeeperRegistryOpts) (KeeperRegistry, error) { + var chainModuleAddr common.Address + var err error + chainId := client.ChainID + + if chainId == networks.ScrollMainnet.ChainID || chainId == networks.ScrollSepolia.ChainID { + chainModuleAddr, err = deployScrollModule(client) + } else if chainId == networks.ArbitrumMainnet.ChainID || chainId == networks.ArbitrumSepolia.ChainID { + chainModuleAddr, err = deployArbitrumModule(client) + } else if chainId == networks.OptimismMainnet.ChainID || chainId == networks.OptimismSepolia.ChainID { + chainModuleAddr, err = deployOptimismModule(client) + } else { + chainModuleAddr, err = deployBaseModule(client) + } + if err != nil { + return nil, err + } + + automationForwarderLogicAddr, err := deployAutomationForwarderLogicSeth(client) + if err != nil { + return nil, err + } + + var allowedReadOnlyAddress common.Address + if chainId == networks.PolygonZkEvmMainnet.ChainID || chainId == networks.PolygonZkEvmCardona.ChainID { + allowedReadOnlyAddress = common.HexToAddress("0x1111111111111111111111111111111111111111") + } else { + allowedReadOnlyAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") + } + + logicCAbi, err := registrylogicc23.AutomationRegistryLogicCMetaData.GetAbi() + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("failed to get AutomationRegistryLogicC2_3 ABI: %w", err) + } + + // TODO update args + logicCData, err := client.DeployContract(client.NewTXOpts(), "AutomationRegistryLogicC2_3", *logicCAbi, common.FromHex(registrylogicc23.AutomationRegistryLogicCMetaData.Bin), + common.HexToAddress(opts.LinkAddr), + common.HexToAddress(opts.LinkUSDFeedAddr), + common.HexToAddress(opts.NativeUSDFeedAddr), + common.HexToAddress(opts.GasFeedAddr), + automationForwarderLogicAddr, + allowedReadOnlyAddress, + uint8(0), + common.HexToAddress(opts.WrappedNativeAddr), + ) + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("AutomationRegistryLogicC2_3 instance deployment have failed: %w", err) + } + + logicBAbi, err := registrylogicb23.AutomationRegistryLogicBMetaData.GetAbi() + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("failed to get AutomationRegistryLogicB2_3 ABI: %w", err) + } + + logicBData, err := client.DeployContract(client.NewTXOpts(), "AutomationRegistryLogicB2_3", *logicBAbi, common.FromHex(registrylogicb23.AutomationRegistryLogicBMetaData.Bin), + logicCData.Address, + ) + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("AutomationRegistryLogicB2_3 instance deployment have failed: %w", err) + } + + logicAAbi, err := registrylogica23.AutomationRegistryLogicAMetaData.GetAbi() + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("failed to get AutomationRegistryLogicA2_3 ABI: %w", err) + } + logicAData, err := client.DeployContract(client.NewTXOpts(), "AutomationRegistryLogicA2_3", *logicAAbi, common.FromHex(registrylogica23.AutomationRegistryLogicAMetaData.Bin), + logicBData.Address, + ) + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("AutomationRegistryLogicA2_3 instance deployment have failed: %w", err) + } + + abi, err := registry23.AutomationRegistryMetaData.GetAbi() + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("failed to get AutomationRegistry2_3 ABI: %w", err) + } + + data, err := client.DeployContract(client.NewTXOpts(), "AutomationRegistry2_3", *abi, common.FromHex(registry23.AutomationRegistryMetaData.Bin), + logicAData.Address, + ) + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("AutomationRegistry2_3 instance deployment have failed: %w", err) + } + + instance, err := iregistry23.NewIAutomationRegistryMaster23(data.Address, wrappers.MustNewWrappedContractBackend(nil, client)) + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("failed to instantiate AutomationRegistry2_3 instance: %w", err) + } + + chainModule, err := i_chain_module.NewIChainModule( + chainModuleAddr, + wrappers.MustNewWrappedContractBackend(nil, client), + ) + + return &EthereumKeeperRegistry{ + client: client, + version: eth_contracts.RegistryVersion_2_3, + registry2_3: instance, + chainModule: chainModule, + address: &data.Address, + }, err +} + // LoadKeeperRegistry returns deployed on given address EthereumKeeperRegistry func LoadKeeperRegistry(l zerolog.Logger, client *seth.Client, address common.Address, registryVersion eth_contracts.KeeperRegistryVersion) (KeeperRegistry, error) { var keeper *EthereumKeeperRegistry @@ -1356,6 +1495,8 @@ func LoadKeeperRegistry(l zerolog.Logger, client *seth.Client, address common.Ad keeper, err = loadRegistry2_1(client, address) case eth_contracts.RegistryVersion_2_2: // why the contract name is not the same as the actual contract name? keeper, err = loadRegistry2_2(client, address) + case eth_contracts.RegistryVersion_2_3: // why the contract name is not the same as the actual contract name? + keeper, err = loadRegistry2_3(client, address) default: return nil, fmt.Errorf("keeper registry version %d is not supported", registryVersion) } @@ -1495,6 +1636,27 @@ func loadRegistry2_2(client *seth.Client, address common.Address) (*EthereumKeep }, nil } +func loadRegistry2_3(client *seth.Client, address common.Address) (*EthereumKeeperRegistry, error) { + abi, err := iregistry23.IAutomationRegistryMaster23MetaData.GetAbi() + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("failed to get AutomationRegistry2_3 ABI: %w", err) + } + + client.ContractStore.AddABI("AutomationRegistry2_3", *abi) + client.ContractStore.AddBIN("AutomationRegistry2_3", common.FromHex(iregistry23.IAutomationRegistryMaster23MetaData.Bin)) + + instance, err := iregistry23.NewIAutomationRegistryMaster23(address, wrappers.MustNewWrappedContractBackend(nil, client)) + if err != nil { + return &EthereumKeeperRegistry{}, fmt.Errorf("failed to instantiate AutomationRegistry2_3 instance: %w", err) + } + + return &EthereumKeeperRegistry{ + address: &address, + client: client, + registry2_3: instance, + }, nil +} + func deployAutomationForwarderLogicSeth(client *seth.Client) (common.Address, error) { abi, err := automationForwarderLogic.AutomationForwarderLogicMetaData.GetAbi() if err != nil { @@ -1567,6 +1729,7 @@ type EthereumKeeperRegistrar struct { registrar *keeper_registrar_wrapper1_2.KeeperRegistrar registrar20 *keeper_registrar_wrapper2_0.KeeperRegistrar registrar21 *registrar21.AutomationRegistrar + registrar23 *registrar23.AutomationRegistrar address *common.Address } @@ -1579,7 +1742,7 @@ func (v *EthereumKeeperRegistrar) Fund(_ *big.Float) error { } // EncodeRegisterRequest encodes register request to call it through link token TransferAndCall -func (v *EthereumKeeperRegistrar) EncodeRegisterRequest(name string, email []byte, upkeepAddr string, gasLimit uint32, adminAddr string, checkData []byte, amount *big.Int, source uint8, senderAddr string, isLogTrigger bool, isMercury bool) ([]byte, error) { +func (v *EthereumKeeperRegistrar) EncodeRegisterRequest(name string, email []byte, upkeepAddr string, gasLimit uint32, adminAddr string, checkData []byte, amount *big.Int, source uint8, senderAddr string, isLogTrigger bool, isMercury bool, linkTokenAddr string) ([]byte, error) { if v.registrar20 != nil { registryABI, err := abi.JSON(strings.NewReader(keeper_registrar_wrapper2_0.KeeperRegistrarMetaData.ABI)) if err != nil { @@ -1667,6 +1830,113 @@ func (v *EthereumKeeperRegistrar) EncodeRegisterRequest(name string, email []byt common.HexToAddress(senderAddr), ) return req, err + } else if v.registrar23 != nil { + //if isLogTrigger { + // var topic0InBytes [32]byte + // // bytes representation of 0x0000000000000000000000000000000000000000000000000000000000000000 + // bytes0 := [32]byte{ + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + // } + // if isMercury { + // // bytes representation of 0xd1ffe9e45581c11d7d9f2ed5f75217cd4be9f8b7eee6af0f6d03f46de53956cd + // topic0InBytes = [32]byte{209, 255, 233, 228, 85, 129, 193, 29, 125, 159, 46, 213, 247, 82, 23, 205, 75, 233, 248, 183, 238, 230, 175, 15, 109, 3, 244, 109, 229, 57, 86, 205} + // } else { + // // bytes representation of 0x3d53a39550e04688065827f3bb86584cb007ab9ebca7ebd528e7301c9c31eb5d + // topic0InBytes = [32]byte{ + // 61, 83, 163, 149, 80, 224, 70, 136, + // 6, 88, 39, 243, 187, 134, 88, 76, + // 176, 7, 171, 158, 188, 167, 235, + // 213, 40, 231, 48, 28, 156, 49, 235, 93, + // } + // } + // + // logTriggerConfigStruct := acutils.IAutomationV21PlusCommonLogTriggerConfig{ + // ContractAddress: common.HexToAddress(upkeepAddr), + // FilterSelector: 0, + // Topic0: topic0InBytes, + // Topic1: bytes0, + // Topic2: bytes0, + // Topic3: bytes0, + // } + // encodedLogTriggerConfig, err := compatibleUtils.Methods["_logTriggerConfig"].Inputs.Pack(&logTriggerConfigStruct) + // if err != nil { + // return nil, err + // } + // + // // TODO update params + // req, err := registrarABI.Pack( + // "register", + // name, + // email, + // common.HexToAddress(upkeepAddr), + // gasLimit, + // common.HexToAddress(adminAddr), + // uint8(1), // trigger type + // checkData, + // encodedLogTriggerConfig, // triggerConfig + // []byte{}, // offchainConfig + // amount, + // common.HexToAddress(senderAddr), + // ) + // + // return req, err + //} + + //struct RegistrationParams { + // address upkeepContract; + // uint96 amount; + // // 1 word full + // address adminAddress; + // uint32 gasLimit; + // uint8 triggerType; + // // 7 bytes left in 2nd word + // IERC20 billingToken; + // // 12 bytes left in 3rd word + // string name; + // bytes encryptedEmail; + // bytes checkData; + // bytes triggerConfig; + // bytes offchainConfig; + //} + + registrarABI = cltypes.MustGetABI(registrar23.AutomationRegistrarABI) + + //type RegistrationParams struct { + // UpkeepContract common.Address + // Amount *big.Int + // AdminAddress common.Address + // GasLimit uint32 + // TriggerType uint8 + // BillingToken common.Address + // Name string + // EncryptedEmail []byte + // CheckData []byte + // TriggerConfig []byte + // OffchainConfig []byte + //} + + params := registrar23.AutomationRegistrar23RegistrationParams{ + UpkeepContract: common.HexToAddress(upkeepAddr), + Amount: amount, + AdminAddress: common.HexToAddress(adminAddr), + GasLimit: gasLimit, + TriggerType: uint8(0), // trigger type + BillingToken: common.HexToAddress(linkTokenAddr), + Name: name, + EncryptedEmail: email, + CheckData: checkData, + TriggerConfig: []byte{}, + OffchainConfig: []byte{}, + } + + //req, err := registrarABI.Pack( + // "registerUpkeep", + // params, + //) + + encodedRegistrationParamsStruct, err := registrarABI.Methods["registerUpkeep"].Inputs.Pack(¶ms) + + return encodedRegistrationParamsStruct, err } registryABI, err := abi.JSON(strings.NewReader(keeper_registrar_wrapper1_2.KeeperRegistrarMetaData.ABI)) if err != nil { @@ -1690,6 +1960,7 @@ func (v *EthereumKeeperRegistrar) EncodeRegisterRequest(name string, email []byt return req, nil } +// TODO add registrar 23 func DeployKeeperRegistrar(client *seth.Client, registryVersion eth_contracts.KeeperRegistryVersion, linkAddr string, registrarSettings KeeperRegistrarSettings) (KeeperRegistrar, error) { if registryVersion == eth_contracts.RegistryVersion_2_0 { abi, err := keeper_registrar_wrapper2_0.KeeperRegistrarMetaData.GetAbi() @@ -1750,6 +2021,56 @@ func DeployKeeperRegistrar(client *seth.Client, registryVersion eth_contracts.Ke registrar21: instance, address: &data.Address, }, nil + } else if registryVersion == eth_contracts.RegistryVersion_2_3 { + abi, err := registrar23.AutomationRegistrarMetaData.GetAbi() + if err != nil { + return &EthereumKeeperRegistrar{}, fmt.Errorf("failed to get KeeperRegistrar2_3 ABI: %w", err) + } + // set default TriggerType to 0(conditional), AutoApproveConfigType to 2(auto approve enabled), AutoApproveMaxAllowed to 1000 + triggerConfigs := []registrar23.AutomationRegistrar23InitialTriggerConfig{ + {TriggerType: 0, AutoApproveType: registrarSettings.AutoApproveConfigType, + AutoApproveMaxAllowed: uint32(registrarSettings.AutoApproveMaxAllowed)}, + {TriggerType: 1, AutoApproveType: registrarSettings.AutoApproveConfigType, + AutoApproveMaxAllowed: uint32(registrarSettings.AutoApproveMaxAllowed)}, + } + + //address LINKAddress, + // IAutomationRegistryMaster2_3 registry, + // InitialTriggerConfig[] memory triggerConfigs, + // IERC20[] memory billingTokens, + // uint256[] memory minRegistrationFees, + // IWrappedNative wrappedNativeToken + + billingTokens := []common.Address{ + common.HexToAddress(linkAddr), + } + minRegistrationFees := []*big.Int{ + big.NewInt(10), + } + + // TODO update params + data, err := client.DeployContract(client.NewTXOpts(), "KeeperRegistrar2_3", *abi, common.FromHex(registrar23.AutomationRegistrarMetaData.Bin), + common.HexToAddress(linkAddr), + common.HexToAddress(registrarSettings.RegistryAddr), + triggerConfigs, + billingTokens, + minRegistrationFees, + common.HexToAddress(registrarSettings.WETHTokenAddr), + ) + if err != nil { + return &EthereumKeeperRegistrar{}, fmt.Errorf("KeeperRegistrar2_3 instance deployment have failed: %w", err) + } + + instance, err := registrar23.NewAutomationRegistrar(data.Address, wrappers.MustNewWrappedContractBackend(nil, client)) + if err != nil { + return &EthereumKeeperRegistrar{}, fmt.Errorf("failed to instantiate KeeperRegistrar2_3 instance: %w", err) + } + + return &EthereumKeeperRegistrar{ + client: client, + registrar23: instance, + address: &data.Address, + }, nil } // non OCR registrar diff --git a/integration-tests/contracts/ethereum_keeper_contracts.go b/integration-tests/contracts/ethereum_keeper_contracts.go index b933c18df0c..41bfbebf697 100644 --- a/integration-tests/contracts/ethereum_keeper_contracts.go +++ b/integration-tests/contracts/ethereum_keeper_contracts.go @@ -2,19 +2,50 @@ package contracts import ( "context" + "errors" + "fmt" "math/big" + "strconv" + "strings" + "time" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_2" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" - + geth "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/rs/zerolog" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3" goabi "github.com/umbracle/ethgo/abi" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" + "github.com/smartcontractkit/chainlink/integration-tests/testreporters" cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" ac "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_compatible_utils" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_consumer_benchmark" registrar21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registrar_wrapper2_1" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_2" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_chain_module" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_consumer_performance_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_consumer_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registrar_wrapper1_2" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registrar_wrapper2_0" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_1" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_2" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_3" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper2_0" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_triggered_streams_lookup_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_upkeep_counter_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/perform_data_checker_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/simple_log_upkeep_counter_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/streams_lookup_upkeep_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_counter_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_perform_counter_restrictive_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/upkeep_transcoder" ) var compatibleUtils = cltypes.MustGetABI(ac.AutomationCompatibleUtilsABI) @@ -23,7 +54,7 @@ var registrarABI = cltypes.MustGetABI(registrar21.AutomationRegistrarABI) type KeeperRegistrar interface { Address() string - EncodeRegisterRequest(name string, email []byte, upkeepAddr string, gasLimit uint32, adminAddr string, checkData []byte, amount *big.Int, source uint8, senderAddr string, isLogTrigger bool, isMercury bool) ([]byte, error) + EncodeRegisterRequest(name string, email []byte, upkeepAddr string, gasLimit uint32, adminAddr string, checkData []byte, amount *big.Int, source uint8, senderAddr string, isLogTrigger bool, isMercury bool, linkTokenAddr string) ([]byte, error) Fund(ethAmount *big.Float) error } @@ -123,13 +154,16 @@ type StaleUpkeepReportLog struct { // KeeperRegistryOpts opts to deploy keeper registry version type KeeperRegistryOpts struct { - RegistryVersion ethereum.KeeperRegistryVersion - LinkAddr string - ETHFeedAddr string - GasFeedAddr string - TranscoderAddr string - RegistrarAddr string - Settings KeeperRegistrySettings + RegistryVersion ethereum.KeeperRegistryVersion + LinkAddr string + ETHFeedAddr string + GasFeedAddr string + TranscoderAddr string + RegistrarAddr string + Settings KeeperRegistrySettings + LinkUSDFeedAddr string + NativeUSDFeedAddr string + WrappedNativeAddr string } // KeeperRegistrySettings represents the settings to fine tune keeper registry @@ -150,24 +184,96 @@ type KeeperRegistrySettings struct { RegistryVersion ethereum.KeeperRegistryVersion } -func (rcs *KeeperRegistrySettings) Encode20OnchainConfig(registrar string) []byte { - configType := goabi.MustNewType("tuple(uint32 paymentPremiumPPB,uint32 flatFeeMicroLink,uint32 checkGasLimit,uint24 stalenessSeconds,uint16 gasCeilingMultiplier,uint96 minUpkeepSpend,uint32 maxPerformGas,uint32 maxCheckDataSize,uint32 maxPerformDataSize,uint256 fallbackGasPrice,uint256 fallbackLinkPrice,address transcoder,address registrar)") - onchainConfig, _ := goabi.Encode(map[string]interface{}{ - "paymentPremiumPPB": rcs.PaymentPremiumPPB, - "flatFeeMicroLink": rcs.FlatFeeMicroLINK, - "checkGasLimit": rcs.CheckGasLimit, - "stalenessSeconds": rcs.StalenessSeconds, - "gasCeilingMultiplier": rcs.GasCeilingMultiplier, - "minUpkeepSpend": rcs.MinUpkeepSpend, - "maxPerformGas": rcs.MaxPerformGas, - "maxCheckDataSize": rcs.MaxCheckDataSize, - "maxPerformDataSize": rcs.MaxPerformDataSize, - "fallbackGasPrice": rcs.FallbackGasPrice, - "fallbackLinkPrice": rcs.FallbackLinkPrice, - "transcoder": common.Address{}, - "registrar": registrar, - }, configType) - return onchainConfig +// KeeperRegistrarSettings represents settings for registrar contract +type KeeperRegistrarSettings struct { + AutoApproveConfigType uint8 + AutoApproveMaxAllowed uint16 + RegistryAddr string + MinLinkJuels *big.Int + WETHTokenAddr string +} + +// KeeperInfo keeper status and balance info +type KeeperInfo struct { + Payee string + Active bool + Balance *big.Int +} + +// UpkeepInfo keeper target info +type UpkeepInfo struct { + Target string + ExecuteGas uint32 + CheckData []byte + Balance *big.Int + LastKeeper string + Admin string + MaxValidBlocknumber uint64 + LastPerformBlockNumber uint32 + AmountSpent *big.Int + Paused bool + OffchainConfig []byte +} + +// LegacyEthereumKeeperRegistry represents keeper registry contract +type LegacyEthereumKeeperRegistry struct { + client blockchain.EVMClient + version ethereum.KeeperRegistryVersion + registry1_1 *keeper_registry_wrapper1_1.KeeperRegistry + registry1_2 *keeper_registry_wrapper1_2.KeeperRegistry + registry1_3 *keeper_registry_wrapper1_3.KeeperRegistry + registry2_0 *keeper_registry_wrapper2_0.KeeperRegistry + registry2_1 *i_keeper_registry_master_wrapper_2_1.IKeeperRegistryMaster + registry2_2 *i_automation_registry_master_wrapper_2_2.IAutomationRegistryMaster + chainModule *i_chain_module.IChainModule + address *common.Address + l zerolog.Logger +} + +func (v *LegacyEthereumKeeperRegistry) ReorgProtectionEnabled() bool { + chainId := v.client.GetChainID().Uint64() + // reorg protection is disabled in polygon zkEVM and Scroll bc currently there is no way to get the block hash onchain + return v.version != ethereum.RegistryVersion_2_2 || (chainId != 1101 && chainId != 1442 && chainId != 2442 && chainId != 534352 && chainId != 534351) +} + +func (v *LegacyEthereumKeeperRegistry) ChainModuleAddress() common.Address { + if v.version == ethereum.RegistryVersion_2_2 { + return v.chainModule.Address() + } + return common.Address{} +} + +func (v *LegacyEthereumKeeperRegistry) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumKeeperRegistry) Fund(ethAmount *big.Float) error { + gasEstimates, err := v.client.EstimateGas(geth.CallMsg{}) + if err != nil { + return err + } + return v.client.Fund(v.address.Hex(), ethAmount, gasEstimates) +} + +func (rcs *KeeperRegistrySettings) Create23OnchainConfig(registrar string, registryOwnerAddress, chainModuleAddress common.Address, reorgProtectionEnabled bool) i_automation_registry_master_wrapper_2_3.AutomationRegistryBase23OnchainConfig { + return i_automation_registry_master_wrapper_2_3.AutomationRegistryBase23OnchainConfig{ + CheckGasLimit: rcs.CheckGasLimit, + StalenessSeconds: rcs.StalenessSeconds, + GasCeilingMultiplier: rcs.GasCeilingMultiplier, + MaxPerformGas: rcs.MaxPerformGas, + MaxCheckDataSize: rcs.MaxCheckDataSize, + MaxPerformDataSize: rcs.MaxPerformDataSize, + MaxRevertDataSize: rcs.MaxRevertDataSize, + FallbackGasPrice: rcs.FallbackGasPrice, + FallbackLinkPrice: rcs.FallbackLinkPrice, + Transcoder: common.Address{}, + Registrars: []common.Address{common.HexToAddress(registrar)}, + UpkeepPrivilegeManager: registryOwnerAddress, + ChainModule: chainModuleAddress, // TODO here is the chainModule + ReorgProtectionEnabled: reorgProtectionEnabled, + FinanceAdmin: registryOwnerAddress, + FallbackNativePrice: big.NewInt(1), + } } func (rcs *KeeperRegistrySettings) Create22OnchainConfig(registrar string, registryOwnerAddress, chainModuleAddress common.Address, reorgProtectionEnabled bool) i_automation_registry_master_wrapper_2_2.AutomationRegistryBase22OnchainConfig { @@ -212,32 +318,2077 @@ func (rcs *KeeperRegistrySettings) Create21OnchainConfig(registrar string, regis } } -// KeeperRegistrarSettings represents settings for registrar contract -type KeeperRegistrarSettings struct { - AutoApproveConfigType uint8 - AutoApproveMaxAllowed uint16 - RegistryAddr string - MinLinkJuels *big.Int +func (rcs *KeeperRegistrySettings) Encode20OnchainConfig(registrar string) []byte { + configType := goabi.MustNewType("tuple(uint32 paymentPremiumPPB,uint32 flatFeeMicroLink,uint32 checkGasLimit,uint24 stalenessSeconds,uint16 gasCeilingMultiplier,uint96 minUpkeepSpend,uint32 maxPerformGas,uint32 maxCheckDataSize,uint32 maxPerformDataSize,uint256 fallbackGasPrice,uint256 fallbackLinkPrice,address transcoder,address registrar)") + onchainConfig, _ := goabi.Encode(map[string]interface{}{ + "paymentPremiumPPB": rcs.PaymentPremiumPPB, + "flatFeeMicroLink": rcs.FlatFeeMicroLINK, + "checkGasLimit": rcs.CheckGasLimit, + "stalenessSeconds": rcs.StalenessSeconds, + "gasCeilingMultiplier": rcs.GasCeilingMultiplier, + "minUpkeepSpend": rcs.MinUpkeepSpend, + "maxPerformGas": rcs.MaxPerformGas, + "maxCheckDataSize": rcs.MaxCheckDataSize, + "maxPerformDataSize": rcs.MaxPerformDataSize, + "fallbackGasPrice": rcs.FallbackGasPrice, + "fallbackLinkPrice": rcs.FallbackLinkPrice, + "transcoder": common.Address{}, + "registrar": registrar, + }, configType) + return onchainConfig } -// KeeperInfo keeper status and balance info -type KeeperInfo struct { - Payee string - Active bool - Balance *big.Int +func (v *LegacyEthereumKeeperRegistry) RegistryOwnerAddress() common.Address { + callOpts := &bind.CallOpts{ + Pending: false, + } + + //nolint: exhaustive + switch v.version { + case ethereum.RegistryVersion_2_2: + ownerAddress, _ := v.registry2_2.Owner(callOpts) + return ownerAddress + case ethereum.RegistryVersion_2_1: + ownerAddress, _ := v.registry2_1.Owner(callOpts) + return ownerAddress + case ethereum.RegistryVersion_2_0: + ownerAddress, _ := v.registry2_0.Owner(callOpts) + return ownerAddress + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1, ethereum.RegistryVersion_1_2, ethereum.RegistryVersion_1_3: + return common.HexToAddress(v.client.GetDefaultWallet().Address()) + } + + return common.HexToAddress(v.client.GetDefaultWallet().Address()) } -// UpkeepInfo keeper target info -type UpkeepInfo struct { - Target string - ExecuteGas uint32 - CheckData []byte - Balance *big.Int - LastKeeper string - Admin string - MaxValidBlocknumber uint64 - LastPerformBlockNumber uint32 - AmountSpent *big.Int - Paused bool - OffchainConfig []byte +func (v *LegacyEthereumKeeperRegistry) SetConfigTypeSafe(ocrConfig OCRv2Config) error { + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + switch v.version { + case ethereum.RegistryVersion_2_1: + tx, err := v.registry2_1.SetConfigTypeSafe(txOpts, + ocrConfig.Signers, + ocrConfig.Transmitters, + ocrConfig.F, + ocrConfig.TypedOnchainConfig21, + ocrConfig.OffchainConfigVersion, + ocrConfig.OffchainConfig, + ) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_2: + tx, err := v.registry2_2.SetConfigTypeSafe(txOpts, + ocrConfig.Signers, + ocrConfig.Transmitters, + ocrConfig.F, + ocrConfig.TypedOnchainConfig22, + ocrConfig.OffchainConfigVersion, + ocrConfig.OffchainConfig, + ) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + default: + return fmt.Errorf("SetConfigTypeSafe is not supported in keeper registry version %d", v.version) + } +} + +func (v *LegacyEthereumKeeperRegistry) SetConfig(config KeeperRegistrySettings, ocrConfig OCRv2Config) error { + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + callOpts := bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: nil, + } + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + tx, err := v.registry1_1.SetConfig( + txOpts, + config.PaymentPremiumPPB, + config.FlatFeeMicroLINK, + config.BlockCountPerTurn, + config.CheckGasLimit, + config.StalenessSeconds, + config.GasCeilingMultiplier, + config.FallbackGasPrice, + config.FallbackLinkPrice, + ) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_1_2: + state, err := v.registry1_2.GetState(&callOpts) + if err != nil { + return err + } + + tx, err := v.registry1_2.SetConfig(txOpts, keeper_registry_wrapper1_2.Config{ + PaymentPremiumPPB: config.PaymentPremiumPPB, + FlatFeeMicroLink: config.FlatFeeMicroLINK, + BlockCountPerTurn: config.BlockCountPerTurn, + CheckGasLimit: config.CheckGasLimit, + StalenessSeconds: config.StalenessSeconds, + GasCeilingMultiplier: config.GasCeilingMultiplier, + MinUpkeepSpend: config.MinUpkeepSpend, + MaxPerformGas: config.MaxPerformGas, + FallbackGasPrice: config.FallbackGasPrice, + FallbackLinkPrice: config.FallbackLinkPrice, + // Keep the transcoder and registrar same. They have separate setters + Transcoder: state.Config.Transcoder, + Registrar: state.Config.Registrar, + }) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_1_3: + state, err := v.registry1_3.GetState(&callOpts) + if err != nil { + return err + } + + tx, err := v.registry1_3.SetConfig(txOpts, keeper_registry_wrapper1_3.Config{ + PaymentPremiumPPB: config.PaymentPremiumPPB, + FlatFeeMicroLink: config.FlatFeeMicroLINK, + BlockCountPerTurn: config.BlockCountPerTurn, + CheckGasLimit: config.CheckGasLimit, + StalenessSeconds: config.StalenessSeconds, + GasCeilingMultiplier: config.GasCeilingMultiplier, + MinUpkeepSpend: config.MinUpkeepSpend, + MaxPerformGas: config.MaxPerformGas, + FallbackGasPrice: config.FallbackGasPrice, + FallbackLinkPrice: config.FallbackLinkPrice, + // Keep the transcoder and registrar same. They have separate setters + Transcoder: state.Config.Transcoder, + Registrar: state.Config.Registrar, + }) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_0: + tx, err := v.registry2_0.SetConfig(txOpts, + ocrConfig.Signers, + ocrConfig.Transmitters, + ocrConfig.F, + ocrConfig.OnchainConfig, + ocrConfig.OffchainConfigVersion, + ocrConfig.OffchainConfig, + ) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2: + return fmt.Errorf("registry version 2.1 and 2.2 must use setConfigTypeSafe function") + default: + return fmt.Errorf("keeper registry version %d is not supported", v.version) + } +} + +// Pause pauses the registry. +func (v *LegacyEthereumKeeperRegistry) Pause() error { + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + var tx *types.Transaction + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + tx, err = v.registry1_1.Pause(txOpts) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_1_2: + tx, err = v.registry1_2.Pause(txOpts) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_1_3: + tx, err = v.registry1_3.Pause(txOpts) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_0: + tx, err = v.registry2_0.Pause(txOpts) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_1: + tx, err = v.registry2_1.Pause(txOpts) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_2: + tx, err = v.registry2_2.Pause(txOpts) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + } + + return fmt.Errorf("keeper registry version %d is not supported", v.version) +} + +// Migrate performs a migration of the given upkeep ids to the specific destination passed as parameter. +func (v *LegacyEthereumKeeperRegistry) Migrate(upkeepIDs []*big.Int, destinationAddress common.Address) error { + if v.version != ethereum.RegistryVersion_1_2 { + return fmt.Errorf("migration of upkeeps is only available for version 1.2 of the registries") + } + + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry1_2.MigrateUpkeeps(txOpts, upkeepIDs, destinationAddress) + if err != nil { + return err + } + + return v.client.ProcessTransaction(tx) +} + +// SetMigrationPermissions sets the permissions of another registry to allow migrations between the two. +func (v *LegacyEthereumKeeperRegistry) SetMigrationPermissions(peerAddress common.Address, permission uint8) error { + if v.version != ethereum.RegistryVersion_1_2 { + return fmt.Errorf("migration of upkeeps is only available for version 1.2 of the registries") + } + + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry1_2.SetPeerRegistryMigrationPermission(txOpts, peerAddress, permission) + if err != nil { + return err + } + + return v.client.ProcessTransaction(tx) +} + +func (v *LegacyEthereumKeeperRegistry) SetRegistrar(registrarAddr string) error { + if v.version == ethereum.RegistryVersion_2_0 { + // we short circuit and exit, so we don't create a new txs messing up the nonce before exiting + return fmt.Errorf("please use set config") + } + + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + callOpts := bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: nil, + } + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + tx, err := v.registry1_1.SetRegistrar(txOpts, common.HexToAddress(registrarAddr)) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_1_2: + state, err := v.registry1_2.GetState(&callOpts) + if err != nil { + return err + } + newConfig := state.Config + newConfig.Registrar = common.HexToAddress(registrarAddr) + tx, err := v.registry1_2.SetConfig(txOpts, newConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_1_3: + state, err := v.registry1_3.GetState(&callOpts) + if err != nil { + return err + } + newConfig := state.Config + newConfig.Registrar = common.HexToAddress(registrarAddr) + tx, err := v.registry1_3.SetConfig(txOpts, newConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + default: + return fmt.Errorf("keeper registry version %d is not supported", v.version) + } +} + +// AddUpkeepFunds adds link for particular upkeep id +func (v *LegacyEthereumKeeperRegistry) AddUpkeepFundsFromKey(_ *big.Int, _ *big.Int, _ int) error { + panic("this method is only supported by contracts using Seth client") +} + +// AddUpkeepFunds adds link for particular upkeep id +func (v *LegacyEthereumKeeperRegistry) AddUpkeepFunds(id *big.Int, amount *big.Int) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + var tx *types.Transaction + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + tx, err = v.registry1_1.AddFunds(opts, id, amount) + case ethereum.RegistryVersion_1_2: + tx, err = v.registry1_2.AddFunds(opts, id, amount) + case ethereum.RegistryVersion_1_3: + tx, err = v.registry1_3.AddFunds(opts, id, amount) + case ethereum.RegistryVersion_2_0: + tx, err = v.registry2_0.AddFunds(opts, id, amount) + case ethereum.RegistryVersion_2_1: + tx, err = v.registry2_1.AddFunds(opts, id, amount) + case ethereum.RegistryVersion_2_2: + tx, err = v.registry2_2.AddFunds(opts, id, amount) + } + + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +// GetUpkeepInfo gets upkeep info +func (v *LegacyEthereumKeeperRegistry) GetUpkeepInfo(ctx context.Context, id *big.Int) (*UpkeepInfo, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + uk, err := v.registry1_1.GetUpkeep(opts, id) + if err != nil { + return nil, err + } + return &UpkeepInfo{ + Target: uk.Target.Hex(), + ExecuteGas: uk.ExecuteGas, + CheckData: uk.CheckData, + Balance: uk.Balance, + LastKeeper: uk.LastKeeper.Hex(), + Admin: uk.Admin.Hex(), + MaxValidBlocknumber: uk.MaxValidBlocknumber, + }, nil + case ethereum.RegistryVersion_1_2: + uk, err := v.registry1_2.GetUpkeep(opts, id) + if err != nil { + return nil, err + } + return &UpkeepInfo{ + Target: uk.Target.Hex(), + ExecuteGas: uk.ExecuteGas, + CheckData: uk.CheckData, + Balance: uk.Balance, + LastKeeper: uk.LastKeeper.Hex(), + Admin: uk.Admin.Hex(), + MaxValidBlocknumber: uk.MaxValidBlocknumber, + }, nil + case ethereum.RegistryVersion_1_3: + uk, err := v.registry1_3.GetUpkeep(opts, id) + if err != nil { + return nil, err + } + return &UpkeepInfo{ + Target: uk.Target.Hex(), + ExecuteGas: uk.ExecuteGas, + CheckData: uk.CheckData, + Balance: uk.Balance, + LastKeeper: uk.LastKeeper.Hex(), + Admin: uk.Admin.Hex(), + MaxValidBlocknumber: uk.MaxValidBlocknumber, + }, nil + case ethereum.RegistryVersion_2_0: + uk, err := v.registry2_0.GetUpkeep(opts, id) + if err != nil { + return nil, err + } + return &UpkeepInfo{ + Target: uk.Target.Hex(), + ExecuteGas: uk.ExecuteGas, + CheckData: uk.CheckData, + Balance: uk.Balance, + Admin: uk.Admin.Hex(), + MaxValidBlocknumber: uk.MaxValidBlocknumber, + LastPerformBlockNumber: uk.LastPerformBlockNumber, + AmountSpent: uk.AmountSpent, + Paused: uk.Paused, + OffchainConfig: uk.OffchainConfig, + }, nil + case ethereum.RegistryVersion_2_1: + uk, err := v.registry2_1.GetUpkeep(opts, id) + if err != nil { + return nil, err + } + return &UpkeepInfo{ + Target: uk.Target.Hex(), + ExecuteGas: uk.PerformGas, + CheckData: uk.CheckData, + Balance: uk.Balance, + Admin: uk.Admin.Hex(), + MaxValidBlocknumber: uk.MaxValidBlocknumber, + LastPerformBlockNumber: uk.LastPerformedBlockNumber, + AmountSpent: uk.AmountSpent, + Paused: uk.Paused, + OffchainConfig: uk.OffchainConfig, + }, nil + case ethereum.RegistryVersion_2_2: + return v.getUpkeepInfo22(opts, id) + } + + return nil, fmt.Errorf("keeper registry version %d is not supported", v.version) +} + +func (v *LegacyEthereumKeeperRegistry) getUpkeepInfo22(opts *bind.CallOpts, id *big.Int) (*UpkeepInfo, error) { + uk, err := v.registry2_2.GetUpkeep(opts, id) + if err != nil { + return nil, err + } + return &UpkeepInfo{ + Target: uk.Target.Hex(), + ExecuteGas: uk.PerformGas, + CheckData: uk.CheckData, + Balance: uk.Balance, + Admin: uk.Admin.Hex(), + MaxValidBlocknumber: uk.MaxValidBlocknumber, + LastPerformBlockNumber: uk.LastPerformedBlockNumber, + AmountSpent: uk.AmountSpent, + Paused: uk.Paused, + OffchainConfig: uk.OffchainConfig, + }, nil +} + +func (v *LegacyEthereumKeeperRegistry) GetKeeperInfo(ctx context.Context, keeperAddr string) (*KeeperInfo, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + var info struct { + Payee common.Address + Active bool + Balance *big.Int + } + var err error + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + info, err = v.registry1_1.GetKeeperInfo(opts, common.HexToAddress(keeperAddr)) + case ethereum.RegistryVersion_1_2: + info, err = v.registry1_2.GetKeeperInfo(opts, common.HexToAddress(keeperAddr)) + case ethereum.RegistryVersion_1_3: + info, err = v.registry1_3.GetKeeperInfo(opts, common.HexToAddress(keeperAddr)) + case ethereum.RegistryVersion_2_0, ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2: + // this is not used anywhere + return nil, fmt.Errorf("not supported") + } + + if err != nil { + return nil, err + } + return &KeeperInfo{ + Payee: info.Payee.Hex(), + Active: info.Active, + Balance: info.Balance, + }, nil +} + +func (v *LegacyEthereumKeeperRegistry) SetKeepers(keepers []string, payees []string, ocrConfig OCRv2Config) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + keepersAddresses := make([]common.Address, 0) + for _, k := range keepers { + keepersAddresses = append(keepersAddresses, common.HexToAddress(k)) + } + payeesAddresses := make([]common.Address, 0) + for _, p := range payees { + payeesAddresses = append(payeesAddresses, common.HexToAddress(p)) + } + var tx *types.Transaction + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + tx, err = v.registry1_1.SetKeepers(opts, keepersAddresses, payeesAddresses) + case ethereum.RegistryVersion_1_2: + tx, err = v.registry1_2.SetKeepers(opts, keepersAddresses, payeesAddresses) + case ethereum.RegistryVersion_1_3: + tx, err = v.registry1_3.SetKeepers(opts, keepersAddresses, payeesAddresses) + case ethereum.RegistryVersion_2_0: + tx, err = v.registry2_0.SetConfig(opts, + ocrConfig.Signers, + ocrConfig.Transmitters, + ocrConfig.F, + ocrConfig.OnchainConfig, + ocrConfig.OffchainConfigVersion, + ocrConfig.OffchainConfig, + ) + case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2: + return fmt.Errorf("not supported") + } + + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +// RegisterUpkeep registers contract to perform upkeep +func (v *LegacyEthereumKeeperRegistry) RegisterUpkeep(target string, gasLimit uint32, admin string, checkData []byte) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + var tx *types.Transaction + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + tx, err = v.registry1_1.RegisterUpkeep( + opts, + common.HexToAddress(target), + gasLimit, + common.HexToAddress(admin), + checkData, + ) + case ethereum.RegistryVersion_1_2: + tx, err = v.registry1_2.RegisterUpkeep( + opts, + common.HexToAddress(target), + gasLimit, + common.HexToAddress(admin), + checkData, + ) + case ethereum.RegistryVersion_1_3: + tx, err = v.registry1_3.RegisterUpkeep( + opts, + common.HexToAddress(target), + gasLimit, + common.HexToAddress(admin), + checkData, + ) + case ethereum.RegistryVersion_2_0: + tx, err = v.registry2_0.RegisterUpkeep( + opts, + common.HexToAddress(target), + gasLimit, + common.HexToAddress(admin), + checkData, + nil, //offchain config + ) + case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2: + return fmt.Errorf("not supported") + } + + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +// CancelUpkeep cancels the given upkeep ID +func (v *LegacyEthereumKeeperRegistry) CancelUpkeep(id *big.Int) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + var tx *types.Transaction + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + tx, err = v.registry1_1.CancelUpkeep(opts, id) + if err != nil { + return err + } + case ethereum.RegistryVersion_1_2: + tx, err = v.registry1_2.CancelUpkeep(opts, id) + if err != nil { + return err + } + case ethereum.RegistryVersion_1_3: + tx, err = v.registry1_3.CancelUpkeep(opts, id) + if err != nil { + return err + } + case ethereum.RegistryVersion_2_0: + tx, err = v.registry2_0.CancelUpkeep(opts, id) + if err != nil { + return err + } + case ethereum.RegistryVersion_2_1: + tx, err = v.registry2_1.CancelUpkeep(opts, id) + if err != nil { + return err + } + case ethereum.RegistryVersion_2_2: + tx, err = v.registry2_2.CancelUpkeep(opts, id) + if err != nil { + return err + } + } + + v.l.Info(). + Str("Upkeep ID", strconv.FormatInt(id.Int64(), 10)). + Str("From", v.client.GetDefaultWallet().Address()). + Str("TX Hash", tx.Hash().String()). + Msg("Cancel Upkeep tx") + return v.client.ProcessTransaction(tx) +} + +// SetUpkeepGasLimit sets the perform gas limit for a given upkeep ID +func (v *LegacyEthereumKeeperRegistry) SetUpkeepGasLimit(id *big.Int, gas uint32) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + var tx *types.Transaction + + switch v.version { + case ethereum.RegistryVersion_1_2: + tx, err = v.registry1_2.SetUpkeepGasLimit(opts, id, gas) + if err != nil { + return err + } + case ethereum.RegistryVersion_1_3: + tx, err = v.registry1_3.SetUpkeepGasLimit(opts, id, gas) + if err != nil { + return err + } + case ethereum.RegistryVersion_2_0: + tx, err = v.registry2_0.SetUpkeepGasLimit(opts, id, gas) + if err != nil { + return err + } + case ethereum.RegistryVersion_2_1: + tx, err = v.registry2_1.SetUpkeepGasLimit(opts, id, gas) + if err != nil { + return err + } + case ethereum.RegistryVersion_2_2: + tx, err = v.registry2_2.SetUpkeepGasLimit(opts, id, gas) + if err != nil { + return err + } + default: + return fmt.Errorf("keeper registry version %d is not supported for SetUpkeepGasLimit", v.version) + } + return v.client.ProcessTransaction(tx) +} + +// GetKeeperList get list of all registered keeper addresses +func (v *LegacyEthereumKeeperRegistry) GetKeeperList(ctx context.Context) ([]string, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + var list []common.Address + var err error + + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + list, err = v.registry1_1.GetKeeperList(opts) + case ethereum.RegistryVersion_1_2: + state, err := v.registry1_2.GetState(opts) + if err != nil { + return []string{}, err + } + list = state.Keepers + case ethereum.RegistryVersion_1_3: + state, err := v.registry1_3.GetState(opts) + if err != nil { + return []string{}, err + } + list = state.Keepers + case ethereum.RegistryVersion_2_0: + state, err := v.registry2_0.GetState(opts) + if err != nil { + return []string{}, err + } + list = state.Transmitters + case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2: + return nil, fmt.Errorf("not supported") + } + + if err != nil { + return []string{}, err + } + addrs := make([]string, 0) + for _, ca := range list { + addrs = append(addrs, ca.Hex()) + } + return addrs, nil +} + +// UpdateCheckData updates the check data of an upkeep +func (v *LegacyEthereumKeeperRegistry) UpdateCheckData(id *big.Int, newCheckData []byte) error { + + switch v.version { + case ethereum.RegistryVersion_1_3: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry1_3.UpdateCheckData(opts, id, newCheckData) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_0: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_0.UpdateCheckData(opts, id, newCheckData) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_1: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_1.SetUpkeepCheckData(opts, id, newCheckData) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_2: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_2.SetUpkeepCheckData(opts, id, newCheckData) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + default: + return fmt.Errorf("UpdateCheckData is not supported by keeper registry version %d", v.version) + } +} + +// SetUpkeepTriggerConfig updates the trigger config of an upkeep (only for version 2.1) +func (v *LegacyEthereumKeeperRegistry) SetUpkeepTriggerConfig(id *big.Int, triggerConfig []byte) error { + + switch v.version { + case ethereum.RegistryVersion_2_1: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_1.SetUpkeepTriggerConfig(opts, id, triggerConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_2: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_2.SetUpkeepTriggerConfig(opts, id, triggerConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + default: + return fmt.Errorf("SetUpkeepTriggerConfig is not supported by keeper registry version %d", v.version) + } +} + +// SetUpkeepPrivilegeConfig sets the privilege config of an upkeep (only for version 2.1) +func (v *LegacyEthereumKeeperRegistry) SetUpkeepPrivilegeConfig(id *big.Int, privilegeConfig []byte) error { + + switch v.version { + case ethereum.RegistryVersion_2_1: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_1.SetUpkeepPrivilegeConfig(opts, id, privilegeConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_2: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_2.SetUpkeepPrivilegeConfig(opts, id, privilegeConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + default: + return fmt.Errorf("SetUpkeepPrivilegeConfig is not supported by keeper registry version %d", v.version) + } +} + +// PauseUpkeep stops an upkeep from an upkeep +func (v *LegacyEthereumKeeperRegistry) PauseUpkeep(id *big.Int) error { + switch v.version { + case ethereum.RegistryVersion_1_3: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry1_3.PauseUpkeep(opts, id) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_0: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_0.PauseUpkeep(opts, id) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_1: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_1.PauseUpkeep(opts, id) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_2: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_2.PauseUpkeep(opts, id) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + default: + return fmt.Errorf("PauseUpkeep is not supported by keeper registry version %d", v.version) + } +} + +// UnpauseUpkeep get list of all registered keeper addresses +func (v *LegacyEthereumKeeperRegistry) UnpauseUpkeep(id *big.Int) error { + switch v.version { + case ethereum.RegistryVersion_1_3: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry1_3.UnpauseUpkeep(opts, id) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_0: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_0.UnpauseUpkeep(opts, id) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_1: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_1.UnpauseUpkeep(opts, id) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_2: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_2.UnpauseUpkeep(opts, id) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + default: + return fmt.Errorf("UnpauseUpkeep is not supported by keeper registry version %d", v.version) + } +} + +func (v *LegacyEthereumKeeperRegistry) SetUpkeepOffchainConfig(id *big.Int, offchainConfig []byte) error { + switch v.version { + case ethereum.RegistryVersion_2_0: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_0.SetUpkeepOffchainConfig(opts, id, offchainConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_1: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_1.SetUpkeepOffchainConfig(opts, id, offchainConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + case ethereum.RegistryVersion_2_2: + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.registry2_2.SetUpkeepOffchainConfig(opts, id, offchainConfig) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) + default: + return fmt.Errorf("SetUpkeepOffchainConfig is not supported by keeper registry version %d", v.version) + } +} + +// Parses upkeep performed log +func (v *LegacyEthereumKeeperRegistry) ParseUpkeepPerformedLog(log *types.Log) (*UpkeepPerformedLog, error) { + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + parsedLog, err := v.registry1_1.ParseUpkeepPerformed(*log) + if err != nil { + return nil, err + } + return &UpkeepPerformedLog{ + Id: parsedLog.Id, + Success: parsedLog.Success, + From: parsedLog.From, + }, nil + case ethereum.RegistryVersion_1_2: + parsedLog, err := v.registry1_2.ParseUpkeepPerformed(*log) + if err != nil { + return nil, err + } + return &UpkeepPerformedLog{ + Id: parsedLog.Id, + Success: parsedLog.Success, + From: parsedLog.From, + }, nil + case ethereum.RegistryVersion_1_3: + parsedLog, err := v.registry1_3.ParseUpkeepPerformed(*log) + if err != nil { + return nil, err + } + return &UpkeepPerformedLog{ + Id: parsedLog.Id, + Success: parsedLog.Success, + From: parsedLog.From, + }, nil + case ethereum.RegistryVersion_2_0: + parsedLog, err := v.registry2_0.ParseUpkeepPerformed(*log) + if err != nil { + return nil, err + } + return &UpkeepPerformedLog{ + Id: parsedLog.Id, + Success: parsedLog.Success, + From: utils.ZeroAddress, + }, nil + case ethereum.RegistryVersion_2_1: + parsedLog, err := v.registry2_1.ParseUpkeepPerformed(*log) + if err != nil { + return nil, err + } + return &UpkeepPerformedLog{ + Id: parsedLog.Id, + Success: parsedLog.Success, + From: utils.ZeroAddress, + }, nil + case ethereum.RegistryVersion_2_2: + parsedLog, err := v.registry2_2.ParseUpkeepPerformed(*log) + if err != nil { + return nil, err + } + return &UpkeepPerformedLog{ + Id: parsedLog.Id, + Success: parsedLog.Success, + From: utils.ZeroAddress, + }, nil + } + return nil, fmt.Errorf("keeper registry version %d is not supported", v.version) +} + +// ParseStaleUpkeepReportLog Parses Stale upkeep report log +func (v *LegacyEthereumKeeperRegistry) ParseStaleUpkeepReportLog(log *types.Log) (*StaleUpkeepReportLog, error) { + //nolint:exhaustive + switch v.version { + case ethereum.RegistryVersion_2_0: + parsedLog, err := v.registry2_0.ParseStaleUpkeepReport(*log) + if err != nil { + return nil, err + } + return &StaleUpkeepReportLog{ + Id: parsedLog.Id, + }, nil + case ethereum.RegistryVersion_2_1: + parsedLog, err := v.registry2_1.ParseStaleUpkeepReport(*log) + if err != nil { + return nil, err + } + return &StaleUpkeepReportLog{ + Id: parsedLog.Id, + }, nil + case ethereum.RegistryVersion_2_2: + parsedLog, err := v.registry2_2.ParseStaleUpkeepReport(*log) + if err != nil { + return nil, err + } + return &StaleUpkeepReportLog{ + Id: parsedLog.Id, + }, nil + } + return nil, fmt.Errorf("keeper registry version %d is not supported", v.version) +} + +// Parses the upkeep ID from an 'UpkeepRegistered' log, returns error on any other log +func (v *LegacyEthereumKeeperRegistry) ParseUpkeepIdFromRegisteredLog(log *types.Log) (*big.Int, error) { + switch v.version { + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1: + parsedLog, err := v.registry1_1.ParseUpkeepRegistered(*log) + if err != nil { + return nil, err + } + return parsedLog.Id, nil + case ethereum.RegistryVersion_1_2: + parsedLog, err := v.registry1_2.ParseUpkeepRegistered(*log) + if err != nil { + return nil, err + } + return parsedLog.Id, nil + case ethereum.RegistryVersion_1_3: + parsedLog, err := v.registry1_3.ParseUpkeepRegistered(*log) + if err != nil { + return nil, err + } + return parsedLog.Id, nil + case ethereum.RegistryVersion_2_0: + parsedLog, err := v.registry2_0.ParseUpkeepRegistered(*log) + if err != nil { + return nil, err + } + return parsedLog.Id, nil + case ethereum.RegistryVersion_2_1: + parsedLog, err := v.registry2_1.ParseUpkeepRegistered(*log) + if err != nil { + return nil, err + } + return parsedLog.Id, nil + case ethereum.RegistryVersion_2_2: + parsedLog, err := v.registry2_2.ParseUpkeepRegistered(*log) + if err != nil { + return nil, err + } + return parsedLog.Id, nil + } + + return nil, fmt.Errorf("keeper registry version %d is not supported", v.version) +} + +// KeeperConsumerRoundConfirmer is a header subscription that awaits for a round of upkeeps +type KeeperConsumerRoundConfirmer struct { + instance KeeperConsumer + upkeepsValue int + doneChan chan struct{} + context context.Context + cancel context.CancelFunc + l zerolog.Logger +} + +// NewKeeperConsumerRoundConfirmer provides a new instance of a KeeperConsumerRoundConfirmer +func NewKeeperConsumerRoundConfirmer( + contract KeeperConsumer, + counterValue int, + timeout time.Duration, + logger zerolog.Logger, +) *KeeperConsumerRoundConfirmer { + ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) + return &KeeperConsumerRoundConfirmer{ + instance: contract, + upkeepsValue: counterValue, + doneChan: make(chan struct{}), + context: ctx, + cancel: ctxCancel, + l: logger, + } +} + +// ReceiveHeader will query the latest Keeper round and check to see whether the round has confirmed +func (o *KeeperConsumerRoundConfirmer) ReceiveHeader(_ blockchain.NodeHeader) error { + upkeeps, err := o.instance.Counter(context.Background()) + if err != nil { + return err + } + l := o.l.Info(). + Str("Contract Address", o.instance.Address()). + Int64("Upkeeps", upkeeps.Int64()). + Int("Required upkeeps", o.upkeepsValue) + if upkeeps.Int64() == int64(o.upkeepsValue) { + l.Msg("Upkeep completed") + o.doneChan <- struct{}{} + } else { + l.Msg("Waiting for upkeep round") + } + return nil +} + +// Wait is a blocking function that will wait until the round has confirmed, and timeout if the deadline has passed +func (o *KeeperConsumerRoundConfirmer) Wait() error { + for { + select { + case <-o.doneChan: + o.cancel() + return nil + case <-o.context.Done(): + return fmt.Errorf("timeout waiting for upkeeps to confirm: %d", o.upkeepsValue) + } + } +} + +// KeeperConsumerPerformanceRoundConfirmer is a header subscription that awaits for a round of upkeeps +type KeeperConsumerPerformanceRoundConfirmer struct { + instance KeeperConsumerPerformance + doneChan chan bool + context context.Context + cancel context.CancelFunc + + lastBlockNum uint64 // Records the number of the last block that came in + blockCadence int64 // How many blocks before an upkeep should happen + blockRange int64 // How many blocks to watch upkeeps for + blocksSinceSubscription int64 // How many blocks have passed since subscribing + expectedUpkeepCount int64 // The count of upkeeps expected next iteration + blocksSinceSuccessfulUpkeep int64 // How many blocks have come in since the last successful upkeep + allMissedUpkeeps []int64 // Tracks the amount of blocks missed in each missed upkeep + totalSuccessfulUpkeeps int64 + + metricsReporter *testreporters.KeeperBlockTimeTestReporter // Testreporter to track results + complete bool + l zerolog.Logger +} + +// NewKeeperConsumerPerformanceRoundConfirmer provides a new instance of a KeeperConsumerPerformanceRoundConfirmer +// Used to track and log performance test results for keepers +func NewKeeperConsumerPerformanceRoundConfirmer( + contract KeeperConsumerPerformance, + expectedBlockCadence int64, // Expected to upkeep every 5/10/20 blocks, for example + blockRange int64, + metricsReporter *testreporters.KeeperBlockTimeTestReporter, + logger zerolog.Logger, +) *KeeperConsumerPerformanceRoundConfirmer { + ctx, cancelFunc := context.WithCancel(context.Background()) + return &KeeperConsumerPerformanceRoundConfirmer{ + instance: contract, + doneChan: make(chan bool), + context: ctx, + cancel: cancelFunc, + blockCadence: expectedBlockCadence, + blockRange: blockRange, + blocksSinceSubscription: 0, + blocksSinceSuccessfulUpkeep: 0, + expectedUpkeepCount: 1, + allMissedUpkeeps: []int64{}, + totalSuccessfulUpkeeps: 0, + metricsReporter: metricsReporter, + complete: false, + lastBlockNum: 0, + l: logger, + } +} + +// ReceiveHeader will query the latest Keeper round and check to see whether the round has confirmed +func (o *KeeperConsumerPerformanceRoundConfirmer) ReceiveHeader(receivedHeader blockchain.NodeHeader) error { + if receivedHeader.Number.Uint64() <= o.lastBlockNum { // Uncle / reorg we won't count + return nil + } + o.lastBlockNum = receivedHeader.Number.Uint64() + // Increment block counters + o.blocksSinceSubscription++ + o.blocksSinceSuccessfulUpkeep++ + upkeepCount, err := o.instance.GetUpkeepCount(context.Background()) + if err != nil { + return err + } + + isEligible, err := o.instance.CheckEligible(context.Background()) + if err != nil { + return err + } + if isEligible { + o.l.Trace(). + Str("Contract Address", o.instance.Address()). + Int64("Upkeeps Performed", upkeepCount.Int64()). + Msg("Upkeep Now Eligible") + } + if upkeepCount.Int64() >= o.expectedUpkeepCount { // Upkeep was successful + if o.blocksSinceSuccessfulUpkeep < o.blockCadence { // If there's an early upkeep, that's weird + o.l.Error(). + Str("Contract Address", o.instance.Address()). + Int64("Upkeeps Performed", upkeepCount.Int64()). + Int64("Expected Cadence", o.blockCadence). + Int64("Actual Cadence", o.blocksSinceSuccessfulUpkeep). + Err(errors.New("found an early Upkeep")) + return fmt.Errorf("found an early Upkeep on contract %s", o.instance.Address()) + } else if o.blocksSinceSuccessfulUpkeep == o.blockCadence { // Perfectly timed upkeep + o.l.Info(). + Str("Contract Address", o.instance.Address()). + Int64("Upkeeps Performed", upkeepCount.Int64()). + Int64("Expected Cadence", o.blockCadence). + Int64("Actual Cadence", o.blocksSinceSuccessfulUpkeep). + Msg("Successful Upkeep on Expected Cadence") + o.totalSuccessfulUpkeeps++ + } else { // Late upkeep + o.l.Warn(). + Str("Contract Address", o.instance.Address()). + Int64("Upkeeps Performed", upkeepCount.Int64()). + Int64("Expected Cadence", o.blockCadence). + Int64("Actual Cadence", o.blocksSinceSuccessfulUpkeep). + Msg("Upkeep Completed Late") + o.allMissedUpkeeps = append(o.allMissedUpkeeps, o.blocksSinceSuccessfulUpkeep-o.blockCadence) + } + // Update upkeep tracking values + o.blocksSinceSuccessfulUpkeep = 0 + o.expectedUpkeepCount++ + } + + if o.blocksSinceSubscription > o.blockRange { + if o.blocksSinceSuccessfulUpkeep > o.blockCadence { + o.l.Warn(). + Str("Contract Address", o.instance.Address()). + Int64("Upkeeps Performed", upkeepCount.Int64()). + Int64("Expected Cadence", o.blockCadence). + Int64("Expected Upkeep Count", o.expectedUpkeepCount). + Int64("Blocks Waiting", o.blocksSinceSuccessfulUpkeep). + Int64("Total Blocks Watched", o.blocksSinceSubscription). + Msg("Finished Watching for Upkeeps While Waiting on a Late Upkeep") + o.allMissedUpkeeps = append(o.allMissedUpkeeps, o.blocksSinceSuccessfulUpkeep-o.blockCadence) + } else { + o.l.Info(). + Str("Contract Address", o.instance.Address()). + Int64("Upkeeps Performed", upkeepCount.Int64()). + Int64("Total Blocks Watched", o.blocksSinceSubscription). + Msg("Finished Watching for Upkeeps") + } + o.doneChan <- true + o.complete = true + return nil + } + return nil +} + +// Wait is a blocking function that will wait until the round has confirmed, and timeout if the deadline has passed +func (o *KeeperConsumerPerformanceRoundConfirmer) Wait() error { + defer func() { o.complete = true }() + for { + select { + case <-o.doneChan: + o.cancel() + o.logDetails() + return nil + case <-o.context.Done(): + return fmt.Errorf("timeout waiting for expected upkeep count to confirm: %d", o.expectedUpkeepCount) + } + } +} + +func (o *KeeperConsumerPerformanceRoundConfirmer) Complete() bool { + return o.complete +} + +func (o *KeeperConsumerPerformanceRoundConfirmer) logDetails() { + report := testreporters.KeeperBlockTimeTestReport{ + ContractAddress: o.instance.Address(), + TotalExpectedUpkeeps: o.blockRange / o.blockCadence, + TotalSuccessfulUpkeeps: o.totalSuccessfulUpkeeps, + AllMissedUpkeeps: o.allMissedUpkeeps, + } + o.metricsReporter.ReportMutex.Lock() + o.metricsReporter.Reports = append(o.metricsReporter.Reports, report) + defer o.metricsReporter.ReportMutex.Unlock() +} + +// LegacyKeeperConsumerBenchmarkRoundConfirmer is a header subscription that awaits for a round of upkeeps +type LegacyKeeperConsumerBenchmarkRoundConfirmer struct { + instance AutomationConsumerBenchmark + registry KeeperRegistry + upkeepID *big.Int + doneChan chan bool + context context.Context + cancel context.CancelFunc + + firstBlockNum uint64 // Records the number of the first block that came in + lastBlockNum uint64 // Records the number of the last block that came in + blockRange int64 // How many blocks to watch upkeeps for + upkeepSLA int64 // SLA after which an upkeep is counted as 'missed' + metricsReporter *testreporters.KeeperBenchmarkTestReporter // Testreporter to track results + upkeepIndex int64 + firstEligibleBuffer int64 + + // State variables, changes as we get blocks + blocksSinceSubscription int64 // How many blocks have passed since subscribing + blocksSinceEligible int64 // How many blocks have come in since upkeep has been eligible for check + countEligible int64 // Number of times the upkeep became eligible + countMissed int64 // Number of times we missed SLA for performing upkeep + upkeepCount int64 // The count of upkeeps done so far + allCheckDelays []int64 // Tracks the amount of blocks missed before an upkeep since it became eligible + complete bool + l zerolog.Logger +} + +// NewLegacyKeeperConsumerBenchmarkRoundConfirmer provides a new instance of a LegacyKeeperConsumerBenchmarkRoundConfirmer +// Used to track and log benchmark test results for keepers +func NewLegacyKeeperConsumerBenchmarkRoundConfirmer( + contract AutomationConsumerBenchmark, + registry KeeperRegistry, + upkeepID *big.Int, + blockRange int64, + upkeepSLA int64, + metricsReporter *testreporters.KeeperBenchmarkTestReporter, + upkeepIndex int64, + firstEligibleBuffer int64, + logger zerolog.Logger, +) *LegacyKeeperConsumerBenchmarkRoundConfirmer { + ctx, cancelFunc := context.WithCancel(context.Background()) + return &LegacyKeeperConsumerBenchmarkRoundConfirmer{ + instance: contract, + registry: registry, + upkeepID: upkeepID, + doneChan: make(chan bool), + context: ctx, + cancel: cancelFunc, + blockRange: blockRange, + upkeepSLA: upkeepSLA, + blocksSinceSubscription: 0, + blocksSinceEligible: 0, + upkeepCount: 0, + allCheckDelays: []int64{}, + metricsReporter: metricsReporter, + complete: false, + lastBlockNum: 0, + upkeepIndex: upkeepIndex, + firstBlockNum: 0, + firstEligibleBuffer: firstEligibleBuffer, + l: logger, + } +} + +// ReceiveHeader will query the latest Keeper round and check to see whether the round has confirmed +func (o *LegacyKeeperConsumerBenchmarkRoundConfirmer) ReceiveHeader(receivedHeader blockchain.NodeHeader) error { + if receivedHeader.Number.Uint64() <= o.lastBlockNum { // Uncle / reorg we won't count + return nil + } + if o.firstBlockNum == 0 { + o.firstBlockNum = receivedHeader.Number.Uint64() + } + o.lastBlockNum = receivedHeader.Number.Uint64() + // Increment block counters + o.blocksSinceSubscription++ + + upkeepCount, err := o.instance.GetUpkeepCount(context.Background(), big.NewInt(o.upkeepIndex)) + if err != nil { + return err + } + + if upkeepCount.Int64() > o.upkeepCount { // A new upkeep was done + if upkeepCount.Int64() != o.upkeepCount+1 { + return errors.New("upkeep count increased by more than 1 in a single block") + } + o.l.Info(). + Uint64("Block_Number", receivedHeader.Number.Uint64()). + Str("Upkeep_ID", o.upkeepID.String()). + Str("Contract_Address", o.instance.Address()). + Int64("Upkeep_Count", upkeepCount.Int64()). + Int64("Blocks_since_eligible", o.blocksSinceEligible). + Str("Registry_Address", o.registry.Address()). + Msg("Upkeep Performed") + + if o.blocksSinceEligible > o.upkeepSLA { + o.l.Warn(). + Uint64("Block_Number", receivedHeader.Number.Uint64()). + Str("Upkeep_ID", o.upkeepID.String()). + Str("Contract_Address", o.instance.Address()). + Int64("Blocks_since_eligible", o.blocksSinceEligible). + Str("Registry_Address", o.registry.Address()). + Msg("Upkeep Missed SLA") + o.countMissed++ + } + + o.allCheckDelays = append(o.allCheckDelays, o.blocksSinceEligible) + o.upkeepCount++ + o.blocksSinceEligible = 0 + } + + isEligible, err := o.instance.CheckEligible(context.Background(), big.NewInt(o.upkeepIndex), big.NewInt(o.blockRange), big.NewInt(o.firstEligibleBuffer)) + if err != nil { + return err + } + if isEligible { + if o.blocksSinceEligible == 0 { + // First time this upkeep became eligible + o.countEligible++ + o.l.Info(). + Uint64("Block_Number", receivedHeader.Number.Uint64()). + Str("Upkeep_ID", o.upkeepID.String()). + Str("Contract_Address", o.instance.Address()). + Str("Registry_Address", o.registry.Address()). + Msg("Upkeep Now Eligible") + } + o.blocksSinceEligible++ + } + + if o.blocksSinceSubscription >= o.blockRange || int64(o.lastBlockNum-o.firstBlockNum) >= o.blockRange { + if o.blocksSinceEligible > 0 { + if o.blocksSinceEligible > o.upkeepSLA { + o.l.Warn(). + Uint64("Block_Number", receivedHeader.Number.Uint64()). + Str("Upkeep_ID", o.upkeepID.String()). + Str("Contract_Address", o.instance.Address()). + Int64("Blocks_since_eligible", o.blocksSinceEligible). + Str("Registry_Address", o.registry.Address()). + Msg("Upkeep remained eligible at end of test and missed SLA") + o.countMissed++ + } else { + o.l.Info(). + Uint64("Block_Number", receivedHeader.Number.Uint64()). + Str("Upkeep_ID", o.upkeepID.String()). + Str("Contract_Address", o.instance.Address()). + Int64("Upkeep_Count", upkeepCount.Int64()). + Int64("Blocks_since_eligible", o.blocksSinceEligible). + Str("Registry_Address", o.registry.Address()). + Msg("Upkeep remained eligible at end of test and was within SLA") + } + o.allCheckDelays = append(o.allCheckDelays, o.blocksSinceEligible) + } + + o.l.Info(). + Uint64("Block_Number", receivedHeader.Number.Uint64()). + Str("Upkeep_ID", o.upkeepID.String()). + Str("Contract_Address", o.instance.Address()). + Int64("Upkeeps_Performed", upkeepCount.Int64()). + Int64("Total_Blocks_Watched", o.blocksSinceSubscription). + Str("Registry_Address", o.registry.Address()). + Msg("Finished Watching for Upkeeps") + + o.doneChan <- true + o.complete = true + return nil + } + return nil +} + +// Wait is a blocking function that will wait until the round has confirmed, and timeout if the deadline has passed +func (o *LegacyKeeperConsumerBenchmarkRoundConfirmer) Wait() error { + defer func() { o.complete = true }() + for { + select { + case <-o.doneChan: + o.cancel() + o.logDetails() + return nil + case <-o.context.Done(): + return fmt.Errorf("timeout waiting for expected number of blocks: %d", o.blockRange) + } + } +} + +func (o *LegacyKeeperConsumerBenchmarkRoundConfirmer) Complete() bool { + return o.complete +} + +func (o *LegacyKeeperConsumerBenchmarkRoundConfirmer) logDetails() { + report := testreporters.KeeperBenchmarkTestReport{ + ContractAddress: o.instance.Address(), + TotalEligibleCount: o.countEligible, + TotalSLAMissedUpkeeps: o.countMissed, + TotalPerformedUpkeeps: o.upkeepCount, + AllCheckDelays: o.allCheckDelays, + RegistryAddress: o.registry.Address(), + } + o.metricsReporter.ReportMutex.Lock() + o.metricsReporter.Reports = append(o.metricsReporter.Reports, report) + defer o.metricsReporter.ReportMutex.Unlock() +} + +// LegacyEthereumUpkeepCounter represents keeper consumer (upkeep) counter contract +type LegacyEthereumUpkeepCounter struct { + client blockchain.EVMClient + consumer *upkeep_counter_wrapper.UpkeepCounter + address *common.Address +} + +func (v *LegacyEthereumUpkeepCounter) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumUpkeepCounter) Fund(ethAmount *big.Float) error { + gasEstimates, err := v.client.EstimateGas(geth.CallMsg{}) + if err != nil { + return err + } + return v.client.Fund(v.address.Hex(), ethAmount, gasEstimates) +} +func (v *LegacyEthereumUpkeepCounter) Counter(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + cnt, err := v.consumer.Counter(opts) + if err != nil { + return nil, err + } + return cnt, nil +} + +func (v *LegacyEthereumUpkeepCounter) SetSpread(testRange *big.Int, interval *big.Int) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := v.consumer.SetSpread(opts, testRange, interval) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +// Just pass for non-logtrigger +func (v *LegacyEthereumUpkeepCounter) Start() error { + return nil +} + +// LegacyEthereumUpkeepPerformCounterRestrictive represents keeper consumer (upkeep) counter contract +type LegacyEthereumUpkeepPerformCounterRestrictive struct { + client blockchain.EVMClient + consumer *upkeep_perform_counter_restrictive_wrapper.UpkeepPerformCounterRestrictive + address *common.Address +} + +func (v *LegacyEthereumUpkeepPerformCounterRestrictive) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumUpkeepPerformCounterRestrictive) Fund(ethAmount *big.Float) error { + gasEstimates, err := v.client.EstimateGas(geth.CallMsg{}) + if err != nil { + return err + } + return v.client.Fund(v.address.Hex(), ethAmount, gasEstimates) +} +func (v *LegacyEthereumUpkeepPerformCounterRestrictive) Counter(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + count, err := v.consumer.GetCountPerforms(opts) + return count, err +} + +func (v *LegacyEthereumUpkeepPerformCounterRestrictive) SetSpread(testRange *big.Int, interval *big.Int) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := v.consumer.SetSpread(opts, testRange, interval) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +// EthereumKeeperConsumer represents keeper consumer (upkeep) contract +type EthereumKeeperConsumer struct { + client blockchain.EVMClient + consumer *keeper_consumer_wrapper.KeeperConsumer + address *common.Address +} + +// Just pass for non-logtrigger +func (v *EthereumKeeperConsumer) Start() error { + return nil +} + +func (v *EthereumKeeperConsumer) Address() string { + return v.address.Hex() +} + +func (v *EthereumKeeperConsumer) Counter(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + cnt, err := v.consumer.Counter(opts) + if err != nil { + return nil, err + } + return cnt, nil +} + +type LegacyEthereumAutomationStreamsLookupUpkeepConsumer struct { + client blockchain.EVMClient + consumer *streams_lookup_upkeep_wrapper.StreamsLookupUpkeep + address *common.Address +} + +func (v *LegacyEthereumAutomationStreamsLookupUpkeepConsumer) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumAutomationStreamsLookupUpkeepConsumer) Start() error { + // For this consumer upkeep, we use this Start() function to set ParamKeys so as to run mercury v0.2 + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + // The default values of ParamKeys are "feedIDs" and "timestamp" which are for v0.3 + tx, err := v.consumer.SetParamKeys(txOpts, "feedIdHex", "blockNumber") + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +func (v *LegacyEthereumAutomationStreamsLookupUpkeepConsumer) Counter(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + cnt, err := v.consumer.Counter(opts) + if err != nil { + return nil, err + } + return cnt, nil +} + +type LegacyEthereumAutomationLogTriggeredStreamsLookupUpkeepConsumer struct { + client blockchain.EVMClient + consumer *log_triggered_streams_lookup_wrapper.LogTriggeredStreamsLookup + address *common.Address +} + +func (v *LegacyEthereumAutomationLogTriggeredStreamsLookupUpkeepConsumer) Address() string { + return v.address.Hex() +} + +// Kick off the log trigger event. The contract uses Mercury v0.2 so no need to set ParamKeys +func (v *LegacyEthereumAutomationLogTriggeredStreamsLookupUpkeepConsumer) Start() error { + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.consumer.Start(txOpts) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +func (v *LegacyEthereumAutomationLogTriggeredStreamsLookupUpkeepConsumer) Counter(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + cnt, err := v.consumer.Counter(opts) + if err != nil { + return nil, err + } + return cnt, nil +} + +type LegacyEthereumAutomationLogCounterConsumer struct { + client blockchain.EVMClient + consumer *log_upkeep_counter_wrapper.LogUpkeepCounter + address *common.Address +} + +func (v *LegacyEthereumAutomationLogCounterConsumer) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumAutomationLogCounterConsumer) Start() error { + txOpts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + + tx, err := v.consumer.Start(txOpts) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +func (v *LegacyEthereumAutomationLogCounterConsumer) Counter(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + cnt, err := v.consumer.Counter(opts) + if err != nil { + return nil, err + } + return cnt, nil +} + +type LegacyEthereumAutomationSimpleLogCounterConsumer struct { + client blockchain.EVMClient + consumer *simple_log_upkeep_counter_wrapper.SimpleLogUpkeepCounter + address *common.Address +} + +func (v *LegacyEthereumAutomationSimpleLogCounterConsumer) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumAutomationSimpleLogCounterConsumer) Start() error { + return nil +} + +func (v *LegacyEthereumAutomationSimpleLogCounterConsumer) Counter(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + cnt, err := v.consumer.Counter(opts) + if err != nil { + return nil, err + } + return cnt, nil +} + +// LegacyEthereumKeeperConsumerPerformance represents a more complicated keeper consumer contract, one intended only for +// performance tests. +type LegacyEthereumKeeperConsumerPerformance struct { + client blockchain.EVMClient + consumer *keeper_consumer_performance_wrapper.KeeperConsumerPerformance + address *common.Address +} + +func (v *LegacyEthereumKeeperConsumerPerformance) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumKeeperConsumerPerformance) Fund(ethAmount *big.Float) error { + gasEstimates, err := v.client.EstimateGas(geth.CallMsg{}) + if err != nil { + return err + } + return v.client.Fund(v.address.Hex(), ethAmount, gasEstimates) +} + +func (v *LegacyEthereumKeeperConsumerPerformance) CheckEligible(ctx context.Context) (bool, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + eligible, err := v.consumer.CheckEligible(opts) + return eligible, err +} + +func (v *LegacyEthereumKeeperConsumerPerformance) GetUpkeepCount(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + eligible, err := v.consumer.GetCountPerforms(opts) + return eligible, err +} + +func (v *LegacyEthereumKeeperConsumerPerformance) SetCheckGasToBurn(_ context.Context, gas *big.Int) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := v.consumer.SetCheckGasToBurn(opts, gas) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +func (v *LegacyEthereumKeeperConsumerPerformance) SetPerformGasToBurn(_ context.Context, gas *big.Int) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := v.consumer.SetPerformGasToBurn(opts, gas) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +// LegacyEthereumKeeperPerformDataCheckerConsumer represents keeper perform data checker contract +type LegacyEthereumKeeperPerformDataCheckerConsumer struct { + client blockchain.EVMClient + performDataChecker *perform_data_checker_wrapper.PerformDataChecker + address *common.Address +} + +func (v *LegacyEthereumKeeperPerformDataCheckerConsumer) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumKeeperPerformDataCheckerConsumer) Counter(ctx context.Context) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + cnt, err := v.performDataChecker.Counter(opts) + if err != nil { + return nil, err + } + return cnt, nil +} + +func (v *LegacyEthereumKeeperPerformDataCheckerConsumer) SetExpectedData(_ context.Context, expectedData []byte) error { + opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) + if err != nil { + return err + } + tx, err := v.performDataChecker.SetExpectedData(opts, expectedData) + if err != nil { + return err + } + return v.client.ProcessTransaction(tx) +} + +// LegacyEthereumAutomationConsumerBenchmark represents a more complicated keeper consumer contract, one intended only for +// Benchmark tests. +type LegacyEthereumAutomationConsumerBenchmark struct { + client blockchain.EVMClient + consumer *automation_consumer_benchmark.AutomationConsumerBenchmark + address *common.Address +} + +func (v *LegacyEthereumAutomationConsumerBenchmark) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumAutomationConsumerBenchmark) Fund(ethAmount *big.Float) error { + gasEstimates, err := v.client.EstimateGas(geth.CallMsg{}) + if err != nil { + return err + } + return v.client.Fund(v.address.Hex(), ethAmount, gasEstimates) +} + +func (v *LegacyEthereumAutomationConsumerBenchmark) CheckEligible(ctx context.Context, id *big.Int, _range *big.Int, firstEligibleBuffer *big.Int) (bool, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + eligible, err := v.consumer.CheckEligible(opts, id, _range, firstEligibleBuffer) + return eligible, err +} + +func (v *LegacyEthereumAutomationConsumerBenchmark) GetUpkeepCount(ctx context.Context, id *big.Int) (*big.Int, error) { + opts := &bind.CallOpts{ + From: common.HexToAddress(v.client.GetDefaultWallet().Address()), + Context: ctx, + } + eligible, err := v.consumer.GetCountPerforms(opts, id) + return eligible, err +} + +// LegacyEthereumKeeperRegistrar corresponds to the registrar which is used to send requests to the registry when +// registering new upkeeps. +type LegacyEthereumKeeperRegistrar struct { + client blockchain.EVMClient + registrar *keeper_registrar_wrapper1_2.KeeperRegistrar + registrar20 *keeper_registrar_wrapper2_0.KeeperRegistrar + registrar21 *registrar21.AutomationRegistrar + address *common.Address +} + +func (v *LegacyEthereumKeeperRegistrar) Address() string { + return v.address.Hex() +} + +func (v *LegacyEthereumKeeperRegistrar) Fund(ethAmount *big.Float) error { + gasEstimates, err := v.client.EstimateGas(geth.CallMsg{}) + if err != nil { + return err + } + return v.client.Fund(v.address.Hex(), ethAmount, gasEstimates) +} + +// EncodeRegisterRequest encodes register request to call it through link token TransferAndCall +func (v *LegacyEthereumKeeperRegistrar) EncodeRegisterRequest(name string, email []byte, upkeepAddr string, gasLimit uint32, adminAddr string, checkData []byte, amount *big.Int, source uint8, senderAddr string, isLogTrigger bool, isMercury bool, linkTokenAddr string) ([]byte, error) { + if v.registrar20 != nil { + registryABI, err := abi.JSON(strings.NewReader(keeper_registrar_wrapper2_0.KeeperRegistrarMetaData.ABI)) + if err != nil { + return nil, err + } + req, err := registryABI.Pack( + "register", + name, + email, + common.HexToAddress(upkeepAddr), + gasLimit, + common.HexToAddress(adminAddr), + checkData, + []byte{}, //offchainConfig + amount, + common.HexToAddress(senderAddr), + ) + + if err != nil { + return nil, err + } + return req, nil + } else if v.registrar21 != nil { + if isLogTrigger { + var topic0InBytes [32]byte + // bytes representation of 0x0000000000000000000000000000000000000000000000000000000000000000 + bytes0 := [32]byte{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + } + if isMercury { + // bytes representation of 0xd1ffe9e45581c11d7d9f2ed5f75217cd4be9f8b7eee6af0f6d03f46de53956cd + topic0InBytes = [32]byte{209, 255, 233, 228, 85, 129, 193, 29, 125, 159, 46, 213, 247, 82, 23, 205, 75, 233, 248, 183, 238, 230, 175, 15, 109, 3, 244, 109, 229, 57, 86, 205} + } else { + // bytes representation of 0x3d53a39550e04688065827f3bb86584cb007ab9ebca7ebd528e7301c9c31eb5d + topic0InBytes = [32]byte{ + 61, 83, 163, 149, 80, 224, 70, 136, + 6, 88, 39, 243, 187, 134, 88, 76, + 176, 7, 171, 158, 188, 167, 235, + 213, 40, 231, 48, 28, 156, 49, 235, 93, + } + } + + logTriggerConfigStruct := ac.IAutomationV21PlusCommonLogTriggerConfig{ + ContractAddress: common.HexToAddress(upkeepAddr), + FilterSelector: 0, + Topic0: topic0InBytes, + Topic1: bytes0, + Topic2: bytes0, + Topic3: bytes0, + } + encodedLogTriggerConfig, err := compatibleUtils.Methods["_logTriggerConfig"].Inputs.Pack(&logTriggerConfigStruct) + if err != nil { + return nil, err + } + + req, err := registrarABI.Pack( + "register", + name, + email, + common.HexToAddress(upkeepAddr), + gasLimit, + common.HexToAddress(adminAddr), + uint8(1), // trigger type + checkData, + encodedLogTriggerConfig, // triggerConfig + []byte{}, // offchainConfig + amount, + common.HexToAddress(senderAddr), + ) + + return req, err + } + req, err := registrarABI.Pack( + "register", + name, + email, + common.HexToAddress(upkeepAddr), + gasLimit, + common.HexToAddress(adminAddr), + uint8(0), // trigger type + checkData, + []byte{}, // triggerConfig + []byte{}, // offchainConfig + amount, + common.HexToAddress(senderAddr), + ) + return req, err + } + registryABI, err := abi.JSON(strings.NewReader(keeper_registrar_wrapper1_2.KeeperRegistrarMetaData.ABI)) + if err != nil { + return nil, err + } + req, err := registryABI.Pack( + "register", + name, + email, + common.HexToAddress(upkeepAddr), + gasLimit, + common.HexToAddress(adminAddr), + checkData, + amount, + source, + common.HexToAddress(senderAddr), + ) + if err != nil { + return nil, err + } + return req, nil +} + +// LegacyEthereumUpkeepTranscoder represents the transcoder which is used to perform migrations +// of upkeeps from one registry to another. +type LegacyEthereumUpkeepTranscoder struct { + client blockchain.EVMClient + transcoder *upkeep_transcoder.UpkeepTranscoder + address *common.Address +} + +func (v *LegacyEthereumUpkeepTranscoder) Address() string { + return v.address.Hex() } diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 8daca81efae..d1e06d7feb2 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -8,7 +8,6 @@ replace github.com/smartcontractkit/chainlink/v2 => ../ require ( github.com/avast/retry-go/v4 v4.5.1 github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df - github.com/chaos-mesh/chaos-mesh/api/v1alpha1 v0.0.0-20220226050744-799408773657 github.com/cli/go-gh/v2 v2.0.0 github.com/ethereum/go-ethereum v1.13.8 github.com/fxamacker/cbor/v2 v2.5.0 @@ -22,19 +21,18 @@ require ( github.com/onsi/gomega v1.30.0 github.com/pelletier/go-toml/v2 v2.2.2 github.com/pkg/errors v0.9.1 - github.com/rs/zerolog v1.31.0 + github.com/rs/zerolog v1.30.0 github.com/scylladb/go-reflectx v1.0.1 github.com/segmentio/ksuid v1.0.4 github.com/shopspring/decimal v1.3.1 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.4 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240620164046-1c03d0a97b20 - github.com/smartcontractkit/chainlink-testing-framework v1.31.1 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240612013352-4fe4a2e2ed0f + github.com/smartcontractkit/chainlink-testing-framework v1.30.5 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 - github.com/smartcontractkit/havoc/k8schaos v0.0.0-20240409145249-e78d20847e37 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c - github.com/smartcontractkit/seth v1.0.12 + github.com/smartcontractkit/seth v1.0.12-0.20240618124527-ca057b90a33b github.com/smartcontractkit/wasp v0.4.7 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 @@ -46,13 +44,13 @@ require ( golang.org/x/sync v0.6.0 golang.org/x/text v0.14.0 gopkg.in/guregu/null.v4 v4.0.0 - k8s.io/apimachinery v0.28.2 ) // avoids ambigious imports of indirect dependencies exclude github.com/hashicorp/consul v1.2.1 replace ( + // Pin K8s versions as their updates are highly disruptive and go mod keeps wanting to update them k8s.io/api => k8s.io/api v0.25.11 k8s.io/client-go => k8s.io/client-go v0.25.11 k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d @@ -113,6 +111,7 @@ require ( github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect + github.com/chaos-mesh/chaos-mesh/api/v1alpha1 v0.0.0-20220226050744-799408773657 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.0 // indirect github.com/chzyer/readline v1.5.1 // indirect @@ -207,7 +206,6 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.15.5 // indirect github.com/go-redis/redis/v8 v8.11.5 // indirect - github.com/go-test/deep v1.0.8 // indirect github.com/go-webauthn/webauthn v0.9.4 // indirect github.com/go-webauthn/x v0.1.5 // indirect github.com/goccy/go-json v0.10.2 // indirect @@ -383,7 +381,7 @@ require ( github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917 // indirect github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240605170242-555ff582f36a // indirect github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240531021326-99118e47f696 // indirect - github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240405215812-5a72bc9af239 // indirect + github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449 // indirect github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 // indirect github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230906073235-9e478e5e19f1 // indirect github.com/smartcontractkit/wsrpc v0.8.1 // indirect @@ -416,7 +414,6 @@ require ( github.com/uber/jaeger-lib v2.4.1+incompatible // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/umbracle/fastrlp v0.0.0-20220527094140-59d5dd30e722 // indirect - github.com/urfave/cli/v2 v2.27.1 // indirect github.com/valyala/fastjson v1.4.1 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/x448/float16 v0.8.4 // indirect @@ -473,6 +470,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.28.2 // indirect k8s.io/apiextensions-apiserver v0.25.3 // indirect + k8s.io/apimachinery v0.28.2 // indirect k8s.io/cli-runtime v0.25.11 // indirect k8s.io/client-go v0.28.2 // indirect k8s.io/component-base v0.26.2 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 97813f85ea1..95a0536abf5 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -652,9 +652,8 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= -github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/go-webauthn/webauthn v0.9.4 h1:YxvHSqgUyc5AK2pZbqkWWR55qKeDPhP8zLDr6lpIc2g= github.com/go-webauthn/webauthn v0.9.4/go.mod h1:LqupCtzSef38FcxzaklmOn7AykGKhAhr9xlRbdbgnTw= github.com/go-webauthn/x v0.1.5 h1:V2TCzDU2TGLd0kSZOXdrqDVV5JB9ILnKxA9S53CSBw0= @@ -1197,7 +1196,6 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= @@ -1457,8 +1455,8 @@ github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= @@ -1514,8 +1512,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240620164046-1c03d0a97b20 h1:Ea3shtV50R1qMkLbDaOwio2C+Ia1dB7pJQzpm7vHzxM= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240620164046-1c03d0a97b20/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240612013352-4fe4a2e2ed0f h1:MfEG+nDHibAFFF1iirnF849YJT8ne+adVEf8p2fVze8= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240612013352-4fe4a2e2ed0f/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo= @@ -1526,22 +1524,20 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240605170242-555ff582f36 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240605170242-555ff582f36a/go.mod h1:QqcZSwLgEIn7YraAIRmomnBMAuVFephiHrIWVlkWbFI= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240531021326-99118e47f696 h1:h1E87+z+JcUEfvbJVF56SnZA/YUFE5ewUE61MaR/Ewg= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240531021326-99118e47f696/go.mod h1:OiWUTrrpSLLTMh7FINWjEh6mmDJCVPaC4yEsDCVaWdU= -github.com/smartcontractkit/chainlink-testing-framework v1.31.1 h1:Qqo5VngCqbHQPfQKZneAN0L1dWXOWWd074Oo9Bex/Q0= -github.com/smartcontractkit/chainlink-testing-framework v1.31.1/go.mod h1:E6uNEZhZZid9PHv6/Kq5Vn63GlO61ZcKB+/f0DKo3Q4= -github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240405215812-5a72bc9af239 h1:Kk5OVlx/5g9q3Z3lhxytZS4/f8ds1MiNM8yaHgK3Oe8= -github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240405215812-5a72bc9af239/go.mod h1:DC8sQMyTlI/44UCTL8QWFwb0bYNoXCfjwCv2hMivYZU= +github.com/smartcontractkit/chainlink-testing-framework v1.30.5 h1:RBeQkaUH095L/hOH6JbfScAo4jkI0osBp8kgULnGwos= +github.com/smartcontractkit/chainlink-testing-framework v1.30.5/go.mod h1:E6uNEZhZZid9PHv6/Kq5Vn63GlO61ZcKB+/f0DKo3Q4= +github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449 h1:fX/xmGm1GBsD1ZZnooNT+eWA0hiTAqFlHzOC5CY4dy8= +github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449/go.mod h1:DC8sQMyTlI/44UCTL8QWFwb0bYNoXCfjwCv2hMivYZU= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0= -github.com/smartcontractkit/havoc/k8schaos v0.0.0-20240409145249-e78d20847e37 h1:ZEhn2Yo1jY4hqy8nasDL4k4pNtopT3rS3Ap1GDb7ODc= -github.com/smartcontractkit/havoc/k8schaos v0.0.0-20240409145249-e78d20847e37/go.mod h1:/kFr0D7SI/vueXl1N03uzOun4nViGPFRyA5X6eL3jXw= github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c h1:lIyMbTaF2H0Q71vkwZHX/Ew4KF2BxiKhqEXwF8rn+KI= github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c/go.mod h1:fb1ZDVXACvu4frX3APHZaEBp0xi1DIm34DcA0CwTsZM= -github.com/smartcontractkit/seth v1.0.12 h1:iVdgMx42XWanPPnBaM5StR4c1XsTr/0/B/kKRZL5BsY= -github.com/smartcontractkit/seth v1.0.12/go.mod h1:thWtbLyW4nRHJGzC5heknQDORoJPErE15sF34LHkorg= +github.com/smartcontractkit/seth v1.0.12-0.20240618124527-ca057b90a33b h1:9to6XdJN1bIVrjLmWm9nyVaaKcIPcJKO8eTJjPYO5vs= +github.com/smartcontractkit/seth v1.0.12-0.20240618124527-ca057b90a33b/go.mod h1:thWtbLyW4nRHJGzC5heknQDORoJPErE15sF34LHkorg= github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 h1:yiKnypAqP8l0OX0P3klzZ7SCcBUxy5KqTAKZmQOvSQE= github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1/go.mod h1:q6f4fe39oZPdsh1i57WznEZgxd8siidMaSFq3wdPmVg= github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230906073235-9e478e5e19f1 h1:Dai1bn+Q5cpeGMQwRdjOdVjG8mmFFROVkSKuUgBErRQ= @@ -1673,8 +1669,8 @@ github.com/unrolled/secure v1.13.0 h1:sdr3Phw2+f8Px8HE5sd1EHdj1aV3yUwed/uZXChLFs github.com/unrolled/secure v1.13.0/go.mod h1:BmF5hyM6tXczk3MpQkFf1hpKSRqCyhqcbiQtiAF7+40= github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk= github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA= -github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= -github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 50b5fb96230..46abccae565 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -110,6 +110,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { "registry_2_2_with_mercury_v02": ethereum.RegistryVersion_2_2, "registry_2_2_with_mercury_v03": ethereum.RegistryVersion_2_2, "registry_2_2_with_logtrigger_and_mercury_v02": ethereum.RegistryVersion_2_2, + "registry_2_3_conditional": ethereum.RegistryVersion_2_3, } for n, rv := range registryVersions {