-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
202 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package configs | ||
|
||
import ( | ||
"fmt" | ||
|
||
cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" | ||
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" | ||
configstypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/configs/types" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/configs/v1_6_0" | ||
v1_6_0_evm "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/configs/v1_6_0/evm" | ||
evmrelaytypes "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types" | ||
) | ||
|
||
func GetCCIPReaderContractReaderConfig( | ||
ccipCapVersion string, | ||
chainSelector cciptypes.ChainSelector, | ||
chainSide configstypes.ChainSide, | ||
) ([]byte, error) { | ||
switch ccipCapVersion { | ||
case "v1.6.0": | ||
return v1_6_0.GetCCIPReaderContractReaderConfig(chainSelector, chainSide) | ||
default: | ||
return nil, fmt.Errorf("unsupported ccip capability version: %s", ccipCapVersion) | ||
} | ||
} | ||
|
||
func GetHomeChainContractReaderConfig( | ||
ccipCapVersion string, | ||
) (evmrelaytypes.ChainReaderConfig, error) { | ||
switch ccipCapVersion { | ||
case "v1.6.0": | ||
return v1_6_0_evm.HomeChainReaderConfigRaw(), nil | ||
default: | ||
return evmrelaytypes.ChainReaderConfig{}, fmt.Errorf("unsupported ccip capability version: %s", ccipCapVersion) | ||
} | ||
} | ||
|
||
func GetChainWriterConfig( | ||
ccipCapVersion string, | ||
chainSelector cciptypes.ChainSelector, | ||
fromAddress string, | ||
maxGasPrice *assets.Wei, | ||
) ([]byte, error) { | ||
switch ccipCapVersion { | ||
case "v1.6.0": | ||
return v1_6_0.GetChainWriterConfig(chainSelector, fromAddress, maxGasPrice) | ||
default: | ||
return nil, fmt.Errorf("unsupported ccip capability version: %s", ccipCapVersion) | ||
} | ||
} |
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,12 @@ | ||
package types | ||
|
||
// ChainSide represents the two sides of a CCIP plugin, | ||
// the source and the destination chains. | ||
type ChainSide string | ||
|
||
const ( | ||
// ChainSideSource represents the source chain of a CCIP plugin. | ||
ChainSideSource ChainSide = "source" | ||
// ChainSideDest represents the destination chain of a CCIP plugin. | ||
ChainSideDest ChainSide = "dest" | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package v1_6_0 | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" | ||
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" | ||
configstypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/configs/types" | ||
v1_6_0_evm "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/configs/v1_6_0/evm" | ||
) | ||
|
||
// GetCCIPReaderContractReaderConfig returns the marshaled JSON configuration for the CCIP reader contract reader. | ||
// A different configuration is returned based on chain family and based on whether we are setting up the chain | ||
// reader to read a source or a destination chain. | ||
func GetCCIPReaderContractReaderConfig(chainSelector cciptypes.ChainSelector, chainSide configstypes.ChainSide) ([]byte, error) { | ||
switch family := getFamily(chainSelector); family { | ||
case "EVM": | ||
cfg, err := v1_6_0_evm.CCIPReaderContractReaderConfig(chainSide) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get EVM CCIP reader contract reader config: %w", err) | ||
} | ||
return json.Marshal(cfg) | ||
default: | ||
return nil, fmt.Errorf("unsupported chain family: %s", family) | ||
} | ||
} | ||
|
||
func GetChainWriterConfig(chainSelector cciptypes.ChainSelector, fromAddress string, maxGasPrice *assets.Wei) ([]byte, error) { | ||
switch family := getFamily(chainSelector); family { | ||
case "EVM": | ||
return json.Marshal(v1_6_0_evm.ChainWriterConfigRaw(common.HexToAddress(fromAddress), maxGasPrice)) | ||
default: | ||
return nil, fmt.Errorf("unsupported chain family: %s", family) | ||
} | ||
} | ||
|
||
// TODO: move this API to chain-selectors library. | ||
func getFamily(_ cciptypes.ChainSelector) string { | ||
return "EVM" | ||
} |
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
Oops, something went wrong.