Skip to content

Commit

Permalink
fix: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ecPablo committed Dec 12, 2024
1 parent f6596c4 commit f0aa7da
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
7 changes: 4 additions & 3 deletions deployment/common/changeset/example/link_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
39 changes: 26 additions & 13 deletions deployment/common/changeset/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package changeset

import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
Expand Down

0 comments on commit f0aa7da

Please sign in to comment.