Skip to content

Commit

Permalink
Merge pull request #33 from hypercerts-org/20-indexer-index-on-chain-…
Browse files Browse the repository at this point in the history
…token-ownership-state

20 indexer index on chain token ownership state
  • Loading branch information
bitbeckers authored Apr 16, 2024
2 parents cb52491 + 3121c56 commit 1479c40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/indexer/indexClaimsStored.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ const defaultConfig = {

export const indexClaimsStoredEvents = async ({
batchSize = defaultConfig.batchSize,
eventName = defaultConfig.eventNam,
eventName = defaultConfig.eventName,
}: IndexerConfig = defaultConfig) => {
const { chainId } = getDeployment();
const contractsWithEvents = await getContractEventsForChain({
chainId,
eventName,
});

if (!contractsWithEvents || contracsWithEvents.length === 0) {
if (!contractsWithEvents || contractsWithEvents.length === 0) {
return;
}

Expand Down Expand Up @@ -66,13 +66,13 @@ export const indexClaimsStoredEvents = async ({
async (claim) =>
await storeClaim({
claim,
contract: { id: contractEvent.contract_id ,
},
,
contract: { id: contractEvent.contract_id },
}),
),
).then(() =>
updateLastBlockIndexedContractEvents({
contractEventsId: contractEvent.id,
lastBlockIndexed: toBloc,
lastBlockIndexed: toBlock,
}),
);
}),
Expand Down
12 changes: 7 additions & 5 deletions src/storage/storeTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const storeTransferSingle = async ({
return;
}

console.debug(`[StoreTransferSingle] Storing ${tokens.legth} tokens`);
console.debug(`[StoreTransferSingle] Storing ${tokens.length} tokens`);

const results = []; // Array to store the results

Expand All @@ -54,7 +54,7 @@ export const storeTransferSingle = async ({

const { data, error } = await supabase.rpc(
"upsert_hypercert_token",
_toke,
_token,
);

if (error) {
Expand All @@ -64,18 +64,20 @@ export const storeTransferSingle = async ({
}

console.debug(
`[StoreTransferSingle] Transferred ${token.token_id} units to ${token.owner_address}},
`[StoreTransferSingle] Transferred ${token.token_id} units to ${token.owner_address}}`,
);

results.push(data);
} catch (error) {
if (error instanceof Error) {
console.error(
`[StoreTransferSingle] Error while storing hypercert: ${error.message}`,
`[StoreTransferSingle] Error while storing transfer: ${error.message}`,
error,
);
} else {
console.error(
`[StoreTransferSingle] An unknown error occurred: ${JSON.stringify(error)}`,
`[StoreTransferSingle] An unknown error occurred while storing the token.`,
error,
);
}
}
Expand Down

0 comments on commit 1479c40

Please sign in to comment.