From 9c0840deceb57716495da611835daab498ca6ef0 Mon Sep 17 00:00:00 2001 From: djeck1432 Date: Thu, 12 Sep 2024 18:36:57 +0200 Subject: [PATCH] add new logic --- backend/src/starknet.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/src/starknet.ts b/backend/src/starknet.ts index 085d195a..8cf92f3f 100644 --- a/backend/src/starknet.ts +++ b/backend/src/starknet.ts @@ -23,6 +23,8 @@ const starknetIdNavigator = new StarknetIdNavigator( const cache = new Map(); export const getVestingEvents = async (address: string) => { + const vesting_milestone_add_selector = hash.getSelectorFromName('VestingMilestoneAdded') + const vested_selector = hash.getSelectorFromName('Vested') // Check if the result is already cached if (cache.has(address)) { @@ -34,7 +36,7 @@ export const getVestingEvents = async (address: string) => { from_block: { block_number: START_BLOCK }, chunk_size: 100, address: address, - keys: [[hash.getSelectorFromName('Vesting')]], + keys: [[hash.getSelectorFromName('VestingEvent')]], }; const events = await provider.getEvents(eventFilter); @@ -50,17 +52,23 @@ export const getVestingEvents = async (address: string) => { const timestamp = parseInt(event.data[1]); // Timestamp (index 1) const amount = parseInt(event.data[2]); // Amount (index 2) - if (timestamp < now && amount) { + if (timestamp < now && event.keys.includes(vesting_milestone_add_selector)) { acc.push({ amount: amount, - timestamp: timestamp, is_claimable: true, + is_claimed: false, + }); + } else if (event.keys.includes(vested_selector)) { + acc.push({ + amount: amount, + is_claimable: false, + is_claimed: true, }); } else { acc.push({ - timestamp: timestamp, amount: amount, is_claimable: false, + is_claimed: false, }); } } catch (error) {