From 6090718258290c04e4c739ad6b2811062f0c32f6 Mon Sep 17 00:00:00 2001 From: Jason Spafford Date: Sun, 24 Dec 2023 11:05:38 -0800 Subject: [PATCH] Add serialized transaction field and return in API This adds a new field to Transaction called serialized which will contain the full base64 encoded transaction of the Ironfish SDK Transaction type. It also returns it in transactions/find API. --- .../20231224185350_add_transaction_serialized/migration.sql | 2 ++ prisma/schema.prisma | 1 + src/transactions/interfaces/serialized-transaction.ts | 1 + src/transactions/transactions.controller.spec.ts | 3 +++ src/transactions/utils/transaction-translator.ts | 1 + 5 files changed, 8 insertions(+) create mode 100644 prisma/migrations/20231224185350_add_transaction_serialized/migration.sql diff --git a/prisma/migrations/20231224185350_add_transaction_serialized/migration.sql b/prisma/migrations/20231224185350_add_transaction_serialized/migration.sql new file mode 100644 index 000000000..64dd4fd0a --- /dev/null +++ b/prisma/migrations/20231224185350_add_transaction_serialized/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "transactions" ADD COLUMN "serialized" VARCHAR; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 073294332..11126d922 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -44,6 +44,7 @@ model Transaction { notes Json spends Json network_version Int + serialized String? @db.VarChar asset_descriptions AssetDescription[] created_assets Asset[] blocks_transactions BlockTransaction[] diff --git a/src/transactions/interfaces/serialized-transaction.ts b/src/transactions/interfaces/serialized-transaction.ts index c964b9525..24724f6e6 100644 --- a/src/transactions/interfaces/serialized-transaction.ts +++ b/src/transactions/interfaces/serialized-transaction.ts @@ -12,6 +12,7 @@ export interface SerializedTransaction { size: number; notes: JsonValue; spends: JsonValue; + serialized: string | null; mints: SerializedAssetDescription[]; burns: SerializedAssetDescription[]; object: 'transaction'; diff --git a/src/transactions/transactions.controller.spec.ts b/src/transactions/transactions.controller.spec.ts index d39578014..a1d8bf24c 100644 --- a/src/transactions/transactions.controller.spec.ts +++ b/src/transactions/transactions.controller.spec.ts @@ -65,6 +65,8 @@ describe('TransactionsController', () => { size: faker.datatype.number(), notes, spends, + serialized: + 'U3dh76O7TMnEb+KPrRghTyz4G3lHV/BWfogtW59oUSFKACk56Jl3eMY9Ky9c5uc2nBhePgCo0hIM+ednqYAjoA', }, }); @@ -85,6 +87,7 @@ describe('TransactionsController', () => { hash: testTransactionHash, fee: expect.any(String), size: expect.any(Number), + serialized: transaction.serialized, notes, spends, }); diff --git a/src/transactions/utils/transaction-translator.ts b/src/transactions/utils/transaction-translator.ts index 8b79a1b63..dfb9c7625 100644 --- a/src/transactions/utils/transaction-translator.ts +++ b/src/transactions/utils/transaction-translator.ts @@ -30,6 +30,7 @@ export function serializedTransactionFromRecord( size: transaction.size, notes: transaction.notes, spends: transaction.spends, + serialized: transaction.serialized, mints, burns, object: 'transaction',