Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions backend/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ async function main() {

console.log({ stream1 });

// Create an example event
const event1 = await prisma.streamEvent.create({
data: {
// Upsert an example event – keyed on the @@unique([transactionHash, eventType])
// constraint so re-running the seed never creates duplicate rows.
const DEMO_TX_HASH = '6f7e8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r';
const event1 = await prisma.streamEvent.upsert({
where: {
transactionHash_eventType: {
transactionHash: DEMO_TX_HASH,
eventType: 'CREATED',
},
},
update: {},
create: {
streamId: stream1.streamId,
eventType: 'CREATED',
amount: '1000000000000',
transactionHash: '6f7e8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r',
transactionHash: DEMO_TX_HASH,
ledgerSequence: 123456,
timestamp: Math.floor(Date.now() / 1000),
metadata: JSON.stringify({ memo: 'Seed data' }),
Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/stream.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export const createStream = async (req: Request, res: Response) => {
},
});

return res.status(201).json(stream);
return res.status(201).json(JSON.parse(JSON.stringify(stream, (_key, value) => typeof value === "bigint" ? value.toString() : value)));
} catch (error) {
if (
error instanceof RangeError ||
Expand Down
6 changes: 3 additions & 3 deletions backend/src/workers/soroban-event-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ export class SorobanEventWorker {
}

const sender = decodeAddress(body["sender"]);
const newEndTime = Number(decodeU64(body["new_end_time"]));
const newEndTime = decodeU64(body["new_end_time"]);
const timestamp = Math.floor(Date.now() / 1000);

await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
Expand Down Expand Up @@ -1164,7 +1164,7 @@ export class SorobanEventWorker {
timestamp,
metadata: JSON.stringify({
sender,
newEndTime,
newEndTime: newEndTime.toString(),
pausedDuration: additionalPausedDuration,
totalPausedDuration: newTotalPausedDuration,
}),
Expand All @@ -1180,7 +1180,7 @@ export class SorobanEventWorker {
sseService.broadcastToStream(String(streamId), "stream.resumed", {
streamId,
sender,
newEndTime,
newEndTime: newEndTime.toString(),
transactionHash: event.txHash,
ledger: event.ledger,
timestamp,
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ describe('POST /v1/streams', () => {
ratePerSecond: '100',
depositedAmount: '86400',
withdrawnAmount: '0',
startTime: 1700000000,
lastUpdateTime: 1700000000,
startTime: 1700000000n,
lastUpdateTime: 1700000000n,
isPaused: false,
pausedAt: null,
totalPausedDuration: 0,
Expand Down
Loading