diff --git a/envio/schema.graphql b/envio/schema.graphql index 19b569e..17a188f 100644 --- a/envio/schema.graphql +++ b/envio/schema.graphql @@ -1,4 +1,5 @@ type SBCDepositContract_DepositEvent { + chainId: Int! id: ID! pubkey: String! withdrawal_credentials: String! diff --git a/envio/src/EventHandlers.ts b/envio/src/EventHandlers.ts index 2a72629..c26b017 100644 --- a/envio/src/EventHandlers.ts +++ b/envio/src/EventHandlers.ts @@ -8,6 +8,7 @@ import { SBCDepositContract.DepositEvent.handler(async ({ event, context }) => { const entity: SBCDepositContract_DepositEvent = { + chainId: event.chainId, id: `${event.chainId}_${event.block.number}_${event.logIndex}`, pubkey: event.params.pubkey, withdrawal_credentials: event.params.withdrawal_credentials, diff --git a/hooks/use-deposit.ts b/hooks/use-deposit.ts index 7e37016..c22505a 100644 --- a/hooks/use-deposit.ts +++ b/hooks/use-deposit.ts @@ -23,12 +23,13 @@ type DepositDataJson = { }; const GET_DEPOSIT_EVENTS = gql` - query MyQuery($pubkeys: [String!]) { + query MyQuery($pubkeys: [String!], $chainId: Int!) { SBCDepositContract_DepositEvent( where: { pubkey: { _in: $pubkeys }, + chainId: {_eq: $chainId} } ) { id @@ -103,8 +104,10 @@ function useDeposit(contractConfig: ContractNetwork | undefined, address: `0x${s query: GET_DEPOSIT_EVENTS, variables: { pubkeys: pksFromFile, + chainId: chainId, }, }); + console.log(data); const existingDeposits = data.SBCDepositContract_DepositEvent.map((d: { pubkey: string }) => d.pubkey); for (const deposit of deposits) {