Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mertwole committed Dec 17, 2024
1 parent 23cb4c1 commit 1fcad31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
17 changes: 5 additions & 12 deletions gear-programs/vft-manager/app/src/services/submit_receipt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ pub async fn submit_receipt<T: ExecContext>(
return Err(Error::NotEthClient);
}

let config = service.config();
if gstd::exec::gas_available()
< config.gas_for_token_ops + config.gas_for_submit_receipt + config.gas_for_reply_deposit
{
return Err(Error::NotEnoughGas);
}

let receipt =
ReceiptEnvelope::decode(&mut &receipt_rlp[..]).map_err(|_| Error::NotSupportedEvent)?;

Expand Down Expand Up @@ -119,16 +112,16 @@ pub async fn submit_receipt<T: ExecContext>(

match supply_type {
TokenSupply::Ethereum => {
token_operations::mint(vara_token_id, receiver, amount, config, msg_id).await?;
token_operations::mint(vara_token_id, receiver, amount, service.config(), msg_id)
.await?;
}
TokenSupply::Gear => {
token_operations::unlock(vara_token_id, receiver, amount, config, msg_id).await?;
token_operations::unlock(vara_token_id, receiver, amount, service.config(), msg_id)
.await?;
}
}

msg_tracker_mut().check_withdraw_result(&msg_id)?;

Ok(())
msg_tracker_mut().check_withdraw_result(&msg_id)
}

pub async fn handle_interrupted_transfer<T: ExecContext>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use sails_rs::prelude::*;

static mut MSG_TRACKER: Option<MessageTracker> = None;

// TODO: Itr doesn't cleaned up.
#[derive(Default, Debug)]
pub struct MessageTracker {
pub message_info: HashMap<MessageId, MessageInfo>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ fn handle_reply_hook(msg_id: MessageId) {
let reply_bytes = msg::load_bytes().expect("Unable to load bytes");

match msg_info.status {
MessageStatus::SendingMessageToWithdrawTokens => {
MessageStatus::SendingMessageToWithdrawTokens
| MessageStatus::WaitingReplyFromTokenWithdrawMessage => {
let reply = match msg_info.details.token_supply {
TokenSupply::Ethereum => decode_mint_reply(&reply_bytes),
TokenSupply::Gear => decode_unlock_reply(&reply_bytes),
Expand Down

0 comments on commit 1fcad31

Please sign in to comment.