Implement new graph-node host API for BigDecimal exponentiation (#467)

* Implement host API for BigDecimal pow

* Handle FEVM future block error in rpc-eth-client getFullBlocks

* Handle future block error in rpc-eth-client getBlockWithTransactions

* Upgrade package versions
This commit is contained in:
2023-11-13 12:22:23 +05:30
committed by GitHub
parent 66d613767e
commit 7b5fbf3d13
15 changed files with 132 additions and 87 deletions
+5 -5
View File
@@ -1,10 +1,10 @@
{
"name": "@cerc-io/graph-node",
"version": "0.2.69",
"version": "0.2.70",
"main": "dist/index.js",
"license": "AGPL-3.0",
"devDependencies": {
"@cerc-io/solidity-mapper": "^0.2.69",
"@cerc-io/solidity-mapper": "^0.2.70",
"@ethersproject/providers": "^5.4.4",
"@graphprotocol/graph-ts": "^0.22.0",
"@nomiclabs/hardhat-ethers": "^2.0.2",
@@ -51,9 +51,9 @@
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/assemblyscript": "0.19.10-watcher-ts-0.1.2",
"@cerc-io/cache": "^0.2.69",
"@cerc-io/ipld-eth-client": "^0.2.69",
"@cerc-io/util": "^0.2.69",
"@cerc-io/cache": "^0.2.70",
"@cerc-io/ipld-eth-client": "^0.2.70",
"@cerc-io/util": "^0.2.70",
"@types/json-diff": "^0.5.2",
"@types/yargs": "^17.0.0",
"bn.js": "^4.11.9",
+19
View File
@@ -459,6 +459,25 @@ export const instantiate = async (
return mulResultBigDecimal;
},
'bigDecimal.pow': async (x: number, y: number) => {
// Create decimal x string.
const xBigDecimal = await BigDecimal.wrap(x);
const xStringPtr = await xBigDecimal.toString();
const xDecimalString = __getString(xStringPtr);
const xDecimal = new GraphDecimal(xDecimalString);
// Create decimal y string.
const yBigDecimal = await BigDecimal.wrap(y);
const yStringPtr = await yBigDecimal.toString();
const yDecimalString = __getString(yStringPtr);
// Perform the decimal pow operation.
const powResult = xDecimal.pow(yDecimalString);
const ptr = await __newString(powResult.toString());
const powResultBigDecimal = await BigDecimal.fromString(ptr);
return powResultBigDecimal;
},
'bigInt.fromString': async (s: number) => {
const string = __getString(s);