Skip to content

Commit

Permalink
improve withdraw functions
Browse files Browse the repository at this point in the history
Signed-off-by: ozkanonur <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Mar 10, 2023
1 parent 365c7df commit e253d07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions mm2src/coins/tendermint/tendermint_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ impl TendermintCoin {
.await
.map_to_mm(WithdrawError::Transport)?;

let account_info = coin.my_account_info().await?;
let timeout_height = current_block + TIMEOUT_HEIGHT_DELTA;
// >> END TX SIMULATION FOR FEE CALCULATION

Expand Down Expand Up @@ -621,6 +620,7 @@ impl TendermintCoin {
.to_any()
.map_to_mm(|e| WithdrawError::InternalError(e.to_string()))?;

let account_info = coin.my_account_info().await?;
let tx_raw = coin
.any_to_signed_raw_tx(account_info, msg_transfer, fee, timeout_height, memo.clone())
.map_to_mm(|e| WithdrawError::InternalError(e.to_string()))?;
Expand Down Expand Up @@ -876,10 +876,9 @@ impl TendermintCoin {
.gen_simulated_tx(account_info, msg.clone(), timeout_height, memo.clone())
.map_to_mm(|e| TendermintCoinRpcError::InternalError(format!("{}", e)))?;

let request = SimulateRequest { tx_bytes, tx: None };
let request = AbciRequest::new(
Some(path.clone()),
request.encode_to_vec().clone(),
SimulateRequest { tx_bytes, tx: None }.encode_to_vec(),
ABCI_REQUEST_HEIGHT,
ABCI_REQUEST_PROVE,
);
Expand Down Expand Up @@ -938,10 +937,10 @@ impl TendermintCoin {
let tx_bytes = self
.gen_simulated_tx(account_info, msg.clone(), timeout_height, memo.clone())
.map_to_mm(|e| TendermintCoinRpcError::InternalError(format!("{}", e)))?;
let request = SimulateRequest { tx_bytes, tx: None };

let request = AbciRequest::new(
Some(path.clone()),
request.encode_to_vec(),
SimulateRequest { tx_bytes, tx: None }.encode_to_vec(),
ABCI_REQUEST_HEIGHT,
ABCI_REQUEST_PROVE,
);
Expand Down Expand Up @@ -1828,8 +1827,6 @@ impl MmCoin for TendermintCoin {
.await
.map_to_mm(WithdrawError::Transport)?;

let account_info = coin.my_account_info().await?;

let timeout_height = current_block + TIMEOUT_HEIGHT_DELTA;
// >> END TX SIMULATION FOR FEE CALCULATION

Expand Down Expand Up @@ -1879,6 +1876,7 @@ impl MmCoin for TendermintCoin {
.to_any()
.map_to_mm(|e| WithdrawError::InternalError(e.to_string()))?;

let account_info = coin.my_account_info().await?;
let tx_raw = coin
.any_to_signed_raw_tx(account_info, msg_send, fee, timeout_height, memo.clone())
.map_to_mm(|e| WithdrawError::InternalError(e.to_string()))?;
Expand Down
4 changes: 2 additions & 2 deletions mm2src/coins/tendermint/tendermint_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ impl TendermintToken {
.await
.map_to_mm(WithdrawError::Transport)?;

let account_info = platform.my_account_info().await?;
let timeout_height = current_block + TIMEOUT_HEIGHT_DELTA;

let fee_amount_u64 = platform
Expand All @@ -195,6 +194,7 @@ impl TendermintToken {

let fee = Fee::from_amount_and_gas(fee_amount, IBC_GAS_LIMIT_DEFAULT);

let account_info = platform.my_account_info().await?;
let tx_raw = platform
.any_to_signed_raw_tx(account_info, msg_transfer, fee, timeout_height, memo.clone())
.map_to_mm(|e| WithdrawError::InternalError(e.to_string()))?;
Expand Down Expand Up @@ -648,7 +648,6 @@ impl MmCoin for TendermintToken {
.await
.map_to_mm(WithdrawError::Transport)?;

let account_info = platform.my_account_info().await?;
let timeout_height = current_block + TIMEOUT_HEIGHT_DELTA;

let fee_amount_u64 = platform
Expand All @@ -672,6 +671,7 @@ impl MmCoin for TendermintToken {

let fee = Fee::from_amount_and_gas(fee_amount, GAS_LIMIT_DEFAULT);

let account_info = platform.my_account_info().await?;
let tx_raw = platform
.any_to_signed_raw_tx(account_info, msg_send, fee, timeout_height, memo.clone())
.map_to_mm(|e| WithdrawError::InternalError(e.to_string()))?;
Expand Down

0 comments on commit e253d07

Please sign in to comment.