Skip to content

Commit

Permalink
return constant fees when swapping (sending) Near (0.450 Tgas)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogh333 committed Jan 14, 2025
1 parent 1357cd9 commit 0d29b66
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["dj8yf0μl", "polyprogrammist"]
edition = "2021"

[dependencies]
ledger_device_sdk = "1.19.2"
ledger_device_sdk = "1.19.3"
include_gif = "1.2.0"
hex = { version = "0.4.3", default-features = false, features = ["serde"] }
bs58 = { version = "0.5.0", default-features = false }
Expand Down
21 changes: 16 additions & 5 deletions src/swap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::utils::crypto::{PathBip32, PublicKeyBe};
use fmt_buffer::Buffer;
use near_gas::{GasBuffer, NearGas};
use near_token::{NearToken, TokenBuffer};

use ledger_device_sdk::{
Expand Down Expand Up @@ -123,9 +124,19 @@ fn check_address(params: &CheckAddressParams) -> Result<(), &'static str> {
}

fn get_printable_amount(params: &PrintableAmountParams) -> Buffer<30> {
let amount = u128::from_be_bytes(params.amount);
let near_token = NearToken::from_yoctonear(amount);
let mut near_token_buffer = TokenBuffer::new();
near_token.display_as_buffer(&mut near_token_buffer);
near_token_buffer
match params.is_fee {
true => {
let gas = NearGas::from_gas(450_000_000_000);
let mut near_gas_buffer = GasBuffer::new();
gas.display_as_buffer(&mut near_gas_buffer);
near_gas_buffer
}
false => {
let amount = u128::from_be_bytes(params.amount);
let near_token = NearToken::from_yoctonear(amount);
let mut near_token_buffer = TokenBuffer::new();
near_token.display_as_buffer(&mut near_token_buffer);
near_token_buffer
}
}
}

0 comments on commit 0d29b66

Please sign in to comment.