From b57be78c18d90e9ad8057fceb34f99e9489a9c48 Mon Sep 17 00:00:00 2001 From: Poseidon Date: Wed, 10 Jul 2024 13:54:00 +0800 Subject: [PATCH] fix: update token if token already exsit (#93) --- route/icp/icp_route.did | 1 + route/icp/src/updates/add_new_token.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/route/icp/icp_route.did b/route/icp/icp_route.did index e3ca42b9..5d493bd9 100644 --- a/route/icp/icp_route.did +++ b/route/icp/icp_route.did @@ -36,6 +36,7 @@ type GenerateTicketError = variant { TemporarilyUnavailable : text; InsufficientAllowance : record { allowance : nat64 }; TransferFailure : text; + UnsupportedAction : text; RedeemFeeNotSet; UnsupportedChainId : text; UnsupportedToken : text; diff --git a/route/icp/src/updates/add_new_token.rs b/route/icp/src/updates/add_new_token.rs index 925a9305..6ed3ce1f 100644 --- a/route/icp/src/updates/add_new_token.rs +++ b/route/icp/src/updates/add_new_token.rs @@ -21,7 +21,10 @@ pub enum AddNewTokenError { pub async fn add_new_token(token: Token) -> Result<(), AddNewTokenError> { if read_state(|s| s.tokens.contains_key(&token.token_id)) { - return Err(AddNewTokenError::AlreadyAdded(token.token_id)); + mutate_state(|s| { + s.tokens.insert(token.token_id.clone(), token); + }); + return Ok(()) } let record = install_icrc2_ledger(