Skip to content

Commit

Permalink
refactor: move money and market utils out of extension
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed May 31, 2024
1 parent e9d7ed2 commit ab7fb16
Show file tree
Hide file tree
Showing 65 changed files with 200 additions and 392 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@
"@dlc-link/dlc-tools": "1.1.1",
"@fungible-systems/zone-file": "2.0.0",
"@hirosystems/token-metadata-api-client": "1.2.0",
"@leather-wallet/models": "0.6.5",
"@leather-wallet/query": "0.6.7",
"@leather-wallet/tokens": "0.4.0",
"@leather-wallet/utils": "0.6.5",
"@leather-wallet/models": "0.6.6",
"@leather-wallet/query": "0.6.8",
"@leather-wallet/tokens": "0.5.0",
"@leather-wallet/utils": "0.6.6",
"@ledgerhq/hw-transport-webusb": "6.27.19",
"@noble/hashes": "1.3.2",
"@noble/secp256k1": "2.0.0",
Expand Down Expand Up @@ -254,7 +254,7 @@
"@btckit/types": "0.0.19",
"@chromatic-com/storybook": "1.2.23",
"@leather-wallet/prettier-config": "0.4.0",
"@leather-wallet/rpc": "0.3.9",
"@leather-wallet/rpc": "0.3.10",
"@leather-wallet/panda-preset": "0.0.5",
"@ls-lint/ls-lint": "2.2.3",
"@mdx-js/loader": "3.0.0",
Expand Down
62 changes: 31 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions src/app/common/asset-utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Money } from '@leather-wallet/models';

import type { MarketData } from '@shared/models/market.model';

import { baseCurrencyAmountInQuote } from './money/calculate-money';
import { i18nFormatCurrency } from './money/format-money';
import { isMoneyGreaterThanZero } from './money/money.utils';
import type { MarketData, Money } from '@leather-wallet/models';
import {
baseCurrencyAmountInQuote,
i18nFormatCurrency,
isMoneyGreaterThanZero,
} from '@leather-wallet/utils';

export function sortAssetsByName<T extends { name: string }[]>(assets: T) {
return assets
Expand Down
4 changes: 1 addition & 3 deletions src/app/common/hooks/balance/use-total-balance.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useMemo } from 'react';

import { useCryptoCurrencyMarketDataMeanAverage } from '@leather-wallet/query';
import { createMoney } from '@leather-wallet/utils';
import { baseCurrencyAmountInQuote, createMoney, i18nFormatCurrency } from '@leather-wallet/utils';

import { baseCurrencyAmountInQuote } from '@app/common/money/calculate-money';
import { i18nFormatCurrency } from '@app/common/money/format-money';
import { useBtcCryptoAssetBalanceNativeSegwit } from '@app/query/bitcoin/balance/btc-balance-native-segwit.hooks';
import { useStxCryptoAssetBalance } from '@app/query/stacks/balance/account-balance.hooks';

Expand Down
3 changes: 1 addition & 2 deletions src/app/common/hooks/use-bitcoin-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useCalculateBitcoinFiatValue,
useCryptoCurrencyMarketDataMeanAverage,
} from '@leather-wallet/query';
import { createMoneyFromDecimal, satToBtc } from '@leather-wallet/utils';
import { createMoneyFromDecimal, i18nFormatCurrency, satToBtc } from '@leather-wallet/utils';
import { bytesToHex } from '@stacks/common';

import {
Expand All @@ -27,7 +27,6 @@ import {
import { useCurrentNetwork } from '@app/store/networks/networks.selectors';

import { initialSearchParams } from '../initial-search-params';
import { i18nFormatCurrency } from '../money/format-money';
import { useDefaultRequestParams } from './use-default-request-search-params';

export interface SimplifiedBitcoinContract {
Expand Down
3 changes: 1 addition & 2 deletions src/app/common/hooks/use-convert-to-fiat-amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { useCallback } from 'react';

import type { Money } from '@leather-wallet/models';
import { useCryptoCurrencyMarketDataMeanAverage } from '@leather-wallet/query';
import { baseCurrencyAmountInQuote } from '@leather-wallet/utils';

import { CryptoCurrencies } from '@shared/models/currencies.model';

import { baseCurrencyAmountInQuote } from '../money/calculate-money';

export function useConvertCryptoCurrencyToFiatAmount(currency: CryptoCurrencies) {
// TODO: unsafe type assumption
const cryptoCurrencyMarketData = useCryptoCurrencyMarketDataMeanAverage(
Expand Down
71 changes: 0 additions & 71 deletions src/app/common/money/calculate-money.spec.ts

This file was deleted.

58 changes: 0 additions & 58 deletions src/app/common/money/calculate-money.ts

This file was deleted.

37 changes: 0 additions & 37 deletions src/app/common/money/format-money.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/app/common/money/money.utils.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import type { UtxoResponseItem } from '@leather-wallet/query';
import { sumNumbers } from '@leather-wallet/utils';
import { sumMoney, sumNumbers } from '@leather-wallet/utils';
import BigNumber from 'bignumber.js';
import { validate } from 'bitcoin-address-validation';

import type { TransferRecipient } from '@shared/models/form.model';

import { sumMoney } from '@app/common/money/calculate-money';

import { filterUneconomicalUtxos, getSizeInfo } from '../utils';

export class InsufficientFundsError extends Error {
Expand Down
Loading

0 comments on commit ab7fb16

Please sign in to comment.