Skip to content

Commit

Permalink
cctx: remove dependency on HRE
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Oct 1, 2023
1 parent e9910ae commit 950f492
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
24 changes: 7 additions & 17 deletions helpers/tx.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getEndpoints } from "@zetachain/networks";

Check failure on line 1 in helpers/tx.ts

View workflow job for this annotation

GitHub Actions / build

Run autofix to sort these imports!
import axios from "axios";
import clc from "cli-color";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import Spinnies from "spinnies";
import WebSocket from "ws";
import { getHardhatConfigNetworks } from "@zetachain/networks";
import { ethers } from "ethers";

const getEndpoint = (key: any): string => {
const endpoint = getEndpoints(key, "zeta_testnet")[0]?.url;
Expand Down Expand Up @@ -52,30 +52,22 @@ const fetchCCTXByInbound = async (
} catch (error) {}
};

const SUBSCRIBE_MESSAGE = {
id: 1,
jsonrpc: "2.0",
method: "subscribe",
params: ["tm.event='NewBlock'"],
};

const fetchCCTXData = async (
cctxHash: string,
spinnies: any,
API: string,
cctxList: any,
pendingNonces: any,
json: Boolean,
hre: HardhatRuntimeEnvironment
json: Boolean
) => {
const networks = hre?.config?.networks;
const networks = getHardhatConfigNetworks();
const cctx = await getCCTX(cctxHash, API);
const receiver_chainId = cctx?.outbound_tx_params[0]?.receiver_chainId;
const outbound_tx_hash = cctx?.outbound_tx_params[0]?.outbound_tx_hash;
let confirmed_on_destination = false;
if (outbound_tx_hash) {
const rpc = findByChainId(networks, parseInt(receiver_chainId))?.url;
const provider = new hre.ethers.providers.JsonRpcProvider(rpc);
const provider = new ethers.providers.JsonRpcProvider(rpc);
const confirmed = await provider.getTransaction(outbound_tx_hash);
confirmed_on_destination = confirmed !== null;
}
Expand Down Expand Up @@ -156,8 +148,7 @@ const fetchTSS = async (API: string) => {

export const trackCCTX = async (
hash: string,
hre: HardhatRuntimeEnvironment,
json: Boolean
json: Boolean = false
): Promise<void> => {
const spinnies = new Spinnies();

Expand Down Expand Up @@ -205,8 +196,7 @@ export const trackCCTX = async (
API,
cctxList,
pendingNonces,
json,
hre
json
);
} catch (error) {}
}
Expand Down
4 changes: 2 additions & 2 deletions tasks/cctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { trackCCTX } from "../helpers";
declare const hre: any;

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
await trackCCTX(args.tx, hre, args.json);
await trackCCTX(args.tx);
};

export const cctxTask = task(
"cctx",
"Track cross-chain transaction status",
main
)
.addPositionalParam("tx", "TX hash of an inbound transaction or a CCTX")
.addPositionalParam("tx", "Hash of an inbound or a cross-chain transaction")
.addFlag("json", "Output as JSON");

0 comments on commit 950f492

Please sign in to comment.