-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add estimate_gas and get_gas_price calls
- Loading branch information
Showing
6 changed files
with
138 additions
and
34 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
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
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,37 @@ | ||
use std::fmt::{self, Display}; | ||
use std::str::FromStr; | ||
|
||
use candid::CandidType; | ||
use serde::Deserialize; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, CandidType, Deserialize)] | ||
pub enum Network { | ||
Mainnet, | ||
Goerli, | ||
} | ||
|
||
impl Display for Network { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Network::Mainnet => f.write_str("Mainnet"), | ||
Network::Goerli => f.write_str("Goerli"), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Error)] | ||
#[error("Bad network")] | ||
pub struct BadNetwork; | ||
|
||
impl FromStr for Network { | ||
type Err = BadNetwork; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"Mainnet" | "mainnet" => Ok(Network::Mainnet), | ||
"Goerli" | "goerli" => Ok(Network::Goerli), | ||
_ => Err(BadNetwork), | ||
} | ||
} | ||
} |