From 47635ff3624c16650594059426d1098b006f030b Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 1 Jul 2024 22:34:38 +0200 Subject: [PATCH] add new chains --- pkg/chains/chain_test.go | 8 ++++---- pkg/chains/chains.go | 39 +++++++++++++++++++++++++++++++++++++++ pkg/chains/chains_test.go | 14 ++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index d14fd39a37..10914ea292 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -59,7 +59,7 @@ func TestChain_Validate(t *testing.T) { name: "should error if chain name invalid", chain: Chain{ ChainId: 42, - ChainName: ChainName_base_sepolia + 1, + ChainName: ChainName_solana_localnet + 1, Network: Network_optimism, NetworkType: NetworkType_testnet, Vm: Vm_evm, @@ -73,7 +73,7 @@ func TestChain_Validate(t *testing.T) { chain: Chain{ ChainId: 42, ChainName: ChainName_empty, - Network: Network_base + 1, + Network: Network_solana + 1, NetworkType: NetworkType_testnet, Vm: Vm_evm, Consensus: Consensus_op_stack, @@ -101,7 +101,7 @@ func TestChain_Validate(t *testing.T) { ChainName: ChainName_empty, Network: Network_base, NetworkType: NetworkType_devnet, - Vm: Vm_evm + 1, + Vm: Vm_svm + 1, Consensus: Consensus_op_stack, IsExternal: true, }, @@ -115,7 +115,7 @@ func TestChain_Validate(t *testing.T) { Network: Network_base, NetworkType: NetworkType_devnet, Vm: Vm_evm, - Consensus: Consensus_op_stack + 1, + Consensus: Consensus_solana_consensus + 1, IsExternal: true, }, errStr: "invalid consensus", diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 11c6f952f0..57eb8feb5a 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -91,6 +91,18 @@ var ( CctxGateway: CCTXGateway_observers, } + // SolanaMainnet is Solana mainnet + SolanaMainnet = Chain{ + ChainName: ChainName_solana_mainnet, + ChainId: 900, + Network: Network_solana, + NetworkType: NetworkType_mainnet, + Vm: Vm_svm, + Consensus: Consensus_solana_consensus, + IsExternal: true, + CctxGateway: CCTXGateway_observers, + } + /** * Testnet chains */ @@ -179,6 +191,18 @@ var ( CctxGateway: CCTXGateway_observers, } + // SolanaTestnet is Solana testnet + SolanaTestnet = Chain{ + ChainName: ChainName_solana_testnet, + ChainId: 901, + Network: Network_solana, + NetworkType: NetworkType_testnet, + Vm: Vm_svm, + Consensus: Consensus_solana_consensus, + IsExternal: true, + CctxGateway: CCTXGateway_observers, + } + /** * Devnet chains */ @@ -236,6 +260,18 @@ var ( CctxGateway: CCTXGateway_observers, } + // SolanaLocalnet is Solana localnet + SolanaLocalnet = Chain{ + ChainName: ChainName_solana_localnet, + ChainId: 902, + Network: Network_solana, + NetworkType: NetworkType_privnet, + Vm: Vm_svm, + Consensus: Consensus_solana_consensus, + IsExternal: true, + CctxGateway: CCTXGateway_observers, + } + /** * Deprecated chains */ @@ -293,6 +329,9 @@ func DefaultChainsList() []*Chain { OptimismSepolia, BaseMainnet, BaseSepolia, + SolanaMainnet, + SolanaTestnet, + SolanaLocalnet, }) } diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index dffb630086..e309431d35 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -23,6 +23,7 @@ func TestChainListByNetworkType(t *testing.T) { &Polygon, &OptimismMainnet, &BaseMainnet, + &SolanaMainnet, }, }, { @@ -38,6 +39,7 @@ func TestChainListByNetworkType(t *testing.T) { &Sepolia, &OptimismSepolia, &BaseSepolia, + &SolanaTestnet, }, }, { @@ -47,6 +49,7 @@ func TestChainListByNetworkType(t *testing.T) { &ZetaChainPrivnet, &BitcoinRegtest, &GoerliLocalnet, + &SolanaLocalnet, }, }, } @@ -99,6 +102,11 @@ func TestChainListByNetwork(t *testing.T) { Network_base, []*Chain{&BaseMainnet, &BaseSepolia}, }, + { + "Solana", + Network_solana, + []*Chain{&SolanaMainnet, &SolanaTestnet, &SolanaLocalnet}, + }, } for _, lt := range listTests { @@ -137,6 +145,9 @@ func TestChainListFunctions(t *testing.T) { &OptimismSepolia, &BaseMainnet, &BaseSepolia, + &SolanaMainnet, + &SolanaTestnet, + &SolanaLocalnet, }, }, { @@ -159,6 +170,9 @@ func TestChainListFunctions(t *testing.T) { &OptimismSepolia, &BaseMainnet, &BaseSepolia, + &SolanaMainnet, + &SolanaTestnet, + &SolanaLocalnet, }, }, }