From 2d71e0396fb7c8c4f6dd99d9a6e39cfb5ce1b392 Mon Sep 17 00:00:00 2001 From: fatcat22 Date: Tue, 16 May 2023 10:33:31 +0800 Subject: [PATCH] fix to_bigint unwrap --- src/brc20/error.rs | 5 +++++ src/brc20/num.rs | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/brc20/error.rs b/src/brc20/error.rs index 04c21b9b10..a7d0aec516 100644 --- a/src/brc20/error.rs +++ b/src/brc20/error.rs @@ -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 From for Error { diff --git a/src/brc20/num.rs b/src/brc20/num.rs index 50bdeed59b..24c81d197a 100644 --- a/src/brc20/num.rs +++ b/src/brc20/num.rs @@ -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"),