Implement remaining json host APIs (#487)

* Instantiate a new wasm string to convert JSON value to BigInt

* Implement remaining json host APIs

* Upgrade graph-ts and graph-cli in test example subgraph

* Handle null context for dataSource context host API

* Use JSONBig for parsing JSON strings
This commit is contained in:
prathamesh0
2023-11-22 18:03:21 +05:30
committed by GitHub
parent 729d862aac
commit ffd1d267d8
7 changed files with 822 additions and 160 deletions
+6 -8
View File
@@ -767,20 +767,18 @@ export const instantiate = async (
return JSONResult.__new(null);
}
},
// TODO: Number methods do not work as 64bit values are not supported in js.
// Tried solution in https://github.com/AssemblyScript/assemblyscript/issues/117#issuecomment-531556954
'json.toI64': async (decimal: number) => {
'json.toI64': (decimal: number) => {
return BigInt(__getString(decimal));
},
'json.toU64': async (decimal: number) => {
'json.toU64': (decimal: number) => {
return BigInt(__getString(decimal));
},
'json.toF64': async (decimal: number) => {
return BigInt(__getString(decimal));
'json.toF64': (decimal: number) => {
return Number(__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);
}
}
};