Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: currency model imports #5859

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"@leather.io/bitcoin": "0.11.2",
"@leather.io/constants": "0.9.2",
"@leather.io/crypto": "1.4.2",
"@leather.io/models": "0.13.0",
"@leather.io/models": "0.14.0",
"@leather.io/query": "2.10.0",
"@leather.io/stacks": "1.0.2",
"@leather.io/tokens": "0.9.0",
Expand Down Expand Up @@ -361,7 +361,9 @@
},
"resolutions": {
"axios": "1.7.4",
"body-parser": "1.20.3",
"braces": "3.0.3",
"dset": "3.1.4",
"fast-xml-parser": "4.4.1",
"nanoid": "3.3.4",
"socket.io-parser": "4.2.4",
Expand Down
61 changes: 36 additions & 25 deletions pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions src/app/common/hooks/use-convert-to-fiat-amount.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useCallback } from 'react';

import type { CryptoCurrencies, Money } from '@leather.io/models';
import type { CryptoCurrency, Money } from '@leather.io/models';
import { useCryptoCurrencyMarketDataMeanAverage } from '@leather.io/query';
import { baseCurrencyAmountInQuote } from '@leather.io/utils';

export function useConvertCryptoCurrencyToFiatAmount(currency: CryptoCurrencies) {
export function useConvertCryptoCurrencyToFiatAmount(currency: CryptoCurrency) {
// TODO: unsafe type assumption
const cryptoCurrencyMarketData = useCryptoCurrencyMarketDataMeanAverage(
currency as 'BTC' | 'STX'
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/fees-row/components/custom-fee-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { SharedComponentsSelectors } from '@tests/selectors/shared-component.sel
import { useField } from 'formik';
import { Flex, Stack, styled } from 'leather-styles/jsx';

import type { CryptoCurrencies, StacksFeeEstimate } from '@leather.io/models';
import type { CryptoCurrency, StacksFeeEstimate } from '@leather.io/models';
import { stxToMicroStx } from '@leather.io/utils';

import { SendFormWarningMessages } from '@app/common/warning-messages';

interface CustomFeeFieldProps {
feeCurrencySymbol: CryptoCurrencies;
feeCurrencySymbol: CryptoCurrency;
lowFeeEstimate: StacksFeeEstimate;
setFieldWarning(value: string): void;
disableFeeSelection?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/fees-row/components/transaction-fee.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { SharedComponentsSelectors } from '@tests/selectors/shared-component.selectors';
import { styled } from 'leather-styles/jsx';

import type { CryptoCurrencies, Money } from '@leather.io/models';
import type { CryptoCurrency, Money } from '@leather.io/models';
import { formatDustUsdAmounts, i18nFormatCurrency } from '@leather.io/utils';

import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip';

interface TransactionFeeProps {
fee: string | number;
feeCurrencySymbol: CryptoCurrencies;
feeCurrencySymbol: CryptoCurrency;
usdAmount: Money | null;
}
export function TransactionFee({ fee, feeCurrencySymbol, usdAmount }: TransactionFeeProps) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type React from 'react';

import type { Blockchains, Currencies } from '@leather.io/models';
import type { Blockchains, Currency } from '@leather.io/models';
import { ItemLayout, Pressable } from '@leather.io/ui';

import { capitalize } from '@app/common/utils';
Expand All @@ -12,7 +12,7 @@ import { ConnectLedgerButton } from './connect-ledger-asset-button';
interface ConnectLedgerAssetItemFallbackProps {
chain: Blockchains;
icon: React.ReactNode;
symbol: Currencies;
symbol: Currency;
variant: AssetListVariant;
}
export function ConnectLedgerAssetItemFallback({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom';

import { AuthType, StacksTransaction } from '@stacks/transactions';

import type { CryptoCurrencies } from '@leather.io/models';
import type { CryptoCurrency } from '@leather.io/models';
import { delay, isError, isString } from '@leather.io/utils';

import { finalizeTxSignature } from '@shared/actions/finalize-tx-signature';
Expand All @@ -25,7 +25,7 @@ async function simulateShortDelayToAvoidUndefinedTabId() {
}

interface UseStacksBroadcastTransactionArgs {
token: CryptoCurrencies;
token: CryptoCurrency;
decimals?: number;
isIncreaseFeeTransaction?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@stacks/transactions';
import BigNumber from 'bignumber.js';

import type { CryptoCurrencies } from '@leather.io/models';
import type { CryptoCurrency } from '@leather.io/models';
import {
useCryptoCurrencyMarketDataMeanAverage,
useGetStacksNetworkBlockTimeQuery,
Expand All @@ -30,7 +30,7 @@ import { getEstimatedConfirmationTime } from '@app/common/transactions/stacks/tr
import { removeTrailingNullCharacters } from '@app/common/utils';
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';

export function useStacksTransactionSummary(token: CryptoCurrencies) {
export function useStacksTransactionSummary(token: CryptoCurrency) {
// TODO: unsafe type assumption
const tokenMarketData = useCryptoCurrencyMarketDataMeanAverage(token as 'BTC' | 'STX');
const { isTestnet } = useCurrentNetworkState();
Expand Down
10 changes: 5 additions & 5 deletions src/app/pages/fund/components/fiat-providers.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import OkxIcon from '@assets/images/fund/fiat-providers/okx-icon.png';
import TransakIcon from '@assets/images/fund/fiat-providers/transak-icon.png';
import { generateOnRampURL } from '@coinbase/cbpay-js';

import type { CryptoCurrencies } from '@leather.io/models';
import type { CryptoCurrency } from '@leather.io/models';

import { COINBASE_APP_ID, MOONPAY_API_KEY, TRANSAK_API_KEY } from '@shared/environment';

Expand Down Expand Up @@ -43,7 +43,7 @@ export const activeFiatProviderIcons: Record<ActiveFiatProvider['name'], string>
[ActiveFiatProviders.Transak]: TransakIcon,
};

function makeCoinbaseUrl(address: string, symbol: CryptoCurrencies) {
function makeCoinbaseUrl(address: string, symbol: CryptoCurrency) {
const code = symbol.toUpperCase();

const onRampURL = generateOnRampURL({
Expand All @@ -58,12 +58,12 @@ function makeCoinbaseUrl(address: string, symbol: CryptoCurrencies) {
return onRampURL;
}

function makeMoonPayUrl(address: string, symbol: CryptoCurrencies) {
function makeMoonPayUrl(address: string, symbol: CryptoCurrency) {
const code = symbol.toLowerCase();
return `https://buy.moonpay.com?apiKey=${MOONPAY_API_KEY}&currencyCode=${code}&walletAddress=${address}`;
}

function makeTransakUrl(address: string, symbol: CryptoCurrencies) {
function makeTransakUrl(address: string, symbol: CryptoCurrency) {
const screenTitle = 'Buy Stacks';
const code = symbol.toUpperCase();

Expand All @@ -82,7 +82,7 @@ interface GetProviderNameArgs {
hasFastCheckoutProcess: boolean;
key: string;
name: string;
symbol: CryptoCurrencies;
symbol: CryptoCurrency;
}
export function getProviderUrl({
address,
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/fund/components/fund.layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Stack, styled } from 'leather-styles/jsx';

import type { Blockchains, CryptoCurrencies } from '@leather.io/models';
import type { Blockchains, CryptoCurrency } from '@leather.io/models';

import { HasChildren } from '@app/common/has-children';

interface FundLayoutProps extends HasChildren {
blockchain: Blockchains;
symbol: CryptoCurrencies;
symbol: CryptoCurrency;
}
export function FundLayout({ blockchain, symbol, children }: FundLayoutProps) {
return (
Expand Down
Loading
Loading