From 50e90b3e655b898fb321a07d0168eed0cd773bca Mon Sep 17 00:00:00 2001 From: oskarvu Date: Tue, 7 Jan 2025 19:53:23 +0700 Subject: [PATCH] Replace assert functions to ones from shared package --- .../config/chain/utils/getNativeAssetInfo.ts | 2 +- .../app/src/config/feature-flags/clientEnv.ts | 2 +- .../app/src/config/wagmi/config.default.ts | 6 ++--- packages/app/src/domain/farms/farmsInfo.ts | 3 +-- packages/app/src/domain/farms/useFarmsInfo.ts | 2 +- packages/app/src/domain/hooks/sanityChecks.ts | 7 +++--- .../src/domain/hooks/useContractAddress.ts | 4 +--- .../useWaitForTransactionReceiptGnosisSafe.ts | 2 +- packages/app/src/domain/market-info/emode.ts | 4 +--- .../market-info/getLiquidationDetails.ts | 7 ++---- .../app/src/domain/market-info/marketInfo.ts | 3 +-- packages/app/src/domain/market-info/utils.ts | 4 +--- .../market-validators/validateBorrow.ts | 5 +--- .../market-validators/validateSetUserEMode.ts | 5 +--- packages/app/src/domain/oracles/query.ts | 3 +-- .../selectMyEarningsSavingsDataByDataType.ts | 2 +- .../useSavingsChartsInfoQuery.ts | 3 +-- .../domain/savings-info/mainnetSavingsInfo.ts | 2 +- .../app/src/domain/savings/assertWithdraw.ts | 3 +-- .../app/src/domain/types/SupportedChainId.ts | 2 +- packages/app/src/domain/types/Token.ts | 4 +--- packages/app/src/domain/types/TokenSymbol.ts | 3 +-- .../src/domain/wallet/useTokens/TokenInfo.ts | 4 +--- .../useTokens/createOraclePriceFetcher.ts | 3 +-- .../components/action-row/ActionRow.tsx | 3 +-- .../actions/components/actions/Actions.tsx | 2 +- .../logic/approveDelegationAction.ts | 2 +- .../logic/createConvertStablesActions.ts | 4 +--- .../logic/createDepositToSavingsActions.ts | 4 +--- .../logic/depositToSavingsAction.ts | 5 +--- .../logic/getSavingsDepositActionPath.ts | 2 +- .../logic/getPsmConvertActionPath.ts | 2 +- .../psm-convert/logic/psmConvertAction.ts | 3 +-- .../stake/logic/createStakeActions.ts | 4 +--- .../stake/logic/getStakeActionPath.ts | 2 +- .../unstake/logic/createUnstakeActions.ts | 3 +-- .../unstake/logic/getUnstakeActionPath.ts | 2 +- .../flavours/upgrade/logic/upgradeAction.ts | 2 +- .../logic/createWithdrawFromSavingsActions.ts | 5 +--- .../logic/getSavingsWithdrawActionPath.ts | 2 +- .../logic/withdrawFromSavingsAction.ts | 5 +--- .../flavours/withdraw/logic/withdrawAction.ts | 2 +- .../app/src/features/actions/logic/permits.ts | 5 ++-- .../actions/logic/stringifyObjectives.ts | 2 +- .../actions/logic/useCreateActions.ts | 3 +-- .../features/dialogs/borrow/logic/assets.ts | 3 +-- .../logic/form/useConvertStablesForm.ts | 2 +- .../convert-stables/views/SuccessView.tsx | 2 +- .../features/dialogs/deposit/logic/assets.ts | 2 +- .../features/dialogs/repay/logic/assets.ts | 3 +-- .../dialogs/sandbox/logic/useSandboxDialog.ts | 2 +- .../TransactionOverview.tsx | 2 +- .../savings/deposit/logic/createTxOverview.ts | 3 +-- .../savings/deposit/logic/objectives.ts | 2 +- .../deposit/logic/useSavingsDepositDialog.ts | 3 +-- .../common/components/TransactionOverview.tsx | 2 +- .../migrate/common/logic/useMigrateDialog.ts | 3 +-- .../withdraw/logic/createTxOverview.ts | 3 +-- .../logic/useSavingsWithdrawDialog.ts | 2 +- .../features/dialogs/withdraw/logic/assets.ts | 3 +-- .../easy-borrow/components/form/Borrow.tsx | 2 +- .../easy-borrow/logic/form/normalization.ts | 3 +-- .../easy-borrow/logic/useEasyBorrow.ts | 3 +-- .../active/ActiveFarmInfoPanel.tsx | 3 +-- .../active/RewardPointsSyncWarning.tsx | 2 +- .../stake/components/TransactionOverview.tsx | 2 +- .../dialogs/stake/logic/useStakeDialog.ts | 3 +-- .../TransactionOverview.tsx | 2 +- .../dialogs/unstake/logic/useUnstakeDialog.ts | 3 +-- .../logic/historic/useFarmHistory.ts | 3 +-- .../farm-details/logic/useFarmDetails.ts | 3 +-- .../components/oracle-panel/OraclePanel.tsx | 2 +- .../oracle-panel/components/ProvidersList.tsx | 2 +- .../logic/makeWalletOverview.ts | 3 +-- .../market-details/logic/useMarketDetails.ts | 12 ++++------ .../markets-table/MarketsTable.stories.tsx | 7 ++---- .../features/markets/logic/transformers.ts | 2 +- .../borrow-table/BorrowTable.stories.tsx | 5 +--- .../deposit-table/DepositTable.stories.tsx | 5 +--- .../src/features/savings/SavingsContainer.tsx | 2 +- .../savings/logic/makeMigrationInfo.ts | 3 +-- .../features/savings/logic/makeSavingsMeta.ts | 2 +- .../savings/views/SavingsDaiAndUSDSView.tsx | 2 +- .../src/features/topbar/logic/useTopbar.ts | 3 +-- .../app/src/pages/MyPortfolio.PageObject.ts | 3 +-- packages/app/src/test/e2e/processEnv.ts | 2 +- .../setupUseContractActionRenderer.tsx | 2 +- packages/app/src/test/utils/addressUtils.ts | 2 +- packages/app/src/test/utils/hexUtils.ts | 2 +- packages/app/src/ui/atoms/button/Button.tsx | 2 +- packages/app/src/ui/atoms/form/Form.tsx | 2 +- .../app/src/ui/atoms/icon-box/IconBox.tsx | 2 +- .../ui/charts/components/ChartTabsPanel.tsx | 2 +- packages/app/src/ui/utils/testIds.ts | 2 +- packages/app/src/utils/applyTransformers.ts | 2 +- packages/app/src/utils/assert.ts | 24 ------------------- packages/app/src/utils/assertNever.ts | 3 --- packages/app/src/utils/bigNumber.ts | 2 +- packages/app/src/utils/strings.ts | 2 +- 99 files changed, 107 insertions(+), 212 deletions(-) delete mode 100644 packages/app/src/utils/assert.ts delete mode 100644 packages/app/src/utils/assertNever.ts diff --git a/packages/app/src/config/chain/utils/getNativeAssetInfo.ts b/packages/app/src/config/chain/utils/getNativeAssetInfo.ts index 13ecbced1..31033fe17 100644 --- a/packages/app/src/config/chain/utils/getNativeAssetInfo.ts +++ b/packages/app/src/config/chain/utils/getNativeAssetInfo.ts @@ -1,4 +1,4 @@ -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' import { getChainConfigEntry } from '..' import { NativeAssetInfo } from '../types' diff --git a/packages/app/src/config/feature-flags/clientEnv.ts b/packages/app/src/config/feature-flags/clientEnv.ts index f443cae87..8389c7cc9 100644 --- a/packages/app/src/config/feature-flags/clientEnv.ts +++ b/packages/app/src/config/feature-flags/clientEnv.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' export function clientEnv(key: string): string { const value = import.meta.env[key] diff --git a/packages/app/src/config/wagmi/config.default.ts b/packages/app/src/config/wagmi/config.default.ts index 66cf54f26..04211d32a 100644 --- a/packages/app/src/config/wagmi/config.default.ts +++ b/packages/app/src/config/wagmi/config.default.ts @@ -1,11 +1,9 @@ +import { SandboxNetwork } from '@/domain/state/sandbox' +import { raise } from '@marsfoundation/common-universal' import { getDefaultConfig } from '@rainbow-me/rainbowkit' import { Chain } from 'viem' import { gnosis, mainnet } from 'viem/chains' import { Config } from 'wagmi' - -import { SandboxNetwork } from '@/domain/state/sandbox' -import { raise } from '@/utils/assert' - import { getChains } from './getChains' import { getTransports } from './getTransports' import { getWallets } from './getWallets' diff --git a/packages/app/src/domain/farms/farmsInfo.ts b/packages/app/src/domain/farms/farmsInfo.ts index 87e610ece..ff887d0b1 100644 --- a/packages/app/src/domain/farms/farmsInfo.ts +++ b/packages/app/src/domain/farms/farmsInfo.ts @@ -1,5 +1,4 @@ -import { raise } from '@/utils/assert' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { CheckedAddress, raise } from '@marsfoundation/common-universal' import { Farm } from './types' export class FarmsInfo { diff --git a/packages/app/src/domain/farms/useFarmsInfo.ts b/packages/app/src/domain/farms/useFarmsInfo.ts index e74d48f2c..16103726c 100644 --- a/packages/app/src/domain/farms/useFarmsInfo.ts +++ b/packages/app/src/domain/farms/useFarmsInfo.ts @@ -1,6 +1,6 @@ import { getChainConfigEntry } from '@/config/chain' import { useTokensInfo } from '@/domain/wallet/useTokens/useTokensInfo' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { useQuery, useSuspenseQuery } from '@tanstack/react-query' import { useCallback } from 'react' import { useAccount, useConfig } from 'wagmi' diff --git a/packages/app/src/domain/hooks/sanityChecks.ts b/packages/app/src/domain/hooks/sanityChecks.ts index 0e9df9dc9..16d9d427e 100644 --- a/packages/app/src/domain/hooks/sanityChecks.ts +++ b/packages/app/src/domain/hooks/sanityChecks.ts @@ -1,9 +1,8 @@ -import { assert } from '@/utils/assert' -import { Address, zeroAddress } from 'viem' -import { gnosis } from 'viem/chains' - import { NATIVE_ASSET_MOCK_ADDRESS } from '@/config/consts' import { wethGatewayAddress } from '@/config/contracts-generated' +import { assert } from '@marsfoundation/common-universal' +import { Address, zeroAddress } from 'viem' +import { gnosis } from 'viem/chains' /** * Do basic sanity checks when sending txs. diff --git a/packages/app/src/domain/hooks/useContractAddress.ts b/packages/app/src/domain/hooks/useContractAddress.ts index fe6c33807..12138e481 100644 --- a/packages/app/src/domain/hooks/useContractAddress.ts +++ b/packages/app/src/domain/hooks/useContractAddress.ts @@ -1,7 +1,5 @@ +import { CheckedAddress, raise } from '@marsfoundation/common-universal' import { Address } from 'viem' - -import { raise } from '@/utils/assert' -import { CheckedAddress } from '@marsfoundation/common-universal' import { useStore } from '../state' import { getOriginChainId, useOriginChainId } from './useOriginChainId' diff --git a/packages/app/src/domain/hooks/useWaitForTransactionReceiptGnosisSafe.ts b/packages/app/src/domain/hooks/useWaitForTransactionReceiptGnosisSafe.ts index e657cfabd..f9a401d9a 100644 --- a/packages/app/src/domain/hooks/useWaitForTransactionReceiptGnosisSafe.ts +++ b/packages/app/src/domain/hooks/useWaitForTransactionReceiptGnosisSafe.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { skipToken, useQuery } from '@tanstack/react-query' import { Address, Client, Hash, parseAbiItem } from 'viem' import { getLogs, getTransactionReceipt, watchBlockNumber } from 'viem/actions' diff --git a/packages/app/src/domain/market-info/emode.ts b/packages/app/src/domain/market-info/emode.ts index c51484201..eb940a6b9 100644 --- a/packages/app/src/domain/market-info/emode.ts +++ b/packages/app/src/domain/market-info/emode.ts @@ -1,6 +1,4 @@ -import { assert } from '@/utils/assert' - -import { Percentage } from '@marsfoundation/common-universal' +import { assert, Percentage } from '@marsfoundation/common-universal' import { AaveFormattedReserve } from './aave-data-layer/query' import { EModeCategories, EModeState } from './marketInfo' import { parseRawPercentage } from './math' diff --git a/packages/app/src/domain/market-info/getLiquidationDetails.ts b/packages/app/src/domain/market-info/getLiquidationDetails.ts index 44540a4f3..bd1377415 100644 --- a/packages/app/src/domain/market-info/getLiquidationDetails.ts +++ b/packages/app/src/domain/market-info/getLiquidationDetails.ts @@ -1,12 +1,9 @@ -import BigNumber from 'bignumber.js' - import { getChainConfigEntry } from '@/config/chain' import { TokenWithValue } from '@/domain/common/types' import { MarketInfo } from '@/domain/market-info/marketInfo' import { TokenSymbol } from '@/domain/types/TokenSymbol' -import { NormalizedUnitNumber, Percentage } from '@marsfoundation/common-universal' - -import { raise } from '@/utils/assert' +import { NormalizedUnitNumber, Percentage, raise } from '@marsfoundation/common-universal' +import BigNumber from 'bignumber.js' import { eModeCategoryIdToName } from '../e-mode/constants' export interface LiquidationDetails { diff --git a/packages/app/src/domain/market-info/marketInfo.ts b/packages/app/src/domain/market-info/marketInfo.ts index 1fe231a84..10e92e8d0 100644 --- a/packages/app/src/domain/market-info/marketInfo.ts +++ b/packages/app/src/domain/market-info/marketInfo.ts @@ -1,9 +1,8 @@ import { getChainConfigEntry } from '@/config/chain' import { NativeAssetInfo } from '@/config/chain/types' import { NATIVE_ASSET_MOCK_ADDRESS } from '@/config/consts' -import { assert, raise } from '@/utils/assert' import { fromRay } from '@/utils/math' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { assert, CheckedAddress, raise } from '@marsfoundation/common-universal' import { BaseUnitNumber, NormalizedUnitNumber, Percentage } from '@marsfoundation/common-universal' import BigNumber from 'bignumber.js' import { bigNumberify } from '../../utils/bigNumber' diff --git a/packages/app/src/domain/market-info/utils.ts b/packages/app/src/domain/market-info/utils.ts index 5a2cd475c..4feec41b7 100644 --- a/packages/app/src/domain/market-info/utils.ts +++ b/packages/app/src/domain/market-info/utils.ts @@ -1,7 +1,5 @@ -import { assert } from '@/utils/assert' import { formatUserSummary } from '@aave/math-utils' - -import { CheckedAddress } from '@marsfoundation/common-universal' +import { assert, CheckedAddress } from '@marsfoundation/common-universal' import { NormalizedUnitNumber, Percentage } from '@marsfoundation/common-universal' import { bigNumberify } from '../../utils/bigNumber' import { AaveBaseCurrency, AaveFormattedReserve, AaveUserSummary, RawAaveUserReserve } from './aave-data-layer/query' diff --git a/packages/app/src/domain/market-validators/validateBorrow.ts b/packages/app/src/domain/market-validators/validateBorrow.ts index e42a7ed5f..542baabcb 100644 --- a/packages/app/src/domain/market-validators/validateBorrow.ts +++ b/packages/app/src/domain/market-validators/validateBorrow.ts @@ -1,7 +1,4 @@ -import { assert } from '@/utils/assert' - -import { CheckedAddress } from '@marsfoundation/common-universal' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, CheckedAddress, NormalizedUnitNumber } from '@marsfoundation/common-universal' import { calculateMaxBorrowBasedOnCollateral } from '../action-max-value-getters/calculateMaxBorrowBasedOnCollateral' import { MarketInfo, Reserve, UserPositionSummary } from '../market-info/marketInfo' import { ReserveStatus } from '../market-info/reserve-status' diff --git a/packages/app/src/domain/market-validators/validateSetUserEMode.ts b/packages/app/src/domain/market-validators/validateSetUserEMode.ts index 163bc4e77..191e73c42 100644 --- a/packages/app/src/domain/market-validators/validateSetUserEMode.ts +++ b/packages/app/src/domain/market-validators/validateSetUserEMode.ts @@ -1,8 +1,5 @@ +import { NormalizedUnitNumber, Percentage, raise } from '@marsfoundation/common-universal' import BigNumber from 'bignumber.js' - -import { raise } from '@/utils/assert' - -import { NormalizedUnitNumber, Percentage } from '@marsfoundation/common-universal' import { MarketInfo } from '../market-info/marketInfo' export interface ValidateSetUserEModeParams { diff --git a/packages/app/src/domain/oracles/query.ts b/packages/app/src/domain/oracles/query.ts index 89cd3e2b4..30b476dd8 100644 --- a/packages/app/src/domain/oracles/query.ts +++ b/packages/app/src/domain/oracles/query.ts @@ -1,6 +1,5 @@ import { getChainConfigEntry } from '@/config/chain' -import { assertNever } from '@/utils/assertNever' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { NormalizedUnitNumber, assertNever } from '@marsfoundation/common-universal' import { queryOptions } from '@tanstack/react-query' import { Config } from 'wagmi' import { MarketInfo, Reserve } from '../market-info/marketInfo' diff --git a/packages/app/src/domain/savings-charts/useMyEarningsInfo/selectMyEarningsSavingsDataByDataType.ts b/packages/app/src/domain/savings-charts/useMyEarningsInfo/selectMyEarningsSavingsDataByDataType.ts index 54be99046..514247df4 100644 --- a/packages/app/src/domain/savings-charts/useMyEarningsInfo/selectMyEarningsSavingsDataByDataType.ts +++ b/packages/app/src/domain/savings-charts/useMyEarningsInfo/selectMyEarningsSavingsDataByDataType.ts @@ -1,7 +1,7 @@ import { TokenWithBalance } from '@/domain/common/types' import { SavingsDisplayType } from '@/domain/savings-charts/useMyEarningsInfo/getSavingsDisplayType' import { SavingsInfo } from '@/domain/savings-info/types' -import { assertNever } from '@/utils/assertNever' +import { assertNever } from '@marsfoundation/common-universal' interface SelectSavingsDataByDisplayTypeParams { displayType: SavingsDisplayType diff --git a/packages/app/src/domain/savings-charts/useSavingsChartsInfoQuery.ts b/packages/app/src/domain/savings-charts/useSavingsChartsInfoQuery.ts index d881448bf..68c850f91 100644 --- a/packages/app/src/domain/savings-charts/useSavingsChartsInfoQuery.ts +++ b/packages/app/src/domain/savings-charts/useSavingsChartsInfoQuery.ts @@ -1,7 +1,6 @@ import { getChainConfigEntry } from '@/config/chain' -import { assert } from '@/utils/assert' import { useTimestamp } from '@/utils/useTimestamp' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { assert, CheckedAddress } from '@marsfoundation/common-universal' import { useAccount, useChainId } from 'wagmi' import { TokenWithBalance } from '../common/types' import { SavingsInfo } from '../savings-info/types' diff --git a/packages/app/src/domain/savings-info/mainnetSavingsInfo.ts b/packages/app/src/domain/savings-info/mainnetSavingsInfo.ts index 786f3755c..dc73cdde2 100644 --- a/packages/app/src/domain/savings-info/mainnetSavingsInfo.ts +++ b/packages/app/src/domain/savings-info/mainnetSavingsInfo.ts @@ -2,8 +2,8 @@ import { susdsAbi } from '@/config/abis/susdsAbi' import { getChainConfigEntry } from '@/config/chain' import { potAbi, potAddress } from '@/config/contracts-generated' import { getContractAddress } from '@/domain/hooks/useContractAddress' -import { raise } from '@/utils/assert' import { bigNumberify } from '@/utils/bigNumber' +import { raise } from '@marsfoundation/common-universal' import { multicall } from 'wagmi/actions' import { PotSavingsInfo } from './potSavingsInfo' import { SavingsInfoQueryOptions, SavingsInfoQueryParams } from './types' diff --git a/packages/app/src/domain/savings/assertWithdraw.ts b/packages/app/src/domain/savings/assertWithdraw.ts index 68ffc8415..e13bdc08f 100644 --- a/packages/app/src/domain/savings/assertWithdraw.ts +++ b/packages/app/src/domain/savings/assertWithdraw.ts @@ -1,6 +1,5 @@ import { Mode } from '@/features/dialogs/savings/withdraw/types' -import { assert } from '@/utils/assert' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { assert, CheckedAddress } from '@marsfoundation/common-universal' import { Address } from 'viem' import { receiverValidationIssueToMessage, validateReceiver } from './validateReceiver' diff --git a/packages/app/src/domain/types/SupportedChainId.ts b/packages/app/src/domain/types/SupportedChainId.ts index 169ac12e6..df24458f5 100644 --- a/packages/app/src/domain/types/SupportedChainId.ts +++ b/packages/app/src/domain/types/SupportedChainId.ts @@ -1,6 +1,6 @@ import { SUPPORTED_CHAIN_IDS } from '@/config/chain/constants' -import { assert } from '@/utils/assert' import { NumberLike, bigNumberify } from '@/utils/bigNumber' +import { assert } from '@marsfoundation/common-universal' import { Opaque } from './types' /** diff --git a/packages/app/src/domain/types/Token.ts b/packages/app/src/domain/types/Token.ts index f69d08b91..4b53c8dcb 100644 --- a/packages/app/src/domain/types/Token.ts +++ b/packages/app/src/domain/types/Token.ts @@ -1,8 +1,6 @@ -import { assert } from '@/utils/assert' +import { assert, BaseUnitNumber, CheckedAddress, NormalizedUnitNumber } from '@marsfoundation/common-universal' import BigNumber from 'bignumber.js' import { zeroAddress } from 'viem' - -import { BaseUnitNumber, CheckedAddress, NormalizedUnitNumber } from '@marsfoundation/common-universal' import { findSignificantPrecision } from '../common/format' import { TokenSymbol } from './TokenSymbol' diff --git a/packages/app/src/domain/types/TokenSymbol.ts b/packages/app/src/domain/types/TokenSymbol.ts index aaff59617..468953719 100644 --- a/packages/app/src/domain/types/TokenSymbol.ts +++ b/packages/app/src/domain/types/TokenSymbol.ts @@ -1,5 +1,4 @@ -import { assert } from '@/utils/assert' - +import { assert } from '@marsfoundation/common-universal' import { Opaque } from './types' /** diff --git a/packages/app/src/domain/wallet/useTokens/TokenInfo.ts b/packages/app/src/domain/wallet/useTokens/TokenInfo.ts index a1b27c853..02a346608 100644 --- a/packages/app/src/domain/wallet/useTokens/TokenInfo.ts +++ b/packages/app/src/domain/wallet/useTokens/TokenInfo.ts @@ -1,9 +1,7 @@ import { TokenWithBalance } from '@/domain/common/types' import { Token } from '@/domain/types/Token' import { TokenSymbol } from '@/domain/types/TokenSymbol' -import { raise } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { CheckedAddress, NormalizedUnitNumber, raise } from '@marsfoundation/common-universal' export interface FeaturedTokens { DAI?: TokenSymbol diff --git a/packages/app/src/domain/wallet/useTokens/createOraclePriceFetcher.ts b/packages/app/src/domain/wallet/useTokens/createOraclePriceFetcher.ts index 437ef4763..1804e363b 100644 --- a/packages/app/src/domain/wallet/useTokens/createOraclePriceFetcher.ts +++ b/packages/app/src/domain/wallet/useTokens/createOraclePriceFetcher.ts @@ -1,9 +1,8 @@ import { ssrAuthOracleConfig } from '@/config/contracts-generated' import { getContractAddress } from '@/domain/hooks/useContractAddress' -import { assertNever } from '@/utils/assertNever' import { bigNumberify } from '@/utils/bigNumber' import { fromRay } from '@/utils/math' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { NormalizedUnitNumber, assertNever } from '@marsfoundation/common-universal' import { erc4626Abi, etherUnits, formatUnits, parseUnits } from 'viem' import { Config } from 'wagmi' import { readContract } from 'wagmi/actions' diff --git a/packages/app/src/features/actions/components/action-row/ActionRow.tsx b/packages/app/src/features/actions/components/action-row/ActionRow.tsx index 893e26e08..d6098d65a 100644 --- a/packages/app/src/features/actions/components/action-row/ActionRow.tsx +++ b/packages/app/src/features/actions/components/action-row/ActionRow.tsx @@ -9,8 +9,7 @@ import { IconStack } from '@/ui/molecules/icon-stack/IconStack' import { cn } from '@/ui/utils/style' import { testIds } from '@/ui/utils/testIds' import { useIsTruncated } from '@/ui/utils/useIsTruncated' -import { assert } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber } from '@marsfoundation/common-universal' import { cva } from 'class-variance-authority' import { ComponentType, ReactNode, createContext, useContext } from 'react' import { ActionHandlerState } from '../../logic/types' diff --git a/packages/app/src/features/actions/components/actions/Actions.tsx b/packages/app/src/features/actions/components/actions/Actions.tsx index 8ad261328..7ef904805 100644 --- a/packages/app/src/features/actions/components/actions/Actions.tsx +++ b/packages/app/src/features/actions/components/actions/Actions.tsx @@ -1,4 +1,4 @@ -import { assertNever } from '@/utils/assertNever' +import { assertNever } from '@marsfoundation/common-universal' import { ApproveDelegationActionRow } from '../../flavours/approve-delegation/ApproveDelegationActionRow' import { ApproveActionRow } from '../../flavours/approve/ApproveActionRow' import { BorrowActionRow } from '../../flavours/borrow/BorrowActionRow' diff --git a/packages/app/src/features/actions/flavours/approve-delegation/logic/approveDelegationAction.ts b/packages/app/src/features/actions/flavours/approve-delegation/logic/approveDelegationAction.ts index c578403d0..5eb8d00bf 100644 --- a/packages/app/src/features/actions/flavours/approve-delegation/logic/approveDelegationAction.ts +++ b/packages/app/src/features/actions/flavours/approve-delegation/logic/approveDelegationAction.ts @@ -3,8 +3,8 @@ import { wethGatewayConfig } from '@/config/contracts-generated' import { getContractAddress } from '@/domain/hooks/useContractAddress' import { ensureConfigTypes } from '@/domain/hooks/useWrite' import { ActionConfig, ActionContext } from '@/features/actions/logic/types' -import { raise } from '@/utils/assert' import { toBigInt } from '@/utils/bigNumber' +import { raise } from '@marsfoundation/common-universal' import { queryOptions } from '@tanstack/react-query' import { ApproveDelegationAction } from '../types' import { borrowAllowance, getBorrowAllowanceQueryKey } from './query' diff --git a/packages/app/src/features/actions/flavours/convert-stables/logic/createConvertStablesActions.ts b/packages/app/src/features/actions/flavours/convert-stables/logic/createConvertStablesActions.ts index 96f39b366..3795628b5 100644 --- a/packages/app/src/features/actions/flavours/convert-stables/logic/createConvertStablesActions.ts +++ b/packages/app/src/features/actions/flavours/convert-stables/logic/createConvertStablesActions.ts @@ -6,9 +6,7 @@ import { } from '@/config/contracts-generated' import { getContractAddress } from '@/domain/hooks/useContractAddress' import { Action, ActionContext } from '@/features/actions/logic/types' -import { assert } from '@/utils/assert' -import { assertNever } from '@/utils/assertNever' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { assert, CheckedAddress, assertNever } from '@marsfoundation/common-universal' import { base } from 'viem/chains' import { ApproveAction } from '../../approve/types' import { ConvertStablesObjective } from '../types' diff --git a/packages/app/src/features/actions/flavours/deposit-to-savings/logic/createDepositToSavingsActions.ts b/packages/app/src/features/actions/flavours/deposit-to-savings/logic/createDepositToSavingsActions.ts index 57e41c442..66e3fb47e 100644 --- a/packages/app/src/features/actions/flavours/deposit-to-savings/logic/createDepositToSavingsActions.ts +++ b/packages/app/src/features/actions/flavours/deposit-to-savings/logic/createDepositToSavingsActions.ts @@ -6,9 +6,7 @@ import { } from '@/config/contracts-generated' import { getContractAddress } from '@/domain/hooks/useContractAddress' import { Action, ActionContext } from '@/features/actions/logic/types' -import { raise } from '@/utils/assert' -import { assertNever } from '@/utils/assertNever' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { CheckedAddress, assertNever, raise } from '@marsfoundation/common-universal' import { ApproveAction } from '../../approve/types' import { DepositToSavingsAction, DepositToSavingsObjective } from '../types' import { getSavingsDepositActionPath } from './getSavingsDepositActionPath' diff --git a/packages/app/src/features/actions/flavours/deposit-to-savings/logic/depositToSavingsAction.ts b/packages/app/src/features/actions/flavours/deposit-to-savings/logic/depositToSavingsAction.ts index 3c03ea7d4..c9d8b97de 100644 --- a/packages/app/src/features/actions/flavours/deposit-to-savings/logic/depositToSavingsAction.ts +++ b/packages/app/src/features/actions/flavours/deposit-to-savings/logic/depositToSavingsAction.ts @@ -17,11 +17,8 @@ import { getBalancesQueryKeyPrefix } from '@/domain/wallet/getBalancesQueryKeyPr import { allowanceQueryKey } from '@/features/actions/flavours/approve/logic/query' import { ActionConfig, ActionContext, GetWriteConfigResult } from '@/features/actions/logic/types' import { calculateGemConversionFactor } from '@/features/actions/utils/savings' -import { assert, raise } from '@/utils/assert' -import { assertNever } from '@/utils/assertNever' import { toBigInt } from '@/utils/bigNumber' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { assert, CheckedAddress, NormalizedUnitNumber, assertNever, raise } from '@marsfoundation/common-universal' import { QueryKey } from '@tanstack/react-query' import { Address, erc4626Abi } from 'viem' import { base, gnosis } from 'viem/chains' diff --git a/packages/app/src/features/actions/flavours/deposit-to-savings/logic/getSavingsDepositActionPath.ts b/packages/app/src/features/actions/flavours/deposit-to-savings/logic/getSavingsDepositActionPath.ts index 708f08a0f..44dd28e60 100644 --- a/packages/app/src/features/actions/flavours/deposit-to-savings/logic/getSavingsDepositActionPath.ts +++ b/packages/app/src/features/actions/flavours/deposit-to-savings/logic/getSavingsDepositActionPath.ts @@ -1,7 +1,7 @@ import { Token } from '@/domain/types/Token' import { TokenSymbol } from '@/domain/types/TokenSymbol' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' import { base, gnosis } from 'viem/chains' export type SavingsDepositActionPath = diff --git a/packages/app/src/features/actions/flavours/psm-convert/logic/getPsmConvertActionPath.ts b/packages/app/src/features/actions/flavours/psm-convert/logic/getPsmConvertActionPath.ts index cc2161836..54b819567 100644 --- a/packages/app/src/features/actions/flavours/psm-convert/logic/getPsmConvertActionPath.ts +++ b/packages/app/src/features/actions/flavours/psm-convert/logic/getPsmConvertActionPath.ts @@ -1,7 +1,7 @@ import { Token } from '@/domain/types/Token' import { TokenSymbol } from '@/domain/types/TokenSymbol' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' import { base } from 'viem/chains' export type PsmConvertActionPath = diff --git a/packages/app/src/features/actions/flavours/psm-convert/logic/psmConvertAction.ts b/packages/app/src/features/actions/flavours/psm-convert/logic/psmConvertAction.ts index d0995ce91..307e791a1 100644 --- a/packages/app/src/features/actions/flavours/psm-convert/logic/psmConvertAction.ts +++ b/packages/app/src/features/actions/flavours/psm-convert/logic/psmConvertAction.ts @@ -5,9 +5,8 @@ import { ensureConfigTypes } from '@/domain/hooks/useWrite' import { TokenSymbol } from '@/domain/types/TokenSymbol' import { getBalancesQueryKeyPrefix } from '@/domain/wallet/getBalancesQueryKeyPrefix' import { ActionConfig, ActionContext } from '@/features/actions/logic/types' -import { assert } from '@/utils/assert' -import { assertNever } from '@/utils/assertNever' import { toBigInt } from '@/utils/bigNumber' +import { assert, assertNever } from '@marsfoundation/common-universal' import { CheckedAddress } from '@marsfoundation/common-universal' import { QueryKey } from '@tanstack/react-query' import { base } from 'viem/chains' diff --git a/packages/app/src/features/actions/flavours/stake/logic/createStakeActions.ts b/packages/app/src/features/actions/flavours/stake/logic/createStakeActions.ts index 95c05f40d..c1c546772 100644 --- a/packages/app/src/features/actions/flavours/stake/logic/createStakeActions.ts +++ b/packages/app/src/features/actions/flavours/stake/logic/createStakeActions.ts @@ -2,9 +2,7 @@ import { migrationActionsConfig, usdsPsmWrapperConfig } from '@/config/contracts import { getContractAddress } from '@/domain/hooks/useContractAddress' import { Token } from '@/domain/types/Token' import { Action, ActionContext } from '@/features/actions/logic/types' -import { assert, raise } from '@/utils/assert' -import { assertNever } from '@/utils/assertNever' -import { BaseUnitNumber, NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, BaseUnitNumber, NormalizedUnitNumber, assertNever, raise } from '@marsfoundation/common-universal' import { TransactionReceipt, decodeEventLog, erc4626Abi } from 'viem' import { ApproveAction } from '../../approve/types' import { PsmConvertAction } from '../../psm-convert/types' diff --git a/packages/app/src/features/actions/flavours/stake/logic/getStakeActionPath.ts b/packages/app/src/features/actions/flavours/stake/logic/getStakeActionPath.ts index 2eec52d8e..6f97b0e1c 100644 --- a/packages/app/src/features/actions/flavours/stake/logic/getStakeActionPath.ts +++ b/packages/app/src/features/actions/flavours/stake/logic/getStakeActionPath.ts @@ -1,7 +1,7 @@ import { Token } from '@/domain/types/Token' import { TokenSymbol } from '@/domain/types/TokenSymbol' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' export type StakeActionPath = | 'usds-to-farm' diff --git a/packages/app/src/features/actions/flavours/unstake/logic/createUnstakeActions.ts b/packages/app/src/features/actions/flavours/unstake/logic/createUnstakeActions.ts index 0b818e56b..c13322cb8 100644 --- a/packages/app/src/features/actions/flavours/unstake/logic/createUnstakeActions.ts +++ b/packages/app/src/features/actions/flavours/unstake/logic/createUnstakeActions.ts @@ -1,8 +1,7 @@ import { migrationActionsConfig, usdsPsmWrapperConfig } from '@/config/contracts-generated' import { getContractAddress } from '@/domain/hooks/useContractAddress' import { Action, ActionContext } from '@/features/actions/logic/types' -import { assert, raise } from '@/utils/assert' -import { assertNever } from '@/utils/assertNever' +import { assert, assertNever, raise } from '@marsfoundation/common-universal' import { ApproveAction } from '../../approve/types' import { DowngradeAction } from '../../downgrade/types' import { PsmConvertAction } from '../../psm-convert/types' diff --git a/packages/app/src/features/actions/flavours/unstake/logic/getUnstakeActionPath.ts b/packages/app/src/features/actions/flavours/unstake/logic/getUnstakeActionPath.ts index d71fd23f4..400f37296 100644 --- a/packages/app/src/features/actions/flavours/unstake/logic/getUnstakeActionPath.ts +++ b/packages/app/src/features/actions/flavours/unstake/logic/getUnstakeActionPath.ts @@ -1,7 +1,7 @@ import { Token } from '@/domain/types/Token' import { TokenSymbol } from '@/domain/types/TokenSymbol' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' export type UnstakeActionPath = 'farm-to-usds' | 'farm-to-usds-to-usdc' | 'farm-to-usds-to-dai' diff --git a/packages/app/src/features/actions/flavours/upgrade/logic/upgradeAction.ts b/packages/app/src/features/actions/flavours/upgrade/logic/upgradeAction.ts index 14aed9621..8aab34ff1 100644 --- a/packages/app/src/features/actions/flavours/upgrade/logic/upgradeAction.ts +++ b/packages/app/src/features/actions/flavours/upgrade/logic/upgradeAction.ts @@ -4,8 +4,8 @@ import { ensureConfigTypes } from '@/domain/hooks/useWrite' import { getBalancesQueryKeyPrefix } from '@/domain/wallet/getBalancesQueryKeyPrefix' import { allowanceQueryKey } from '@/features/actions/flavours/approve/logic/query' import { ActionConfig, ActionContext } from '@/features/actions/logic/types' -import { raise } from '@/utils/assert' import { toBigInt } from '@/utils/bigNumber' +import { raise } from '@marsfoundation/common-universal' import { UpgradeAction } from '../types' export function createUpgradeActionConfig(action: UpgradeAction, context: ActionContext): ActionConfig { diff --git a/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/createWithdrawFromSavingsActions.ts b/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/createWithdrawFromSavingsActions.ts index 9aec69d1d..396541501 100644 --- a/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/createWithdrawFromSavingsActions.ts +++ b/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/createWithdrawFromSavingsActions.ts @@ -8,10 +8,7 @@ import { import { getContractAddress } from '@/domain/hooks/useContractAddress' import { SavingsInfo } from '@/domain/savings-info/types' import { Action, ActionContext } from '@/features/actions/logic/types' -import { assert, raise } from '@/utils/assert' -import { assertNever } from '@/utils/assertNever' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { assert, CheckedAddress, NormalizedUnitNumber, assertNever, raise } from '@marsfoundation/common-universal' import BigNumber from 'bignumber.js' import { gnosis } from 'viem/chains' import { ApproveAction } from '../../approve/types' diff --git a/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/getSavingsWithdrawActionPath.ts b/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/getSavingsWithdrawActionPath.ts index 23ed1531b..3fa30bb3a 100644 --- a/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/getSavingsWithdrawActionPath.ts +++ b/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/getSavingsWithdrawActionPath.ts @@ -1,7 +1,7 @@ import { Token } from '@/domain/types/Token' import { TokenSymbol } from '@/domain/types/TokenSymbol' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' import { base, gnosis } from 'viem/chains' export interface GetSavingsWithdrawActionPathParams { diff --git a/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/withdrawFromSavingsAction.ts b/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/withdrawFromSavingsAction.ts index 64bf1d9e7..090ffef4b 100644 --- a/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/withdrawFromSavingsAction.ts +++ b/packages/app/src/features/actions/flavours/withdraw-from-savings/logic/withdrawFromSavingsAction.ts @@ -17,11 +17,8 @@ import { getBalancesQueryKeyPrefix } from '@/domain/wallet/getBalancesQueryKeyPr import { allowanceQueryKey } from '@/features/actions/flavours/approve/logic/query' import { ActionConfig, ActionContext, GetWriteConfigResult } from '@/features/actions/logic/types' import { calculateGemConversionFactor } from '@/features/actions/utils/savings' -import { assert, raise } from '@/utils/assert' -import { assertNever } from '@/utils/assertNever' import { toBigInt } from '@/utils/bigNumber' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { assert, CheckedAddress, NormalizedUnitNumber, assertNever, raise } from '@marsfoundation/common-universal' import { QueryKey } from '@tanstack/react-query' import { Address, erc4626Abi } from 'viem' import { gnosis } from 'viem/chains' diff --git a/packages/app/src/features/actions/flavours/withdraw/logic/withdrawAction.ts b/packages/app/src/features/actions/flavours/withdraw/logic/withdrawAction.ts index 003a91278..498f997f5 100644 --- a/packages/app/src/features/actions/flavours/withdraw/logic/withdrawAction.ts +++ b/packages/app/src/features/actions/flavours/withdraw/logic/withdrawAction.ts @@ -6,8 +6,8 @@ import { ensureConfigTypes } from '@/domain/hooks/useWrite' import { aaveDataLayerQueryKey } from '@/domain/market-info/aave-data-layer/query' import { getBalancesQueryKeyPrefix } from '@/domain/wallet/getBalancesQueryKeyPrefix' import { allowanceQueryKey } from '@/features/actions/flavours/approve/logic/query' -import { raise } from '@/utils/assert' import { toBigInt } from '@/utils/bigNumber' +import { raise } from '@marsfoundation/common-universal' import { ActionConfig, ActionContext } from '../../../logic/types' import { WithdrawAction } from '../types' diff --git a/packages/app/src/features/actions/logic/permits.ts b/packages/app/src/features/actions/logic/permits.ts index edc27d4ae..9ce40dbac 100644 --- a/packages/app/src/features/actions/logic/permits.ts +++ b/packages/app/src/features/actions/logic/permits.ts @@ -1,8 +1,7 @@ -import { assert } from '@/utils/assert' -import { Signature } from 'viem' - import { getChainConfigEntry } from '@/config/chain' import { Token } from '@/domain/types/Token' +import { assert } from '@marsfoundation/common-universal' +import { Signature } from 'viem' export interface Permit { token: Token diff --git a/packages/app/src/features/actions/logic/stringifyObjectives.ts b/packages/app/src/features/actions/logic/stringifyObjectives.ts index 8af1dfb01..c7881f1eb 100644 --- a/packages/app/src/features/actions/logic/stringifyObjectives.ts +++ b/packages/app/src/features/actions/logic/stringifyObjectives.ts @@ -1,5 +1,5 @@ -import { assertNever } from '@/utils/assertNever' import { JSONStringifyRich } from '@/utils/object' +import { assertNever } from '@marsfoundation/common-universal' import { Objective } from './types' export function stringifyObjectivesDeep(objectives: Objective[]): string { diff --git a/packages/app/src/features/actions/logic/useCreateActions.ts b/packages/app/src/features/actions/logic/useCreateActions.ts index 1382edb55..a957eeb49 100644 --- a/packages/app/src/features/actions/logic/useCreateActions.ts +++ b/packages/app/src/features/actions/logic/useCreateActions.ts @@ -3,8 +3,7 @@ import { useChainConfigEntry } from '@/domain/hooks/useChainConfigEntry' import { getContractAddress } from '@/domain/hooks/useContractAddress' import { ActionsSettings } from '@/domain/state/actions-settings' import { TokenSymbol } from '@/domain/types/TokenSymbol' -import { assert, raise } from '@/utils/assert' -import { BaseUnitNumber } from '@marsfoundation/common-universal' +import { assert, BaseUnitNumber, raise } from '@marsfoundation/common-universal' import { maxUint256 } from 'viem' import { useChainId } from 'wagmi' import { ApproveDelegationAction } from '../flavours/approve-delegation/types' diff --git a/packages/app/src/features/dialogs/borrow/logic/assets.ts b/packages/app/src/features/dialogs/borrow/logic/assets.ts index 85090135f..eafbeda14 100644 --- a/packages/app/src/features/dialogs/borrow/logic/assets.ts +++ b/packages/app/src/features/dialogs/borrow/logic/assets.ts @@ -1,11 +1,10 @@ -import { assert } from '@/utils/assert' - import { NativeAssetInfo } from '@/config/chain/types' import { TokenWithBalance } from '@/domain/common/types' import { MarketInfo } from '@/domain/market-info/marketInfo' import { Token } from '@/domain/types/Token' import { MarketWalletInfo } from '@/domain/wallet/useMarketWalletInfo' import { applyTransformers } from '@/utils/applyTransformers' +import { assert } from '@marsfoundation/common-universal' export interface GetBorrowOptionsParams { token: Token diff --git a/packages/app/src/features/dialogs/convert-stables/logic/form/useConvertStablesForm.ts b/packages/app/src/features/dialogs/convert-stables/logic/form/useConvertStablesForm.ts index 008435bff..8d50df1cc 100644 --- a/packages/app/src/features/dialogs/convert-stables/logic/form/useConvertStablesForm.ts +++ b/packages/app/src/features/dialogs/convert-stables/logic/form/useConvertStablesForm.ts @@ -1,8 +1,8 @@ import { TokenSymbol } from '@/domain/types/TokenSymbol' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' -import { assert } from '@/utils/assert' import { useDebounce } from '@/utils/useDebounce' import { zodResolver } from '@hookform/resolvers/zod' +import { assert } from '@marsfoundation/common-universal' import { UseFormReturn, useForm } from 'react-hook-form' import { ConvertStablesFormFields, NormalizedConvertStablesFormValues } from '../../types' import { getConvertStablesFormFields } from './getConvertStablesFormFields' diff --git a/packages/app/src/features/dialogs/convert-stables/views/SuccessView.tsx b/packages/app/src/features/dialogs/convert-stables/views/SuccessView.tsx index 145b0a088..e17bc67f8 100644 --- a/packages/app/src/features/dialogs/convert-stables/views/SuccessView.tsx +++ b/packages/app/src/features/dialogs/convert-stables/views/SuccessView.tsx @@ -3,7 +3,7 @@ import { SuccessViewCheckmark } from '@/features/dialogs/common/components/succe import { SuccessViewContent } from '@/features/dialogs/common/components/success-view/SuccessViewContent' import { SuccessViewProceedButton } from '@/features/dialogs/common/components/success-view/SuccessViewProceedButton' import { testIds } from '@/ui/utils/testIds' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { SuccessViewPanel } from '../../common/components/success-view/SuccessViewPanel' import { SuccessViewTokenRow } from '../../common/components/success-view/SuccessViewTokenRow' import { TxOverview } from '../logic/createTxOverview' diff --git a/packages/app/src/features/dialogs/deposit/logic/assets.ts b/packages/app/src/features/dialogs/deposit/logic/assets.ts index 6aaf57ecc..02684e472 100644 --- a/packages/app/src/features/dialogs/deposit/logic/assets.ts +++ b/packages/app/src/features/dialogs/deposit/logic/assets.ts @@ -4,7 +4,7 @@ import { MarketInfo } from '@/domain/market-info/marketInfo' import { Token } from '@/domain/types/Token' import { MarketWalletInfo } from '@/domain/wallet/useMarketWalletInfo' import { applyTransformers } from '@/utils/applyTransformers' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' export interface GetDepositOptionsParams { token: Token diff --git a/packages/app/src/features/dialogs/repay/logic/assets.ts b/packages/app/src/features/dialogs/repay/logic/assets.ts index aaa6c7e34..546946486 100644 --- a/packages/app/src/features/dialogs/repay/logic/assets.ts +++ b/packages/app/src/features/dialogs/repay/logic/assets.ts @@ -4,8 +4,7 @@ import { MarketInfo } from '@/domain/market-info/marketInfo' import { Token } from '@/domain/types/Token' import { MarketWalletInfo } from '@/domain/wallet/useMarketWalletInfo' import { applyTransformers } from '@/utils/applyTransformers' -import { assert } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber } from '@marsfoundation/common-universal' export interface GetDepositOptionsParams { token: Token diff --git a/packages/app/src/features/dialogs/sandbox/logic/useSandboxDialog.ts b/packages/app/src/features/dialogs/sandbox/logic/useSandboxDialog.ts index 0de1eb848..deb3cade4 100644 --- a/packages/app/src/features/dialogs/sandbox/logic/useSandboxDialog.ts +++ b/packages/app/src/features/dialogs/sandbox/logic/useSandboxDialog.ts @@ -3,9 +3,9 @@ import { createSandboxConnector } from '@/domain/sandbox/createSandboxConnector' import { useSandboxState } from '@/domain/sandbox/useSandboxState' import { useStore } from '@/domain/state' import { useCloseDialog } from '@/domain/state/dialogs' -import { assert } from '@/utils/assert' import { NotRetryableError, retry } from '@/utils/promises' import { getTimestampInSeconds } from '@/utils/time' +import { assert } from '@marsfoundation/common-universal' import { UseMutationResult, useMutation } from '@tanstack/react-query' import { useRef } from 'react' import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts' diff --git a/packages/app/src/features/dialogs/savings/common/components/transaction-overview/TransactionOverview.tsx b/packages/app/src/features/dialogs/savings/common/components/transaction-overview/TransactionOverview.tsx index 2c821772f..3fed1090b 100644 --- a/packages/app/src/features/dialogs/savings/common/components/transaction-overview/TransactionOverview.tsx +++ b/packages/app/src/features/dialogs/savings/common/components/transaction-overview/TransactionOverview.tsx @@ -1,7 +1,7 @@ import { Token } from '@/domain/types/Token' import { TransactionOverview } from '@/ui/organisms/transaction-overview/TransactionOverview' import { testIds } from '@/ui/utils/testIds' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { SavingsDialogTxOverview } from '../../types' import { TransactionOverviewPlaceholder } from './components/TransactionOverviewPlaceholder' diff --git a/packages/app/src/features/dialogs/savings/deposit/logic/createTxOverview.ts b/packages/app/src/features/dialogs/savings/deposit/logic/createTxOverview.ts index 81fc2fc59..3afa1bff3 100644 --- a/packages/app/src/features/dialogs/savings/deposit/logic/createTxOverview.ts +++ b/packages/app/src/features/dialogs/savings/deposit/logic/createTxOverview.ts @@ -3,8 +3,7 @@ import { Token } from '@/domain/types/Token' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' import { TransferFromUserFormNormalizedData } from '@/features/dialogs/common/logic/transfer-from-user/form' import { TxOverviewRouteItem } from '@/features/dialogs/common/types' -import { raise } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { NormalizedUnitNumber, raise } from '@marsfoundation/common-universal' import { SavingsDialogTxOverview } from '../../common/types' export interface CreateTxOverviewParams { diff --git a/packages/app/src/features/dialogs/savings/deposit/logic/objectives.ts b/packages/app/src/features/dialogs/savings/deposit/logic/objectives.ts index b9c6e0cab..58e096de2 100644 --- a/packages/app/src/features/dialogs/savings/deposit/logic/objectives.ts +++ b/packages/app/src/features/dialogs/savings/deposit/logic/objectives.ts @@ -1,7 +1,7 @@ import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' import { DepositToSavingsObjective } from '@/features/actions/flavours/deposit-to-savings/types' import { TransferFromUserFormNormalizedData } from '@/features/dialogs/common/logic/transfer-from-user/form' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' export interface CreateObjectivesParams { formValues: TransferFromUserFormNormalizedData diff --git a/packages/app/src/features/dialogs/savings/deposit/logic/useSavingsDepositDialog.ts b/packages/app/src/features/dialogs/savings/deposit/logic/useSavingsDepositDialog.ts index ab5670a78..605692a29 100644 --- a/packages/app/src/features/dialogs/savings/deposit/logic/useSavingsDepositDialog.ts +++ b/packages/app/src/features/dialogs/savings/deposit/logic/useSavingsDepositDialog.ts @@ -12,9 +12,8 @@ import { import { getTransferFromUserFormValidator } from '@/features/dialogs/common/logic/transfer-from-user/validation' import { FormFieldsForDialog, PageState, PageStatus } from '@/features/dialogs/common/types' import { determineApyImprovement } from '@/features/savings/logic/determineApyImprovement' -import { assert, raise } from '@/utils/assert' import { zodResolver } from '@hookform/resolvers/zod' -import { Percentage } from '@marsfoundation/common-universal' +import { assert, Percentage, raise } from '@marsfoundation/common-universal' import { useState } from 'react' import { UseFormReturn, useForm } from 'react-hook-form' import { useChainId } from 'wagmi' diff --git a/packages/app/src/features/dialogs/savings/migrate/common/components/TransactionOverview.tsx b/packages/app/src/features/dialogs/savings/migrate/common/components/TransactionOverview.tsx index 6b71b5e1d..a9a3329b2 100644 --- a/packages/app/src/features/dialogs/savings/migrate/common/components/TransactionOverview.tsx +++ b/packages/app/src/features/dialogs/savings/migrate/common/components/TransactionOverview.tsx @@ -1,7 +1,7 @@ import { Token } from '@/domain/types/Token' import { TransactionOverview } from '@/ui/organisms/transaction-overview/TransactionOverview' import { testIds } from '@/ui/utils/testIds' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { TransactionOverviewPlaceholder } from '../../../common/components/transaction-overview/components/TransactionOverviewPlaceholder' import { MigrateDialogTxOverview } from '../types' diff --git a/packages/app/src/features/dialogs/savings/migrate/common/logic/useMigrateDialog.ts b/packages/app/src/features/dialogs/savings/migrate/common/logic/useMigrateDialog.ts index eb4cff979..cff4a971e 100644 --- a/packages/app/src/features/dialogs/savings/migrate/common/logic/useMigrateDialog.ts +++ b/packages/app/src/features/dialogs/savings/migrate/common/logic/useMigrateDialog.ts @@ -12,9 +12,8 @@ import { useDebouncedFormValues, } from '@/features/dialogs/common/logic/transfer-from-user/form' import { FormFieldsForDialog, PageState, PageStatus } from '@/features/dialogs/common/types' -import { assert } from '@/utils/assert' import { zodResolver } from '@hookform/resolvers/zod' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber } from '@marsfoundation/common-universal' import { useState } from 'react' import { UseFormReturn, useForm } from 'react-hook-form' import { useChainId } from 'wagmi' diff --git a/packages/app/src/features/dialogs/savings/withdraw/logic/createTxOverview.ts b/packages/app/src/features/dialogs/savings/withdraw/logic/createTxOverview.ts index c1552bb98..63afa3a16 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/logic/createTxOverview.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/logic/createTxOverview.ts @@ -3,8 +3,7 @@ import { Token } from '@/domain/types/Token' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' import { TransferFromUserFormNormalizedData } from '@/features/dialogs/common/logic/transfer-from-user/form' import { TxOverviewRouteItem } from '@/features/dialogs/common/types' -import { raise } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { NormalizedUnitNumber, raise } from '@marsfoundation/common-universal' import { SavingsDialogTxOverview } from '../../common/types' export interface CreateTxOverviewParams { diff --git a/packages/app/src/features/dialogs/savings/withdraw/logic/useSavingsWithdrawDialog.ts b/packages/app/src/features/dialogs/savings/withdraw/logic/useSavingsWithdrawDialog.ts index 8223f355c..0b0639c84 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/logic/useSavingsWithdrawDialog.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/logic/useSavingsWithdrawDialog.ts @@ -9,8 +9,8 @@ import { InjectedActionsContext, Objective } from '@/features/actions/logic/type import { AssetInputSchema } from '@/features/dialogs/common/logic/form' import { useDebouncedFormValues } from '@/features/dialogs/common/logic/transfer-from-user/form' import { FormFieldsForDialog, PageState, PageStatus } from '@/features/dialogs/common/types' -import { assert, raise } from '@/utils/assert' import { zodResolver } from '@hookform/resolvers/zod' +import { assert, raise } from '@marsfoundation/common-universal' import { useState } from 'react' import { UseFormReturn, useForm } from 'react-hook-form' import { useChainId } from 'wagmi' diff --git a/packages/app/src/features/dialogs/withdraw/logic/assets.ts b/packages/app/src/features/dialogs/withdraw/logic/assets.ts index b44c10f3e..932fe3b4b 100644 --- a/packages/app/src/features/dialogs/withdraw/logic/assets.ts +++ b/packages/app/src/features/dialogs/withdraw/logic/assets.ts @@ -4,8 +4,7 @@ import { MarketInfo } from '@/domain/market-info/marketInfo' import { Token } from '@/domain/types/Token' import { MarketWalletInfo } from '@/domain/wallet/useMarketWalletInfo' import { applyTransformers } from '@/utils/applyTransformers' -import { assert } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber } from '@marsfoundation/common-universal' export function getTokenSupply(marketInfo: MarketInfo, withdrawAsset: TokenWithValue): NormalizedUnitNumber { const position = marketInfo.findOnePositionBySymbol(withdrawAsset.token.symbol) diff --git a/packages/app/src/features/easy-borrow/components/form/Borrow.tsx b/packages/app/src/features/easy-borrow/components/form/Borrow.tsx index f6e753138..3bacabc00 100644 --- a/packages/app/src/features/easy-borrow/components/form/Borrow.tsx +++ b/packages/app/src/features/easy-borrow/components/form/Borrow.tsx @@ -5,7 +5,7 @@ import { Panel } from '@/ui/atoms/panel/Panel' import { AssetInput } from '@/ui/organisms/asset-input/AssetInput' import { cn } from '@/ui/utils/style' import { testIds } from '@/ui/utils/testIds' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' import { XIcon } from 'lucide-react' import { Control } from 'react-hook-form' import { EasyBorrowFormSchema } from '../../logic/form/validation' diff --git a/packages/app/src/features/easy-borrow/logic/form/normalization.ts b/packages/app/src/features/easy-borrow/logic/form/normalization.ts index 306b541d9..3438b294c 100644 --- a/packages/app/src/features/easy-borrow/logic/form/normalization.ts +++ b/packages/app/src/features/easy-borrow/logic/form/normalization.ts @@ -1,6 +1,5 @@ import { TokenWithBalance, TokenWithValue } from '@/domain/common/types' -import { raise } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { NormalizedUnitNumber, raise } from '@marsfoundation/common-universal' import { EasyBorrowFormNormalizedData } from '../types' import type { AssetInputSchema, EasyBorrowFormSchema } from './validation' diff --git a/packages/app/src/features/easy-borrow/logic/useEasyBorrow.ts b/packages/app/src/features/easy-borrow/logic/useEasyBorrow.ts index d9aac9e05..5db2e57d4 100644 --- a/packages/app/src/features/easy-borrow/logic/useEasyBorrow.ts +++ b/packages/app/src/features/easy-borrow/logic/useEasyBorrow.ts @@ -16,9 +16,8 @@ import { useMarketWalletInfo } from '@/domain/wallet/useMarketWalletInfo' import { useTokensInfo } from '@/domain/wallet/useTokens/useTokensInfo' import { InjectedActionsContext, Objective } from '@/features/actions/logic/types' import { sandboxDialogConfig } from '@/features/dialogs/sandbox/SandboxDialog' -import { assert, raise } from '@/utils/assert' import { zodResolver } from '@hookform/resolvers/zod' -import { Percentage } from '@marsfoundation/common-universal' +import { assert, Percentage, raise } from '@marsfoundation/common-universal' import { useCallback, useEffect, useState } from 'react' import { UseFormReturn, useForm } from 'react-hook-form' import { useAccount } from 'wagmi' diff --git a/packages/app/src/features/farm-details/components/farm-info-panel/active/ActiveFarmInfoPanel.tsx b/packages/app/src/features/farm-details/components/farm-info-panel/active/ActiveFarmInfoPanel.tsx index aaf9560aa..cfc00bda4 100644 --- a/packages/app/src/features/farm-details/components/farm-info-panel/active/ActiveFarmInfoPanel.tsx +++ b/packages/app/src/features/farm-details/components/farm-info-panel/active/ActiveFarmInfoPanel.tsx @@ -10,8 +10,7 @@ import { DelayedComponent } from '@/ui/atoms/delayed-component/DelayedComponent' import { Panel } from '@/ui/atoms/panel/Panel' import { cn } from '@/ui/utils/style' import { testIds } from '@/ui/utils/testIds' -import { assert } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber } from '@marsfoundation/common-universal' import { mainnet } from 'viem/chains' import { ApyTooltip } from '../../apy-tooltip/ApyTooltip' import { ChroniclePointsTooltip } from '../../chronicle-points-tooltip/ChroniclePointsTooltip' diff --git a/packages/app/src/features/farm-details/components/farm-info-panel/active/RewardPointsSyncWarning.tsx b/packages/app/src/features/farm-details/components/farm-info-panel/active/RewardPointsSyncWarning.tsx index dea29d958..d9145b9d1 100644 --- a/packages/app/src/features/farm-details/components/farm-info-panel/active/RewardPointsSyncWarning.tsx +++ b/packages/app/src/features/farm-details/components/farm-info-panel/active/RewardPointsSyncWarning.tsx @@ -1,6 +1,6 @@ import { RewardPointsSyncStatus } from '@/features/farm-details/types' import { Alert } from '@/ui/molecules/alert/Alert' -import { assertNever } from '@/utils/assertNever' +import { assertNever } from '@marsfoundation/common-universal' export interface RewardPointsSyncWarningProps { status: RewardPointsSyncStatus diff --git a/packages/app/src/features/farm-details/dialogs/stake/components/TransactionOverview.tsx b/packages/app/src/features/farm-details/dialogs/stake/components/TransactionOverview.tsx index 52179d5ca..33c5f8eac 100644 --- a/packages/app/src/features/farm-details/dialogs/stake/components/TransactionOverview.tsx +++ b/packages/app/src/features/farm-details/dialogs/stake/components/TransactionOverview.tsx @@ -2,7 +2,7 @@ import { Token } from '@/domain/types/Token' import { TransactionOverview } from '@/ui/organisms/transaction-overview/TransactionOverview' import { RouteItem } from '@/ui/organisms/transaction-overview/rows/TransactionOverviewRoute' import { testIds } from '@/ui/utils/testIds' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import type { TxOverview } from '../logic/createTxOverview' interface StakeTransactionOverviewProps { diff --git a/packages/app/src/features/farm-details/dialogs/stake/logic/useStakeDialog.ts b/packages/app/src/features/farm-details/dialogs/stake/logic/useStakeDialog.ts index 830631f37..45d89038e 100644 --- a/packages/app/src/features/farm-details/dialogs/stake/logic/useStakeDialog.ts +++ b/packages/app/src/features/farm-details/dialogs/stake/logic/useStakeDialog.ts @@ -13,9 +13,8 @@ import { } from '@/features/dialogs/common/logic/transfer-from-user/form' import { getTransferFromUserFormValidator } from '@/features/dialogs/common/logic/transfer-from-user/validation' import { FormFieldsForDialog, PageState, PageStatus } from '@/features/dialogs/common/types' -import { assert, raise } from '@/utils/assert' import { zodResolver } from '@hookform/resolvers/zod' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber, raise } from '@marsfoundation/common-universal' import { useState } from 'react' import { UseFormReturn, useForm } from 'react-hook-form' import { useChainId } from 'wagmi' diff --git a/packages/app/src/features/farm-details/dialogs/unstake/components/transaction-overview/TransactionOverview.tsx b/packages/app/src/features/farm-details/dialogs/unstake/components/transaction-overview/TransactionOverview.tsx index d643c2a6a..d168da14a 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/components/transaction-overview/TransactionOverview.tsx +++ b/packages/app/src/features/farm-details/dialogs/unstake/components/transaction-overview/TransactionOverview.tsx @@ -3,7 +3,7 @@ import { HorizontalScroll } from '@/ui/atoms/horizontal-scroll/HorizontalScroll' import { TransactionOverview } from '@/ui/organisms/transaction-overview/TransactionOverview' import { RouteItem } from '@/ui/organisms/transaction-overview/rows/TransactionOverviewRoute' import { testIds } from '@/ui/utils/testIds' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { TxOverview } from '../../logic/createTxOverview' import { UnstakeTransactionOutcome } from './UnstakeTransactionOutcome' diff --git a/packages/app/src/features/farm-details/dialogs/unstake/logic/useUnstakeDialog.ts b/packages/app/src/features/farm-details/dialogs/unstake/logic/useUnstakeDialog.ts index cd2db80ed..5aa15e9de 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/logic/useUnstakeDialog.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/logic/useUnstakeDialog.ts @@ -8,10 +8,9 @@ import { AssetInputSchema } from '@/features/dialogs/common/logic/form' import { useDebouncedFormValues } from '@/features/dialogs/common/logic/transfer-from-user/form' import { FormFieldsForDialog, PageState, PageStatus } from '@/features/dialogs/common/types' import { calculateReward } from '@/features/farm-details/logic/calculateReward' -import { assert, raise } from '@/utils/assert' import { useTimestamp } from '@/utils/useTimestamp' import { zodResolver } from '@hookform/resolvers/zod' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber, raise } from '@marsfoundation/common-universal' import { useEffect, useState } from 'react' import { UseFormReturn, useForm } from 'react-hook-form' import { useChainId } from 'wagmi' diff --git a/packages/app/src/features/farm-details/logic/historic/useFarmHistory.ts b/packages/app/src/features/farm-details/logic/historic/useFarmHistory.ts index 7927738fb..0ee0e3032 100644 --- a/packages/app/src/features/farm-details/logic/historic/useFarmHistory.ts +++ b/packages/app/src/features/farm-details/logic/historic/useFarmHistory.ts @@ -1,8 +1,7 @@ import { getChainConfigEntry } from '@/config/chain' import { Timeframe } from '@/ui/charts/defaults' import { useFilterChartDataByTimeframe } from '@/ui/charts/logic/useFilterDataByTimeframe' -import { raise } from '@/utils/assert' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { CheckedAddress, raise } from '@marsfoundation/common-universal' import { UseQueryResult, useQuery } from '@tanstack/react-query' import { useState } from 'react' import { farmHistoricDataQueryOptions } from './query' diff --git a/packages/app/src/features/farm-details/logic/useFarmDetails.ts b/packages/app/src/features/farm-details/logic/useFarmDetails.ts index 611f9f062..3ffc0963a 100644 --- a/packages/app/src/features/farm-details/logic/useFarmDetails.ts +++ b/packages/app/src/features/farm-details/logic/useFarmDetails.ts @@ -11,8 +11,7 @@ import { Token } from '@/domain/types/Token' import { useTokensInfo } from '@/domain/wallet/useTokens/useTokensInfo' import { sandboxDialogConfig } from '@/features/dialogs/sandbox/SandboxDialog' import { Timeframe } from '@/ui/charts/defaults' -import { raise } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { NormalizedUnitNumber, raise } from '@marsfoundation/common-universal' import { useConnectModal } from '@rainbow-me/rainbowkit' import { useAccount, useChainId } from 'wagmi' import { claimDialogConfig } from '../dialogs/claim/ClaimDialog' diff --git a/packages/app/src/features/market-details/components/oracle-panel/OraclePanel.tsx b/packages/app/src/features/market-details/components/oracle-panel/OraclePanel.tsx index 6e760c862..1edf47622 100644 --- a/packages/app/src/features/market-details/components/oracle-panel/OraclePanel.tsx +++ b/packages/app/src/features/market-details/components/oracle-panel/OraclePanel.tsx @@ -1,6 +1,6 @@ import { UseOracleInfoResult } from '@/domain/oracles/useOracleInfo' import { Skeleton } from '@/ui/atoms/skeleton/Skeleton' -import { assertNever } from '@/utils/assertNever' +import { assertNever } from '@marsfoundation/common-universal' import { FixedOraclePanel } from './components/FixedOraclePanel' import { MarketOraclePanel } from './components/MarketOraclePanel' import { UnderlyingAssetOraclePanel } from './components/UnderlyingAssetOraclePanel' diff --git a/packages/app/src/features/market-details/components/oracle-panel/components/ProvidersList.tsx b/packages/app/src/features/market-details/components/oracle-panel/components/ProvidersList.tsx index d831f2d65..067a18f1b 100644 --- a/packages/app/src/features/market-details/components/oracle-panel/components/ProvidersList.tsx +++ b/packages/app/src/features/market-details/components/oracle-panel/components/ProvidersList.tsx @@ -1,7 +1,7 @@ import { OracleFeedProvider } from '@/config/chain/types' import { assets } from '@/ui/assets' import { testIds } from '@/ui/utils/testIds' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' interface ProvidersListProps { providers: OracleFeedProvider[] diff --git a/packages/app/src/features/market-details/logic/makeWalletOverview.ts b/packages/app/src/features/market-details/logic/makeWalletOverview.ts index 233b53e44..8f5691125 100644 --- a/packages/app/src/features/market-details/logic/makeWalletOverview.ts +++ b/packages/app/src/features/market-details/logic/makeWalletOverview.ts @@ -5,8 +5,7 @@ import { MarketInfo, Reserve } from '@/domain/market-info/marketInfo' import { getValidateBorrowArgs, validateBorrow } from '@/domain/market-validators/validateBorrow' import { MarketWalletInfo } from '@/domain/wallet/useMarketWalletInfo' import { applyTransformers } from '@/utils/applyTransformers' -import { assert } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber } from '@marsfoundation/common-universal' import { WalletOverview } from '../types' export interface MakeWalletOverviewParams { diff --git a/packages/app/src/features/market-details/logic/useMarketDetails.ts b/packages/app/src/features/market-details/logic/useMarketDetails.ts index 0e676b92e..4e5ebb54e 100644 --- a/packages/app/src/features/market-details/logic/useMarketDetails.ts +++ b/packages/app/src/features/market-details/logic/useMarketDetails.ts @@ -1,20 +1,18 @@ import { getChainConfigEntry } from '@/config/chain' import { getNativeAssetInfo } from '@/config/chain/utils/getNativeAssetInfo' +import { paths } from '@/config/paths' import { useCapAutomatorInfo } from '@/domain/cap-automator/useCapAutomatorInfo' import { useD3MInfo } from '@/domain/d3m-info/useD3MInfo' import { NotFoundError } from '@/domain/errors/not-found' import { useMarketInfo } from '@/domain/market-info/useMarketInfo' -import { Token } from '@/domain/types/Token' -import { useMarketWalletInfo } from '@/domain/wallet/useMarketWalletInfo' -import { raise } from '@/utils/assert' -import { useChainId } from 'wagmi' - -import { paths } from '@/config/paths' import { UseOracleInfoResult, useOracleInfo } from '@/domain/oracles/useOracleInfo' import { useSandboxPageRedirect } from '@/domain/sandbox/useSandboxPageRedirect' import { OpenDialogFunction, useOpenDialog } from '@/domain/state/dialogs' +import { Token } from '@/domain/types/Token' +import { useMarketWalletInfo } from '@/domain/wallet/useMarketWalletInfo' import { sandboxDialogConfig } from '@/features/dialogs/sandbox/SandboxDialog' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { CheckedAddress, raise } from '@marsfoundation/common-universal' +import { useChainId } from 'wagmi' import { MarketOverview, WalletOverview } from '../types' import { makeDaiMarketOverview } from './makeDaiMarketOverview' import { makeMarketOverview } from './makeMarketOverview' diff --git a/packages/app/src/features/markets/components/markets-table/MarketsTable.stories.tsx b/packages/app/src/features/markets/components/markets-table/MarketsTable.stories.tsx index fd4ceb969..763aaf934 100644 --- a/packages/app/src/features/markets/components/markets-table/MarketsTable.stories.tsx +++ b/packages/app/src/features/markets/components/markets-table/MarketsTable.stories.tsx @@ -1,14 +1,11 @@ +import { TokenSymbol } from '@/domain/types/TokenSymbol' +import { NormalizedUnitNumber, Percentage, raise } from '@marsfoundation/common-universal' import { WithClassname, WithTooltipProvider } from '@sb/decorators' import { tokens } from '@sb/tokens' import { getMobileStory, getTabletStory } from '@sb/viewports' import { Meta, StoryObj } from '@storybook/react' import { within } from '@storybook/test' import { withRouter } from 'storybook-addon-remix-react-router' - -import { raise } from '@/utils/assert' -import { NormalizedUnitNumber, Percentage } from '@marsfoundation/common-universal' - -import { TokenSymbol } from '@/domain/types/TokenSymbol' import { MarketsTable } from './MarketsTable' const meta: Meta = { diff --git a/packages/app/src/features/markets/logic/transformers.ts b/packages/app/src/features/markets/logic/transformers.ts index e2f23ec63..e9ac8e2c8 100644 --- a/packages/app/src/features/markets/logic/transformers.ts +++ b/packages/app/src/features/markets/logic/transformers.ts @@ -5,7 +5,7 @@ import { sortByUsdValue } from '@/domain/common/sorters' import { MarketInfo, Reserve } from '@/domain/market-info/marketInfo' import { RowClickOptions } from '@/ui/molecules/data-table/DataTable' import { Transformer, TransformerResult, applyTransformers } from '@/utils/applyTransformers' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' import { generatePath } from 'react-router-dom' import { MarketEntry } from '../types' diff --git a/packages/app/src/features/my-portfolio/components/borrow-table/BorrowTable.stories.tsx b/packages/app/src/features/my-portfolio/components/borrow-table/BorrowTable.stories.tsx index b07196015..de369ad1d 100644 --- a/packages/app/src/features/my-portfolio/components/borrow-table/BorrowTable.stories.tsx +++ b/packages/app/src/features/my-portfolio/components/borrow-table/BorrowTable.stories.tsx @@ -1,13 +1,10 @@ +import { NormalizedUnitNumber, Percentage, raise } from '@marsfoundation/common-universal' import { WithTooltipProvider } from '@sb/decorators' import { tokens } from '@sb/tokens' import { getMobileStory, getTabletStory } from '@sb/viewports' import { Meta, StoryObj } from '@storybook/react' import { within } from '@storybook/test' import { withRouter } from 'storybook-addon-remix-react-router' - -import { raise } from '@/utils/assert' -import { NormalizedUnitNumber, Percentage } from '@marsfoundation/common-universal' - import { Borrow } from '../../logic/assets' import { BorrowTable } from './BorrowTable' diff --git a/packages/app/src/features/my-portfolio/components/deposit-table/DepositTable.stories.tsx b/packages/app/src/features/my-portfolio/components/deposit-table/DepositTable.stories.tsx index 578f353a2..2655241e4 100644 --- a/packages/app/src/features/my-portfolio/components/deposit-table/DepositTable.stories.tsx +++ b/packages/app/src/features/my-portfolio/components/deposit-table/DepositTable.stories.tsx @@ -1,13 +1,10 @@ +import { NormalizedUnitNumber, Percentage, raise } from '@marsfoundation/common-universal' import { WithTooltipProvider } from '@sb/decorators' import { tokens } from '@sb/tokens' import { getMobileStory, getTabletStory } from '@sb/viewports' import { Meta, StoryObj } from '@storybook/react' import { within } from '@storybook/test' import { withRouter } from 'storybook-addon-remix-react-router' - -import { raise } from '@/utils/assert' -import { NormalizedUnitNumber, Percentage } from '@marsfoundation/common-universal' - import { Deposit } from '../../logic/assets' import { DepositTable } from './DepositTable' diff --git a/packages/app/src/features/savings/SavingsContainer.tsx b/packages/app/src/features/savings/SavingsContainer.tsx index fd50ab044..10000f861 100644 --- a/packages/app/src/features/savings/SavingsContainer.tsx +++ b/packages/app/src/features/savings/SavingsContainer.tsx @@ -1,6 +1,6 @@ import { useUnsupportedChain } from '@/domain/hooks/useUnsupportedChain' import { withSuspense } from '@/ui/utils/withSuspense' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' import { SavingsSkeleton } from './components/skeleton/SavingsSkeleton' import { useSavings } from './logic/useSavings' import { GuestView } from './views/GuestView' diff --git a/packages/app/src/features/savings/logic/makeMigrationInfo.ts b/packages/app/src/features/savings/logic/makeMigrationInfo.ts index 833a59662..89f827182 100644 --- a/packages/app/src/features/savings/logic/makeMigrationInfo.ts +++ b/packages/app/src/features/savings/logic/makeMigrationInfo.ts @@ -4,8 +4,7 @@ import { TokenSymbol } from '@/domain/types/TokenSymbol' import { TokensInfo } from '@/domain/wallet/useTokens/TokenInfo' import { downgradeDialogConfig } from '@/features/dialogs/savings/migrate/downgrade/DowngradeDialog' import { upgradeDialogConfig } from '@/features/dialogs/savings/migrate/upgrade/UpgradeDialog' -import { assert } from '@/utils/assert' -import { Percentage } from '@marsfoundation/common-universal' +import { assert, Percentage } from '@marsfoundation/common-universal' import { determineApyImprovement } from './determineApyImprovement' export interface UseMigrationInfoParams { diff --git a/packages/app/src/features/savings/logic/makeSavingsMeta.ts b/packages/app/src/features/savings/logic/makeSavingsMeta.ts index 27d06d00d..a44bce716 100644 --- a/packages/app/src/features/savings/logic/makeSavingsMeta.ts +++ b/packages/app/src/features/savings/logic/makeSavingsMeta.ts @@ -1,6 +1,6 @@ import { getChainConfigEntry } from '@/config/chain' import { TokenSymbol } from '@/domain/types/TokenSymbol' -import { assert, raise } from '@/utils/assert' +import { assert, raise } from '@marsfoundation/common-universal' export interface SavingsMetaItem { savingsToken: TokenSymbol diff --git a/packages/app/src/features/savings/views/SavingsDaiAndUSDSView.tsx b/packages/app/src/features/savings/views/SavingsDaiAndUSDSView.tsx index a5ed90b06..a9750f746 100644 --- a/packages/app/src/features/savings/views/SavingsDaiAndUSDSView.tsx +++ b/packages/app/src/features/savings/views/SavingsDaiAndUSDSView.tsx @@ -1,6 +1,6 @@ import { UseSavingsChartsInfoQueryResult } from '@/domain/savings-charts/useSavingsChartsInfoQuery' import { PageLayout } from '@/ui/layouts/PageLayout' -import { assert, raise } from '@/utils/assert' +import { assert, raise } from '@marsfoundation/common-universal' import { PageHeader } from '../components/PageHeader' import { DaiSavingsCharts } from '../components/savings-charts/DaiSavingsCharts' import { UsdsSavingsCharts } from '../components/savings-charts/UsdsSavingsCharts' diff --git a/packages/app/src/features/topbar/logic/useTopbar.ts b/packages/app/src/features/topbar/logic/useTopbar.ts index e4159ac68..a3b2a69a2 100644 --- a/packages/app/src/features/topbar/logic/useTopbar.ts +++ b/packages/app/src/features/topbar/logic/useTopbar.ts @@ -5,8 +5,7 @@ import { sandboxDialogConfig } from '@/features/dialogs/sandbox/SandboxDialog' import { selectNetworkDialogConfig } from '@/features/dialogs/select-network/SelectNetworkDialog' import { SupportedChain } from '@/features/topbar/types' import { getBuildInfo } from '@/ui/utils/getBuildInfo' -import { raise } from '@/utils/assert' -import { CheckedAddress } from '@marsfoundation/common-universal' +import { CheckedAddress, raise } from '@marsfoundation/common-universal' import { useConnectModal } from '@rainbow-me/rainbowkit' import { useAccount, useChainId, useChains } from 'wagmi' import { TopbarProps } from '../components/topbar/Topbar' diff --git a/packages/app/src/pages/MyPortfolio.PageObject.ts b/packages/app/src/pages/MyPortfolio.PageObject.ts index e7cff4d41..cfcf5465b 100644 --- a/packages/app/src/pages/MyPortfolio.PageObject.ts +++ b/packages/app/src/pages/MyPortfolio.PageObject.ts @@ -3,8 +3,7 @@ import { BasePageObject } from '@/test/e2e/BasePageObject' import { buildUrl } from '@/test/e2e/setup' import { parseTable } from '@/test/e2e/utils' import { testIds } from '@/ui/utils/testIds' -import { assert } from '@/utils/assert' -import { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { assert, NormalizedUnitNumber } from '@marsfoundation/common-universal' import { expect } from '@playwright/test' import { z } from 'zod' diff --git a/packages/app/src/test/e2e/processEnv.ts b/packages/app/src/test/e2e/processEnv.ts index 0149392c3..37cb954ab 100644 --- a/packages/app/src/test/e2e/processEnv.ts +++ b/packages/app/src/test/e2e/processEnv.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' export function processEnv(key: string): string { const value = process.env[key] diff --git a/packages/app/src/test/integration/setupUseContractActionRenderer.tsx b/packages/app/src/test/integration/setupUseContractActionRenderer.tsx index 7ad3409ac..aa8a775a3 100644 --- a/packages/app/src/test/integration/setupUseContractActionRenderer.tsx +++ b/packages/app/src/test/integration/setupUseContractActionRenderer.tsx @@ -1,6 +1,6 @@ import { Action } from '@/features/actions/logic/types' import { UseContractActionParams, useContractAction } from '@/features/actions/logic/useContractAction' -import { raise } from '@/utils/assert' +import { raise } from '@marsfoundation/common-universal' import { useMemo } from 'react' import { TransactionReceipt } from 'viem' import { useAccount, useChainId, useConfig } from 'wagmi' diff --git a/packages/app/src/test/utils/addressUtils.ts b/packages/app/src/test/utils/addressUtils.ts index 4a84ebb2d..36124eb6a 100644 --- a/packages/app/src/test/utils/addressUtils.ts +++ b/packages/app/src/test/utils/addressUtils.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { type Address, getAddress } from 'viem' import { asciiToHex, randomHexString } from './hexUtils' diff --git a/packages/app/src/test/utils/hexUtils.ts b/packages/app/src/test/utils/hexUtils.ts index 5bc5b75e6..5eb307aab 100644 --- a/packages/app/src/test/utils/hexUtils.ts +++ b/packages/app/src/test/utils/hexUtils.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import type { Hex } from 'viem' export function hexStringToHex(input: string): Hex { diff --git a/packages/app/src/ui/atoms/button/Button.tsx b/packages/app/src/ui/atoms/button/Button.tsx index c29b4beaf..4aa330e0c 100644 --- a/packages/app/src/ui/atoms/button/Button.tsx +++ b/packages/app/src/ui/atoms/button/Button.tsx @@ -1,5 +1,5 @@ import { cn } from '@/ui/utils/style' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { Slot } from '@radix-ui/react-slot' import { type VariantProps, cva } from 'class-variance-authority' import * as React from 'react' diff --git a/packages/app/src/ui/atoms/form/Form.tsx b/packages/app/src/ui/atoms/form/Form.tsx index ff6fe94b1..d695bf016 100644 --- a/packages/app/src/ui/atoms/form/Form.tsx +++ b/packages/app/src/ui/atoms/form/Form.tsx @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import * as React from 'react' import { FieldPath, FieldValues, FormProvider, useFormContext } from 'react-hook-form' diff --git a/packages/app/src/ui/atoms/icon-box/IconBox.tsx b/packages/app/src/ui/atoms/icon-box/IconBox.tsx index 0fec6be99..9a16b50fb 100644 --- a/packages/app/src/ui/atoms/icon-box/IconBox.tsx +++ b/packages/app/src/ui/atoms/icon-box/IconBox.tsx @@ -1,5 +1,5 @@ -import { assertNever } from '@/utils/assertNever' import { RequiredProps } from '@/utils/types' +import { assertNever } from '@marsfoundation/common-universal' import { type VariantProps, cva } from 'class-variance-authority' import { AlertTriangleIcon, CheckCircle2Icon, InfoIcon } from 'lucide-react' import { forwardRef } from 'react' diff --git a/packages/app/src/ui/charts/components/ChartTabsPanel.tsx b/packages/app/src/ui/charts/components/ChartTabsPanel.tsx index 361b18484..9498014d5 100644 --- a/packages/app/src/ui/charts/components/ChartTabsPanel.tsx +++ b/packages/app/src/ui/charts/components/ChartTabsPanel.tsx @@ -2,7 +2,7 @@ import { DelayedComponent } from '@/ui/atoms/delayed-component/DelayedComponent' import { Panel } from '@/ui/atoms/panel/Panel' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/ui/atoms/tabs/Tabs' import { useResizeObserver } from '@/ui/utils/useResizeObserver' -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import { AlertTriangle, Loader2 } from 'lucide-react' import { useRef, useState } from 'react' import { Timeframe } from '../defaults' diff --git a/packages/app/src/ui/utils/testIds.ts b/packages/app/src/ui/utils/testIds.ts index 68854f7f8..fb5bf3038 100644 --- a/packages/app/src/ui/utils/testIds.ts +++ b/packages/app/src/ui/utils/testIds.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' // @note: only allowed value here is 'true' a function or nested object // actual value of data test id (string) is generated based on a path in the object tree diff --git a/packages/app/src/utils/applyTransformers.ts b/packages/app/src/utils/applyTransformers.ts index d5f86e6d5..eb207c90e 100644 --- a/packages/app/src/utils/applyTransformers.ts +++ b/packages/app/src/utils/applyTransformers.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' export type TransformerResult = | TResult diff --git a/packages/app/src/utils/assert.ts b/packages/app/src/utils/assert.ts deleted file mode 100644 index f140624af..000000000 --- a/packages/app/src/utils/assert.ts +++ /dev/null @@ -1,24 +0,0 @@ -export function assert(condition: unknown, error?: string | Error): asserts condition { - if (!condition) { - if (error) { - raise(typeof error === 'string' ? `assertion failed: ${error}` : error) - } else { - raise('assertion failed') - } - } -} - -export class AssertionError extends Error { - constructor(message: string) { - super(message) - this.name = 'AssertionError' - } -} - -export function raise(error: string | Error): never { - if (error instanceof Error) { - throw error - } - - throw new AssertionError(error) -} diff --git a/packages/app/src/utils/assertNever.ts b/packages/app/src/utils/assertNever.ts deleted file mode 100644 index b332c8024..000000000 --- a/packages/app/src/utils/assertNever.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function assertNever(x: never): never { - throw new Error(`Unexpected object: ${x}`) -} diff --git a/packages/app/src/utils/bigNumber.ts b/packages/app/src/utils/bigNumber.ts index ca2c63ac4..4349c1969 100644 --- a/packages/app/src/utils/bigNumber.ts +++ b/packages/app/src/utils/bigNumber.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' import BigNumber from 'bignumber.js' export type NumberLike = string | number | BigNumber | bigint diff --git a/packages/app/src/utils/strings.ts b/packages/app/src/utils/strings.ts index a2048240f..f29be9c85 100644 --- a/packages/app/src/utils/strings.ts +++ b/packages/app/src/utils/strings.ts @@ -1,4 +1,4 @@ -import { assert } from '@/utils/assert' +import { assert } from '@marsfoundation/common-universal' export function trimCharEnd(str: string, char: string): string { assert(char.length === 1, 'char has to be a single character')