Skip to content

Commit

Permalink
Merge pull request #43 from okx/yz/fix_tobigint
Browse files Browse the repository at this point in the history
fix to_bigint unwrap
  • Loading branch information
wanyvic authored May 16, 2023
2 parents 1e683ae + 2d71e03 commit 8a1faa9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/brc20/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ pub enum BRC20Error {

#[error("transferable owner not match {0}")]
TransferableOwnerNotMatch(InscriptionId),

/// an InternalError is an error that happens exceed our expect
/// and should not happen under normal circumstances
#[error("internal error: {0}")]
InternalError(String),
}

impl<L: LedgerRead> From<BRC20Error> for Error<L> {
Expand Down
5 changes: 4 additions & 1 deletion src/brc20/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ impl Num {
self
.0
.to_bigint()
.unwrap()
.ok_or(BRC20Error::InternalError(format!(
"convert {} to bigint failed",
self.0
)))?
.to_u128()
.ok_or(BRC20Error::Overflow {
op: String::from("to_u128"),
Expand Down

0 comments on commit 8a1faa9

Please sign in to comment.