Skip to content

Commit

Permalink
update old abieos references
Browse files Browse the repository at this point in the history
  • Loading branch information
igorls committed Apr 15, 2024
1 parent 4a8d246 commit 3c24fea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
5 changes: 3 additions & 2 deletions api/routes/v1-history/get_actions/get_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down
11 changes: 0 additions & 11 deletions workers/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions workers/ds-pool.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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}`);
Expand All @@ -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}`);
}
Expand Down
19 changes: 15 additions & 4 deletions workers/hyperionWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -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 {
Expand Down

0 comments on commit 3c24fea

Please sign in to comment.