Skip to content

Commit e6bbae4

Browse files
authored
Merge pull request #12131 from hicommonwealth/ryan/create-launchpad-trade-bigint-fix
Fix bigint serialization error
2 parents 8bf0ad0 + faa4bf0 commit e6bbae4

File tree

4 files changed

+26
-37
lines changed

4 files changed

+26
-37
lines changed

libs/model/src/aggregates/token/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export async function handleCapReached(
9595
privateKey: config.WEB3.LAUNCHPAD_PRIVATE_KEY!,
9696
});
9797

98+
token.liquidity_transferred = true;
99+
log.debug(`Liquidity transferred to ${token_address}`);
100+
98101
if (notifyUsers.length > 0) {
99102
await provider.triggerWorkflow({
100103
key: WorkflowKeys.LaunchpadCapReached,
@@ -105,9 +108,6 @@ export async function handleCapReached(
105108
},
106109
});
107110
}
108-
109-
token.liquidity_transferred = true;
110-
log.debug(`Liquidity transferred to ${token_address}`);
111111
}
112112

113113
await models.sequelize.transaction(async (transaction) => {
@@ -119,7 +119,6 @@ export async function handleCapReached(
119119
event_name: 'LaunchpadTokenGraduated',
120120
event_payload: {
121121
token: token.toJSON(),
122-
...onChainTokenData,
123122
},
124123
},
125124
],

libs/model/src/policies/EventStream.policy.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ const eventStreamMappers: EventStreamMappers = {
183183
};
184184
},
185185
LaunchpadTokenTraded: async (payload) => {
186+
// TODO: the LaunchpadToken usually hasn't been projected by this point,
187+
// so only the transaction data is available. Refactor to use tokenData
188+
// and make sure bigint is serialized correctly, then re-enable in policy.
189+
186190
const launchpadToken = await models.LaunchpadToken.findOne({
187191
where: { token_address: payload.token_address },
188192
});
@@ -266,9 +270,9 @@ export function EventStreamPolicy(): Policy<{
266270
);
267271
},
268272
LaunchpadTokenTraded: async ({ payload }) => {
269-
await pushToEventStream(
270-
await eventStreamMappers.LaunchpadTokenTraded(payload),
271-
);
273+
// await pushToEventStream(
274+
// await eventStreamMappers.LaunchpadTokenTraded(payload),
275+
// );
272276
},
273277
LaunchpadTokenGraduated: async ({ payload }) => {
274278
await pushToEventStream(

libs/model/test/policies/eventStream.policy.spec.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -339,20 +339,20 @@ describe('EventStream Policy Integration Tests', () => {
339339
block_timestamp: 1n,
340340
} satisfies z.infer<typeof events.LaunchpadTokenCreated>),
341341
},
342-
{
343-
event_name: 'LaunchpadTokenTraded',
344-
event_payload: serializeBigIntObj({
345-
block_timestamp: 1n,
346-
transaction_hash: '0x1111111111111111111111111111111111111111',
347-
trader_address: '0x1111111111111111111111111111111111111111',
348-
token_address: '0x7777777777777777777777777777777777777777',
349-
is_buy: true,
350-
eth_chain_id: 1,
351-
eth_amount: 1n,
352-
community_token_amount: 1n,
353-
floating_supply: 1n,
354-
} satisfies z.infer<typeof events.LaunchpadTokenTraded>),
355-
},
342+
// {
343+
// event_name: 'LaunchpadTokenTraded',
344+
// event_payload: serializeBigIntObj({
345+
// block_timestamp: 1n,
346+
// transaction_hash: '0x1111111111111111111111111111111111111111',
347+
// trader_address: '0x1111111111111111111111111111111111111111',
348+
// token_address: '0x7777777777777777777777777777777777777777',
349+
// is_buy: true,
350+
// eth_chain_id: 1,
351+
// eth_amount: 1n,
352+
// community_token_amount: 1n,
353+
// floating_supply: 1n,
354+
// } satisfies z.infer<typeof events.LaunchpadTokenTraded>),
355+
// },
356356
{
357357
event_name: 'LaunchpadTokenGraduated',
358358
event_payload: serializeBigIntObj({
@@ -366,13 +366,6 @@ describe('EventStream Policy Integration Tests', () => {
366366
launchpad_liquidity: 1n,
367367
eth_market_cap_target: 1000,
368368
},
369-
launchpadLiquidity: 1n,
370-
poolLiquidity: 1n,
371-
curveId: 1n,
372-
scalar: 1n,
373-
reserveRation: 1n,
374-
LPhook: '0x123',
375-
funded: true,
376369
} satisfies z.infer<typeof events.LaunchpadTokenGraduated>),
377370
},
378371
];
@@ -386,7 +379,7 @@ describe('EventStream Policy Integration Tests', () => {
386379
'CommunityCreated',
387380
'ThreadCreated',
388381
'LaunchpadTokenCreated',
389-
'LaunchpadTokenTraded',
382+
// 'LaunchpadTokenTraded',
390383
'LaunchpadTokenGraduated',
391384
] satisfies Events[];
392385

libs/schemas/src/events/events.schemas.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,7 @@ export const events = {
400400
}),
401401

402402
LaunchpadTokenGraduated: z.object({
403-
token: LaunchpadToken.extend({}),
404-
launchpadLiquidity: z.coerce.bigint(),
405-
poolLiquidity: z.coerce.bigint(),
406-
curveId: z.coerce.bigint(),
407-
scalar: z.coerce.bigint(),
408-
reserveRation: z.coerce.bigint(),
409-
LPhook: z.string(),
410-
funded: z.boolean(),
403+
token: LaunchpadToken,
411404
}),
412405

413406
LaunchpadTokenTraded: z.object({

0 commit comments

Comments
 (0)