Skip to content

Commit

Permalink
refactor: silence TS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Oct 27, 2023
1 parent 8ba02eb commit 347eb0c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
10 changes: 6 additions & 4 deletions helpers/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ const fetchZRC20Balance = async (address: string) => {
const provider = new ethers.providers.JsonRpcProvider(rpc);
const promises = Object.keys(networks).map(async (networkName) => {
try {
const zrc20 = getAddress("zrc20", networkName);
const zrc20 = getAddress("zrc20", networkName as any);
const contract = new ethers.Contract(zrc20, ZRC20.abi, provider);
const balance = await contract.balanceOf(address);
const denom = networks[networkName].assets[0].symbol;
const denom =
networks[networkName as keyof typeof networks].assets[0].symbol;
if (balance > 0) {
const b = parseFloat(formatEther(balance)).toFixed(2);
return `${b} ${denom}`;
Expand All @@ -86,7 +87,7 @@ const fetchZRC20Balance = async (address: string) => {
return result.filter((item) => item !== undefined).join(", ");
};

export const getBalances = async (address, btc_address = null) => {
export const getBalances = async (address: any, btc_address = null) => {
const balancePromises = Object.keys(networks).map((networkName) => {
const api = getEndpoints("evm", networkName as any);
if (api.length >= 1) {
Expand All @@ -96,6 +97,7 @@ export const getBalances = async (address, btc_address = null) => {
}
});
const balances = await Promise.all(balancePromises);
if (btc_address) balances.push(await fetchBitcoinBalance(btc_address));
if (btc_address)
balances.push((await fetchBitcoinBalance(btc_address)) as any);
return balances.filter((balance) => balance != null);
};
3 changes: 2 additions & 1 deletion helpers/sendZETA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const sendZETA = async (
recipient: string
) => {
let connectorContract: any;
const destinationChainId = networks[destination]?.chain_id;
const destinationChainId =
networks[destination as keyof typeof networks]?.chain_id;
if (!destinationChainId) {
throw new Error("Invalid destination chain");
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const fetchCCTXData = async (
let confirmed_on_destination = false;
if (outbound_tx_hash) {
const chainName = findByChainId(networks, parseInt(receiver_chainId));
const rpc = getEndpoints("evm", chainName)[0]?.url;
const rpc = getEndpoints("evm", chainName as any)[0]?.url;
const provider = new ethers.providers.JsonRpcProvider(rpc);
const confirmed = await provider.getTransaction(outbound_tx_hash);
confirmed_on_destination = confirmed !== null;
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@typechain/ethers-v5": "^10.1.0",
"@typechain/hardhat": "^6.1.2",
"@types/chai": "^4.2.0",
"@types/isomorphic-fetch": "^0.0.38",
"@types/mocha": ">=9.1.0",
"@types/node": ">=12.0.0",
"@types/ws": "^8.5.5",
Expand Down Expand Up @@ -73,8 +74,8 @@
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@openzeppelin/contracts": "^4.9.2",
"@uniswap/v2-periphery": "^1.1.0-beta.0",
"@zetachain/networks": "^2.4.3",
"@zetachain/faucet-cli": "^4.0.1",
"@zetachain/networks": "^2.4.3",
"@zetachain/protocol-contracts": "^2.1.0",
"axios": "^1.4.0",
"bech32": "^2.0.0",
Expand All @@ -95,4 +96,4 @@
"tiny-secp256k1": "^2.2.3",
"ws": "^8.13.0"
}
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,11 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/isomorphic-fetch@^0.0.38":
version "0.0.38"
resolved "https://registry.yarnpkg.com/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.38.tgz#90882932a371e294a3c6143430275c15cb6ebf1b"
integrity sha512-DcXWx26qmt89lQ1Saoit0P38yHqT7fGceVs7UpMy2gU7AjEZISPdM7rqoFY5VHtl33H+cJ+VBDYmNRssTM4Zlw==

"@types/json-schema@^7.0.9":
version "7.0.12"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb"
Expand Down

0 comments on commit 347eb0c

Please sign in to comment.