diff --git a/scripts/graphql/all-user-balance-from-block.ts b/scripts/graphql/all-user-balance-from-block.ts deleted file mode 100644 index 6c1520b..0000000 --- a/scripts/graphql/all-user-balance-from-block.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { DocumentNode, gql } from '@apollo/client/core'; - -export function getAllUserBlockFromBlockQuery(): DocumentNode { - return gql` - query GetAllUserBlockFromBlock($lastBlockNumber: BigInt!) { - userBalanceHistoryEntities( - where:{ - user_not: "0x0000000000000000000000000000000000000000" - blockNumber_lte: $lastBlockNumber - } - first: 1000 - orderBy: blockNumber - orderDirection: desc - ) { - balance - blockNumber - user { - id - } - } - } - `; -} \ No newline at end of file diff --git a/scripts/graphql/graph-service.ts b/scripts/graphql/graph-service.ts index 91bf69b..7d2746a 100644 --- a/scripts/graphql/graph-service.ts +++ b/scripts/graphql/graph-service.ts @@ -1,6 +1,5 @@ -import { UserBalanceHistoryEntity, UserEntity } from '../../generated/gql'; +import { UserEntity } from '../../generated/gql'; import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client/core'; -import { getAllUserBlockFromBlockQuery } from './all-user-balance-from-block'; import { getAllUsersOnBlockQuery } from './all-users-on-block'; function getSubgraphUrl() { @@ -41,31 +40,4 @@ export async function getAllUsersOnBlock(block: number): Promise { } return allUsers; -} - -export async function getAllUserBalanceByBlock(startBlock: number): Promise { - let allData: UserBalanceHistoryEntity[] = []; - let lastBlockNumber = startBlock; - let fetchMore = true; - - while (fetchMore) { - const { data } = await client.query({ - variables: { lastBlockNumber }, - query: getAllUserBlockFromBlockQuery(), - }); - - const entries = data.userBalanceHistoryEntities; - if (entries.length === 0) { - fetchMore = false; - } else { - allData = [...allData, ...entries]; - if (entries.length === 1000) { - lastBlockNumber = entries[entries.length - 1].blockNumber; - } else { - lastBlockNumber = entries[entries.length - 1].blockNumber - 1; - } - } - } - - return allData; } \ No newline at end of file