Skip to content

Commit 2966cd7

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 6090718 commit 2966cd7

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-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.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)