Skip to content

Commit

Permalink
Merge pull request #41 from kodadot/fix/unlimited
Browse files Browse the repository at this point in the history
fix/unlimited
  • Loading branch information
vikiival authored Aug 16, 2024
2 parents a5513d7 + 58bed21 commit 6aee545
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mappings/registry/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export async function handleCollectionAdd(context: Log, process: Context): Promi
const event = unwrap(context, getCreateCollectionEvent)
const final = await getOrCreate(process.store, CE, event.collection, {})

const max = Number(event.info.maxSupply)

final.blockNumber = BigInt(event.blockNumber)
// final.burned = false
final.baseUri = event.info.baseURI
Expand All @@ -28,7 +30,7 @@ export async function handleCollectionAdd(context: Log, process: Context): Promi
final.highestSale = BigInt(0)
final.id = contractOf(event.collection)
final.issuer = event.caller || event.creator
final.max = Number(event.info.maxSupply) ?? undefined
final.max = max <= Number.MAX_SAFE_INTEGER ? max : undefined
final.metadata = event.info.contractURI
final.name = event.info.name
final.nftCount = final.nftCount || 0
Expand Down
14 changes: 14 additions & 0 deletions src/mappings/utils/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ export function addressOf(event: string): string {
}


export function numberify(value: Optional<string | number | bigint>): Optional<number> {
if (!value) {
return undefined;
}

const num = Number(value);
if (!isFinite(num) || num > Number.MAX_SAFE_INTEGER) {
return undefined;
}

return num;
}


export function unwrap<T>(ctx: Context, unwrapFn: UnwrapFunc<T>): CallWith<T> {
const baseCall = toBaseEvent(ctx);
const unwrapped = unwrapFn(ctx);
Expand Down

0 comments on commit 6aee545

Please sign in to comment.