intiate logger in web3sidechainclient
MODIFY
src/constant.ts
src/constant.ts
@@ -9,7 +9,7 @@ export const setWeb3Client = (web3Client) => {
}
export const EXTRA_GAS_FOR_PROXY_CALL = 1000000
-export const LOGGER = new Logger();
+
export const BIG_ONE = new BN(1)
export const BIG_TWO = new BN(2)

MODIFY
src/plasma/index.ts
src/plasma/index.ts
@@ -3,7 +3,6 @@ import { ERC721 } from "./erc721";
import { Web3SideChainClient } from "../utils";
import { IPlasmaClientConfig, IPlasmaContracts, ITransactionOption } from "../interfaces";
import { DepositManager } from "./deposit_manager";
-import { LOGGER } from "../constant";
import { RegistryContract } from "./registry";
import { Ether } from "./ether";
import { ExitManager, RootChain } from "../pos";
@@ -49,7 +48,7 @@ export class PlasmaClient {
constructor(config: IPlasmaClientConfig) {
this.client_ = new Web3SideChainClient(config);
- LOGGER.enableLog(config.log);
+ this.client_.logger.enableLog(config.log);
}
init() {

MODIFY
src/pos/index.ts
src/pos/index.ts
@@ -2,7 +2,6 @@ import { ERC20 } from "./erc20";
import { RootChainManager } from "./root_chain_manager";
import { Web3SideChainClient } from "../utils";
import { IPOSClientConfig } from "../interfaces";
-import { LOGGER } from "../constant";
import { ExitManager } from "./exit_manager";
import { RootChain } from "./root_chain";
import { ERC721 } from "./erc721";
@@ -22,12 +21,12 @@ export class POSClient {
constructor(config: IPOSClientConfig) {
this.client_ = new Web3SideChainClient(config);
+ this.client_.logger.enableLog(config.log);
}
init() {
const client = this.client_;
let config: IPOSClientConfig = client.config;
- LOGGER.enableLog(config.log);
return client.init().then(_ => {
const mainPOSContracts = this.client_.mainPOSContracts;

MODIFY
src/pos/root_chain.ts
src/pos/root_chain.ts
import { BaseToken, Web3SideChainClient } from "../utils";
import { TYPE_AMOUNT } from "../types";
import BN from "bn.js";
-import { BIG_ONE, CHECKPOINT_INTERVAL, BIG_TWO, LOGGER } from "../constant";
+import { BIG_ONE, CHECKPOINT_INTERVAL, BIG_TWO } from "../constant";
import { ITransactionOption } from "../interfaces";
export class RootChain extends BaseToken {

MODIFY
src/utils/base_token.ts
src/utils/base_token.ts
@@ -2,7 +2,7 @@ import { Web3SideChainClient } from "./web3_side_chain_client";
import { ITransactionConfig, ITransactionOption, IContractInitParam } from "../interfaces";
import { BaseContractMethod, BaseContract, BaseWeb3Client } from "../abstracts";
import { merge } from "../utils";
-import { EXTRA_GAS_FOR_PROXY_CALL, LOGGER } from "../constant";
+import { EXTRA_GAS_FOR_PROXY_CALL } from "../constant";
import { ContractWriteResult } from "../helpers";
import { promiseResolve } from "./promise_resolve";
import { ERROR_TYPE } from "../enums";
@@ -43,7 +43,7 @@ export class BaseToken {
}
protected processWrite(method: BaseContractMethod, option: ITransactionOption = {}): Promise<ContractWriteResult> {
- LOGGER.log("process write");
+ this.client.logger.log("process write");
return this.createTransactionConfig(
{
txConfig: option,
@@ -51,7 +51,7 @@ export class BaseToken {
method,
isParent: this.contractParam.isParent
}).then(config => {
- LOGGER.log("process write config");
+ this.client.logger.log("process write config");
if (option.returnTransaction) {
return merge(config, {
data: method.encodeABI(),
@@ -67,7 +67,7 @@ export class BaseToken {
}
protected sendTransaction(option: ITransactionOption = {}): Promise<ContractWriteResult> {
- LOGGER.log("process write");
+ this.client.logger.log("process write");
const isParent = this.contractParam.isParent;
const client = this.getClient_(isParent);
return this.createTransactionConfig(
@@ -77,7 +77,7 @@ export class BaseToken {
method: null as any,
isParent: this.contractParam.isParent
}).then(config => {
- LOGGER.log("process write config");
+ this.client.logger.log("process write config");
if (option.returnTransaction) {
return config as any;
}
@@ -90,7 +90,7 @@ export class BaseToken {
}
protected readTransaction(option: ITransactionOption = {}): Promise<ContractWriteResult> {
- LOGGER.log("process read");
+ this.client.logger.log("process read");
const isParent = this.contractParam.isParent;
const client = this.getClient_(isParent);
return this.createTransactionConfig(
@@ -100,7 +100,7 @@ export class BaseToken {
method: null as any,
isParent: this.contractParam.isParent
}).then(config => {
- LOGGER.log("process read config");
+ this.client.logger.log("process read config");
if (option.returnTransaction) {
return config as any;
}
@@ -111,7 +111,7 @@ export class BaseToken {
}
protected processRead<T>(method: BaseContractMethod, option: ITransactionOption = {}): Promise<T> {
- LOGGER.log("process read");
+ this.client.logger.log("process read");
return this.createTransactionConfig(
{
txConfig: option,
@@ -119,7 +119,7 @@ export class BaseToken {
method,
isParent: this.contractParam.isParent
}).then(config => {
- LOGGER.log("process read config");
+ this.client.logger.log("process read config");
if (option.returnTransaction) {
return merge(config, {
data: method.encodeABI(),

MODIFY
src/utils/web3_side_chain_client.ts
src/utils/web3_side_chain_client.ts
-import { Web3Client, LOGGER } from "../constant";
+import { Web3Client } from "../constant";
import { IPlasmaClientConfig } from "../interfaces";
import { BaseWeb3Client } from "../abstracts";
import { ABIHelper } from "../helpers";
+import { Logger } from "./logger";
export class Web3SideChainClient {
parent: BaseWeb3Client;
@@ -50,7 +51,7 @@ export class Web3SideChainClient {
}
get logger() {
- return LOGGER;
+ return new Logger();
}
}

intiate logger in web3sidechainclient