Skip to content

Commit da14652

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 e00ce68 commit da14652

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

src/blocks/blocks.controller.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ describe('BlocksController', () => {
150150
mints: [],
151151
burns: [],
152152
},
153+
{
154+
hash: uuid(),
155+
fee: faker.datatype.number(),
156+
size: faker.datatype.number(),
157+
notes: [{ commitment: uuid() }],
158+
spends: [{ nullifier: uuid() }],
159+
mints: [],
160+
burns: [],
161+
serialized: 'serialized',
162+
},
153163
],
154164
},
155165
],
@@ -169,10 +179,14 @@ describe('BlocksController', () => {
169179
difficulty: block.difficulty,
170180
sequence: block.sequence,
171181
timestamp: block.timestamp.toISOString(),
172-
transactions_count: 1,
182+
transactions_count: 2,
173183
previous_block_hash: block.previous_block_hash,
174184
size: block.size,
175185
});
186+
187+
const serializedBlock = data[0] as SerializedBlockWithTransactions;
188+
expect(serializedBlock.transactions[0].serialized).toBeNull();
189+
expect(serializedBlock.transactions[1].serialized).toBe('serialized');
176190
});
177191
});
178192
});

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export class TransactionDto {
5353
@IsArray()
5454
@ValidateNested({ each: true })
5555
readonly burns!: BurnDto[];
56+
57+
@IsOptional()
58+
@IsString()
59+
readonly serialized?: string;
5660
}
5761

5862
export class UpsertTransactionsDto {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface UpsertTransactionOptions {
88
size: number;
99
notes: Note[];
1010
spends: Spend[];
11+
serialized?: string;
1112
}
1213

1314
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';
@@ -431,6 +432,7 @@ describe('TransactionsController', () => {
431432
expect(body1.spends).toStrictEqual(transaction1.spends);
432433
expect(body1.hash).toStrictEqual(transaction1.hash);
433434
expect(body1.expiration).toStrictEqual(transaction1.expiration);
435+
expect(body1.serialized).toBeNull();
434436

435437
const { body: body2 } = await request(app.getHttpServer())
436438
.get('/transactions/find')
@@ -441,6 +443,7 @@ describe('TransactionsController', () => {
441443
expect(body2.spends).toStrictEqual(transaction2.spends);
442444
expect(body2.hash).toStrictEqual(transaction2.hash);
443445
expect(body2.expiration).toStrictEqual(transaction2.expiration);
446+
expect(body2.serialized).toBe('serialized');
444447
});
445448
});
446449

src/transactions/transactions.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class TransactionsService {
3939
size: tx.size,
4040
notes: classToPlain(tx.notes),
4141
spends: classToPlain(tx.spends),
42+
serialized: tx.serialized ?? null,
4243
})),
4344
skipDuplicates: true,
4445
});

0 commit comments

Comments
 (0)