* Removed pluginType "hack" * Fix some ERC 721 & 1155 function signature hashes * Fix UI for ERC721 operations * Explicit Batch Transfer UI with ERC1155 * Unified some ERC721 & 1155 non-static functions naming * Fix UI for ERC1155 operations * Added missing pin-lock check when signing transactions * Fix the shell script that builds the elf files for testing * Add tests dependency ethers * Removed the space in the test filename * Tests build script refactoring * Now works when called from anywhere (not just the script's directory) * Now handles LNS & LNX builds together (less duplicated code) * Temporarily disable Nano X tests Until Zemu supports Nano X 2.0 SDK * Tests now start with blind signing disabled Makes it closer to reality & very few of them requires it * Update to the latest sdk version * make eth_plugin_perform_init() readable Introduce 2 functions. * Now properly parses the apdu and displays the total quantity of NFT IDs transferred in ERC1155 batch transfer * Add NFT prod public keys * Added extra checks for the chain ID handling Following the security review * NFTs now only supported by LNS * Version bump Co-authored-by: Alexandre Paillier <alexandre.paillier@ledger.fr> Co-authored-by: greenknot <greenknot@users.noreply.github.com>
107 lines
3.3 KiB
C
107 lines
3.3 KiB
C
#include "shared_context.h"
|
|
#include "apdu_constants.h"
|
|
#include "ui_flow.h"
|
|
#include "feature_signTx.h"
|
|
#include "eth_plugin_interface.h"
|
|
|
|
void handleSign(uint8_t p1,
|
|
uint8_t p2,
|
|
uint8_t *workBuffer,
|
|
uint16_t dataLength,
|
|
unsigned int *flags,
|
|
unsigned int *tx) {
|
|
UNUSED(tx);
|
|
parserStatus_e txResult;
|
|
uint32_t i;
|
|
|
|
if (os_global_pin_is_validated() != BOLOS_UX_OK) {
|
|
PRINTF("Device is PIN-locked");
|
|
THROW(0x6982);
|
|
}
|
|
if (p1 == P1_FIRST) {
|
|
if (dataLength < 1) {
|
|
PRINTF("Invalid data\n");
|
|
THROW(0x6a80);
|
|
}
|
|
if (appState != APP_STATE_IDLE) {
|
|
reset_app_context();
|
|
}
|
|
appState = APP_STATE_SIGNING_TX;
|
|
tmpCtx.transactionContext.pathLength = workBuffer[0];
|
|
if ((tmpCtx.transactionContext.pathLength < 0x01) ||
|
|
(tmpCtx.transactionContext.pathLength > MAX_BIP32_PATH)) {
|
|
PRINTF("Invalid path\n");
|
|
THROW(0x6a80);
|
|
}
|
|
workBuffer++;
|
|
dataLength--;
|
|
for (i = 0; i < tmpCtx.transactionContext.pathLength; i++) {
|
|
if (dataLength < 4) {
|
|
PRINTF("Invalid data\n");
|
|
THROW(0x6a80);
|
|
}
|
|
tmpCtx.transactionContext.bip32Path[i] = U4BE(workBuffer, 0);
|
|
workBuffer += 4;
|
|
dataLength -= 4;
|
|
}
|
|
tmpContent.txContent.dataPresent = false;
|
|
dataContext.tokenContext.pluginStatus = ETH_PLUGIN_RESULT_UNAVAILABLE;
|
|
|
|
initTx(&txContext, &global_sha3, &tmpContent.txContent, customProcessor, NULL);
|
|
|
|
// EIP 2718: TransactionType might be present before the TransactionPayload.
|
|
uint8_t txType = *workBuffer;
|
|
if (txType >= MIN_TX_TYPE && txType <= MAX_TX_TYPE) {
|
|
// Enumerate through all supported txTypes here...
|
|
if (txType == EIP2930 || txType == EIP1559) {
|
|
cx_hash((cx_hash_t *) &global_sha3, 0, workBuffer, 1, NULL, 0);
|
|
txContext.txType = txType;
|
|
workBuffer++;
|
|
dataLength--;
|
|
} else {
|
|
PRINTF("Transaction type %d not supported\n", txType);
|
|
THROW(0x6501);
|
|
}
|
|
} else {
|
|
txContext.txType = LEGACY;
|
|
}
|
|
PRINTF("TxType: %x\n", txContext.txType);
|
|
} else if (p1 != P1_MORE) {
|
|
THROW(0x6B00);
|
|
}
|
|
if (p2 != 0) {
|
|
THROW(0x6B00);
|
|
}
|
|
if ((p1 == P1_MORE) && (appState != APP_STATE_SIGNING_TX)) {
|
|
PRINTF("Signature not initialized\n");
|
|
THROW(0x6985);
|
|
}
|
|
if (txContext.currentField == RLP_NONE) {
|
|
PRINTF("Parser not initialized\n");
|
|
THROW(0x6985);
|
|
}
|
|
txResult = processTx(&txContext,
|
|
workBuffer,
|
|
dataLength,
|
|
(chainConfig->kind == CHAIN_KIND_WANCHAIN ? TX_FLAG_TYPE : 0));
|
|
switch (txResult) {
|
|
case USTREAM_SUSPENDED:
|
|
break;
|
|
case USTREAM_FINISHED:
|
|
break;
|
|
case USTREAM_PROCESSING:
|
|
THROW(0x9000);
|
|
case USTREAM_FAULT:
|
|
THROW(0x6A80);
|
|
default:
|
|
PRINTF("Unexpected parser status\n");
|
|
THROW(0x6A80);
|
|
}
|
|
|
|
if (txResult == USTREAM_FINISHED) {
|
|
finalizeParsing(false);
|
|
}
|
|
|
|
*flags |= IO_ASYNCH_REPLY;
|
|
}
|