Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions registry/manual.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@
],
"averageBlocktimeHint": 450,
"supportsShanghai": true,
"tags": [
"bsc"
],
"etherscanApiUrl": "https://api.etherscan.io/v2/api?chainid=56",
"etherscanApiKeyName": "ETHERSCAN_API_KEY",
"wrappedNativeToken": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
Expand All @@ -418,6 +421,9 @@
"averageBlocktimeHint": 450,
"supportsShanghai": true,
"isTestnet": true,
"tags": [
"bsc"
],
"nativeCurrencySymbol": "BNB",
"etherscanApiUrl": "https://api.etherscan.io/v2/api?chainid=97",
"etherscanApiKeyName": "ETHERSCAN_API_KEY",
Expand Down
6 changes: 6 additions & 0 deletions scripts/templates/generated_named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ impl NamedChain {
%%gnosis_predicate
}

/// Returns true if this chain is a BNB Smart Chain (BSC) network.
#[inline]
pub const fn is_bsc(&self) -> bool {
%%bsc_predicate
}

/// Returns true if the chain contains Polygon configuration.
#[inline]
pub const fn is_polygon(self) -> bool {
Expand Down
2 changes: 2 additions & 0 deletions scripts/update-registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ChainFlag:
ChainFlag("FLAG_ETHEREUM", "E", "ethereum", tag="ethereum"),
ChainFlag("FLAG_OPTIMISM", "O", "optimism", tag="optimism"),
ChainFlag("FLAG_GNOSIS", "G", "gnosis", tag="gnosis"),
ChainFlag("FLAG_BSC", "B", "bsc", tag="bsc"),
ChainFlag("FLAG_POLYGON", "P", "polygon", tag="polygon"),
ChainFlag("FLAG_ARBITRUM", "A", "arbitrum", tag="arbitrum"),
ChainFlag("FLAG_ELASTIC", "X", "elastic", tag="elastic"),
Expand Down Expand Up @@ -311,6 +312,7 @@ def generated_named(chains: list[Chain]) -> str:
phf_maps=phf_maps,
polygon_predicate=flag_predicates["polygon"],
arbitrum_predicate=flag_predicates["arbitrum"],
bsc_predicate=flag_predicates["bsc"],
serde_aliases=serde_aliases,
string_table_data=string_table_data,
shanghai_predicate=flag_predicates["supports_shanghai"],
Expand Down
17 changes: 17 additions & 0 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,12 @@ impl Chain {
matches!(self.named(), Some(named) if named.is_gnosis())
}

/// Returns true if this chain is a BNB Smart Chain (BSC) network.
#[inline]
pub const fn is_bsc(&self) -> bool {
matches!(self.named(), Some(named) if named.is_bsc())
}

/// Returns `true` if this chain is a Polygon chain.
#[inline]
pub const fn is_polygon(&self) -> bool {
Expand Down Expand Up @@ -928,6 +934,17 @@ mod tests {
assert_eq!(default, expected);
}

#[test]
fn test_is_bsc() {
assert!(NamedChain::BinanceSmartChain.is_bsc());
assert!(NamedChain::BinanceSmartChainTestnet.is_bsc());
assert!(Chain::bsc_mainnet().is_bsc());
assert!(Chain::bsc_testnet().is_bsc());

assert!(!NamedChain::Mainnet.is_bsc());
assert!(!Chain::mainnet().is_bsc());
}

#[cfg(feature = "rlp")]
#[test]
fn test_id_chain_encodable_length() {
Expand Down
6 changes: 6 additions & 0 deletions src/generated/named.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading