Skip to content

Commit bcc4ff5

Browse files
committed
Add uploading serialized transaction to syncer
This allows the syncer services command to now upload the serialized transaction format to the API.
1 parent 7c801cb commit bcc4ff5

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

src/blocks/blocks.controller.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ describe('BlocksController', () => {
149149
mints: [],
150150
burns: [],
151151
},
152+
{
153+
hash: uuid(),
154+
fee: faker.datatype.number(),
155+
size: faker.datatype.number(),
156+
notes: [{ commitment: uuid() }],
157+
spends: [{ nullifier: uuid() }],
158+
mints: [],
159+
burns: [],
160+
serialized: 'serialized',
161+
},
152162
],
153163
},
154164
],
@@ -168,10 +178,14 @@ describe('BlocksController', () => {
168178
difficulty: block.difficulty,
169179
sequence: block.sequence,
170180
timestamp: block.timestamp.toISOString(),
171-
transactions_count: 1,
181+
transactions_count: 2,
172182
previous_block_hash: block.previous_block_hash,
173183
size: block.size,
174184
});
185+
186+
const serializedBlock = data[0] as SerializedBlockWithTransactions;
187+
expect(serializedBlock.transactions[0].serialized).toBeNull();
188+
expect(serializedBlock.transactions[1].serialized).toBe('serialized');
175189
});
176190
});
177191
});

src/transactions/dto/upsert-transactions.dto.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ export class TransactionDto {
6161
@ValidateNested({ each: true })
6262
@Type(() => BurnDto)
6363
readonly burns!: BurnDto[];
64+
65+
@IsOptional()
66+
@IsString()
67+
readonly serialized?: string;
6468
}
6569

6670
export class UpsertTransactionsDto {

src/transactions/interfaces/upsert-transaction-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface UpsertTransactionOptions {
1010
size: number;
1111
notes: Note[];
1212
spends: Spend[];
13+
serialized?: string;
1314
}
1415

1516
interface Note {

src/transactions/transactions.controller.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ describe('TransactionsController', () => {
413413
spends: [{ nullifier: uuid() }],
414414
mints: [],
415415
burns: [],
416+
serialized: 'serialized',
416417
};
417418

418419
const API_KEY = 'test';
@@ -432,6 +433,7 @@ describe('TransactionsController', () => {
432433
expect(body1.spends).toStrictEqual(transaction1.spends);
433434
expect(body1.hash).toStrictEqual(transaction1.hash);
434435
expect(body1.expiration).toStrictEqual(transaction1.expiration);
436+
expect(body1.serialized).toBeNull();
435437

436438
const { body: body2 } = await request(app.getHttpServer())
437439
.get('/transactions/find')
@@ -443,6 +445,7 @@ describe('TransactionsController', () => {
443445
expect(body2.spends).toStrictEqual(transaction2.spends);
444446
expect(body2.hash).toStrictEqual(transaction2.hash);
445447
expect(body2.expiration).toStrictEqual(transaction2.expiration);
448+
expect(body2.serialized).toBe('serialized');
446449
});
447450
});
448451

src/transactions/transactions.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class TransactionsService {
4040
size: tx.size,
4141
notes: classToPlain(tx.notes),
4242
spends: classToPlain(tx.spends),
43-
serialized: tx.serialized,
43+
serialized: tx.serialized ?? null,
4444
})),
4545
skipDuplicates: true,
4646
});

0 commit comments

Comments
 (0)