Skip to content

Commit

Permalink
refactor: Create @contexts folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovipu committed Dec 7, 2024
1 parent 4d000d6 commit 8e618b3
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Outlet, RouterProvider, createBrowserRouter } from 'react-router-dom';

import Footer from '@components/Footer';
import Nav from '@components/Nav';
import { WalletProvider } from '@contexts/wallet-context';
import BorrowPage from '@pages/_borrow/BorrowPage';
import LandingPage from '@pages/_landing/LandingPage';
import LendPage from '@pages/_lend/LendPage';
import LiquidatePage from '@pages/_liquidate/LiquidatePage';
import WelcomePage from '@pages/_welcome/WelcomePage';
import { WalletProvider } from './stellar-wallet';

const PageWrapper = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/CryptoAmountSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useWallet } from '@contexts/wallet-context';
import { isBalanceZero } from '@lib/converters';
import { formatCentAmount } from '@lib/formatting';
import type { SupportedCurrency } from 'currencies';
import { isNil } from 'ramda';
import type { ChangeEvent } from 'react';
import { useWallet } from 'src/stellar-wallet';
import { Button } from './Button';

export interface CryptoAmountSelectorProps {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useWallet } from '@contexts/wallet-context';
import type { PropsWithChildren } from 'react';
import { Link } from 'react-router-dom';
import { useWallet } from 'src/stellar-wallet';
import logo from '/public/laina_v3_shrinked.png';
import { Button } from './Button';
import Identicon from './Identicon';
Expand Down
2 changes: 1 addition & 1 deletion src/components/WalletCard/AssetsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button } from '@components/Button';
import { Loading } from '@components/Loading';
import { useWallet } from '@contexts/wallet-context';
import { formatAmount, toDollarsFormatted } from '@lib/formatting';
import type { SupportedCurrency } from 'currencies';
import { isNil } from 'ramda';
import { useState } from 'react';
import { CURRENCY_BINDINGS } from 'src/currency-bindings';
import { useWallet } from 'src/stellar-wallet';

export interface AssetsModalProps {
modalId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/WalletCard/LoansModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { useState } from 'react';

import { Button } from '@components/Button';
import { Loading } from '@components/Loading';
import { useWallet } from '@contexts/wallet-context';
import { contractClient as loanManagerClient } from '@contracts/loan_manager';
import { formatAmount, toDollarsFormatted } from '@lib/formatting';
import type { SupportedCurrency } from 'currencies';
import { CURRENCY_BINDINGS } from 'src/currency-bindings';
import { useWallet } from 'src/stellar-wallet';

export interface AssetsModalProps {
modalId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/WalletCard/WalletCard.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Loading } from '@components/Loading';
import { type PositionsRecord, type PriceRecord, useWallet } from '@contexts/wallet-context';
import { formatCentAmount, toCents } from '@lib/formatting';
import type { SupportedCurrency } from 'currencies';
import { isNil } from 'ramda';
import { type PositionsRecord, type PriceRecord, useWallet } from 'src/stellar-wallet';
import { Button } from '../Button';
import { Card } from '../Card';
import Identicon from '../Identicon';
Expand Down
2 changes: 1 addition & 1 deletion src/stellar-wallet.tsx → src/contexts/wallet-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type PropsWithChildren, createContext, useContext, useEffect, useState
import { contractClient as loanManagerClient } from '@contracts/loan_manager';
import { getBalances } from '@lib/horizon';
import { type SupportedCurrency, isSupportedCurrency } from 'currencies';
import { CURRENCY_BINDINGS_ARR } from './currency-bindings';
import { CURRENCY_BINDINGS_ARR } from '../currency-bindings';

const WALLET_TIMEOUT_DAYS = 3;

Expand Down
2 changes: 1 addition & 1 deletion src/pages/_borrow/BorrowModal/BorrowModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useWallet } from '@contexts/wallet-context';
import type { CurrencyBinding } from 'src/currency-bindings';
import { useWallet } from 'src/stellar-wallet';
import { BorrowStep } from './BorrowStep';
import { TrustLineStep } from './TrustlineStep';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/_borrow/BorrowModal/BorrowStep.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Button } from '@components/Button';
import { CryptoAmountSelector } from '@components/CryptoAmountSelector';
import { Loading } from '@components/Loading';
import { type BalanceRecord, type PriceRecord, type Wallet, useWallet } from '@contexts/wallet-context';
import { contractClient as loanManagerClient } from '@contracts/loan_manager';
import { getIntegerPart, to7decimals } from '@lib/converters';
import { SCALAR_7, fromCents, toCents } from '@lib/formatting';
import type { SupportedCurrency } from 'currencies';
import { type ChangeEvent, useState } from 'react';
import { CURRENCY_BINDINGS, CURRENCY_BINDINGS_ARR, type CurrencyBinding } from 'src/currency-bindings';
import { type BalanceRecord, type PriceRecord, type Wallet, useWallet } from 'src/stellar-wallet';

