Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions contracts/solver-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

#[derive(AccessControlRole, Clone, Copy)]
#[near(serializers = [json])]
Expand Down
15 changes: 6 additions & 9 deletions contracts/solver-registry/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ impl Contract {
fee: u32,
#[callback_result] call_result: Result<(), PromiseError>,
) -> Option<u32> {
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);
Expand All @@ -134,8 +132,8 @@ impl Contract {
}
.emit();

Some(pool_id)
}
pool_id
})
}

#[private]
Expand All @@ -144,12 +142,11 @@ impl Contract {
amount: U128,
#[callback_result] used_fund: Result<U128, PromiseError>,
) -> 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,
}
}
}
Expand Down
Loading