Add support for ERC-721 and ERC-1155 (v3) (#218)
* First draft for erc721 token allowance * Split ui and provide parameters into their own files * Print txtype when not supported * fix compilation for erc721 * Use pluginType * Add debug statement in compound plugin * add debug error msg in plugin error * Add parameter parsing for all methods * Remove debug logs * Add SET_APPROVAL_FOR_ALL; Add correct parsing method on contract init * Add dst_size parameter to copy functions * Add query contract id code * format * Add UIs * update ethapp.asc * Change setExternalPlugin to setPlugin; Add support for ERC721 * clang-format * Fix typo Unconsistent -> Inconsistent * Add support for 721; use extraInfo * Add extraInfo to ethpluginQueryConractUI * Rename extraInfo to item * Add txFromEtherscan to tests * Add nft key and temp padding * Remove comments around HAVE_BYPASS_SIGNATURES * Rename TESTING_KEY to NFT_TESTING_KEY * Add comments regarding value of queryContractUI->item * Fix comment regarding method selector * Rename provideToken to provideInfo; Update plugin doc * fix caps of eth_plugin_prepare_provide_info * fix caps of handle_provide_info * Use verificationFn insead of hardcoded cx_ecdsa_verify * Add comments about nftInfo_t and tokenDefinition_t * Add erc721 test * Remove comment from plugin interface version * Fix network_ticker duplicate * Add setPlugin and provideNFTInfo to doc.asc * Add back setExternalPlugin; implement new setPlugin * Update plugin sdk * Call setPlugin instead of setExternalPlugin * setPlugin work without checking sig * Remove printf of displayed fees * Add working 721 test * Finalize ERC721 and add simple test * Display NFT address on set approval and operator * Support set approval for all for erc721 * Finish UI for set approval for all erc721 * Move copy_parameter and copy_address to eth_plugin_internal; Add tests for erc721 * update plugin sdk * Add erc1155 plugin and 1155 tests placeholder * Add restriction for AWS key and setPlugin * Add NOT_OLD_INTERNAL variant; Add erc_1155_plugin_call * Fixed compilation warnings (function pointer casting) Co-authored-by: pscott <scott.piriou@ledger.fr>
This commit is contained in:
@@ -188,8 +188,9 @@ bool starkware_verify_asset_id(uint8_t *tmp32, uint8_t *tokenId, bool assetTypeO
|
||||
if (quantumSet) {
|
||||
cx_sha3_t sha3;
|
||||
tokenDefinition_t *currentToken = NULL;
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_TOKEN) {
|
||||
currentToken = &tmpCtx.transactionContext.tokens[dataContext.tokenContext.quantumIndex];
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) {
|
||||
currentToken =
|
||||
&tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token;
|
||||
}
|
||||
cx_keccak_init(&sha3, 256);
|
||||
compute_token_id(&sha3,
|
||||
@@ -214,9 +215,9 @@ bool starkware_verify_asset_id(uint8_t *tmp32, uint8_t *tokenId, bool assetTypeO
|
||||
|
||||
bool starkware_verify_token(uint8_t *token) {
|
||||
if (quantumSet) {
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_TOKEN) {
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) {
|
||||
tokenDefinition_t *currentToken =
|
||||
&tmpCtx.transactionContext.tokens[dataContext.tokenContext.quantumIndex];
|
||||
&tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token;
|
||||
if (memcmp(token + 32 - 20, currentToken->address, 20) != 0) {
|
||||
PRINTF("Token not matching got %.*H\n", 20, token + 32 - 20);
|
||||
PRINTF("Current token %.*H\n", 20, currentToken->address);
|
||||
@@ -235,7 +236,7 @@ bool starkware_verify_token(uint8_t *token) {
|
||||
|
||||
bool starkware_verify_quantum(uint8_t *quantum) {
|
||||
if (quantumSet) {
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_TOKEN) {
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) {
|
||||
if (memcmp(quantum, dataContext.tokenContext.quantum, 32) != 0) {
|
||||
PRINTF("Quantum not matching got %.*H\n", 32, quantum);
|
||||
PRINTF("Current quantum %.*H\n", 32, dataContext.tokenContext.quantum);
|
||||
@@ -301,7 +302,7 @@ void starkware_print_amount(uint8_t *amountData,
|
||||
char *ticker = chainConfig->coinName;
|
||||
|
||||
if ((amountData == NULL) ||
|
||||
(forEscape && (dataContext.tokenContext.quantumIndex == MAX_TOKEN))) {
|
||||
(forEscape && (dataContext.tokenContext.quantumIndex == MAX_ITEMS))) {
|
||||
decimals = WEI_TO_ETHER;
|
||||
if (!forEscape) {
|
||||
convertUint256BE(tmpContent.txContent.value.value,
|
||||
@@ -312,7 +313,7 @@ void starkware_print_amount(uint8_t *amountData,
|
||||
}
|
||||
} else {
|
||||
tokenDefinition_t *token =
|
||||
&tmpCtx.transactionContext.tokens[dataContext.tokenContext.quantumIndex];
|
||||
&tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token;
|
||||
decimals = token->decimals;
|
||||
ticker = token->ticker;
|
||||
readu256BE(amountData, &amountPre);
|
||||
@@ -334,9 +335,9 @@ void starkware_print_amount(uint8_t *amountData,
|
||||
void starkware_print_ticker(char *destination, size_t destinationLength) {
|
||||
char *ticker = chainConfig->coinName;
|
||||
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_TOKEN) {
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) {
|
||||
tokenDefinition_t *token =
|
||||
&tmpCtx.transactionContext.tokens[dataContext.tokenContext.quantumIndex];
|
||||
&tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token;
|
||||
ticker = token->ticker;
|
||||
}
|
||||
strlcpy(destination, ticker, destinationLength);
|
||||
@@ -345,9 +346,9 @@ void starkware_print_ticker(char *destination, size_t destinationLength) {
|
||||
// TODO : rewrite as independant code
|
||||
void starkware_print_asset_contract(char *destination, size_t destinationLength) {
|
||||
// token has been validated to be present previously
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_TOKEN) {
|
||||
if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) {
|
||||
tokenDefinition_t *token =
|
||||
&tmpCtx.transactionContext.tokens[dataContext.tokenContext.quantumIndex];
|
||||
&tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token;
|
||||
getEthDisplayableAddress(token->address,
|
||||
destination,
|
||||
destinationLength,
|
||||
|
||||
Reference in New Issue
Block a user