const HEALTH_FACTOR_AUTO_THRESHOLD = 1.65;
const HEALTH_FACTOR_MIN_THRESHOLD = 1.2;
Expand Down
5 changes: 3 additions & 2 deletions src/pages/_borrow/BorrowModal/TrustlineStep.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useState } from 'react';

import { Button } from '@components/Button';
import { Loading } from '@components/Loading';
import type { SignTransaction, Wallet } from '@contexts/wallet-context';
import { createAddTrustlineTransaction, sendTransaction } from '@lib/horizon';
import { useState } from 'react';
import type { CurrencyBinding } from 'src/currency-bindings';
import type { SignTransaction, Wallet } from 'src/stellar-wallet';

export interface TrustLineStepProps {
onClose: () => void;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_borrow/BorrowableAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { useCallback, useEffect, useMemo, useState } from 'react';

import { Button } from '@components/Button';
import { Loading } from '@components/Loading';
import { useWallet } from '@contexts/wallet-context';
import { contractClient as loanManagerClient } from '@contracts/loan_manager';
import { isBalanceZero } from '@lib/converters';
import { formatAPR } from '@lib/formatting';
import type { CurrencyBinding } from 'src/currency-bindings';
import { useWallet } from 'src/stellar-wallet';
import { BorrowModal } from './BorrowModal/BorrowModal';

interface BorrowableAssetCardProps {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_lend/DepositModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button } from '@components/Button';
import { CryptoAmountSelector } from '@components/CryptoAmountSelector';
import { Loading } from '@components/Loading';
import { useWallet } from '@contexts/wallet-context';
import { getIntegerPart, to7decimals } from '@lib/converters';
import { SCALAR_7, toCents } from '@lib/formatting';
import { type ChangeEvent, useState } from 'react';
import type { CurrencyBinding } from 'src/currency-bindings';
import { useWallet } from 'src/stellar-wallet';

export interface DepositModalProps {
modalId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_lend/LendableAsset.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button } from '@components/Button';
import { Loading } from '@components/Loading';
import { type Balance, useWallet } from '@contexts/wallet-context';
import { isBalanceZero } from '@lib/converters';
import { formatAPY, formatAmount, toDollarsFormatted } from '@lib/formatting';
import { isNil } from 'ramda';
import { useCallback, useEffect, useState } from 'react';
import type { CurrencyBinding } from 'src/currency-bindings';
import { type Balance, useWallet } from 'src/stellar-wallet';
import { DepositModal } from './DepositModal';

export interface LendableAssetProps {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"@components/*": ["src/components/*"],
"@pages/*": ["src/pages/*"],
"@contracts/*": ["src/contracts/*"],
"@lib/*": ["src/lib/*"]
"@lib/*": ["src/lib/*"],
"@contexts/*": ["src/contexts/*"]
}
}
}

0 comments on commit 8e618b3

Please sign in to comment.