Skip to content

Commit

Permalink
[SUBGRAPH] isToken must not be null (#1917)
Browse files Browse the repository at this point in the history
* isToken must not be null

* lil optimizations
  • Loading branch information
0xdavinchee authored Mar 27, 2024
1 parent ec3163c commit a4d33c6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/subgraph/src/mappings/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,28 @@ 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);

if (resolverEntry == null) {
resolverEntry = new ResolverEntry(id);
resolverEntry.createdAtBlockNumber = block.number;
resolverEntry.createdAtTimestamp = block.timestamp;
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 = getIsToken(target.toHex());
}
const isListed = target.notEqual(ZERO_ADDRESS);

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

0 comments on commit a4d33c6

Please sign in to comment.