diff --git a/webserver/server/app/controllers/TransactionHistoryController.ts b/webserver/server/app/controllers/TransactionHistoryController.ts index 7278487e..a136be13 100644 --- a/webserver/server/app/controllers/TransactionHistoryController.ts +++ b/webserver/server/app/controllers/TransactionHistoryController.ts @@ -33,7 +33,9 @@ export class TransactionHistoryController extends Controller { requestBody: EndpointTypes[typeof route]['input'], @Res() errorResponse: TsoaResponse< - StatusCodes.CONFLICT | StatusCodes.BAD_REQUEST | StatusCodes.UNPROCESSABLE_ENTITY, + | StatusCodes.CONFLICT + | StatusCodes.BAD_REQUEST + | StatusCodes.UNPROCESSABLE_ENTITY, ErrorShape > ): Promise { diff --git a/webserver/server/app/services/TransactionHistoryService.ts b/webserver/server/app/services/TransactionHistoryService.ts index fa0d1643..eef02778 100644 --- a/webserver/server/app/services/TransactionHistoryService.ts +++ b/webserver/server/app/services/TransactionHistoryService.ts @@ -4,7 +4,7 @@ import { sqlHistoryForAddresses } from '../models/transaction/sqlHistoryForAddre import type { PoolClient } from 'pg'; import type { TransactionPaginationType } from './PaginationService'; import type { RelationFilter } from '../../../shared/models/common'; -import { Address, Transaction } from '@dcspark/cardano-multiplatform-lib-nodejs'; +import { Address } from '@dcspark/cardano-multiplatform-lib-nodejs'; export async function historyForCredentials( request: TransactionPaginationType & { @@ -40,7 +40,6 @@ export async function historyForCredentials( transaction: { hash: entry.hash.toString('hex'), payload: entry.payload.toString('hex'), - outputs: computeOutputs(entry.payload), metadata: entry.metadata && entry.metadata.toString('hex'), inputCredentials: entry.input_addresses ? (entry.input_addresses as string[]).map(getPaymentCred) @@ -82,7 +81,6 @@ export async function historyForAddresses( transaction: { hash: entry.hash.toString('hex'), payload: entry.payload.toString('hex'), - outputs: computeOutputs(entry.payload), metadata: entry.metadata && entry.metadata.toString('hex'), inputCredentials: entry.input_addresses ? (entry.input_addresses as string[]).map(getPaymentCred) @@ -92,81 +90,6 @@ export async function historyForAddresses( }; } -function computeOutputs( - tx: Buffer -): { asset: { policyId: string; assetName: string } | null; amount: string; address: string }[] { - const transaction = Transaction.from_bytes(tx); - - const rawOutputs = transaction.body().outputs(); - - const outputs = []; - - for (let i = 0; i < rawOutputs.len(); i++) { - const output = rawOutputs.get(i); - - const rawAddress = output.address(); - const address = rawAddress.to_bech32(); - rawAddress.free(); - - const amount = output.amount(); - const ma = amount.multiasset(); - - if (ma) { - const policyIds = ma.keys(); - - for (let j = 0; j < policyIds.len(); j++) { - const policyId = policyIds.get(j); - - const assets = ma.get(policyId); - - if (!assets) { - continue; - } - - const assetNames = assets.keys(); - - for (let k = 0; k < assetNames.len(); k++) { - const assetName = assetNames.get(k); - - const amount = assets.get(assetName); - - if (amount === undefined) { - continue; - } - - outputs.push({ - amount: amount.to_str(), - asset: { - policyId: policyId.to_hex(), - assetName: Buffer.from(assetName.to_bytes()).toString('hex'), - }, - address - }); - - assetName.free(); - } - - assetNames.free(); - assets.free(); - policyId.free(); - } - - policyIds.free(); - ma.free(); - } - - outputs.push({ amount: amount.coin().to_str(), asset: null, address }); - - amount.free(); - output.free(); - } - - rawOutputs.free(); - transaction.free(); - - return outputs; -} - function getPaymentCred(addressRaw: string): string { const address = Address.from_bytes(Buffer.from(addressRaw.slice(2), 'hex')); diff --git a/webserver/shared/models/TransactionHistory.ts b/webserver/shared/models/TransactionHistory.ts index 70f262ea..e5b1de3d 100644 --- a/webserver/shared/models/TransactionHistory.ts +++ b/webserver/shared/models/TransactionHistory.ts @@ -37,12 +37,6 @@ export type TransactionInfo = { */ payload: string; - outputs: { - asset: { policyId: PolicyId; assetName: AssetName } | null; - amount: string; - address: string; - }[]; - metadata: string | null; inputCredentials: string[];