diff --git a/src/blocks/blocks.controller.spec.ts b/src/blocks/blocks.controller.spec.ts index 52272dcdd..1536161f6 100644 --- a/src/blocks/blocks.controller.spec.ts +++ b/src/blocks/blocks.controller.spec.ts @@ -150,6 +150,16 @@ describe('BlocksController', () => { mints: [], burns: [], }, + { + hash: uuid(), + fee: faker.datatype.number(), + size: faker.datatype.number(), + notes: [{ commitment: uuid() }], + spends: [{ nullifier: uuid() }], + mints: [], + burns: [], + serialized: 'serialized', + }, ], }, ], @@ -169,10 +179,14 @@ describe('BlocksController', () => { difficulty: block.difficulty, sequence: block.sequence, timestamp: block.timestamp.toISOString(), - transactions_count: 1, + transactions_count: 2, previous_block_hash: block.previous_block_hash, size: block.size, }); + + const serializedBlock = data[0] as SerializedBlockWithTransactions; + expect(serializedBlock.transactions[0].serialized).toBeNull(); + expect(serializedBlock.transactions[1].serialized).toBe('serialized'); }); }); }); diff --git a/src/transactions/dto/upsert-transactions.dto.ts b/src/transactions/dto/upsert-transactions.dto.ts index 5f23de9b7..4c96a7fb4 100644 --- a/src/transactions/dto/upsert-transactions.dto.ts +++ b/src/transactions/dto/upsert-transactions.dto.ts @@ -53,6 +53,10 @@ export class TransactionDto { @IsArray() @ValidateNested({ each: true }) readonly burns!: BurnDto[]; + + @IsOptional() + @IsString() + readonly serialized?: string; } export class UpsertTransactionsDto { diff --git a/src/transactions/interfaces/upsert-transaction-options.ts b/src/transactions/interfaces/upsert-transaction-options.ts index 22455f66f..02f0d87ac 100644 --- a/src/transactions/interfaces/upsert-transaction-options.ts +++ b/src/transactions/interfaces/upsert-transaction-options.ts @@ -8,6 +8,7 @@ export interface UpsertTransactionOptions { size: number; notes: Note[]; spends: Spend[]; + serialized?: string; } interface Note { diff --git a/src/transactions/transactions.controller.spec.ts b/src/transactions/transactions.controller.spec.ts index a1d8bf24c..abc3d9ba4 100644 --- a/src/transactions/transactions.controller.spec.ts +++ b/src/transactions/transactions.controller.spec.ts @@ -413,6 +413,7 @@ describe('TransactionsController', () => { spends: [{ nullifier: uuid() }], mints: [], burns: [], + serialized: 'serialized' }; const API_KEY = 'test'; @@ -431,6 +432,7 @@ describe('TransactionsController', () => { expect(body1.spends).toStrictEqual(transaction1.spends); expect(body1.hash).toStrictEqual(transaction1.hash); expect(body1.expiration).toStrictEqual(transaction1.expiration); + expect(body1.serialized).toBeNull(); const { body: body2 } = await request(app.getHttpServer()) .get('/transactions/find') @@ -441,6 +443,7 @@ describe('TransactionsController', () => { expect(body2.spends).toStrictEqual(transaction2.spends); expect(body2.hash).toStrictEqual(transaction2.hash); expect(body2.expiration).toStrictEqual(transaction2.expiration); + expect(body2.serialized).toBe('serialized'); }); }); diff --git a/src/transactions/transactions.service.ts b/src/transactions/transactions.service.ts index 00a1b7eb7..991b6316a 100644 --- a/src/transactions/transactions.service.ts +++ b/src/transactions/transactions.service.ts @@ -39,6 +39,7 @@ export class TransactionsService { size: tx.size, notes: classToPlain(tx.notes), spends: classToPlain(tx.spends), + serialized: tx.serialized ?? null, })), skipDuplicates: true, });