@dexknot/shared

v1.1.0

Published

The submodule is a part of monorepo [Dexknot](https://github.com/yozh-io/dexknot).

Downloads

1

Readme

shared

The submodule is a part of monorepo Dexknot.

Contains store, themes, locales, hooks, utils, types used in different applications.

Install

  • yarn
yarn add --dev @dexknot/shared

or

  • npm
npm install --dev @dexknot/shared

Importing

Individual components can be imported:

//Hooks
import {
  hooks
} from '@dexknot/shared';
  const {
    useAbortableTimeout,
    useAdvancedSettings,
    useAlertMessage,
    useApproveStatus,
    useBuildSwapTx,
    useExecuteApprove,
    useExecuteQuote,
    useExecuteSwap,
    useFeeRange,
    useGasPriceOptions,
    useInterval,
    useLocalStorage,
    useProtocolInstances,
    useRate,
    useTokens,
    useTotalRouteSteps,
    useUpdateAllowance,
    useUpdateParams,
    useUpdateSpender,
    useUpdateUsdcPricesForBalances,
    useUpdateUsdcPricesForSelectedTokens,
    useUsdStablecoins,
    useWaitTime,
    useWidgetHeightContext,
    WidgetHeightProvider
  } = hooks,

  //Locales
  import {
    locales
  } from '@dexknot/shared';
  const {
    translationEN,
    translationUA,
    SUPPORTED_LOCALES,
    DEFAULT_LOCALE
  } = locales,

  //Store
  import {
    store
  } from '@dexknot/shared';
  const {
    AppState,
    AppDispatch,
    addTokenToAllTokens,
    approveInitialState,
    approveReducer,
    applyDefaultSettings,
    cleanLastTxHash,
    configuredStore,
    fetchCoinInfoById,
    fetchTokens,
    updateDecimalsForTypedValue,
    recalculateTypedValueOnSelectCurrency,
    recalculateTypedValueOnSwitchCurrency,
    removeTokenFromAllTokens,
    rootReducer,
    selectCurrency,
    selectSwapProtocol,
    setBuildTxError,
    setCustomGasPrice,
    setDefaultSettings,
    setEstimateGasError,
    setExplorer,
    setGasPriceInfo,
    setGasPriceSettingsMode,
    setIsWaitingTx,
    setLastTxHash,
    setSlippage,
    setSpender,
    setTxErrorMessage,
    setRecipient,
    swapInitialState,
    swapReducer,
    switchCurrencies,
    tokensInitialState,
    tokensReducer,
    txInitialState,
    txReducer,
    typeInput,
    userInitialState,
    userReducer,
    updateAllQuotes,
    updateAllTokenBalances,
    updatePriceTokenInUsd,
    updateTokenInfo
  } = store,

  //Theme
  import {
    theme
  } from '@dexknot/shared';
  const {
    baseTypographyOptions,
    darkTheme,
    defaultTheme
  } = theme,

  //Types
  import {
    types
  } from '@dexknot/shared';
  const {
    ApproveState,
    AppStateTypes,
    SupportedLocale,
    SwapState,
    TokensState,
    TransactionsState,
    UserState
  } = types,

  //Utils
  import {
    utils
  } from '@dexknot/shared';
  const {
    bigFloatToFixed,
    calculateGasMargin,
    calculateRoughFees,
    calculateTxFee,
    catchNetworkError,
    convertStringCase,
    countOfCustomTokens,
    createQuoteInfoLabel,
    createTxCostLabel,
    formatGweiFixed,
    formatUsdFixed,
    getDefaultGasLimit,
    getErrorMessage,
    getFilteredNetworkListButton,
    getNameOrTokensInRoutes,
    getSupportedChainsByProtocols
    getTxStatus,
    isSupportedChain,
    parseGwei,
    roundPercentInRoutes,
    toHex,
    validateDefaultChainId,
    validateDefaultTokensOptions,
    validateDefaultValue,
    validateReferrerOptions,
  } = utils