Now uses the new asset util functions

Now the first asset is properly stored at index 0 instead of 1
This commit is contained in:
Alexandre Paillier
2024-05-07 17:20:20 +02:00
parent 18a02dcacb
commit c2e0f7ca6a
6 changed files with 14 additions and 21 deletions

View File

@@ -5,6 +5,7 @@
#include "os_io_seproxyhal.h"
#include "extra_tokens.h"
#include "network.h"
#include "manage_asset_info.h"
#ifdef HAVE_CONTRACT_NAME_IN_DESCRIPTOR
@@ -26,10 +27,7 @@ void handleProvideErc20TokenInformation(uint8_t p1,
cx_sha256_init(&sha256);
tmpCtx.transactionContext.currentItemIndex =
(tmpCtx.transactionContext.currentItemIndex + 1) % MAX_ITEMS;
tokenDefinition_t *token =
&tmpCtx.transactionContext.tokens[tmpCtx.transactionContext.currentItemIndex];
tokenDefinition_t *token = &get_current_asset_info()->token;
if (dataLength < 1) {
THROW(0x6A80);
@@ -95,7 +93,7 @@ void handleProvideErc20TokenInformation(uint8_t p1,
THROW(0x6A80);
#endif
}
tmpCtx.transactionContext.tokenSet[tmpCtx.transactionContext.currentItemIndex] = 1;
validate_current_asset_info();
THROW(0x9000);
}
@@ -117,10 +115,7 @@ void handleProvideErc20TokenInformation(uint8_t p1,
uint8_t hash[INT256_LENGTH];
cx_ecfp_public_key_t tokenKey;
tmpCtx.transactionContext.currentItemIndex =
(tmpCtx.transactionContext.currentItemIndex + 1) % MAX_ITEMS;
tokenDefinition_t *token =
&tmpCtx.transactionContext.extraInfo[tmpCtx.transactionContext.currentItemIndex].token;
tokenDefinition_t *token = &get_current_asset_info()->token;
PRINTF("Provisioning currentItemIndex %d\n", tmpCtx.transactionContext.currentItemIndex);
@@ -183,7 +178,7 @@ void handleProvideErc20TokenInformation(uint8_t p1,
}
}
tmpCtx.transactionContext.tokenSet[tmpCtx.transactionContext.currentItemIndex] = 1;
validate_current_asset_info();
THROW(0x9000);
}

View File

@@ -8,6 +8,7 @@
#include "os_io_seproxyhal.h"
#include "network.h"
#include "public_keys.h"
#include "manage_asset_info.h"
#define TYPE_SIZE 1
#define VERSION_SIZE 1
@@ -56,10 +57,7 @@ void handleProvideNFTInformation(uint8_t p1,
PRINTF("NFT metadata provided without proper plugin loaded!\n");
THROW(0x6985);
}
tmpCtx.transactionContext.currentItemIndex =
(tmpCtx.transactionContext.currentItemIndex + 1) % MAX_ITEMS;
nftInfo_t *nft =
&tmpCtx.transactionContext.extraInfo[tmpCtx.transactionContext.currentItemIndex].nft;
nftInfo_t *nft = &get_current_asset_info()->nft;
PRINTF("Provisioning currentItemIndex %d\n", tmpCtx.transactionContext.currentItemIndex);
@@ -201,7 +199,7 @@ void handleProvideNFTInformation(uint8_t p1,
#endif
}
tmpCtx.transactionContext.tokenSet[tmpCtx.transactionContext.currentItemIndex] = 1;
validate_current_asset_info();
THROW(0x9000);
}