diff --git a/src/strategies/nation3-passport-coop-with-delegations/index.ts b/src/strategies/nation3-passport-coop-with-delegations/index.ts index 6fd51d1ea..42f56e945 100644 --- a/src/strategies/nation3-passport-coop-with-delegations/index.ts +++ b/src/strategies/nation3-passport-coop-with-delegations/index.ts @@ -1,10 +1,13 @@ import { BigNumber, BigNumberish } from '@ethersproject/bignumber'; import { Multicaller } from '../../utils'; import { formatUnits } from '@ethersproject/units'; +import { subgraphRequest } from '../../utils'; export const author = 'nation3'; export const version = '0.3.0'; +type Query = {[key: string]: any} + const DECIMALS = 18; const balanceAbi = [ @@ -29,15 +32,10 @@ export async function strategy( ): Promise> { const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; - const erc721SignerCaller = new Multicaller(network, provider, signerAbi, { - blockTag - }); - const erc721OwnerCaller = new Multicaller(network, provider, ownerAbi, { - blockTag - }); const erc20BalanceCaller = new Multicaller(network, provider, balanceAbi, { blockTag }); + const erc721LastTokenIdCaller = new Multicaller( network, provider, @@ -45,12 +43,38 @@ export async function strategy( { blockTag } ); + const erc721SignerCaller = new Multicaller(network, provider, signerAbi, { + blockTag + }); + const erc721OwnerCaller = new Multicaller(network, provider, ownerAbi, { + blockTag + }); + + const passportIssuanceSubgrgraph = "https://api.thegraph.com/subgraphs/name/nation3/passportissuance"; + + const revokedQuery: Query = { + revokes: { + id: true, + _to: true, + _tokenId: true, + } + } + + const revokedUsersResponse = await subgraphRequest(passportIssuanceSubgrgraph, revokedQuery); + + const revokedPassports: number[] = revokedUsersResponse.revokes.map(revokeObject => { + return BigNumber.from(revokeObject._tokenId).toNumber(); + }); + + erc721LastTokenIdCaller.call('lastTokenId', options.erc721, 'getNextId'); const lastIndex = await erc721LastTokenIdCaller.execute(); const lastTokenId = BigNumber.from(lastIndex.lastTokenId).toNumber(); for (let i = 1; i < lastTokenId; i++) { + if (revokedPassports.includes(i)) continue; + erc721SignerCaller.call(i, options.erc721, 'signerOf', [i]); erc721OwnerCaller.call(i, options.erc721, 'ownerOf', [i]); }