Skip to content

Commit

Permalink
add new chains
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Jul 1, 2024
1 parent 6b1f1ff commit 47635ff
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/chains/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
},
Expand All @@ -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",
Expand Down
39 changes: 39 additions & 0 deletions pkg/chains/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -293,6 +329,9 @@ func DefaultChainsList() []*Chain {
OptimismSepolia,
BaseMainnet,
BaseSepolia,
SolanaMainnet,
SolanaTestnet,
SolanaLocalnet,
})
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/chains/chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestChainListByNetworkType(t *testing.T) {
&Polygon,
&OptimismMainnet,
&BaseMainnet,
&SolanaMainnet,
},
},
{
Expand All @@ -38,6 +39,7 @@ func TestChainListByNetworkType(t *testing.T) {
&Sepolia,
&OptimismSepolia,
&BaseSepolia,
&SolanaTestnet,
},
},
{
Expand All @@ -47,6 +49,7 @@ func TestChainListByNetworkType(t *testing.T) {
&ZetaChainPrivnet,
&BitcoinRegtest,
&GoerliLocalnet,
&SolanaLocalnet,
},
},
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -137,6 +145,9 @@ func TestChainListFunctions(t *testing.T) {
&OptimismSepolia,
&BaseMainnet,
&BaseSepolia,
&SolanaMainnet,
&SolanaTestnet,
&SolanaLocalnet,
},
},
{
Expand All @@ -159,6 +170,9 @@ func TestChainListFunctions(t *testing.T) {
&OptimismSepolia,
&BaseMainnet,
&BaseSepolia,
&SolanaMainnet,
&SolanaTestnet,
&SolanaLocalnet,
},
},
}
Expand Down

0 comments on commit 47635ff

Please sign in to comment.