diff --git a/deployment/common/changeset/example/link_transfer_test.go b/deployment/common/changeset/example/link_transfer_test.go index a956634f0c7..cd84613be00 100644 --- a/deployment/common/changeset/example/link_transfer_test.go +++ b/deployment/common/changeset/example/link_transfer_test.go @@ -11,6 +11,7 @@ import ( chain_selectors "github.com/smartcontractkit/chain-selectors" "github.com/smartcontractkit/chainlink/deployment/common/changeset/example" + "github.com/smartcontractkit/chainlink/deployment/common/proposalutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/stretchr/testify/require" @@ -32,7 +33,7 @@ func setupLinkTransferTestEnv(t *testing.T) deployment.Environment { } env := memory.NewMemoryEnvironment(t, lggr, zapcore.DebugLevel, cfg) chainSelector := env.AllChainSelectors()[0] - config := changeset.SingleGroupMCMS(t) + config := proposalutils.SingleGroupMCMS(t) // Deploy MCMS and Timelock env, err := changeset.ApplyChangesets(t, env, nil, []changeset.ChangesetApplication{ @@ -87,7 +88,7 @@ func TestLinkTransferMCMS(t *testing.T) { _, err = deployment.ConfirmIfNoError(chain, tx, err) require.NoError(t, err) - timelocks := map[uint64]*changeset.TimelockExecutionContracts{ + timelocks := map[uint64]*proposalutils.TimelockExecutionContracts{ chainSelector: { Timelock: mcmsState.Timelock, CallProxy: mcmsState.CallProxy, @@ -162,7 +163,7 @@ func TestLinkTransfer(t *testing.T) { _, err = deployment.ConfirmIfNoError(chain, tx, err) require.NoError(t, err) - timelocks := map[uint64]*changeset.TimelockExecutionContracts{ + timelocks := map[uint64]*proposalutils.TimelockExecutionContracts{ chainSelector: { Timelock: mcmsState.Timelock, CallProxy: mcmsState.CallProxy, diff --git a/deployment/common/changeset/state.go b/deployment/common/changeset/state.go index 7184e5e4d79..0db34abad71 100644 --- a/deployment/common/changeset/state.go +++ b/deployment/common/changeset/state.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/ethereum/go-ethereum/common" + owner_helpers "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/common/proposalutils" @@ -22,17 +23,6 @@ type MCMSWithTimelockState struct { *proposalutils.MCMSWithTimelockContracts } -func MaybeLoadMCMSWithTimelockState(chain deployment.Chain, addresses map[string]deployment.TypeAndVersion) (*MCMSWithTimelockState, error) { - contracts, err := proposalutils.MaybeLoadMCMSWithTimelockContracts(chain, addresses) - if err != nil { - return nil, err - } - - return &MCMSWithTimelockState{ - MCMSWithTimelockContracts: contracts, - }, nil -} - func (state MCMSWithTimelockState) GenerateMCMSWithTimelockView() (v1_0.MCMSWithTimelockView, error) { if err := state.Validate(); err != nil { return v1_0.MCMSWithTimelockView{}, err @@ -95,7 +85,9 @@ func MaybeLoadMCMSWithTimelockState(env deployment.Environment, chainSelectors [ // - It only found part of the bundle of contracts // - If found more than one instance of a contract (we expect one bundle in the given addresses) func MaybeLoadMCMSWithTimelockChainState(chain deployment.Chain, addresses map[string]deployment.TypeAndVersion) (*MCMSWithTimelockState, error) { - state := MCMSWithTimelockState{} + state := MCMSWithTimelockState{ + MCMSWithTimelockContracts: &proposalutils.MCMSWithTimelockContracts{}, + } // We expect one of each contract on the chain. timelock := deployment.NewTypeAndVersion(types.RBACTimelock, deployment.Version1_0_0) callProxy := deployment.NewTypeAndVersion(types.CallProxy, deployment.Version1_0_0) @@ -160,7 +152,28 @@ func (s LinkTokenState) GenerateLinkView() (v1_0.LinkTokenView, error) { return v1_0.GenerateLinkTokenView(s.LinkToken) } -func MaybeLoadLinkTokenState(chain deployment.Chain, addresses map[string]deployment.TypeAndVersion) (*LinkTokenState, error) { +// MaybeLoadLinkTokenState loads the LinkTokenState state for each chain in the given environment. +func MaybeLoadLinkTokenState(env deployment.Environment, chainSelectors []uint64) (map[uint64]*LinkTokenState, error) { + result := map[uint64]*LinkTokenState{} + for _, chainSelector := range chainSelectors { + chain, ok := env.Chains[chainSelector] + if !ok { + return nil, fmt.Errorf("chain %d not found", chainSelector) + } + addressesChain, err := env.ExistingAddresses.AddressesForChain(chainSelector) + if err != nil { + return nil, err + } + state, err := MaybeLoadLinkTokenChainState(chain, addressesChain) + if err != nil { + return nil, err + } + result[chainSelector] = state + } + return result, nil +} + +func MaybeLoadLinkTokenChainState(chain deployment.Chain, addresses map[string]deployment.TypeAndVersion) (*LinkTokenState, error) { state := LinkTokenState{} linkToken := deployment.NewTypeAndVersion(types.LinkToken, deployment.Version1_0_0) // Perhaps revisit if we have a use case for multiple. diff --git a/deployment/common/changeset/transfer_to_mcms_with_timelock_test.go b/deployment/common/changeset/transfer_to_mcms_with_timelock_test.go index 523493cb87d..7ba11596a2d 100644 --- a/deployment/common/changeset/transfer_to_mcms_with_timelock_test.go +++ b/deployment/common/changeset/transfer_to_mcms_with_timelock_test.go @@ -1,7 +1,6 @@ package changeset import ( - "math/big" "testing" "github.com/ethereum/go-ethereum/common"