Skip to content

Commit

Permalink
lil optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdavinchee committed Mar 27, 2024
1 parent 0cb3fd9 commit f7710ca
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/subgraph/src/mappings/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ export function handleRoleRevoked(event: RoleRevoked): void {
ev.save();
}

function getIsToken(id: string): boolean {
return Token.load(id) != null;
}

function getOrInitResolverEntry(id: string, target: Address, block: ethereum.Block): ResolverEntry {
let resolverEntry = ResolverEntry.load(id);

const isListed = target.notEqual(ZERO_ADDRESS);
const isToken = Token.load(target.toHex()) != null;

if (resolverEntry == null) {
resolverEntry = new ResolverEntry(id);
Expand All @@ -55,12 +58,12 @@ function getOrInitResolverEntry(id: string, target: Address, block: ethereum.Blo
resolverEntry.targetAddress = target;
// on initialization, we are unlikely to set this to zero address
// if we do, this gets fixed in subsequent set events
resolverEntry.isToken = isToken;
resolverEntry.isToken = getIsToken(target.toHex());
}

// we only update this if the target is not equal to the zero address
if (isListed) {
resolverEntry.isToken = isToken;
resolverEntry.isToken = getIsToken(target.toHex());
}
resolverEntry.updatedAtBlockNumber = block.number;
resolverEntry.updatedAtTimestamp = block.timestamp;
Expand Down

0 comments on commit f7710ca

Please sign in to comment.