Skip to content

Commit

Permalink
support btc
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Aug 9, 2023
1 parent 9470b58 commit a66f1d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 3 additions & 1 deletion helpers/fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export const fetchZEVMFees = async (
provider: any,
hre: HardhatRuntimeEnvironment
) => {
const zrc20Address = getAddress("zrc20", network);
const btcZRC20 = "0x65a45c57636f9BcCeD4fe193A602008578BcA90b"; // TODO: use getAddress("zrc20", "btc_testnet") when available
const zrc20Address =
network === "btc_testnet" ? btcZRC20 : getAddress("zrc20", network);
if (!zrc20Address) return;

const contract = new hre.ethers.Contract(zrc20Address, ZRC20.abi, provider);
Expand Down
23 changes: 12 additions & 11 deletions tasks/fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";

import type { FeeDetails } from "../helpers/fees";
import { fetchCCMFees, fetchZEVMFees } from "../helpers/fees";
import { getAddress } from "@zetachain/protocol-contracts";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const { ethers } = hre as any;
Expand All @@ -12,19 +13,19 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const feesZEVM: Record<string, FeeDetails> = {};
const feesCCM: Record<string, FeeDetails> = {};

const networks = Object.keys(hre.config.networks);
const networks = [...Object.keys(hre.config.networks), "btc_testnet"];

await Promise.all(
networks.map(async (network) => {
return Promise.all([
fetchZEVMFees(network, provider, hre),
fetchCCMFees(network, hre),
])
.then(([zevmFees, ccmFees]) => {
if (zevmFees) feesZEVM[network] = zevmFees;
if (ccmFees) feesCCM[network] = ccmFees;
})
.catch(() => {});
networks.map(async (n) => {
try {
const zevmFees = await fetchZEVMFees(n, provider, hre);
if (zevmFees) feesZEVM[n] = zevmFees;
} catch (err) {}

try {
const ccmFees = await fetchCCMFees(n, hre);
if (ccmFees) feesCCM[n] = ccmFees;
} catch (err) {}
})
);

Expand Down

0 comments on commit a66f1d2

Please sign in to comment.