From 900df668e83f8fb2e90e9024489f092d2a0d2e7e Mon Sep 17 00:00:00 2001 From: Enzo Cioppettini Date: Fri, 22 Dec 2023 12:58:50 -0300 Subject: [PATCH] address reviews: add comments and use string for amount --- .../tasks/src/multiera/multiera_asset_utxo.rs | 19 +++++++++++++++++-- .../app/controllers/AssetUtxosController.ts | 2 +- webserver/shared/models/AssetUtxos.ts | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/indexer/tasks/src/multiera/multiera_asset_utxo.rs b/indexer/tasks/src/multiera/multiera_asset_utxo.rs index c3657132..5a5f28d2 100644 --- a/indexer/tasks/src/multiera/multiera_asset_utxo.rs +++ b/indexer/tasks/src/multiera/multiera_asset_utxo.rs @@ -80,8 +80,17 @@ async fn handle( let utxo = if let Some(utxo) = utxo { utxo } else { - // this can happen if the tx was not valid, in which case the - // input is not spent. + // We iterate over the combination of in + // the tx body: + // + // If tx succeeded, inputs are consumed and we skip collateral. + // + // If tx failed, we skip inputs and consume collateral + // + // We don't need to have that piece of logic here, because the + // MultieraUsedInputTask takes care of discriminating by not + // inserting the unused ones in the map, so we can just skip + // the input. continue; }; @@ -95,6 +104,9 @@ async fn handle( } }; + // 0 values were allowed in the serialization of multiassets + // before conway. We need to filter these here, because the + // asset may not actually be in the assets table. if value == 0 { continue; } @@ -148,6 +160,9 @@ async fn handle( } }; + // 0 values were allowed in the serialization of multiassets + // before conway. We need to filter these here, because the + // asset may not actually be in the assets table. if value == 0 { continue; } diff --git a/webserver/server/app/controllers/AssetUtxosController.ts b/webserver/server/app/controllers/AssetUtxosController.ts index 5ef50ac6..2e7c781f 100644 --- a/webserver/server/app/controllers/AssetUtxosController.ts +++ b/webserver/server/app/controllers/AssetUtxosController.ts @@ -66,7 +66,7 @@ export class AssetUtxosController extends Controller { tx: data.output_tx_hash as string, }, paymentCred: Buffer.from(addressBytes as Uint8Array).toString('hex'), - amount: data.amount ? Number(data.amount) : undefined, + amount: data.amount ? data.amount : undefined, slot: data.slot, cip14Fingerprint: bech32.encode('asset', bech32.toWords(data.cip14_fingerprint)), }; diff --git a/webserver/shared/models/AssetUtxos.ts b/webserver/shared/models/AssetUtxos.ts index 728f3be8..4919044c 100644 --- a/webserver/shared/models/AssetUtxos.ts +++ b/webserver/shared/models/AssetUtxos.ts @@ -14,9 +14,9 @@ export type AssetUtxosResponse = { * If the utxo is created, this has the amount. It's undefined if the utxo * is spent. * - * @example 1031423725351 + * @example '1031423725351' */ - amount: number | undefined, + amount: string | undefined, utxo: { tx: string, index: number,