-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add temporary fixes to get the code to compile
- Loading branch information
1 parent
b33f02a
commit f7cd53e
Showing
9 changed files
with
201 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
deployment/common/changeset/state/state.go → deployment/common/changeset/state/evm.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
package state | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package state | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gagliardetto/solana-go" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment" | ||
proposalutilssolana "github.com/smartcontractkit/chainlink/deployment/common/proposalutils/solana" | ||
"github.com/smartcontractkit/chainlink/deployment/common/types" | ||
) | ||
|
||
// MCMSWithTimelockStateStateSolana holds the Go bindings | ||
// for a MCMSWithTimelock contract deployment. | ||
// It is public for use in product specific packages. | ||
// Either all fields are nil or all fields are non-nil. | ||
type MCMSWithTimelockStateSolana struct { | ||
*proposalutilssolana.MCMSWithTimelockProgramsSolana | ||
} | ||
|
||
// MaybeLoadMCMSWithTimelockState loads the MCMSWithTimelockState state for each chain in the given environment. | ||
func MaybeLoadMCMSWithTimelockStateSolana(env deployment.Environment, chainSelectors []uint64) (map[uint64]*MCMSWithTimelockStateSolana, error) { | ||
result := map[uint64]*MCMSWithTimelockStateSolana{} | ||
for _, chainSelector := range chainSelectors { | ||
chain, ok := env.SolChains[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 := MaybeLoadMCMSWithTimelockChainStateSolana(chain, addressesChain) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result[chainSelector] = state | ||
} | ||
return result, nil | ||
} | ||
|
||
// MaybeLoadMCMSWithTimelockChainState looks for the addresses corresponding to | ||
// contracts deployed with DeployMCMSWithTimelock and loads them into a | ||
// MCMSWithTimelockState struct. If none of the contracts are found, the state struct will be nil. | ||
// An error indicates: | ||
// - Found but was unable to load a contract | ||
// - 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 MaybeLoadMCMSWithTimelockChainStateSolana(chain deployment.SolChain, addresses map[string]deployment.TypeAndVersion) (*MCMSWithTimelockStateSolana, error) { | ||
state := MCMSWithTimelockStateSolana{ | ||
MCMSWithTimelockProgramsSolana: &proposalutilssolana.MCMSWithTimelockProgramsSolana{}, | ||
} | ||
// 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) | ||
proposer := deployment.NewTypeAndVersion(types.ProposerManyChainMultisig, deployment.Version1_0_0) | ||
canceller := deployment.NewTypeAndVersion(types.CancellerManyChainMultisig, deployment.Version1_0_0) | ||
bypasser := deployment.NewTypeAndVersion(types.BypasserManyChainMultisig, deployment.Version1_0_0) | ||
|
||
// Convert map keys to a slice | ||
wantTypes := []deployment.TypeAndVersion{timelock, proposer, canceller, bypasser, callProxy} | ||
|
||
// Ensure we either have the bundle or not. | ||
_, err := deployment.AddressesContainBundle(addresses, wantTypes) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to check MCMS contracts on chain %s error: %w", chain.Name(), err) | ||
} | ||
|
||
for address, tvStr := range addresses { | ||
switch { | ||
case tvStr.Type == timelock.Type && tvStr.Version.String() == timelock.Version.String(): | ||
pub, err := solana.PublicKeyFromBase58(address) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to create solana public key from timelock address (%s): %w", address, err) | ||
} | ||
state.Timelock = pub | ||
|
||
case tvStr.Type == callProxy.Type && tvStr.Version.String() == callProxy.Version.String(): | ||
pub, err := solana.PublicKeyFromBase58(address) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to create solana public key from timelock address (%s): %w", address, err) | ||
} | ||
state.CallProxy = pub | ||
|
||
case tvStr.Type == proposer.Type && tvStr.Version.String() == proposer.Version.String(): | ||
pub, err := solana.PublicKeyFromBase58(address) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to create solana public key from timelock address (%s): %w", address, err) | ||
} | ||
state.ProposerMcm = pub | ||
|
||
case tvStr.Type == bypasser.Type && tvStr.Version.String() == bypasser.Version.String(): | ||
pub, err := solana.PublicKeyFromBase58(address) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to create solana public key from timelock address (%s): %w", address, err) | ||
} | ||
state.BypasserMcm = pub | ||
|
||
case tvStr.Type == canceller.Type && tvStr.Version.String() == canceller.Version.String(): | ||
pub, err := solana.PublicKeyFromBase58(address) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to create solana public key from timelock address (%s): %w", address, err) | ||
} | ||
state.CancellerMcm = pub | ||
} | ||
|
||
} | ||
return &state, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters