diff --git a/api/routes/v1-history/get_actions/get_actions.ts b/api/routes/v1-history/get_actions/get_actions.ts index 5955a81f..fbb9e007 100644 --- a/api/routes/v1-history/get_actions/get_actions.ts +++ b/api/routes/v1-history/get_actions/get_actions.ts @@ -2,7 +2,7 @@ import {FastifyInstance, FastifyReply, FastifyRequest} from "fastify"; import {mergeActionMeta, timedQuery} from "../../../helpers/functions"; import {Serialize} from "eosjs"; import {hLog} from "../../../../helpers/common_functions"; -import * as AbiEOS from "@eosrio/node-abieos"; +import {Abieos} from "@eosrio/node-abieos"; import {ApiResponse} from "@elastic/elasticsearch"; import {TextDecoder, TextEncoder} from "util"; import {JsonRpc} from "eosjs/dist"; @@ -135,7 +135,8 @@ async function getContractAtBlock(esClient, rpc, chain, accountName: string, blo if (check_action) { if (actions.has(check_action)) { try { - AbiEOS['load_abi'](accountName, JSON.stringify(abi)); + const abieos = Abieos.getInstance(); + abieos.loadAbi(accountName, JSON.stringify(abi)); } catch (e) { hLog(e); } diff --git a/workers/deserializer.ts b/workers/deserializer.ts index 1cdca2a6..d3463efb 100644 --- a/workers/deserializer.ts +++ b/workers/deserializer.ts @@ -705,17 +705,6 @@ export default class MainDSWorker extends HyperionWorker { } } - getAbiDataType(field: string, contract: string, type: string): string { - switch (field) { - case "action": { - return this.abieos.getTypeForAction(contract, type); - } - case "table": { - return this.abieos.getTypeForTable(contract, type); - } - } - } - async verifyLocalType(contract: string, type: string, block_num, field: string) { let abiStatus: boolean; let resultType: string; diff --git a/workers/ds-pool.ts b/workers/ds-pool.ts index 6b9dc888..676ca8dc 100644 --- a/workers/ds-pool.ts +++ b/workers/ds-pool.ts @@ -1,6 +1,5 @@ import {HyperionWorker} from "./hyperionWorker"; import {cargo, queue} from "async"; -import * as AbiEOS from "@eosrio/node-abieos"; import {Serialize} from "../addons/eosjs-native"; import {debugLog, hLog} from "../helpers/common_functions"; import {Message} from "amqplib"; @@ -233,7 +232,7 @@ export default class DSPoolWorker extends HyperionWorker { let _status; let resultType; try { - resultType = AbiEOS['get_type_for_' + field](contract, type); + resultType = this.getAbiDataType(field, contract, type); _status = true; } catch { _status = false; @@ -267,7 +266,7 @@ export default class DSPoolWorker extends HyperionWorker { // successful load from ES cache if (_status) { try { - resultType = AbiEOS['get_type_for_' + field](contract, type); + resultType = this.getAbiDataType(field, contract, type); _status = true; return [_status, resultType]; } catch (e) { @@ -281,7 +280,7 @@ export default class DSPoolWorker extends HyperionWorker { if (_status === true) { try { - resultType = AbiEOS['get_type_for_' + field](contract, type); + resultType = this.getAbiDataType(field, contract, type); _status = true; } catch (e) { debugLog(`(abieos/current) >> ${e.message}`); @@ -297,7 +296,7 @@ export default class DSPoolWorker extends HyperionWorker { const [_status, actionType] = await self.verifyLocalType(action.account, action.name, block_num, "action"); if (_status) { try { - return this.abieos.binToJson(action.account, actionType, Buffer.from(action.data, 'hex')); + return self.abieos.binToJson(action.account, actionType, Buffer.from(action.data, 'hex')); } catch (e) { debugLog(`(abieos) ${action.account}::${action.name} @ ${block_num} >>> ${e.message}`); } diff --git a/workers/hyperionWorker.ts b/workers/hyperionWorker.ts index a1689f0f..ba9c03cc 100644 --- a/workers/hyperionWorker.ts +++ b/workers/hyperionWorker.ts @@ -231,7 +231,7 @@ export abstract class HyperionWorker { } else { _status = this.abieos.loadAbiHex(contract, abi_hex); if (!_status) { - hLog(`AbiEOS.load_abi_hex error for ${contract} at ${block_num}`); + hLog(`Abieos::loadAbiHex error for ${contract} at ${block_num}`); if (this.failedAbiMap.has(contract)) { this.failedAbiMap.get(contract).add(block_num); } else { @@ -251,8 +251,19 @@ export abstract class HyperionWorker { } } - async loadCurrentAbiHex(contract) { - let _status; + getAbiDataType(field: string, contract: string, type: string): string { + switch (field) { + case "action": { + return this.abieos.getTypeForAction(contract, type); + } + case "table": { + return this.abieos.getTypeForTable(contract, type); + } + } + } + + async loadCurrentAbiHex(contract: string) { + let _status: boolean; if (this.failedAbiMap.has(contract) && this.failedAbiMap.get(contract).has(-1)) { _status = false; debugLog('ignore current abi for', contract); @@ -262,7 +273,7 @@ export abstract class HyperionWorker { const abi_hex = Buffer.from(currentAbi.abi).toString('hex'); _status = this.abieos.loadAbiHex(contract, abi_hex); if (!_status) { - hLog(`AbiEOS.load_abi_hex error for ${contract} at head`); + hLog(`Abieos::loadAbiHex error for ${contract} at head`); if (this.failedAbiMap.has(contract)) { this.failedAbiMap.get(contract).add(-1); } else {