{"size": 830, "ext": "js", "max_stars_repo_path": "evaluation/relay/evaluation.js", "max_stars_repo_name": "soberm/x-chain-protocols", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "evaluation/relay/evaluation.js", "max_issues_repo_name": "soberm/x-chain-protocols", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "evaluation/relay/evaluation.js", "max_forks_repo_name": "soberm/x-chain-protocols", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.9230769231, "max_line_length": 103, "alphanum_fraction": 0.5710843373}
require("../runner")(__dirname, waitUntilConfirmedWithinRelay);

async function waitUntilConfirmedWithinRelay({source, destination, receipt}) {
    const blockHash = (await source.web3.eth.getTransactionReceipt(receipt.transactionHash)).blockHash;

    return new Promise(resolve => {
        const subscription = destination.web3.eth.subscribe("newBlockHeaders", async err => {
            if (err !== null) {
               console.error(err);
               return;
            }

            const isConfirmed = await destination.contracts.relay.instance.methods.isBlockConfirmed(
                0,
                blockHash,
                source.confirmations,
            ).call();

            if (isConfirmed) {
                subscription.unsubscribe();
                resolve();
            }
        });
    });
}
