Merge pull request #536 from LedgerHQ/feat/apa/explicit_unknown_ticker

Explicit unknown ticker
This commit is contained in:
apaillier-ledger
2024-02-13 17:11:04 +01:00
committed by GitHub
53 changed files with 15 additions and 109 deletions

View File

@@ -31,6 +31,10 @@ void handle_get_printable_amount(get_printable_amount_parameters_t* params,
}
// If the amount is a fee, the ticker should be the chain's native currency
if (params->is_fee) {
// fallback mechanism in the absence of chain ID in swap config
if (chain_id == 0) {
chain_id = config->chainId;
}
strlcpy(ticker, get_displayable_ticker(&chain_id, config), sizeof(ticker));
decimals = WEI_TO_ETHER;
}

View File

@@ -49,6 +49,10 @@ bool copy_transaction_parameters(create_transaction_parameters_t* sign_transacti
return false;
}
// fallback mechanism in the absence of chain ID in swap config
if (chain_id == 0) {
chain_id = config->chainId;
}
// If the amount is a fee, its value is nominated in ETH even if we're doing an ERC20 swap
strlcpy(ticker, get_displayable_ticker(&chain_id, config), sizeof(ticker));
decimals = WEI_TO_ETHER;

View File

@@ -11,6 +11,8 @@ typedef struct network_info_s {
uint64_t chain_id;
} network_info_t;
static const char *unknown_ticker = "???";
// Mappping of chain ids to networks.
static const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 1, .name = "Ethereum", .ticker = "ETH"},
@@ -140,7 +142,11 @@ const char *get_displayable_ticker(const uint64_t *chain_id, const chain_config_
const char *ticker = get_network_ticker_from_chain_id(chain_id);
if (ticker == NULL) {
ticker = chain_cfg->coinName;
if (*chain_id == chain_cfg->chainId) {
ticker = chain_cfg->coinName;
} else {
ticker = unknown_ticker;
}
}
return ticker;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 773 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

View File

@@ -83,90 +83,6 @@ def test_sign_simple(cmd):
assert v == 0x26 # 38
assert r.hex() == "6f389d15320f0501383526ed03de917c14212716f09a262dbc98431086a5db49"
assert s.hex() == "0dc994b7b97230bb35fdf6fec2f4d8ff4cfb8bfeb2a652c364c738ff033c05dd"
def test_sign_dai_coin_type_on_network_5234(cmd):
result: list = []
# DAI coin type
bip32_path="44'/700'/1'/0/0"
transaction = Transaction(
txType=0xEB,
nonce=0,
gasPrice=0x0306dc4200,
gasLimit=0x5208,
to="0x5a321744667052affa8386ed49e00ef223cbffc3",
value=0x6f9c9e7bf61818,
chainID=5243,
)
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
if cmd.model == "nanos":
# Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00000.png")
cmd.client.press_and_release('right')
# Amount 1/3, 2/3, 3/3
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00001.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00002.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00003.png")
cmd.client.press_and_release('right')
# Address 1/3, 2/3, 3/3
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00004.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00005.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00006.png")
cmd.client.press_and_release('right')
# Network 5243
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00007.png")
cmd.client.press_and_release('right')
# Max Fees
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00008.png")
cmd.client.press_and_release('right')
# Accept and send
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00009.png")
cmd.client.press_and_release('both')
if cmd.model == "nanox" or cmd.model == "nanosp":
# Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00000.png")
cmd.client.press_and_release('right')
# Amount
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00001.png")
cmd.client.press_and_release('right')
# Address
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00002.png")
cmd.client.press_and_release('right')
# Network 5243
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00003.png")
cmd.client.press_and_release('right')
# Max Fees
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00004.png")
cmd.client.press_and_release('right')
# Accept and send
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/dai_coin_type_on_network_5234/00005.png")
cmd.client.press_and_release('both')
v, r, s = result
assert v == 0x1A # 26
assert r.hex() == "7ebfa5d5cac1e16bb1f1a8c67706b5c6019c0f198df6bb44e742a9de72330961"
assert s.hex() == "537419d8d1443d38ea87943c110789decb43b8f4fea8fae256fe842f669da634"
def test_sign_reject(cmd):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 B

After

Width:  |  Height:  |  Size: 359 B

View File

@@ -1 +0,0 @@
00013.png

Before

Width:  |  Height:  |  Size: 9 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 B

After

Width:  |  Height:  |  Size: 360 B

View File

@@ -1 +0,0 @@
00009.png

Before

Width:  |  Height:  |  Size: 9 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 773 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

View File

@@ -36,25 +36,3 @@ nano_models.forEach(function(model) {
await expect(tx).rejects.toEqual(new TransportStatusError(0x6807));
}));
});
nano_models.forEach(function(model) {
test('[Nano ' + model.letter + '] Transfer Ether on network 5234 on Ethereum app', zemu(model, async (sim, eth) => {
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'ED44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080',
);
await waitForAppScreen(sim);
let clicks;
if (model.letter === 'S') clicks = 10;
else clicks = 6;
await sim.navigateAndCompareSnapshots('.', model.name + '_transfer_ethereum_5234_network', [clicks, -1, 0]);
await expect(tx).resolves.toEqual({
"r": "07a7982dfd16360c96a03467877d0cf9c36f799deff4dace250cdb18e28a3b90",
"s": "773318a93da2e32c1cf308ddd6add1e8c0d285973e541520a05fb4dc720e4fb1",
"v": "2908",
});
}));
});