diff --git a/packages/graph-node/src/loader.ts b/packages/graph-node/src/loader.ts index 5eb038c8..dacbe2c6 100644 --- a/packages/graph-node/src/loader.ts +++ b/packages/graph-node/src/loader.ts @@ -778,9 +778,9 @@ export const instantiate = async ( 'json.toF64': async (decimal: number) => { return BigInt(__getString(decimal)); }, - // TODO: Debug toBigInt not working. 'json.toBigInt': async (decimal: number) => { - return ASBigInt.fromString(decimal); + const ptr = await __newString(__getString(decimal)); + return ASBigInt.fromString(ptr); } } }; diff --git a/packages/graph-node/test/subgraph/example1/src/mapping.ts b/packages/graph-node/test/subgraph/example1/src/mapping.ts index 8f2f6c09..cc38c2f6 100644 --- a/packages/graph-node/test/subgraph/example1/src/mapping.ts +++ b/packages/graph-node/test/subgraph/example1/src/mapping.ts @@ -581,9 +581,9 @@ export function testJsonFromBytes (): void { // const i64Value = numberValue.toI64(); // assert(i64Value == 123, 'values are not equal'); - // TODO: Debug json toBigInt failing test case. - // const bigIntValue = numberValue.toBigInt(); - // assert(bigIntValue.toString() == '123', 'values are not equal'); + const bigIntValue = numberValue.toBigInt(); + const expectedBigInt = BigInt.fromString('123'); + assert(bigIntValue.equals(expectedBigInt), 'BigInt values are not equal'); } export function testJsonTryFromBytes (): void {