fix isDeposited
MODIFY
package.json
package.json
{
"name": "@maticnetwork/maticjs",
- "version": "3.0.0-beta.7",
+ "version": "3.0.0-beta.8",
"description": "Javascript developer library for interacting with Matic Network",
"main": "dist/npm.export.js",
"types": "dist/ts/index.d.ts",

MODIFY
src/pos/erc20.ts
src/pos/erc20.ts
@@ -195,8 +195,8 @@ export class ERC20 extends POSToken {
/**
* transfer amount to another user
*
- * @param {string} to
* @param {TYPE_AMOUNT} amount
+ * @param {string} to
* @param {ITransactionOption} [option]
* @returns
* @memberof ERC20

MODIFY
src/utils/base_token.ts
src/utils/base_token.ts
@@ -73,9 +73,10 @@ export class BaseToken<T_CLIENT_CONFIG> {
protected sendTransaction(option: ITransactionOption = {}): Promise<ContractWriteResult> {
this.validateTxOption_(option);
- this.client.logger.log("process write");
const isParent = this.contractParam.isParent;
const client = this.getClient(isParent);
+ client.logger.log("process write");
+
return this.createTransactionConfig(
{
txConfig: option,
@@ -83,7 +84,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
method: null as any,
isParent: this.contractParam.isParent
}).then(config => {
- this.client.logger.log("process write config");
+ client.logger.log("process write config");
if (option.returnTransaction) {
return config as any;
}
@@ -97,9 +98,9 @@ export class BaseToken<T_CLIENT_CONFIG> {
protected readTransaction(option: ITransactionOption = {}): Promise<ContractWriteResult> {
this.validateTxOption_(option);
- this.client.logger.log("process read");
const isParent = this.contractParam.isParent;
const client = this.getClient(isParent);
+ client.logger.log("process read");
return this.createTransactionConfig(
{
txConfig: option,
@@ -107,7 +108,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
method: null as any,
isParent: this.contractParam.isParent
}).then(config => {
- this.client.logger.log("write tx config created");
+ client.logger.log("write tx config created");
if (option.returnTransaction) {
return config as any;
}
@@ -169,9 +170,9 @@ export class BaseToken<T_CLIENT_CONFIG> {
protected async createTransactionConfig({ txConfig, method, isParent, isWrite }: ITransactionConfigParam) {
const defaultConfig = isParent ? this.parentDefaultConfig : this.childDefaultConfig;
txConfig = merge(defaultConfig, (txConfig || {}));
- this.client.logger.log("txConfig", txConfig, "onRoot", isParent, "isWrite", isWrite);
const client = isParent ? this.client.parent :
this.client.child;
+ client.logger.log("txConfig", txConfig, "onRoot", isParent, "isWrite", isWrite);
const estimateGas = (config: ITransactionConfig) => {
return method ? method.estimateGas(config) :
client.estimateGas(config);
@@ -193,7 +194,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
: txConfig.gasLimit,
!txConfig.nonce ? client.getTransactionCount(txConfig.from as string, 'pending') : txConfig.nonce,
]);
- this.client.logger.log("options filled");
+ client.logger.log("options filled");
txConfig.gasLimit = Number(gasLimit);
txConfig.nonce = nonce;
if (isEIP1559Supported && isMaxFeeProvided) {
@@ -202,7 +203,7 @@ export class BaseToken<T_CLIENT_CONFIG> {
}
else {
const gasPrice = !txConfig.gasPrice ? await client.getGasPrice() : txConfig.gasPrice;
- console.log('gas price calculated', gasPrice);
+ client.logger.log('gas price calculated', gasPrice);
txConfig.gasPrice = Number(gasPrice);
}

MODIFY
src/utils/bridge_client.ts
src/utils/bridge_client.ts
@@ -41,7 +41,12 @@ export class BridgeClient<T> {
]);
}).then(result => {
const [receipt, lastStateId] = result;
- const rootStateId = client.child.decodeParameters(receipt.logs[3].topics[0], ['uint256'])[0];
+ const eventSignature = `0x103fed9db65eac19c4d870f49ab7520fe03b99f1838e5996caf47e9e43308392`;
+ const targetLog = receipt.logs.find(q => q.topics[0] === eventSignature);
+ if (!targetLog) {
+ 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);
return new BN(lastStateId).gte(
rootStateIdBN

MODIFY
test/debug.js
test/debug.js
@@ -40,7 +40,7 @@ const execute = async () => {
- // return console.log(await client.isDeposited('0xc67599f5c967f2040786d5924ec55d37bf943c009bdd23f3b50e5ae66efde258'));
+ return console.log(await client.isDeposited('0xc67599f5c967f2040786d5924ec55d37bf943c009bdd23f3b50e5ae66efde258'));
// const balance = await mumbaiERC20Token.getBalance(

MODIFY
test/specs/erc20.spec.ts
test/specs/erc20.spec.ts
@@ -95,11 +95,11 @@ describe('ERC20', () => {
});
- // it('isDeposited', async () => {
- // const txHash = '0xc67599f5c967f2040786d5924ec55d37bf943c009bdd23f3b50e5ae66efde258';
- // const isExited = await posClient.isDeposited(txHash);
- // expect(isExited).to.be.an('boolean').equal(true);
- // })
+ it('isDeposited', async () => {
+ const txHash = '0xc67599f5c967f2040786d5924ec55d37bf943c009bdd23f3b50e5ae66efde258';
+ const isDeposited = await posClient.isDeposited(txHash);
+ expect(isDeposited).to.be.an('boolean').equal(true);
+ })
it('withdrawstart return tx', async () => {
const result = await erc20Child.withdrawStart('10', {

fix isDeposited