Skip to content

Commit 3c24fea

Browse files
committed
update old abieos references
1 parent 4a8d246 commit 3c24fea

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

api/routes/v1-history/get_actions/get_actions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {FastifyInstance, FastifyReply, FastifyRequest} from "fastify";
22
import {mergeActionMeta, timedQuery} from "../../../helpers/functions";
33
import {Serialize} from "eosjs";
44
import {hLog} from "../../../../helpers/common_functions";
5-
import * as AbiEOS from "@eosrio/node-abieos";
5+
import {Abieos} from "@eosrio/node-abieos";
66
import {ApiResponse} from "@elastic/elasticsearch";
77
import {TextDecoder, TextEncoder} from "util";
88
import {JsonRpc} from "eosjs/dist";
@@ -135,7 +135,8 @@ async function getContractAtBlock(esClient, rpc, chain, accountName: string, blo
135135
if (check_action) {
136136
if (actions.has(check_action)) {
137137
try {
138-
AbiEOS['load_abi'](accountName, JSON.stringify(abi));
138+
const abieos = Abieos.getInstance();
139+
abieos.loadAbi(accountName, JSON.stringify(abi));
139140
} catch (e) {
140141
hLog(e);
141142
}

workers/deserializer.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -705,17 +705,6 @@ export default class MainDSWorker extends HyperionWorker {
705705
}
706706
}
707707

708-
getAbiDataType(field: string, contract: string, type: string): string {
709-
switch (field) {
710-
case "action": {
711-
return this.abieos.getTypeForAction(contract, type);
712-
}
713-
case "table": {
714-
return this.abieos.getTypeForTable(contract, type);
715-
}
716-
}
717-
}
718-
719708
async verifyLocalType(contract: string, type: string, block_num, field: string) {
720709
let abiStatus: boolean;
721710
let resultType: string;

workers/ds-pool.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {HyperionWorker} from "./hyperionWorker";
22
import {cargo, queue} from "async";
3-
import * as AbiEOS from "@eosrio/node-abieos";
43
import {Serialize} from "../addons/eosjs-native";
54
import {debugLog, hLog} from "../helpers/common_functions";
65
import {Message} from "amqplib";
@@ -233,7 +232,7 @@ export default class DSPoolWorker extends HyperionWorker {
233232
let _status;
234233
let resultType;
235234
try {
236-
resultType = AbiEOS['get_type_for_' + field](contract, type);
235+
resultType = this.getAbiDataType(field, contract, type);
237236
_status = true;
238237
} catch {
239238
_status = false;
@@ -267,7 +266,7 @@ export default class DSPoolWorker extends HyperionWorker {
267266
// successful load from ES cache
268267
if (_status) {
269268
try {
270-
resultType = AbiEOS['get_type_for_' + field](contract, type);
269+
resultType = this.getAbiDataType(field, contract, type);
271270
_status = true;
272271
return [_status, resultType];
273272
} catch (e) {
@@ -281,7 +280,7 @@ export default class DSPoolWorker extends HyperionWorker {
281280

282281
if (_status === true) {
283282
try {
284-
resultType = AbiEOS['get_type_for_' + field](contract, type);
283+
resultType = this.getAbiDataType(field, contract, type);
285284
_status = true;
286285
} catch (e) {
287286
debugLog(`(abieos/current) >> ${e.message}`);
@@ -297,7 +296,7 @@ export default class DSPoolWorker extends HyperionWorker {
297296
const [_status, actionType] = await self.verifyLocalType(action.account, action.name, block_num, "action");
298297
if (_status) {
299298
try {
300-
return this.abieos.binToJson(action.account, actionType, Buffer.from(action.data, 'hex'));
299+
return self.abieos.binToJson(action.account, actionType, Buffer.from(action.data, 'hex'));
301300
} catch (e) {
302301
debugLog(`(abieos) ${action.account}::${action.name} @ ${block_num} >>> ${e.message}`);
303302
}

workers/hyperionWorker.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export abstract class HyperionWorker {
231231
} else {
232232
_status = this.abieos.loadAbiHex(contract, abi_hex);
233233
if (!_status) {
234-
hLog(`AbiEOS.load_abi_hex error for ${contract} at ${block_num}`);
234+
hLog(`Abieos::loadAbiHex error for ${contract} at ${block_num}`);
235235
if (this.failedAbiMap.has(contract)) {
236236
this.failedAbiMap.get(contract).add(block_num);
237237
} else {
@@ -251,8 +251,19 @@ export abstract class HyperionWorker {
251251
}
252252
}
253253

254-
async loadCurrentAbiHex(contract) {
255-
let _status;
254+
getAbiDataType(field: string, contract: string, type: string): string {
255+
switch (field) {
256+
case "action": {
257+
return this.abieos.getTypeForAction(contract, type);
258+
}
259+
case "table": {
260+
return this.abieos.getTypeForTable(contract, type);
261+
}
262+
}
263+
}
264+
265+
async loadCurrentAbiHex(contract: string) {
266+
let _status: boolean;
256267
if (this.failedAbiMap.has(contract) && this.failedAbiMap.get(contract).has(-1)) {
257268
_status = false;
258269
debugLog('ignore current abi for', contract);
@@ -262,7 +273,7 @@ export abstract class HyperionWorker {
262273
const abi_hex = Buffer.from(currentAbi.abi).toString('hex');
263274
_status = this.abieos.loadAbiHex(contract, abi_hex);
264275
if (!_status) {
265-
hLog(`AbiEOS.load_abi_hex error for ${contract} at head`);
276+
hLog(`Abieos::loadAbiHex error for ${contract} at head`);
266277
if (this.failedAbiMap.has(contract)) {
267278
this.failedAbiMap.get(contract).add(-1);
268279
} else {

0 commit comments

Comments
 (0)