diff --git a/contracts/solver-registry/src/lib.rs b/contracts/solver-registry/src/lib.rs index 956d5e4..b1c5a10 100644 --- a/contracts/solver-registry/src/lib.rs +++ b/contracts/solver-registry/src/lib.rs @@ -39,9 +39,11 @@ mod view; const GAS_ADD_WORKER_KEY: Gas = Gas::from_tgas(20); const GAS_REMOVE_WORKER_KEY: Gas = Gas::from_tgas(20); const GAS_ADD_WORKER_KEY_CALLBACK: Gas = Gas::from_tgas(10); -const GAS_REMOVE_WORKER_KEY_CALLBACK: Gas = Gas::from_tgas(20) // 20 Tgas for the callback function itself - .saturating_add(GAS_ADD_WORKER_KEY) - .saturating_add(GAS_ADD_WORKER_KEY_CALLBACK); +const GAS_REMOVE_WORKER_KEY_CALLBACK: Gas = Gas::from_gas( + Gas::from_tgas(20).as_gas() // 20 Tgas for the callback function itself + + GAS_ADD_WORKER_KEY.as_gas() + + GAS_ADD_WORKER_KEY_CALLBACK.as_gas(), +); #[derive(AccessControlRole, Clone, Copy)] #[near(serializers = [json])] diff --git a/contracts/solver-registry/src/pool.rs b/contracts/solver-registry/src/pool.rs index 66de51d..9cfd7f8 100644 --- a/contracts/solver-registry/src/pool.rs +++ b/contracts/solver-registry/src/pool.rs @@ -119,9 +119,7 @@ impl Contract { fee: u32, #[callback_result] call_result: Result<(), PromiseError>, ) -> Option { - if call_result.is_err() { - None - } else { + call_result.ok().map(|()| { // Add the new liquidity pool let pool = Pool::new(token_ids.clone(), fee); self.pools.push(pool); @@ -134,8 +132,8 @@ impl Contract { } .emit(); - Some(pool_id) - } + pool_id + }) } #[private] @@ -144,12 +142,11 @@ impl Contract { amount: U128, #[callback_result] used_fund: Result, ) -> U128 { - if let Ok(used_fund) = used_fund { + match used_fund { // Refund the unused amount. // ft_transfer_call() returns the used fund - U128(amount.0.saturating_sub(used_fund.0)) - } else { - amount + Ok(used) => U128(amount.0.saturating_sub(used.0)), + Err(_) => amount, } } }