mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user