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
+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);