implement isBN in utils
MODIFY
src/abstracts/base_web3_client.ts
src/abstracts/base_web3_client.ts
+import BN from "bn.js";
import { BaseContract } from "../abstracts";
import { ITransactionConfig, ITransactionReceipt, ITransactionData, IBlock, IBlockWithTransaction, IJsonRpcRequestPayload, IJsonRpcResponse, ITransactionWriteResult } from "../interfaces";
import { Logger } from "../utils";
@@ -41,4 +42,5 @@ export abstract class BaseWeb3Client {
abstract encodeParameters(params: any[], types: any[]): string;
abstract decodeParameters(hexString: string, types: any[]): any[];
abstract etheriumSha3(...value): string;
+
}

MODIFY
src/utils/bridge_client.ts
src/utils/bridge_client.ts
import BN from "bn.js";
import { Web3SideChainClient } from "../utils";
import { ExitUtil } from "../pos";
-import { BaseToken } from "..";
+import { BaseToken, utils } from "..";
export class BridgeClient<T> {
@@ -51,7 +51,7 @@ export class BridgeClient<T> {
throw new Error("StateSynced event not found");
}
const rootStateId = client.child.decodeParameters(targetLog.topics[1], ['uint256'])[0];
- const rootStateIdBN = BN.isBN(rootStateId) ? rootStateId : new BN(rootStateId);
+ const rootStateIdBN = utils.isBN(rootStateId) ? rootStateId : new BN(rootStateId);
return new BN(lastStateId).gte(
rootStateIdBN
);

MODIFY
src/utils/converter.ts
src/utils/converter.ts
import BN from "bn.js";
+import { utils } from "../utils";
export class Converter {
static toHex(amount: BN | string | number) {
@@ -11,7 +12,7 @@ export class Converter {
}
amount = new BN(amount);
}
- if (BN.isBN(amount)) {
+ if (utils.isBN(amount)) {
return '0x' + amount.toString(16);
}
else {

MODIFY
src/utils/index.ts
src/utils/index.ts
+import BN from "bn.js";
import { BaseWeb3Client, Converter, TYPE_AMOUNT } from "..";
export * from "./use";
@@ -19,5 +20,8 @@ export * from "./abi_manager";
export const utils = {
converter: Converter,
- Web3Client: BaseWeb3Client
+ Web3Client: BaseWeb3Client,
+ isBN(value) {
+ return BN.isBN(value);
+ }
};
\ No newline at end of file

MODIFY
src/utils/proof_util.ts
src/utils/proof_util.ts
@@ -6,7 +6,7 @@ import { mapPromise } from "./map_promise";
const TRIE = require('merkle-patricia-tree');
const rlp = ethUtils.rlp;
import EthereumBlock from 'ethereumjs-block/from-rpc';
-import { promiseResolve } from "..";
+import { Converter, promiseResolve, utils } from "..";
export class ProofUtil {
@@ -217,7 +217,8 @@ export class ProofUtil {
];
}),
]);
- if (receipt.status !== undefined && receipt.status !== null && receipt.type !== '0x0' && receipt.type !== '0x') {
+ const hexType = Converter.toHex(receipt.type);
+ if (receipt.status != null && hexType !== '0x0' && hexType !== '0x') {
encodedData = Buffer.concat([ethUtils.toBuffer(receipt.type), encodedData]);
}
return encodedData;

implement isBN in utils