fix: isExited
MODIFY
src/pos/erc20.ts
src/pos/erc20.ts
@@ -148,9 +148,13 @@ export class ERC20 extends POSToken {
if (!txHash) {
throw new Error(`txHash not provided`);
}
- return this.exitManager.isExitProcessed(
+ return this.exitManager.getExitHash(
txHash, Log_Event_Signature.Erc20Transfer
+ ).then(exitHash => {
+ return this.rootChainManager.isExitProcessed(
+ exitHash
);
+ });
}
}
\ No newline at end of file

MODIFY
src/pos/exit_manager.ts
src/pos/exit_manager.ts
@@ -25,19 +25,6 @@ export class ExitManager {
this.requestConcurrency = requestConcurrency;
}
- async exit(burnTxHash: string, logSignature: string, option: ITransactionOption) {
- const payload = await this.buildPayloadForExit(
- burnTxHash,
- logSignature,
- );
- const method = this.rootChain.method("exit", payload);
-
- return this.rootChain['processWrite'](
- method,
- option
- );
- }
-
async exitFast(burnTxHash: string, logSignature: string, option: ITransactionOption) {
const payload = await this.buildPayloadForFastExit(
burnTxHash,
@@ -276,7 +263,7 @@ export class ExitManager {
);
}
- async getExitHash(burnTxHash, logEventSig, requestConcurrency?) {
+ async getExitHash(burnTxHash, logEventSig) {
const lastChildBlock = await this.rootChain.getLastChildBlock();
const receipt = await this.maticClient_.getTransactionReceipt(burnTxHash);
const block = await this.maticClient_.getBlockWithTransaction(receipt.blockNumber);
@@ -290,7 +277,7 @@ export class ExitManager {
receipt,
block,
this.maticClient_,
- requestConcurrency
+ this.requestConcurrency
);
const logIndex = this.getLogIndex_(logEventSig, receipt);
@@ -305,12 +292,4 @@ export class ExitManager {
);
}
- isExitProcessed(burnTxHash: string, logSignature: string) {
- const exitHash = this.getExitHash(
- burnTxHash, logSignature, this.requestConcurrency
- );
- return this.rootChain.method(
- "processedExits", exitHash
- ).read<boolean>();
- }
}
\ No newline at end of file

MODIFY
src/pos/root_chain_manager.ts
src/pos/root_chain_manager.ts
@@ -30,12 +30,18 @@ export class RootChainManager extends BaseToken {
return this.processWrite(method, option);
}
- async exit(payload: string, option: ITransactionOption) {
- const method = this.method("exit", payload);
+ async exit(exitPayload: string, option: ITransactionOption) {
+ const method = this.method("exit", exitPayload);
return this.processWrite(
method,
option
);
}
+ isExitProcessed(exitHash: string) {
+ return this.method(
+ "processedExits", exitHash
+ ).read<boolean>();
+ }
+
}
\ No newline at end of file

MODIFY
src/utils/proof_util.ts
src/utils/proof_util.ts
@@ -96,12 +96,9 @@ export class ProofUtil {
static async queryRootHash(client: BaseWeb3Client, startBlock: number, endBlock: number) {
try {
- console.log("rootHash1");
const rootHash = await client.getRootHash(startBlock, endBlock);
- console.log("rootHash", rootHash);
return ethUtils.toBuffer(`0x${rootHash}`);
} catch (err) {
- console.error("err", err);
return null;
}
}

MODIFY
test/debug.js
test/debug.js
@@ -63,9 +63,10 @@ const execute = async () => {
// const isCheckPointed = await maticPOS.isCheckPointed('0xbadbf10a33ba5ae48cfa1660e011eb15bf927773610ace9466c71d14749d4132');
// return console.log("isCheckPointed", isCheckPointed);
- const exitResult = await childErc20.withdrawExit('0xe078925f8bbe43f99bb325cef6e895946f4086fbc05cf4686766b0a172fae396');
- console.log('txHash', await exitResult.getTransactionHash());
- console.log('receipt', await exitResult.getReceipt());
+ const exitResult = await childErc20.isExited('0xe078925f8bbe43f99bb325cef6e895946f4086fbc05cf4686766b0a172fae396');
+ console.log("isExited", exitResult);
+ // console.log('txHash', await exitResult.getTransactionHash());
+ // console.log('receipt', await exitResult.getReceipt());

fix: isExited