Skip to content

Commit

Permalink
feat: add supports_shanghai, deprecate supports_push0
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Nov 18, 2023
1 parent 88a298b commit 4bf26f3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
14 changes: 11 additions & 3 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,24 @@ impl Chain {
}
}

/// Returns whether the chain supports the `PUSH0` opcode or not.
/// Returns whether the chain supports the [Shanghai hardfork][ref].
///
/// See [`NamedChain::supports_push0`] for more info.
pub const fn supports_push0(self) -> bool {
///
/// [ref]: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md
pub const fn supports_shanghai(self) -> bool {
match self.kind() {
ChainKind::Named(named) => named.supports_push0(),
ChainKind::Named(named) => named.supports_shanghai(),
ChainKind::Id(_) => false,
}
}

#[doc(hidden)]
#[deprecated(since = "0.1.3", note = "use `supports_shanghai` instead")]
pub const fn supports_push0(self) -> bool {
self.supports_shanghai()
}

/// Returns the chain's blockchain explorer and its API (Etherscan and Etherscan-like) URLs.
///
/// See [`NamedChain::etherscan_urls`] for more info.
Expand Down
28 changes: 19 additions & 9 deletions src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,31 @@ impl NamedChain {
}
}

/// Returns whether the chain supports the `PUSH0` opcode or not.
/// Returns whether the chain supports the [Shanghai hardfork][ref].
///
/// For more information, see EIP-3855:
/// `<https://eips.ethereum.org/EIPS/eip-3855>`
pub const fn supports_push0(self) -> bool {
/// [ref]: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md
pub const fn supports_shanghai(self) -> bool {
use NamedChain as C;

match self {
NamedChain::Mainnet
| NamedChain::Goerli
| NamedChain::Sepolia
| NamedChain::Gnosis
| NamedChain::Chiado => true,
C::Mainnet
| C::Goerli
| C::Sepolia
| C::OptimismGoerli
| C::OptimismSepolia
| C::BaseGoerli
| C::Gnosis
| C::Chiado => true,
_ => false,
}
}

#[doc(hidden)]
#[deprecated(since = "0.1.3", note = "use `supports_shanghai` instead")]
pub const fn supports_push0(self) -> bool {
self.supports_shanghai()
}

/// Returns the chain's blockchain explorer and its API (Etherscan and Etherscan-like) URLs.
///
/// Returns `(API_URL, BASE_URL)`
Expand Down

0 comments on commit 4bf26f3

Please sign in to comment.