From 4e7fe3f42a398511e7bf6b63e13e03e309457906 Mon Sep 17 00:00:00 2001 From: Ice Date: Tue, 11 Feb 2025 14:35:23 +0100 Subject: [PATCH] chore: rest of ts fixes and applies --- packages/swapkit/helpers/src/types/index.ts | 1 - packages/swapkit/helpers/src/types/sdk.ts | 24 ------------------- packages/toolboxes/utxo/src/helpers/api.ts | 4 +--- .../toolboxes/utxo/src/helpers/coinselect.ts | 4 ++-- packages/toolboxes/utxo/src/helpers/txSize.ts | 2 +- packages/toolboxes/utxo/src/index.ts | 2 +- packages/toolboxes/utxo/src/toolbox/utxo.ts | 7 +----- .../utxo/src/{types/common.ts => types.ts} | 4 ++-- packages/toolboxes/utxo/src/types/index.ts | 2 -- packages/wallets/keepkey/src/chains/utxo.ts | 3 +-- packages/wallets/ledger/src/ledger.ts | 3 +-- 11 files changed, 10 insertions(+), 46 deletions(-) rename packages/toolboxes/utxo/src/{types/common.ts => types.ts} (96%) delete mode 100644 packages/toolboxes/utxo/src/types/index.ts diff --git a/packages/swapkit/helpers/src/types/index.ts b/packages/swapkit/helpers/src/types/index.ts index 62c563118..dc4d2ad7e 100644 --- a/packages/swapkit/helpers/src/types/index.ts +++ b/packages/swapkit/helpers/src/types/index.ts @@ -1,7 +1,6 @@ export * from "./chains"; export * from "./commonTypes"; export * from "./derivationPath"; -export * from "./network"; export * from "./tokens"; export * from "./wallet"; export * from "./sdk"; diff --git a/packages/swapkit/helpers/src/types/sdk.ts b/packages/swapkit/helpers/src/types/sdk.ts index af4d63f62..e971bdb2b 100644 --- a/packages/swapkit/helpers/src/types/sdk.ts +++ b/packages/swapkit/helpers/src/types/sdk.ts @@ -1,28 +1,4 @@ -import type { CovalentApiType, EthplorerApiType } from "@swapkit/toolbox-evm"; -import type { BlockchairApiType } from "@swapkit/toolbox-utxo"; - import type { AssetValue } from "../modules/assetValue"; -import type { Chain, CosmosChain, UTXOChain } from "./chains"; - -type CovalentChains = - | Chain.Base - | Chain.BinanceSmartChain - | Chain.Polygon - | Chain.Avalanche - | Chain.Arbitrum - | Chain.Optimism; - -export type ChainApis = { [key in CovalentChains]?: CovalentApiType } & { - [key in Chain.Ethereum]?: EthplorerApiType; -} & { - [key in UTXOChain]?: BlockchairApiType; -} & { - [key in CosmosChain | Chain.Solana | Chain.Radix | Chain.Polkadot | Chain.Chainflip]?: string; -} & { - [key in Chain.Fiat]?: undefined; -}; - -export type ChainApi = EthplorerApiType | CovalentApiType | BlockchairApiType | string; export type GenericSwapParams = { buyAsset?: AssetValue; diff --git a/packages/toolboxes/utxo/src/helpers/api.ts b/packages/toolboxes/utxo/src/helpers/api.ts index b552f4336..aea1b9df5 100644 --- a/packages/toolboxes/utxo/src/helpers/api.ts +++ b/packages/toolboxes/utxo/src/helpers/api.ts @@ -273,14 +273,12 @@ export function getUtxoApi(chain: UTXOChain) { if (customUtxoApi) { warnOnce(true, "Using custom UTXO API. Be sure to implement all methods to avoid issues."); - return customUtxoApi as UTXOApiType; + return customUtxoApi as ReturnType; } return utxoApi(chain); } -export type UTXOApiType = ReturnType; - interface BlockchairMultipleBalancesResponse { [key: string]: number; } diff --git a/packages/toolboxes/utxo/src/helpers/coinselect.ts b/packages/toolboxes/utxo/src/helpers/coinselect.ts index 19f809eb1..e64c1077e 100644 --- a/packages/toolboxes/utxo/src/helpers/coinselect.ts +++ b/packages/toolboxes/utxo/src/helpers/coinselect.ts @@ -1,6 +1,5 @@ import { Chain, type UTXOChain } from "@swapkit/helpers"; -import type { TargetOutput, UTXOCalculateTxSizeParams, UTXOType } from "../types/index"; import { TX_OVERHEAD, UTXOScriptType, @@ -8,7 +7,8 @@ import { getInputSize, getOutputSize, getScriptTypeForAddress, -} from "../utils/index"; +} from "../helpers"; +import type { TargetOutput, UTXOCalculateTxSizeParams, UTXOType } from "../types"; export const getDustThreshold = (chain: UTXOChain) => { switch (chain) { diff --git a/packages/toolboxes/utxo/src/helpers/txSize.ts b/packages/toolboxes/utxo/src/helpers/txSize.ts index 80576870d..4bf2260e3 100644 --- a/packages/toolboxes/utxo/src/helpers/txSize.ts +++ b/packages/toolboxes/utxo/src/helpers/txSize.ts @@ -5,7 +5,7 @@ import type { UTXOCalculateTxSizeParams, UTXOInputWithScriptType, UTXOType, -} from "../types/index"; +} from "../types"; /** * Minimum transaction fee diff --git a/packages/toolboxes/utxo/src/index.ts b/packages/toolboxes/utxo/src/index.ts index f304254d5..1574f6b5b 100644 --- a/packages/toolboxes/utxo/src/index.ts +++ b/packages/toolboxes/utxo/src/index.ts @@ -6,4 +6,4 @@ export { type Network, networks, Psbt, Transaction } from "bitcoinjs-lib"; export * from "./toolbox/index"; export * from "./toolbox/utxo"; export * from "./helpers/index"; -export * from "./types/index"; +export * from "./types"; diff --git a/packages/toolboxes/utxo/src/toolbox/utxo.ts b/packages/toolboxes/utxo/src/toolbox/utxo.ts index b38fac54d..a32fa71bf 100644 --- a/packages/toolboxes/utxo/src/toolbox/utxo.ts +++ b/packages/toolboxes/utxo/src/toolbox/utxo.ts @@ -23,12 +23,7 @@ import { getUtxoApi, standardFeeRates, } from "../helpers"; -import type { - TargetOutput, - UTXOBuildTxParams, - UTXOType, - UTXOWalletTransferParams, -} from "../types/common"; +import type { TargetOutput, UTXOBuildTxParams, UTXOType, UTXOWalletTransferParams } from "../types"; import { validateAddress as validateBCHAddress } from "./bitcoinCash"; import type { BCHToolbox, BTCToolbox, DASHToolbox, DOGEToolbox, LTCToolbox } from "./index"; diff --git a/packages/toolboxes/utxo/src/types/common.ts b/packages/toolboxes/utxo/src/types.ts similarity index 96% rename from packages/toolboxes/utxo/src/types/common.ts rename to packages/toolboxes/utxo/src/types.ts index 737cdf948..10ee78809 100644 --- a/packages/toolboxes/utxo/src/types/common.ts +++ b/packages/toolboxes/utxo/src/types.ts @@ -1,7 +1,7 @@ import type { AssetValue, FeeOption, UTXOChain, Witness } from "@swapkit/helpers"; -import type { UTXOScriptType } from "../helpers"; -import type { BCHToolbox, BTCToolbox, DOGEToolbox, LTCToolbox } from "../index"; +import type { UTXOScriptType } from "./helpers"; +import type { BCHToolbox, BTCToolbox, DOGEToolbox, LTCToolbox } from "./index"; export type TransactionType = { toHex(): string; diff --git a/packages/toolboxes/utxo/src/types/index.ts b/packages/toolboxes/utxo/src/types/index.ts deleted file mode 100644 index 6dcff997e..000000000 --- a/packages/toolboxes/utxo/src/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./blockchairApiTypes"; -export * from "./common"; diff --git a/packages/wallets/keepkey/src/chains/utxo.ts b/packages/wallets/keepkey/src/chains/utxo.ts index 4188c43a4..feb720cd5 100644 --- a/packages/wallets/keepkey/src/chains/utxo.ts +++ b/packages/wallets/keepkey/src/chains/utxo.ts @@ -124,11 +124,10 @@ export const utxoWalletMethods = async ({ const { psbt, inputs: rawInputs } = await toolbox.buildTx({ ...rest, memo, - feeOptionKey, recipient, feeRate: feeRate || (await toolbox.getFeeRates())[feeOptionKey || FeeOption.Fast], sender: from, - fetchTxHex: chain, + fetchTxHex: chain === Chain.BitcoinCash, }); const inputs = rawInputs.map(({ value, index, hash, txHex }) => ({ diff --git a/packages/wallets/ledger/src/ledger.ts b/packages/wallets/ledger/src/ledger.ts index 8a9606732..7c43e6419 100644 --- a/packages/wallets/ledger/src/ledger.ts +++ b/packages/wallets/ledger/src/ledger.ts @@ -8,7 +8,6 @@ import { StagenetChain, WalletOption, filterSupportedChains, - getRPCUrl, } from "@swapkit/helpers"; import type { DepositParam, TransferParams } from "@swapkit/toolbox-cosmos"; import type { UTXOBuildTxParams } from "@swapkit/toolbox-utxo"; @@ -127,7 +126,7 @@ const getWalletMethods = async ({ }; const signingClient = await createSigningStargateClient( - getRPCUrl(Chain.Cosmos), + SKConfig.get("rpcUrls")[chain], signer, "0.007uatom", );