Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graph): update mapping to claim #1061

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions graph/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export function getID(tokenID: BigInt, contract: Address): string {
export function getOrCreateAllowlist(
claimID: BigInt,
root: Bytes,
contract: Address
contract: Address,
): Allowlist {
let id = getID(claimID, contract);
const id = getID(claimID, contract);
let list = Allowlist.load(id);

log.debug("Created allowlistID: {}", [id]);
Expand All @@ -29,18 +29,24 @@ export function getOrCreateAllowlist(
export function getOrCreateClaim(
claimID: BigInt,
contract: Address,
timestamp: BigInt
timestamp: BigInt,
): Claim {
let id = getID(claimID, contract);
const id = getID(claimID, contract);
let claim = Claim.load(id);

log.debug("Created claimID: {}", [id]);

if (claim == null) {
claim = new Claim(id);
const list = Allowlist.load(id);

if (timestamp) {
claim.creation = timestamp;
}

if (list) {
claim.allowlist = list.id;
}
claim.tokenID = claimID;
claim.contract = contract.toHexString();
claim.save();
Expand All @@ -52,17 +58,17 @@ export function getOrCreateClaim(
export function getOrCreateClaimToken(
claimID: BigInt,
tokenID: BigInt,
contract: Address
contract: Address,
): ClaimToken {
let minterContract = HypercertMinter.bind(contract);
const minterContract = HypercertMinter.bind(contract);

let id = getID(tokenID, contract);
const id = getID(tokenID, contract);
let fraction = ClaimToken.load(id);

if (fraction == null) {
log.debug("Creating claimToken: {}", [id]);

let owner = minterContract.ownerOf(tokenID);
const owner = minterContract.ownerOf(tokenID);

fraction = new ClaimToken(id);
fraction.owner = owner;
Expand Down
Loading