Skip to content

Commit

Permalink
fix: loading soul names on network that has no soulnames
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Jan 23, 2024
1 parent ee5db5f commit f7db927
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/modules/soul-name/tail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ export const tailSoulNames = async (
masa: MasaInterface,
limit: number = 5,
): Promise<SoulNameDetails[]> => {
const soulNameMintEventsFilter =
masa.contracts.instances.SoulNameContract.filters.Transfer(
constants.AddressZero,
);
const { hasAddress, filters, queryFilter } =
masa.contracts.instances.SoulNameContract;

if (!hasAddress) {
logger("error", "SoulName Contract is not deployed to this network!");
return [];
}

const soulNameMintEventsFilter = filters.Transfer(constants.AddressZero);

const { number } =
(await masa.config.signer.provider?.getBlock("latest")) ?? {};
Expand All @@ -29,11 +34,7 @@ export const tailSoulNames = async (
const toBlock = lastBlockNumber ? lastBlockNumber - offset * x : "latest";

soulNameMintEvents.push(
...(await masa.contracts.instances.SoulNameContract.queryFilter(
soulNameMintEventsFilter,
fromBlock,
toBlock,
)),
...(await queryFilter(soulNameMintEventsFilter, fromBlock, toBlock)),
);
x++;
} while (soulNameMintEvents.length <= limit);
Expand Down

0 comments on commit f7db927

Please sign in to comment.