Skip to content

Commit

Permalink
🐛 Fix amount conversion logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nagdahimanshu committed Jun 10, 2024
1 parent 570d902 commit 74cd359
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
16 changes: 14 additions & 2 deletions src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ static bool set_amount_ui_uint8(ethQueryContractUI_t *msg,
return amountToString(amount, INT256_LENGTH, decimals, ticker, msg->msg, msg->msgLength);
}

// Set UI with custom title for amount (Lisk L1) screen with uint8 data.
static bool set_amount_l1_ui_uint8(ethQueryContractUI_t *msg,
const uint8_t *amount,
const char *title) {
strlcpy(msg->title, title, msg->titleLength);

uint8_t decimals = 8;
const char *ticker = "LSK";

return amountToString(amount, INT256_LENGTH, decimals, ticker, msg->msg, msg->msgLength);
}

// Set UI with custom title for amount screen with uint8 data.
static bool set_amount_ui_arr(ethQueryContractUI_t *msg,
const arr_uint8_t *amount,
Expand Down Expand Up @@ -125,7 +137,7 @@ void handle_query_contract_ui(ethQueryContractUI_t *msg) {
case CLAIM_REGULAR_ACCOUNT:
switch (msg->screenIndex) {
case 0:
ret = set_amount_ui_uint8(msg,
ret = set_amount_l1_ui_uint8(msg,
context->lisk.body.claim.claim_amount,
"Claim LSK");
break;
Expand All @@ -144,7 +156,7 @@ void handle_query_contract_ui(ethQueryContractUI_t *msg) {
case CLAIM_MULTI_SIGNATURE_ACCOUNT:
switch (msg->screenIndex) {
case 0:
ret = set_amount_ui_uint8(msg,
ret = set_amount_l1_ui_uint8(msg,
context->lisk.body.claim.claim_amount,
"Claim LSK");
break;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_airdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def test_claim_airdrop(backend, firmware, navigator, test_name, wallet_addr):
data = contract.encodeABI("claimAirdrop", [
bytes.fromhex("77abc2dd8ca5021dbb8e91e63f574b1e440764d2"),
4915507196,
20000000000000000000,
[
bytes.fromhex("9ca797d905e78f38685b61f62521632ef486bc6ce3e707d2af41b7fe146303c1"),
]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_claim_regular_account(backend, firmware, navigator, test_name, wallet_a
bytes.fromhex("6f3f752b8381917128bc5145128af0d83e3d7547c83a2d28b20bb04b8952f4a6")
],
bytes.fromhex("f83c23fb2532ad248e107ebd5312f1f78f742488fdec815c94d6b63aa7682eb6"),
86511774,
1000000000, # 10 LSK to be claimed
bytes.fromhex("00bb7b59073f45177edf430090d5aa3c44aa7f23"),
(
bytes.fromhex("664272cc25b0d20adf551b7a015795b9ad4ab23a4a19a509642bc042c00e5256"),
Expand All @@ -37,7 +37,7 @@ def test_claim_multisig_account(backend, firmware, navigator, test_name, wallet_
bytes.fromhex("629779421eb7409cb867a7d8ee45aadc89a8b86f24423b737e1430832a78f026")
],
bytes.fromhex("77abc2dd8ca5021dbb8e91e63f574b1e440764d2"),
4915507196,
1000000000, # 10 LSK to be claimed
(
[
],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def test_create_position(backend, firmware, navigator, test_name, wallet_addr):
data = contract.encodeABI("createPosition", [
86511774,
200000000000000000,
100
])

Expand Down

0 comments on commit 74cd359

Please sign in to comment.