From 6aaf991058001a487da63438758de2b5ab0e9c30 Mon Sep 17 00:00:00 2001 From: markrypto Date: Wed, 24 Mar 2021 13:43:59 -0600 Subject: [PATCH] refine 0x exchange confirms --- deps/python-keepkey | 2 +- lib/firmware/ethereum_contracts/zxswap.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/deps/python-keepkey b/deps/python-keepkey index 981a181bb..19511a98c 160000 --- a/deps/python-keepkey +++ b/deps/python-keepkey @@ -1 +1 @@ -Subproject commit 981a181bb808c6fbd226b2702681d91e51b18050 +Subproject commit 19511a98cda8c3b92627b1a0989b4dfb4d1f653b diff --git a/lib/firmware/ethereum_contracts/zxswap.c b/lib/firmware/ethereum_contracts/zxswap.c index 99dfde448..177e95856 100644 --- a/lib/firmware/ethereum_contracts/zxswap.c +++ b/lib/firmware/ethereum_contracts/zxswap.c @@ -48,9 +48,16 @@ bool zx_confirmZxSwap(uint32_t data_total, const EthereumSignTx *msg) { const TokenType *from, *to; uint8_t *fromAddress, *toAddress; char constr1[40], constr2[40]; - uint32_t numOfTokens, adder; + uint32_t numOfTokens, adder, isSushi; + char *exchange; numOfTokens = read_be(msg->data_initial_chunk.bytes + 4 + 5*32 - 4); + isSushi = read_be(msg->data_initial_chunk.bytes + 4 + 4*32 - 4); + if (isSushi == 0) { + exchange = "Uniswap"; + } else { + exchange = "Sushiswap"; + } switch (numOfTokens) { case 2: @@ -70,13 +77,6 @@ bool zx_confirmZxSwap(uint32_t data_total, const EthereumSignTx *msg) { from = tokenByChainAddress(msg->chain_id, fromAddress); to = tokenByChainAddress(msg->chain_id, toAddress); - - snprintf(constr1, 20, "%s for %s", from->ticker, to->ticker); - - if (!confirm(ButtonRequestType_ButtonRequest_ConfirmOutput, "Uniswap", - "Confirm Uniswap Swap:\n%s", constr1)) { - return false; - } // Get token trade amount data bignum256 sellTokenAmount, minBuyTokenAmount; @@ -93,7 +93,7 @@ bool zx_confirmZxSwap(uint32_t data_total, const EthereumSignTx *msg) { snprintf(constr1, 32, "%s", sellToken); snprintf(constr2, 32, "%s", minBuyToken); - return confirm(ButtonRequestType_ButtonRequest_ConfirmOutput, "Uniswap", + return confirm(ButtonRequestType_ButtonRequest_ConfirmOutput, exchange, "Sell %s\nBuy at least %s", constr1, constr2); return true;