Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
LouiseMedova committed Aug 26, 2024
1 parent 11f6a23 commit 1a3ba49
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 34 deletions.
22 changes: 8 additions & 14 deletions gear-programs/bridging-payment/src/services/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,14 @@ pub async fn send_message_with_gas_for_reply(
reply_timeout: u32,
msg_id: MessageId,
) -> Result<(), Error> {
gstd::msg::send_bytes_with_gas_for_reply(
destination,
message,
gas_to_send,
0,
gas_deposit,
)
.map_err(|_| Error::SendFailure)?
.up_to(Some(reply_timeout))
.map_err(|_| Error::ReplyTimeout)?
.handle_reply(move || handle_reply_hook(msg_id))
.map_err(|_| Error::ReplyHook)?
.await
.map_err(|_| Error::ReplyFailure)?;
gstd::msg::send_bytes_with_gas_for_reply(destination, message, gas_to_send, 0, gas_deposit)
.map_err(|_| Error::SendFailure)?
.up_to(Some(reply_timeout))
.map_err(|_| Error::ReplyTimeout)?
.handle_reply(move || handle_reply_hook(msg_id))
.map_err(|_| Error::ReplyHook)?
.await
.map_err(|_| Error::ReplyFailure)?;
Ok(())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub async fn send_message_to_bridge_builtin(

let bytes = gbuiltin_eth_bridge::Request::SendEthMessage {
destination: receiver_contract_address,
payload: payload_bytes
payload: payload_bytes,
}
.encode();

Expand Down
6 changes: 3 additions & 3 deletions gear-programs/vft-gateway/src/services/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ pub enum Error {
SendFailure,
ReplyFailure,
BurnTokensDecode,
BurnFailure,
BurnFailure,
RequestToBuiltinSend,
RequestToBuiltinReply,
BuiltinDecode,
PayloadSize,
MintTokensDecode,
ReplyTimeout,
MintFailure,
MintFailure,
NoCorrespondingEthAddress,
ReplyHook,
MessageNotFound,
Expand All @@ -21,4 +21,4 @@ pub enum Error {
BurnTokensFailed,
BridgeBuiltinMessageFailed,
TokensRefunded,
}
}
26 changes: 10 additions & 16 deletions gear-programs/vft-gateway/src/services/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,14 @@ pub async fn send_message_with_gas_for_reply(
reply_timeout: u32,
msg_id: MessageId,
) -> Result<(), Error> {
gstd::msg::send_bytes_with_gas_for_reply(
destination,
message,
gas_to_send,
0,
gas_deposit,
)
.map_err(|_| Error::SendFailure)?
.up_to(Some(reply_timeout))
.map_err(|_| Error::ReplyTimeout)?
.handle_reply(move || handle_reply_hook(msg_id))
.map_err(|_| Error::ReplyHook)?
.await
.map_err(|_| Error::ReplyFailure)?;
gstd::msg::send_bytes_with_gas_for_reply(destination, message, gas_to_send, 0, gas_deposit)
.map_err(|_| Error::SendFailure)?
.up_to(Some(reply_timeout))
.map_err(|_| Error::ReplyTimeout)?
.handle_reply(move || handle_reply_hook(msg_id))
.map_err(|_| Error::ReplyHook)?
.await
.map_err(|_| Error::ReplyFailure)?;
Ok(())
}

Expand Down Expand Up @@ -132,8 +126,8 @@ fn decode_burn_reply(bytes: &[u8]) -> Result<bool, Error> {
}

fn decode_bridge_reply(mut bytes: &[u8]) -> Result<Option<U256>, Error> {
let reply = gbuiltin_eth_bridge::Response::decode(&mut bytes)
.map_err(|_| Error::BuiltinDecode)?;
let reply =
gbuiltin_eth_bridge::Response::decode(&mut bytes).map_err(|_| Error::BuiltinDecode)?;

match reply {
gbuiltin_eth_bridge::Response::EthMessageQueued { nonce, .. } => Ok(Some(nonce)),
Expand Down

0 comments on commit 1a3ba49

Please sign in to comment.