import { Provider } from '@ethersproject/providers' ; import { subgraphRequest } from '../../utils' ; import { verifyResults } from './graphUtils' ; export const TOKEN_DISTRIBUTION_SUBGRAPH_URL = { '1' : 'https://api.thegraph.com/subgraphs/name/graphprotocol/token-distribution' , '4' : 'https://api.thegraph.com/subgraphs/name/davekaj/token-distribution-rinkeby' } ; interface TokenLockWallets { [ key ] : string [ ] ; } dev returns export async function getTokenLockWallets ( _space , network , _provider , addresses , options , snapshot ) { const tokenLockParams = { tokenLockWallets : { __args : { where : { beneficiary_in : addresses } , first : options . pageSize } , id : true , beneficiary : true } } ; if ( snapshot !== 'latest' ) { tokenLockParams . tokenLockWallets . __args . block = { number : snapshot } ; } const result = await subgraphRequest ( TOKEN_DISTRIBUTION_SUBGRAPH_URL [ network ] , tokenLockParams ) ; const tokenLockWallets = { } ; if ( result && result . tokenLockWallets ) { if ( options . expectedResults ) { verifyResults ( JSON . stringify ( result . tokenLockWallets ) , JSON . stringify ( options . expectedResults . tokenLockWallets ) , 'Token lock wallets' ) ; } result . tokenLockWallets . forEach ( ( tw ) => { if ( tokenLockWallets [ tw . beneficiary ] == undefined ) tokenLockWallets [ tw . beneficiary ] = [ ] ; tokenLockWallets [ tw . beneficiary ] = tokenLockWallets [ tw . beneficiary ] . concat ( tw . id ) ; } ) ; } else { console . error ( 'Subgraph request failed' ) ; } return tokenLockWallets || { } ; }