add: isclaimable function
MODIFY
src/hermez/bridge_util.ts
src/hermez/bridge_util.ts
@@ -88,6 +88,10 @@ export class BridgeUtil {
});
}
+ getBridgeLogData(transactionHash: string, isParent: boolean) {
+ return this.getBridgeLogData_(transactionHash, isParent);
+ }
+
buildPayloadForClaim(transactionHash: string, isParent: boolean, networkId: number) {
return this.getBridgeLogData_(transactionHash, isParent).then(data => {
const {

MODIFY
src/hermez/erc20.ts
src/hermez/erc20.ts
@@ -173,8 +173,8 @@ export class ERC20 extends HermezToken {
* @returns
* @memberof ERC20
*/
- exit(burnTransactionHash: string, option?: ITransactionOption) {
- this.checkForRoot("exit");
+ withdrawExit(burnTransactionHash: string, option?: ITransactionOption) {
+ this.checkForRoot("withdrawExit");
return this.childBridge.networkID().then(networkId => {
return this.bridgeUtil.buildPayloadForClaim(
burnTransactionHash, false, networkId

MODIFY
src/hermez/index.ts
src/hermez/index.ts
@@ -10,9 +10,6 @@ export * from "./bridge_util";
export class HermezClient extends HermezBridgeClient<IHermezClientConfig> {
- rootChainBridge: Bridge;
- childChainBridge: Bridge;
-
init(config: IHermezClientConfig) {
const client = this.client;

MODIFY
src/services/network_service.ts
src/services/network_service.ts
@@ -41,4 +41,11 @@ export class NetworkService {
return result.proof;
})
}
+
+ getBridgeTransactionDetails(networkID: number, depositCount: number) {
+ const url = `/bridge?net_id=${networkID}&deposit_cnt=${depositCount}`;
+ return this.httpRequest.get<any>(url).then(result => {
+ return result.deposit;
+ })
+ }
}

MODIFY
src/utils/hermez_bridge_client.ts
src/utils/hermez_bridge_client.ts
import { Web3SideChainClient } from "../utils";
-import { BridgeUtil } from "../hermez";
+import { BridgeUtil, Bridge } from "../hermez";
+import { service } from "../services";
export class HermezBridgeClient<T> {
client: Web3SideChainClient<T> = new Web3SideChainClient();
-
bridgeUtil: BridgeUtil;
+ rootChainBridge: Bridge;
+ childChainBridge: Bridge;
/**
* check whether a txHash is synced with child chain
@@ -15,7 +17,13 @@ export class HermezBridgeClient<T> {
* @memberof HermezBridgeClient
*/
isDepositClaimable(txHash: string) {
- return;
+ return Promise.all([this.rootChainBridge.networkID(), this.bridgeUtil.getBridgeLogData(
+ txHash, true
+ )]).then(result => {
+ return service.network.getBridgeTransactionDetails(result[0], result[1].depositCount)
+ }).then(details => {
+ return details.ready_for_claim;
+ })
}
/**
@@ -26,7 +34,13 @@ export class HermezBridgeClient<T> {
* @memberof HermezBridgeClient
*/
isWithdrawExitable(txHash: string) {
- return;
+ return Promise.all([this.childChainBridge.networkID(), this.bridgeUtil.getBridgeLogData(
+ txHash, false
+ )]).then(result => {
+ return service.network.getBridgeTransactionDetails(result[0], result[1].depositCount)
+ }).then(details => {
+ return details.ready_for_claim;
+ })
}
}
\ No newline at end of file

add: isclaimable function