rm log using console and set using logger
MODIFY
src/pos/erc20.ts
src/pos/erc20.ts
@@ -44,7 +44,7 @@ export class ERC20 extends POSToken {
* @memberof ERC20
*/
getAllowance(userAddress: string, option?: ITransactionOption) {
- this.checkForRoot_("getAllowance");
+ this.checkForRoot("getAllowance");
return Promise.all([this.getPredicateAddress(), this.getContract()]).then(result => {
const [predicateAddress, contract] = result;
@@ -58,7 +58,7 @@ export class ERC20 extends POSToken {
}
approve(amount: TYPE_AMOUNT, option?: ITransactionOption) {
- this.checkForRoot_("approve");
+ this.checkForRoot("approve");
return Promise.all([this.getPredicateAddress(), this.getContract()]).then(result => {
const [predicateAddress, contract] = result;
@@ -88,7 +88,7 @@ export class ERC20 extends POSToken {
* @memberof ERC20
*/
deposit(amount: TYPE_AMOUNT, userAddress: string, option?: ITransactionOption) {
- this.checkForRoot_("deposit");
+ this.checkForRoot("deposit");
const amountInABI = this.client.parent.encodeParameters(
@@ -104,7 +104,7 @@ export class ERC20 extends POSToken {
}
private depositEther_(amount: TYPE_AMOUNT, option: ITransactionOption = {}) {
- this.checkForRoot_("depositEther");
+ this.checkForRoot("depositEther");
option.value = Converter.toHex(amount);
@@ -122,7 +122,7 @@ export class ERC20 extends POSToken {
* @memberof ERC20
*/
withdrawStart(amount: TYPE_AMOUNT, option?: ITransactionOption) {
- this.checkForChild_("withdrawStart");
+ this.checkForChild("withdrawStart");
return this.getContract().then(contract => {
@@ -143,7 +143,7 @@ export class ERC20 extends POSToken {
* @memberof ERC20
*/
withdrawExit(burnTransactionHash: string, option?: ITransactionOption) {
- this.checkForRoot_("withdrawExit");
+ this.checkForRoot("withdrawExit");
return this.exitUtil.buildPayloadForExit(
burnTransactionHash,
@@ -167,7 +167,7 @@ export class ERC20 extends POSToken {
* @memberof ERC20
*/
withdrawExitFaster(burnTransactionHash: string, option?: ITransactionOption) {
- this.checkForRoot_("withdrawExitFaster");
+ this.checkForRoot("withdrawExitFaster");
return this.exitUtil.buildPayloadForExit(
@@ -211,7 +211,7 @@ export class ERC20 extends POSToken {
* @memberof ERC20
*/
transfer(to: string, amount: TYPE_AMOUNT, option?: ITransactionOption) {
- return this.transferERC20_(to, amount, option);
+ return this.transferERC20(to, amount, option);
}
}
\ No newline at end of file

MODIFY
src/pos/erc721.ts
src/pos/erc721.ts
@@ -98,7 +98,7 @@ export class ERC721 extends POSToken {
}
isApproved(tokenId: string, option?: ITransactionOption) {
- this.checkForRoot_("isApproved");
+ this.checkForRoot("isApproved");
return this.getContract().then(contract => {
const method = contract.method(
@@ -115,7 +115,7 @@ export class ERC721 extends POSToken {
}
isApprovedAll(userAddress: string, option?: ITransactionOption) {
- this.checkForRoot_("isApprovedAll");
+ this.checkForRoot("isApprovedAll");
return Promise.all([this.getContract(), this.getPredicateAddress()]).then(result => {
const [contract, predicateAddress] = result;
@@ -130,7 +130,7 @@ export class ERC721 extends POSToken {
}
approve(tokenId: TYPE_AMOUNT, option?: ITransactionOption) {
- this.checkForRoot_("approve");
+ this.checkForRoot("approve");
return Promise.all([this.getContract(), this.getPredicateAddress()]).then(result => {
const [contract, predicateAddress] = result;
@@ -144,7 +144,7 @@ export class ERC721 extends POSToken {
}
approveAll(option?: ITransactionOption) {
- this.checkForRoot_("approveAll");
+ this.checkForRoot("approveAll");
return Promise.all([this.getContract(), this.getPredicateAddress()]).then(result => {
const [contract, predicateAddress] = result;
@@ -159,7 +159,7 @@ export class ERC721 extends POSToken {
deposit(tokenId: TYPE_AMOUNT, userAddress: string, option?: ITransactionOption) {
- this.checkForRoot_("deposit");
+ this.checkForRoot("deposit");
const amountInABI = this.client.parent.encodeParameters(
[Converter.toHex(tokenId)],
@@ -174,7 +174,7 @@ export class ERC721 extends POSToken {
}
depositMany(tokenIds: TYPE_AMOUNT[], userAddress: string, option?: ITransactionOption) {
- this.checkForRoot_("depositMany");
+ this.checkForRoot("depositMany");
const tokensInUint256 = this.validateMany__(tokenIds);
@@ -191,7 +191,7 @@ export class ERC721 extends POSToken {
}
withdrawStart(tokenId: TYPE_AMOUNT, option?: ITransactionOption) {
- this.checkForChild_("withdrawStart");
+ this.checkForChild("withdrawStart");
return this.getContract().then(contract => {
@@ -204,7 +204,7 @@ export class ERC721 extends POSToken {
}
withdrawStartMany(tokenIds: TYPE_AMOUNT[], option?: ITransactionOption) {
- this.checkForChild_("withdrawStartMany");
+ this.checkForChild("withdrawStartMany");
const tokensInUint256 = this.validateMany__(tokenIds);
@@ -218,7 +218,7 @@ export class ERC721 extends POSToken {
}
withdrawExit(burnTransactionHash: string, option?: ITransactionOption) {
- this.checkForRoot_("withdrawExit");
+ this.checkForRoot("withdrawExit");
return this.exitUtil.buildPayloadForExit(
@@ -233,7 +233,7 @@ export class ERC721 extends POSToken {
}
withdrawExitMany(burnTransactionHash: string, option?: ITransactionOption) {
- this.checkForRoot_("withdrawExitMany");
+ this.checkForRoot("withdrawExitMany");
return this.exitUtil.buildPayloadForExit(
@@ -248,7 +248,7 @@ export class ERC721 extends POSToken {
}
withdrawExitFaster(burnTransactionHash: string, option?: ITransactionOption) {
- this.checkForRoot_("withdrawExitFaster");
+ this.checkForRoot("withdrawExitFaster");
return this.exitUtil.buildPayloadForExit(
@@ -263,7 +263,7 @@ export class ERC721 extends POSToken {
}
withdrawExitFasterMany(burnTransactionHash: string, option?: ITransactionOption) {
- this.checkForRoot_("withdrawExitFasterMany");
+ this.checkForRoot("withdrawExitFasterMany");
return this.exitUtil.buildPayloadForExit(
@@ -314,7 +314,7 @@ export class ERC721 extends POSToken {
* @memberof ERC721
*/
transfer(tokenId: string, from: string, to: string, option?: ITransactionOption) {
- return this.transferERC721_(
+ return this.transferERC721(
from,
to,
tokenId,

MODIFY
src/pos/exit_util.ts
src/pos/exit_util.ts
@@ -105,15 +105,15 @@ export class ExitUtil {
private async getRootBlockInfoFromAPI(txBlockNumber: number) {
try {
- console.log("block info from API 1");
+ this.maticClient_.logger.log("block info from API 1");
const headerBlock = await service.network.getBlockIncluded(txBlockNumber);
- console.log("block info from API 2", headerBlock);
+ this.maticClient_.logger.log("block info from API 2", headerBlock);
if (!headerBlock || !headerBlock.start || !headerBlock.end || !headerBlock.headerBlockNumber) {
throw Error('Network API Error');
}
return headerBlock;
} catch (err) {
- console.log("block info from API", err);
+ this.maticClient_.logger.log("block info from API", err);
return this.getRootBlockInfo(txBlockNumber);
}
}
@@ -137,7 +137,7 @@ export class ExitUtil {
if (!blockProof) {
throw Error('Network API Error');
}
- console.log("block proof from API 1");
+ this.maticClient_.logger.log("block proof from API 1");
return blockProof;
} catch (err) {
return this.getBlockProof(txBlockNumber, rootBlockInfo);

MODIFY
src/utils/base_token.ts
src/utils/base_token.ts
@@ -46,7 +46,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
}
protected processWrite(method: BaseContractMethod, option: ITransactionOption = {}): Promise<ContractWriteResult> {
- this.validateTxOption__(option);
+ this.validateTxOption_(option);
this.client.logger.log("process write");
return this.createTransactionConfig(
@@ -72,11 +72,11 @@ export class BaseToken<T_CLIENT_CONFIG> {
}
protected sendTransaction(option: ITransactionOption = {}): Promise<ContractWriteResult> {
- this.validateTxOption__(option);
+ this.validateTxOption_(option);
this.client.logger.log("process write");
const isParent = this.contractParam.isParent;
- const client = this.getClient_(isParent);
+ const client = this.getClient(isParent);
return this.createTransactionConfig(
{
txConfig: option,
@@ -97,10 +97,10 @@ export class BaseToken<T_CLIENT_CONFIG> {
}
protected readTransaction(option: ITransactionOption = {}): Promise<ContractWriteResult> {
- this.validateTxOption__(option);
+ this.validateTxOption_(option);
this.client.logger.log("process read");
const isParent = this.contractParam.isParent;
- const client = this.getClient_(isParent);
+ const client = this.getClient(isParent);
return this.createTransactionConfig(
{
txConfig: option,
@@ -108,7 +108,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
method: null as any,
isParent: this.contractParam.isParent
}).then(config => {
- this.client.logger.log("process read config");
+ this.client.logger.log("write tx config created");
if (option.returnTransaction) {
return config as any;
}
@@ -118,14 +118,14 @@ export class BaseToken<T_CLIENT_CONFIG> {
});
}
- private validateTxOption__(option: ITransactionOption) {
+ private validateTxOption_(option: ITransactionOption) {
if (typeof option !== 'object' || Array.isArray(option)) {
new ErrorHelper(ERROR_TYPE.TransactionOptionNotObject).throw();
}
}
protected processRead<T>(method: BaseContractMethod, option: ITransactionOption = {}): Promise<T> {
- this.validateTxOption__(option);
+ this.validateTxOption_(option);
this.client.logger.log("process read");
return this.createTransactionConfig(
{
@@ -134,7 +134,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
method,
isParent: this.contractParam.isParent
}).then(config => {
- this.client.logger.log("process read config");
+ this.client.logger.log("read tx config created");
if (option.returnTransaction) {
return merge(config, {
data: method.encodeABI(),
@@ -147,13 +147,13 @@ export class BaseToken<T_CLIENT_CONFIG> {
});
}
- protected getClient_(isParent) {
+ protected getClient(isParent) {
return isParent ? this.client.parent :
this.client.child;
}
private getContract_({ isParent, tokenAddress, abi }) {
- const client = this.getClient_(isParent);
+ const client = this.getClient(isParent);
return client.getContract(tokenAddress, abi);
}
@@ -195,7 +195,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
return txConfig;
}
- protected transferERC20_(to: string, amount: TYPE_AMOUNT, option?: ITransactionOption) {
+ protected transferERC20(to: string, amount: TYPE_AMOUNT, option?: ITransactionOption) {
return this.getContract().then(contract => {
const method = contract.method(
"transfer",
@@ -208,7 +208,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
});
}
- protected transferERC721_(from: string, to: string, tokenId: string, option: ITransactionOption) {
+ protected transferERC721(from: string, to: string, tokenId: string, option: ITransactionOption) {
return this.getContract().then(contract => {
const method = contract.method(
"transferFrom",
@@ -222,13 +222,13 @@ export class BaseToken<T_CLIENT_CONFIG> {
});
}
- protected checkForRoot_(methodName) {
+ protected checkForRoot(methodName) {
if (!this.contractParam.isParent) {
this.client.logger.error(ERROR_TYPE.AllowedOnRoot, methodName).throw();
}
}
- protected checkForChild_(methodName) {
+ protected checkForChild(methodName) {
if (this.contractParam.isParent) {
this.client.logger.error(ERROR_TYPE.AllowedOnChild, "withdrawStart").throw();
}

MODIFY
src/utils/merkle_tree.ts
src/utils/merkle_tree.ts
@@ -39,7 +39,6 @@ export class MerkleTree {
for (let i = 0; i < nodes.length; i += 2) {
const left = nodes[i];
const right = nodes[i + 1];
- console.log("left", left, "right", right);
const data = SafeBuffer.concat([left, right]);
treeLevel.push(sha3(data));

MODIFY
src/utils/proof_util.ts
src/utils/proof_util.ts
@@ -72,7 +72,6 @@ export class ProofUtil {
// Build a merkle tree of correct size for the subtree using these merkle roots
const leaves = Array.from({ length: 2 ** heightDifference }, () => ethUtils.toBuffer(leafRoots));
leaves[0] = remainingNodesHash;
- console.log("leaves", leaves);
const subTreeMerkleRoot = new MerkleTree(leaves).getRoot();
reversedProof.push(subTreeMerkleRoot);
}

MODIFY
src/utils/web3_side_chain_client.ts
src/utils/web3_side_chain_client.ts
@@ -35,7 +35,7 @@ export class Web3SideChainClient<T_CONFIG> {
const network = config.network;
const version = config.version;
const abiHelper = this.abiManager = new ABIManager(network, version);
- console.log("init called", abiHelper);
+ this.logger.log("init called", abiHelper);
return abiHelper.init().catch(err => {
throw new Error(`network ${network} - ${version} is not supported`);
});

rm log using console and set using logger