From 7e5f343f5dcac1673ce2e4b826f44f0cb8a19314 Mon Sep 17 00:00:00 2001 From: Masood Abdolian Date: Wed, 13 Nov 2024 12:27:36 +0000 Subject: [PATCH 1/5] feat: Revise the Prettier configuration to ensure that imports are sorted --- .changeset/tender-crews-drum.md | 5 + .prettierrc | 14 +- .vscode/extensions.json | 3 + apps/rosen/app/(bridge)/BridgeForm.tsx | 18 +- apps/rosen/app/(bridge)/BridgeTransaction.tsx | 5 +- .../app/(bridge)/ConnectOrSubmitButton.tsx | 2 +- apps/rosen/app/(bridge)/UseAllAmount.tsx | 2 +- apps/rosen/app/(bridge)/page.tsx | 24 +- apps/rosen/app/App.tsx | 11 +- apps/rosen/app/Toolbar.tsx | 10 +- apps/rosen/app/_actions/calculateFee.ts | 10 +- apps/rosen/app/_actions/validateAddress.ts | 4 +- apps/rosen/app/_backend/assets/repository.ts | 3 +- apps/rosen/app/_backend/events/repository.ts | 1 - apps/rosen/app/_backend/events/services.ts | 3 +- apps/rosen/app/_backend/utils.ts | 1 + apps/rosen/app/_hooks/useBridgeForm.ts | 12 +- apps/rosen/app/_hooks/useMaxTransfer.ts | 4 +- apps/rosen/app/_hooks/useNetwork.ts | 5 +- apps/rosen/app/_hooks/useTokenBalance.ts | 5 +- apps/rosen/app/_hooks/useTransaction.ts | 6 +- apps/rosen/app/_hooks/useTransactionFees.ts | 9 +- .../app/_hooks/useTransactionFormData.ts | 3 +- apps/rosen/app/_hooks/useWallet.ts | 7 +- .../app/_networks/bitcoin/getMaxTransfer.ts | 3 +- apps/rosen/app/_networks/bitcoin/index.ts | 9 +- apps/rosen/app/_networks/bitcoin/server.ts | 4 +- apps/rosen/app/_networks/cardano/index.ts | 15 +- apps/rosen/app/_networks/cardano/server.ts | 4 +- apps/rosen/app/_networks/ergo/index.ts | 7 +- apps/rosen/app/_networks/ergo/server.ts | 4 +- .../app/_networks/ethereum/getMaxTransfer.ts | 3 +- apps/rosen/app/_networks/ethereum/index.ts | 7 +- apps/rosen/app/_networks/ethereum/server.ts | 4 +- apps/rosen/app/_networks/index.ts | 4 +- apps/rosen/app/_theme/theme.tsx | 33 +-- apps/rosen/app/_types/network.ts | 3 +- apps/rosen/app/_utils/getMaxTransfer.ts | 5 +- .../app/api/v1/assets/detail/[id]/route.ts | 1 - .../api/v1/assets/detail/[id]/validations.ts | 1 + apps/rosen/app/api/v1/assets/route.ts | 1 - apps/rosen/app/api/v1/assets/validations.ts | 3 +- apps/rosen/app/api/v1/events/route.ts | 1 - apps/rosen/app/api/v1/events/validations.ts | 1 + apps/rosen/app/api/v1/withValidation.ts | 1 + apps/rosen/app/assets/TableRow.tsx | 20 +- apps/rosen/app/assets/page.tsx | 10 +- apps/rosen/app/events/TableRow.tsx | 8 +- apps/rosen/app/events/page.tsx | 9 +- apps/rosen/unitTests/utils/index.test.ts | 3 +- apps/rosen/vitest.config.ts | 3 +- package-lock.json | 220 ++++++++++++++++-- package.json | 1 + 53 files changed, 376 insertions(+), 179 deletions(-) create mode 100644 .changeset/tender-crews-drum.md create mode 100644 .vscode/extensions.json diff --git a/.changeset/tender-crews-drum.md b/.changeset/tender-crews-drum.md new file mode 100644 index 00000000..eb8f3af0 --- /dev/null +++ b/.changeset/tender-crews-drum.md @@ -0,0 +1,5 @@ +--- +'@rosen-bridge/rosen-app': minor +--- + +Revise the Prettier configuration to ensure that imports are sorted diff --git a/.prettierrc b/.prettierrc index 544138be..dd317443 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,15 @@ { - "singleQuote": true + "quoteProps": "consistent", + "singleQuote": true, + "importOrder": [ + "^(@?react|@?next)", + "", + "^@/(.*)$", + "^[.](.*)" + ], + "importOrderCaseInsensitive": true, + "importOrderParserPlugins": ["typescript", "jsx"], + "importOrderSeparation": true, + "importOrderSortSpecifiers": false, + "plugins": ["@trivago/prettier-plugin-sort-imports"] } diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..c83e2634 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["esbenp.prettier-vscode"] +} diff --git a/apps/rosen/app/(bridge)/BridgeForm.tsx b/apps/rosen/app/(bridge)/BridgeForm.tsx index 7e756eff..b1e54331 100644 --- a/apps/rosen/app/(bridge)/BridgeForm.tsx +++ b/apps/rosen/app/(bridge)/BridgeForm.tsx @@ -1,8 +1,9 @@ 'use client'; import { useCallback, ChangeEvent } from 'react'; -import { getDecimalString } from '@rosen-ui/utils'; +import { Autocomplete } from '@mui/material'; +import { RosenChainToken } from '@rosen-bridge/tokens'; import { Grid, TextField, @@ -14,20 +15,19 @@ import { SvgIcon, Alert, } from '@rosen-bridge/ui-kit'; +import { NETWORKS } from '@rosen-ui/constants'; +import { getDecimalString } from '@rosen-ui/utils'; import useBridgeForm from '@/_hooks/useBridgeForm'; -import { useNetwork } from '@/_hooks/useNetwork'; - -import { getTokenNameAndId } from '@/_utils'; import { useMaxTransfer } from '@/_hooks/useMaxTransfer'; +import { useNetwork } from '@/_hooks/useNetwork'; import useTokenBalance from '@/_hooks/useTokenBalance'; -import useTransactionFormData from '@/_hooks/useTransactionFormData'; import { useTokenMap } from '@/_hooks/useTokenMap'; +import useTransactionFormData from '@/_hooks/useTransactionFormData'; import useWallet from '@/_hooks/useWallet'; +import { getTokenNameAndId } from '@/_utils'; + import { UseAllAmount } from './UseAllAmount'; -import { NETWORKS } from '@rosen-ui/constants'; -import { Autocomplete } from '@mui/material'; -import { RosenChainToken } from '@rosen-bridge/tokens'; /** * bridge form container comp @@ -290,7 +290,7 @@ export const BridgeForm = () => { ), }} inputProps={{ - style: { fontSize: '2rem' }, + 'style': { fontSize: '2rem' }, 'aria-label': 'amount input', }} variant="filled" diff --git a/apps/rosen/app/(bridge)/BridgeTransaction.tsx b/apps/rosen/app/(bridge)/BridgeTransaction.tsx index 6ea5eead..ae56ef4d 100644 --- a/apps/rosen/app/(bridge)/BridgeTransaction.tsx +++ b/apps/rosen/app/(bridge)/BridgeTransaction.tsx @@ -1,5 +1,7 @@ 'use client'; +import { Dispatch, SetStateAction } from 'react'; + import { Alert, Amount, @@ -14,10 +16,9 @@ import { useTokenMap } from '@/_hooks/useTokenMap'; import useTransactionFees from '@/_hooks/useTransactionFees'; import useTransactionFormData from '@/_hooks/useTransactionFormData'; import useWallet from '@/_hooks/useWallet'; - import { getTokenNameAndId } from '@/_utils'; + import { ChooseWalletModal } from './ChooseWalletModal'; -import { Dispatch, SetStateAction } from 'react'; import { WalletInfo } from './WalletInfo'; export interface BridgeTransactionProps { diff --git a/apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx b/apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx index b00f8ce3..2b4f4b47 100644 --- a/apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx +++ b/apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx @@ -16,12 +16,12 @@ import { } from '@rosen-bridge/ui-kit'; import { useNetwork } from '@/_hooks/useNetwork'; +import { useTokenMap } from '@/_hooks/useTokenMap'; import { useTransaction } from '@/_hooks/useTransaction'; import useTransactionFees from '@/_hooks/useTransactionFees'; import useTransactionFormData from '@/_hooks/useTransactionFormData'; import useWallet from '@/_hooks/useWallet'; import { getTokenNameAndId } from '@/_utils'; -import { useTokenMap } from '@/_hooks/useTokenMap'; interface ConnectOrSubmitButtonProps { setChooseWalletsModalOpen: (open: boolean) => void; diff --git a/apps/rosen/app/(bridge)/UseAllAmount.tsx b/apps/rosen/app/(bridge)/UseAllAmount.tsx index cac1c7d9..a04bb2e5 100644 --- a/apps/rosen/app/(bridge)/UseAllAmount.tsx +++ b/apps/rosen/app/(bridge)/UseAllAmount.tsx @@ -1,3 +1,4 @@ +import { SyncProblem } from '@rosen-bridge/icons'; import { Button, CircularProgress, @@ -7,7 +8,6 @@ import { SvgIcon, Typography, } from '@rosen-bridge/ui-kit'; -import { SyncProblem } from '@rosen-bridge/icons'; export interface UseAllAmountProps { error: boolean; diff --git a/apps/rosen/app/(bridge)/page.tsx b/apps/rosen/app/(bridge)/page.tsx index 4f7f5166..4695b17c 100644 --- a/apps/rosen/app/(bridge)/page.tsx +++ b/apps/rosen/app/(bridge)/page.tsx @@ -7,22 +7,22 @@ import { Alert, styled } from '@rosen-bridge/ui-kit'; import { NETWORKS } from '@rosen-ui/constants'; import { RosenAmountValue } from '@rosen-ui/types'; -import { BridgeTransaction } from './BridgeTransaction'; import { BridgeForm } from './BridgeForm'; +import { BridgeTransaction } from './BridgeTransaction'; import { ConnectOrSubmitButton } from './ConnectOrSubmitButton'; const BridgeContainer = styled('div')(({ theme }) => ({ - position: 'absolute', - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - maxWidth: theme.breakpoints.values.desktop, - width: '100%', - gap: theme.spacing(3), - padding: theme.spacing(4), - display: 'grid', - gridTemplateColumns: '8fr 4fr', - gridTemplateRows: '1fr auto auto', + 'position': 'absolute', + 'top': '50%', + 'left': '50%', + 'transform': 'translate(-50%, -50%)', + 'maxWidth': theme.breakpoints.values.desktop, + 'width': '100%', + 'gap': theme.spacing(3), + 'padding': theme.spacing(4), + 'display': 'grid', + 'gridTemplateColumns': '8fr 4fr', + 'gridTemplateRows': '1fr auto auto', '& > button': { width: '50%', justifySelf: 'flex-end', diff --git a/apps/rosen/app/App.tsx b/apps/rosen/app/App.tsx index f94ab56d..8b8ab4f5 100644 --- a/apps/rosen/app/App.tsx +++ b/apps/rosen/app/App.tsx @@ -1,13 +1,12 @@ 'use client'; -import React from 'react'; - /** * FIXME: import NoSsr from ui-kit * local:ergo/rosen-bridge/ui#193 */ -import { NoSsr } from '@mui/material'; +import React from 'react'; +import { NoSsr } from '@mui/material'; import { styled, AppSnackbar, @@ -16,11 +15,11 @@ import { ThemeProvider, } from '@rosen-bridge/ui-kit'; -import { SideBar } from './SideBar'; -import Toolbar from './Toolbar'; - import { theme } from '@/_theme/theme'; + import { WalletContextProvider } from './_contexts/walletContext'; +import { SideBar } from './SideBar'; +import Toolbar from './Toolbar'; const Root = styled('div')(({ theme }) => ({ width: '100vw', diff --git a/apps/rosen/app/Toolbar.tsx b/apps/rosen/app/Toolbar.tsx index 8ca1e6a9..27aac730 100644 --- a/apps/rosen/app/Toolbar.tsx +++ b/apps/rosen/app/Toolbar.tsx @@ -8,11 +8,11 @@ import { const pageTitleMap: Record = { '(bridge)': 'Rosen Bridge', - events: 'Events', - assets: 'Assets', - dashboard: 'Dashboard', - support: 'Support', - transactions: 'Transactions', + 'events': 'Events', + 'assets': 'Assets', + 'dashboard': 'Dashboard', + 'support': 'Support', + 'transactions': 'Transactions', }; /** diff --git a/apps/rosen/app/_actions/calculateFee.ts b/apps/rosen/app/_actions/calculateFee.ts index d590d111..efaa3562 100644 --- a/apps/rosen/app/_actions/calculateFee.ts +++ b/apps/rosen/app/_actions/calculateFee.ts @@ -4,6 +4,11 @@ import { ErgoNetworkType, MinimumFeeBox } from '@rosen-bridge/minimum-fee'; import cardanoKoiosClientFactory from '@rosen-clients/cardano-koios'; import ergoExplorerClientFactory from '@rosen-clients/ergo-explorer'; import { getHeight as ethereumGetHeight } from '@rosen-network/ethereum'; +import { NETWORKS, NETWORK_VALUES } from '@rosen-ui/constants'; +import { Network } from '@rosen-ui/types'; +import Joi from 'joi'; + +import { wrap } from '@/_safeServerAction'; const cardanoKoiosClient = cardanoKoiosClientFactory( process.env.CARDANO_KOIOS_API!, @@ -12,11 +17,6 @@ const ergoExplorerClient = ergoExplorerClientFactory( process.env.ERGO_EXPLORER_API!, ); -import { NETWORKS, NETWORK_VALUES } from '@rosen-ui/constants'; -import { Network } from '@rosen-ui/types'; -import { wrap } from '@/_safeServerAction'; -import Joi from 'joi'; - const GetHeight = { [NETWORKS.ETHEREUM]: ethereumGetHeight, [NETWORKS.CARDANO]: async () => diff --git a/apps/rosen/app/_actions/validateAddress.ts b/apps/rosen/app/_actions/validateAddress.ts index 6f4f76e1..d05a8ea0 100644 --- a/apps/rosen/app/_actions/validateAddress.ts +++ b/apps/rosen/app/_actions/validateAddress.ts @@ -1,11 +1,11 @@ 'use server'; +import { validateAddress as validate } from '@rosen-bridge/address-codec'; import { NETWORK_VALUES } from '@rosen-ui/constants'; import { Network } from '@rosen-ui/types'; +import Joi from 'joi'; import { wrap } from '@/_safeServerAction'; -import Joi from 'joi'; -import { validateAddress as validate } from '@rosen-bridge/address-codec'; /** * server action to verify the wallet addresses diff --git a/apps/rosen/app/_backend/assets/repository.ts b/apps/rosen/app/_backend/assets/repository.ts index c27885b3..1028b4d8 100644 --- a/apps/rosen/app/_backend/assets/repository.ts +++ b/apps/rosen/app/_backend/assets/repository.ts @@ -3,12 +3,11 @@ import { LockedAssetEntity, TokenEntity, } from '@rosen-ui/asset-calculator'; +import { Network } from '@rosen-ui/types'; import NotFoundError from '@/_errors/NotFoundError'; import dataSource from '../dataSource'; -import { Network } from '@rosen-ui/types'; - import '../initialize-datasource-if-needed'; const bridgedAssetRepository = dataSource.getRepository(BridgedAssetEntity); diff --git a/apps/rosen/app/_backend/events/repository.ts b/apps/rosen/app/_backend/events/repository.ts index 69569190..e0622541 100644 --- a/apps/rosen/app/_backend/events/repository.ts +++ b/apps/rosen/app/_backend/events/repository.ts @@ -4,7 +4,6 @@ import { EventTriggerEntity } from '@rosen-bridge/watcher-data-extractor'; import { Network } from '@rosen-ui/types'; import dataSource from '../dataSource'; - import '../initialize-datasource-if-needed'; const blockRepository = dataSource.getRepository(BlockEntity); diff --git a/apps/rosen/app/_backend/events/services.ts b/apps/rosen/app/_backend/events/services.ts index f2a165e5..d05bbb2a 100644 --- a/apps/rosen/app/_backend/events/services.ts +++ b/apps/rosen/app/_backend/events/services.ts @@ -3,9 +3,8 @@ import { Network } from '@rosen-ui/types'; import { getRosenTokens } from '@/_backend/utils'; -import { getEvents } from './repository'; - import { UNSUPPORTED_TOKEN_NAME } from '../constants'; +import { getEvents } from './repository'; const tokenMap = new TokenMap(getRosenTokens()); diff --git a/apps/rosen/app/_backend/utils.ts b/apps/rosen/app/_backend/utils.ts index a70e8199..7de96e1d 100644 --- a/apps/rosen/app/_backend/utils.ts +++ b/apps/rosen/app/_backend/utils.ts @@ -2,6 +2,7 @@ import fs from 'fs'; import path from 'path'; + import { wrap } from '@/_safeServerAction'; /** diff --git a/apps/rosen/app/_hooks/useBridgeForm.ts b/apps/rosen/app/_hooks/useBridgeForm.ts index c2d9ab48..8b8863dc 100644 --- a/apps/rosen/app/_hooks/useBridgeForm.ts +++ b/apps/rosen/app/_hooks/useBridgeForm.ts @@ -1,19 +1,17 @@ import { useContext } from 'react'; import { useController } from 'react-hook-form'; +import { Network, RosenAmountValue } from '@rosen-ui/types'; import { getNonDecimalString } from '@rosen-ui/utils'; -import useTransactionFormData from './useTransactionFormData'; - -import { WalletContext } from '@/_contexts/walletContext'; - import { validateAddress } from '@/_actions/validateAddress'; - +import { WalletContext } from '@/_contexts/walletContext'; import { availableNetworks } from '@/_networks'; +import { unwrap } from '@/_safeServerAction'; import { getMaxTransfer, getMinTransfer } from '@/_utils'; + import { useTokenMap } from './useTokenMap'; -import { Network, RosenAmountValue } from '@rosen-ui/types'; -import { unwrap } from '@/_safeServerAction'; +import useTransactionFormData from './useTransactionFormData'; /** * handles the form field registrations and form state changes diff --git a/apps/rosen/app/_hooks/useMaxTransfer.ts b/apps/rosen/app/_hooks/useMaxTransfer.ts index d3a26c7b..13450036 100644 --- a/apps/rosen/app/_hooks/useMaxTransfer.ts +++ b/apps/rosen/app/_hooks/useMaxTransfer.ts @@ -1,12 +1,12 @@ import { useCallback, useEffect, useState, useTransition } from 'react'; +import { NETWORKS } from '@rosen-ui/constants'; import { RosenAmountValue } from '@rosen-ui/types'; -import { NETWORKS } from '@rosen-ui/constants'; +import { getMaxTransfer } from '@/_utils'; import { useNetwork } from './useNetwork'; import useTokenBalance from './useTokenBalance'; -import { getMaxTransfer } from '@/_utils'; import useTransactionFormData from './useTransactionFormData'; import useWallet from './useWallet'; diff --git a/apps/rosen/app/_hooks/useNetwork.ts b/apps/rosen/app/_hooks/useNetwork.ts index 47f6a3e7..b05e53f7 100644 --- a/apps/rosen/app/_hooks/useNetwork.ts +++ b/apps/rosen/app/_hooks/useNetwork.ts @@ -1,12 +1,13 @@ import { useEffect, useMemo, useState } from 'react'; +import { RosenChainToken } from '@rosen-bridge/tokens'; import { NETWORK_VALUES } from '@rosen-ui/constants'; +import { Network } from '@rosen-ui/types'; + import { AvailableNetworks, availableNetworks } from '@/_networks'; import useBridgeForm from './useBridgeForm'; import { useTokenMap } from './useTokenMap'; -import { Network } from '@rosen-ui/types'; -import { RosenChainToken } from '@rosen-bridge/tokens'; type BlackList = { fromChain: Network; diff --git a/apps/rosen/app/_hooks/useTokenBalance.ts b/apps/rosen/app/_hooks/useTokenBalance.ts index 26992075..3be931cc 100644 --- a/apps/rosen/app/_hooks/useTokenBalance.ts +++ b/apps/rosen/app/_hooks/useTokenBalance.ts @@ -1,13 +1,12 @@ import { useState, useEffect, useCallback } from 'react'; import { TokenInfo } from '@rosen-ui/types'; +import { RosenAmountValue } from '@rosen-ui/types'; +import { Wallet } from '@rosen-ui/wallet-api'; import useBridgeForm from './useBridgeForm'; import useWallet from './useWallet'; -import { Wallet } from '@rosen-ui/wallet-api'; -import { RosenAmountValue } from '@rosen-ui/types'; - interface UseTokenBalance { isLoading: boolean; // THIS IS A WRAPPED-VALUE diff --git a/apps/rosen/app/_hooks/useTransaction.ts b/apps/rosen/app/_hooks/useTransaction.ts index 9ec0f270..677d097e 100644 --- a/apps/rosen/app/_hooks/useTransaction.ts +++ b/apps/rosen/app/_hooks/useTransaction.ts @@ -2,13 +2,13 @@ import { useState } from 'react'; import { RosenChainToken } from '@rosen-bridge/tokens'; import { useSnackbar } from '@rosen-bridge/ui-kit'; +import { RosenAmountValue } from '@rosen-ui/types'; +import { getNonDecimalString } from '@rosen-ui/utils'; import { useNetwork } from './useNetwork'; +import { useTokenMap } from './useTokenMap'; import useTransactionFormData from './useTransactionFormData'; import useWallet from './useWallet'; -import { getNonDecimalString } from '@rosen-ui/utils'; -import { useTokenMap } from './useTokenMap'; -import { RosenAmountValue } from '@rosen-ui/types'; /** * a react hook to create and sign and submit transactions diff --git a/apps/rosen/app/_hooks/useTransactionFees.ts b/apps/rosen/app/_hooks/useTransactionFees.ts index edbb0d29..e0cf6129 100644 --- a/apps/rosen/app/_hooks/useTransactionFees.ts +++ b/apps/rosen/app/_hooks/useTransactionFees.ts @@ -1,15 +1,14 @@ import { useMemo, useEffect, useRef, useCallback, useTransition } from 'react'; + import { RosenChainToken } from '@rosen-bridge/tokens'; import { useSnackbar } from '@rosen-bridge/ui-kit'; - +import { Network } from '@rosen-ui/types'; import { getNonDecimalString, getDecimalString } from '@rosen-ui/utils'; -import { useNetwork } from './useNetwork'; - import { calculateFee } from '@/_actions/calculateFee'; - -import { Network } from '@rosen-ui/types'; import { unwrap } from '@/_safeServerAction'; + +import { useNetwork } from './useNetwork'; import { useTokenMap } from './useTokenMap'; /** diff --git a/apps/rosen/app/_hooks/useTransactionFormData.ts b/apps/rosen/app/_hooks/useTransactionFormData.ts index fe10b8cf..d6afa1b3 100644 --- a/apps/rosen/app/_hooks/useTransactionFormData.ts +++ b/apps/rosen/app/_hooks/useTransactionFormData.ts @@ -1,8 +1,9 @@ import { useWatch, useFormContext, FieldValues } from 'react-hook-form'; -import type { BridgeForm } from '@/(bridge)/page'; import { Network } from '@rosen-ui/types'; +import type { BridgeForm } from '@/(bridge)/page'; + /** * provide access to the bridge form context and current form values */ diff --git a/apps/rosen/app/_hooks/useWallet.ts b/apps/rosen/app/_hooks/useWallet.ts index aef32cb6..41d318f0 100644 --- a/apps/rosen/app/_hooks/useWallet.ts +++ b/apps/rosen/app/_hooks/useWallet.ts @@ -1,11 +1,12 @@ import { useEffect, useContext, useCallback, useRef } from 'react'; -import { Wallet, WalletBase } from '@rosen-ui/wallet-api'; -import { useLocalStorageManager } from '@rosen-ui/common-hooks'; -import { useNetwork } from './useNetwork'; +import { useLocalStorageManager } from '@rosen-ui/common-hooks'; +import { Wallet, WalletBase } from '@rosen-ui/wallet-api'; import { WalletContext } from '@/_contexts/walletContext'; +import { useNetwork } from './useNetwork'; + interface WalletDescriptor { readonly name: string; readonly expDate: string; diff --git a/apps/rosen/app/_networks/bitcoin/getMaxTransfer.ts b/apps/rosen/app/_networks/bitcoin/getMaxTransfer.ts index fb034714..a26dc33c 100644 --- a/apps/rosen/app/_networks/bitcoin/getMaxTransfer.ts +++ b/apps/rosen/app/_networks/bitcoin/getMaxTransfer.ts @@ -7,10 +7,11 @@ import { getAddressUtxos, getMinimumMeaningfulSatoshi, } from '@rosen-network/bitcoin'; +import { NATIVE_TOKENS, NETWORKS } from '@rosen-ui/constants'; import { wrap } from '@/_safeServerAction'; import { BitcoinNetwork } from '@/_types/network'; -import { NATIVE_TOKENS, NETWORKS } from '@rosen-ui/constants'; + import { getTokenMap } from '../getTokenMap.server'; /** diff --git a/apps/rosen/app/_networks/bitcoin/index.ts b/apps/rosen/app/_networks/bitcoin/index.ts index f7fce92a..c9bdecd7 100644 --- a/apps/rosen/app/_networks/bitcoin/index.ts +++ b/apps/rosen/app/_networks/bitcoin/index.ts @@ -1,13 +1,12 @@ import { BitcoinIcon } from '@rosen-bridge/icons'; -import { xdefiWalletCreator } from '@rosen-ui/xdefi-wallet'; - -import { getMaxTransfer } from './getMaxTransfer'; - import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants'; +import { xdefiWalletCreator } from '@rosen-ui/xdefi-wallet'; import { unwrap } from '@/_safeServerAction'; import { BitcoinNetwork as BitcoinNetworkType } from '@/_types/network'; +import { getTokenMap } from '../getTokenMap.client'; +import { getMaxTransfer } from './getMaxTransfer'; import { generateOpReturnData, generateUnsignedTx, @@ -15,8 +14,6 @@ import { getAddressBalance, } from './server'; -import { getTokenMap } from '../getTokenMap.client'; - const config = { getTokenMap, generateOpReturnData: unwrap(generateOpReturnData), diff --git a/apps/rosen/app/_networks/bitcoin/server.ts b/apps/rosen/app/_networks/bitcoin/server.ts index 9c07decc..c3889df5 100644 --- a/apps/rosen/app/_networks/bitcoin/server.ts +++ b/apps/rosen/app/_networks/bitcoin/server.ts @@ -1,5 +1,6 @@ 'use server'; +import { TokenMap } from '@rosen-bridge/tokens'; import { generateOpReturnData as generateOpReturnDataCore, generateUnsignedTx as generateUnsignedTxCore, @@ -7,9 +8,8 @@ import { submitTransaction as submitTransactionCore, } from '@rosen-network/bitcoin'; -import { wrap } from '@/_safeServerAction'; -import { TokenMap } from '@rosen-bridge/tokens'; import { getRosenTokens } from '@/_backend/utils'; +import { wrap } from '@/_safeServerAction'; export const generateOpReturnData = wrap(generateOpReturnDataCore, { traceKey: 'generateOpReturnData', diff --git a/apps/rosen/app/_networks/cardano/index.ts b/apps/rosen/app/_networks/cardano/index.ts index a8245a3f..81e33274 100644 --- a/apps/rosen/app/_networks/cardano/index.ts +++ b/apps/rosen/app/_networks/cardano/index.ts @@ -1,15 +1,15 @@ -import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants'; - -import { unwrap } from '@/_safeServerAction'; -import { CardanoNetwork as CardanoNetworkType } from '@/_types/network'; - import { CardanoIcon } from '@rosen-bridge/icons'; - +import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants'; import { eternlWalletCreator } from '@rosen-ui/eternl-wallet'; import { flintWalletCreator } from '@rosen-ui/flint-wallet'; import { laceWalletCreator } from '@rosen-ui/lace-wallet'; import { namiWalletCreator } from '@rosen-ui/nami-wallet'; +import { unwrap } from '@/_safeServerAction'; +import { CardanoNetwork as CardanoNetworkType } from '@/_types/network'; + +import { getTokenMap } from '../getTokenMap.client'; +import { getMaxTransfer } from './getMaxTransfer'; import { decodeWasmValue, generateLockAuxiliaryData, @@ -17,9 +17,6 @@ import { setTxWitnessSet, } from './server'; -import { getTokenMap } from '../getTokenMap.client'; -import { getMaxTransfer } from './getMaxTransfer'; - const config = { getTokenMap, decodeWasmValue: unwrap(decodeWasmValue), diff --git a/apps/rosen/app/_networks/cardano/server.ts b/apps/rosen/app/_networks/cardano/server.ts index 93b32377..3584e0af 100644 --- a/apps/rosen/app/_networks/cardano/server.ts +++ b/apps/rosen/app/_networks/cardano/server.ts @@ -1,5 +1,6 @@ 'use server'; +import { TokenMap } from '@rosen-bridge/tokens'; import { decodeWasmValue as decodeWasmValueCore, generateLockAuxiliaryData as generateLockAuxiliaryDataCore, @@ -7,9 +8,8 @@ import { setTxWitnessSet as setTxWitnessSetCore, } from '@rosen-network/cardano'; -import { wrap } from '@/_safeServerAction'; -import { TokenMap } from '@rosen-bridge/tokens'; import { getRosenTokens } from '@/_backend/utils'; +import { wrap } from '@/_safeServerAction'; export const decodeWasmValue = wrap(decodeWasmValueCore, { cache: Infinity, diff --git a/apps/rosen/app/_networks/ergo/index.ts b/apps/rosen/app/_networks/ergo/index.ts index 6149b654..acb00bbd 100644 --- a/apps/rosen/app/_networks/ergo/index.ts +++ b/apps/rosen/app/_networks/ergo/index.ts @@ -1,14 +1,13 @@ -import { nautilusWalletCreator } from '@rosen-ui/nautilus-wallet'; - +import { ErgoIcon } from '@rosen-bridge/icons'; import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants'; +import { nautilusWalletCreator } from '@rosen-ui/nautilus-wallet'; import { unwrap } from '@/_safeServerAction'; import { ErgoNetwork as ErgoNetworkType } from '@/_types/network'; -import { ErgoIcon } from '@rosen-bridge/icons'; -import { generateUnsignedTx } from './server'; import { getTokenMap } from '../getTokenMap.client'; import { getMaxTransfer } from './getMaxTransfer'; +import { generateUnsignedTx } from './server'; const config = { getTokenMap, diff --git a/apps/rosen/app/_networks/ergo/server.ts b/apps/rosen/app/_networks/ergo/server.ts index a2e5a255..b4119ca3 100644 --- a/apps/rosen/app/_networks/ergo/server.ts +++ b/apps/rosen/app/_networks/ergo/server.ts @@ -1,10 +1,10 @@ 'use server'; +import { TokenMap } from '@rosen-bridge/tokens'; import { generateUnsignedTx as generateUnsignedTxCore } from '@rosen-network/ergo'; -import { wrap } from '@/_safeServerAction'; -import { TokenMap } from '@rosen-bridge/tokens'; import { getRosenTokens } from '@/_backend/utils'; +import { wrap } from '@/_safeServerAction'; export const generateUnsignedTx = wrap( generateUnsignedTxCore(new TokenMap(getRosenTokens())), diff --git a/apps/rosen/app/_networks/ethereum/getMaxTransfer.ts b/apps/rosen/app/_networks/ethereum/getMaxTransfer.ts index 8fc853e2..29c1f29e 100644 --- a/apps/rosen/app/_networks/ethereum/getMaxTransfer.ts +++ b/apps/rosen/app/_networks/ethereum/getMaxTransfer.ts @@ -1,13 +1,12 @@ 'use server'; +import { ETH_TRANSFER_GAS, getFeeData } from '@rosen-network/ethereum'; import { NATIVE_TOKENS, NETWORKS } from '@rosen-ui/constants'; import { wrap } from '@/_safeServerAction'; import { EthereumNetwork } from '@/_types/network'; import { getTokenMap } from '../getTokenMap.server'; -import { RosenAmountValue } from '@rosen-ui/types'; -import { ETH_TRANSFER_GAS, getFeeData } from '@rosen-network/ethereum'; /** * get max transfer for ethereum diff --git a/apps/rosen/app/_networks/ethereum/index.ts b/apps/rosen/app/_networks/ethereum/index.ts index 6b270578..bcfc420b 100644 --- a/apps/rosen/app/_networks/ethereum/index.ts +++ b/apps/rosen/app/_networks/ethereum/index.ts @@ -1,13 +1,12 @@ -import { metaMaskWalletCreator } from '@rosen-ui/metamask-wallet'; - +import { EthereumIcon } from '@rosen-bridge/icons'; import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants'; +import { metaMaskWalletCreator } from '@rosen-ui/metamask-wallet'; import { unwrap } from '@/_safeServerAction'; import { EthereumNetwork as EthereumNetworkType } from '@/_types/network'; -import { EthereumIcon } from '@rosen-bridge/icons'; -import { getMaxTransfer } from './getMaxTransfer'; import { getTokenMap } from '../getTokenMap.client'; +import { getMaxTransfer } from './getMaxTransfer'; import { generateLockData, generateTxParameters } from './server'; /** diff --git a/apps/rosen/app/_networks/ethereum/server.ts b/apps/rosen/app/_networks/ethereum/server.ts index 3dad63cc..3999e814 100644 --- a/apps/rosen/app/_networks/ethereum/server.ts +++ b/apps/rosen/app/_networks/ethereum/server.ts @@ -1,13 +1,13 @@ 'use server'; +import { TokenMap } from '@rosen-bridge/tokens'; import { generateLockData as generateLockDataCore, generateTxParameters as generateTxParametersCore, } from '@rosen-network/ethereum'; -import { wrap } from '@/_safeServerAction'; -import { TokenMap } from '@rosen-bridge/tokens'; import { getRosenTokens } from '@/_backend/utils'; +import { wrap } from '@/_safeServerAction'; export const generateLockData = wrap(generateLockDataCore, { traceKey: 'generateLockData', diff --git a/apps/rosen/app/_networks/index.ts b/apps/rosen/app/_networks/index.ts index d908b1fd..91de7c40 100644 --- a/apps/rosen/app/_networks/index.ts +++ b/apps/rosen/app/_networks/index.ts @@ -1,10 +1,10 @@ +import { NETWORKS } from '@rosen-ui/constants'; + import BitcoinNetwork from './bitcoin'; import CardanoNetwork from './cardano'; import ErgoNetwork from './ergo'; import EthereumNetwork from './ethereum'; -import { NETWORKS } from '@rosen-ui/constants'; - export const availableNetworks = { [NETWORKS.ERGO]: ErgoNetwork, [NETWORKS.ETHEREUM]: EthereumNetwork, diff --git a/apps/rosen/app/_theme/theme.tsx b/apps/rosen/app/_theme/theme.tsx index f6812efd..ade40257 100644 --- a/apps/rosen/app/_theme/theme.tsx +++ b/apps/rosen/app/_theme/theme.tsx @@ -185,8 +185,8 @@ const create = (baseTheme: Theme) => MuiButton: { styleOverrides: { containedSecondary: { - color: baseTheme.palette.text.primary, - backgroundColor: baseTheme.palette.neutral.light, + 'color': baseTheme.palette.text.primary, + 'backgroundColor': baseTheme.palette.neutral.light, '&:hover': { backgroundColor: baseTheme.palette.neutral.light, }, @@ -225,7 +225,7 @@ const create = (baseTheme: Theme) => styleOverrides: { root: { '.MuiInputLabel-root': { - transform: 'translate(12px, 16px) scale(1)', + 'transform': 'translate(12px, 16px) scale(1)', '&.MuiInputLabel-shrink': { transform: 'translate(12px, 7px) scale(0.75)', }, @@ -234,11 +234,14 @@ const create = (baseTheme: Theme) => transform: 'translateY(8px)', }, '.MuiOutlinedInput-root': { - overflow: 'hidden', - borderRadius: baseTheme.spacing(2), - backgroundColor: alpha(baseTheme.palette.background.paper, 0.75), - minHeight: baseTheme.spacing(8.5), - transition: baseTheme.transitions.create([ + 'overflow': 'hidden', + 'borderRadius': baseTheme.spacing(2), + 'backgroundColor': alpha( + baseTheme.palette.background.paper, + 0.75, + ), + 'minHeight': baseTheme.spacing(8.5), + 'transition': baseTheme.transitions.create([ 'background-color', 'box-shadow', ]), @@ -252,7 +255,7 @@ const create = (baseTheme: Theme) => backgroundColor: alpha(baseTheme.palette.background.paper, 1.0), }, }, - fieldset: { + 'fieldset': { border: 'none', }, }, @@ -261,11 +264,11 @@ const create = (baseTheme: Theme) => MuiFilledInput: { styleOverrides: { root: { - overflow: 'hidden', - borderRadius: baseTheme.shape.borderRadius, - backgroundColor: alpha(baseTheme.palette.background.paper, 0.75), - minHeight: baseTheme.spacing(8.5), - transition: baseTheme.transitions.create([ + 'overflow': 'hidden', + 'borderRadius': baseTheme.shape.borderRadius, + 'backgroundColor': alpha(baseTheme.palette.background.paper, 0.75), + 'minHeight': baseTheme.spacing(8.5), + 'transition': baseTheme.transitions.create([ 'background-color', 'box-shadow', ]), @@ -350,7 +353,7 @@ const create = (baseTheme: Theme) => fontWeight: 'bold', ...(baseTheme.palette.mode === 'light' ? { - background: 'linear-gradient(180deg, #28335F 0%, #B15A3F 100%)', + 'background': 'linear-gradient(180deg, #28335F 0%, #B15A3F 100%)', '-webkit-background-clip': 'text', '-webkit-text-fill-color': 'transparent', } diff --git a/apps/rosen/app/_types/network.ts b/apps/rosen/app/_types/network.ts index fe932bd6..82bedb09 100644 --- a/apps/rosen/app/_types/network.ts +++ b/apps/rosen/app/_types/network.ts @@ -1,6 +1,5 @@ -import { Wallet } from '@rosen-ui/wallet-api'; - import { Network, RosenAmountValue } from '@rosen-ui/types'; +import { Wallet } from '@rosen-ui/wallet-api'; interface GetMaxTransferParams { balance: RosenAmountValue; diff --git a/apps/rosen/app/_utils/getMaxTransfer.ts b/apps/rosen/app/_utils/getMaxTransfer.ts index 527a4148..2a8e051f 100644 --- a/apps/rosen/app/_utils/getMaxTransfer.ts +++ b/apps/rosen/app/_utils/getMaxTransfer.ts @@ -1,11 +1,12 @@ +import { NETWORKS } from '@rosen-ui/constants'; +import { Network, RosenAmountValue } from '@rosen-ui/types'; + import { BitcoinNetwork, CardanoNetwork, ErgoNetwork, EthereumNetwork, } from '@/_types/network'; -import { NETWORKS } from '@rosen-ui/constants'; -import { Network, RosenAmountValue } from '@rosen-ui/types'; /** * return max transfer, considering all the context that affects it diff --git a/apps/rosen/app/api/v1/assets/detail/[id]/route.ts b/apps/rosen/app/api/v1/assets/detail/[id]/route.ts index b1438109..2f238cbe 100644 --- a/apps/rosen/app/api/v1/assets/detail/[id]/route.ts +++ b/apps/rosen/app/api/v1/assets/detail/[id]/route.ts @@ -1,7 +1,6 @@ import { getAsset } from '@/_backend/assets'; import withValidation from '../../../withValidation'; - import { validateGet } from './validations'; export const GET = withValidation(validateGet, (value) => getAsset(value.id)); diff --git a/apps/rosen/app/api/v1/assets/detail/[id]/validations.ts b/apps/rosen/app/api/v1/assets/detail/[id]/validations.ts index 3842f032..90477df0 100644 --- a/apps/rosen/app/api/v1/assets/detail/[id]/validations.ts +++ b/apps/rosen/app/api/v1/assets/detail/[id]/validations.ts @@ -1,4 +1,5 @@ import { NextRequest } from 'next/server'; + import Joi from 'joi'; interface GETPositionalParams { diff --git a/apps/rosen/app/api/v1/assets/route.ts b/apps/rosen/app/api/v1/assets/route.ts index 93164ded..56ce8fa8 100644 --- a/apps/rosen/app/api/v1/assets/route.ts +++ b/apps/rosen/app/api/v1/assets/route.ts @@ -3,7 +3,6 @@ import { pick } from 'lodash-es'; import { getAllAssets } from '@/_backend/assets'; import withValidation from '../withValidation'; - import { validateGet } from './validations'; export const GET = withValidation(validateGet, (value) => diff --git a/apps/rosen/app/api/v1/assets/validations.ts b/apps/rosen/app/api/v1/assets/validations.ts index 0bf339c3..fab385c5 100644 --- a/apps/rosen/app/api/v1/assets/validations.ts +++ b/apps/rosen/app/api/v1/assets/validations.ts @@ -1,7 +1,8 @@ import { NextRequest } from 'next/server'; -import Joi from 'joi'; + import { NETWORK_VALUES } from '@rosen-ui/constants'; import { Network } from '@rosen-ui/types'; +import Joi from 'joi'; interface GETQueryParams { offset: number; diff --git a/apps/rosen/app/api/v1/events/route.ts b/apps/rosen/app/api/v1/events/route.ts index 95c2eb1f..30e9e271 100644 --- a/apps/rosen/app/api/v1/events/route.ts +++ b/apps/rosen/app/api/v1/events/route.ts @@ -1,7 +1,6 @@ import { getEventsWithFullTokenData } from '@/_backend/events'; import withValidation from '../withValidation'; - import EventsValidations from './validations'; export const GET = withValidation(EventsValidations.GET, (value) => diff --git a/apps/rosen/app/api/v1/events/validations.ts b/apps/rosen/app/api/v1/events/validations.ts index 5c12dd6d..24a5cf7a 100644 --- a/apps/rosen/app/api/v1/events/validations.ts +++ b/apps/rosen/app/api/v1/events/validations.ts @@ -1,4 +1,5 @@ import { NextRequest } from 'next/server'; + import Joi from 'joi'; interface GETQueryParams { diff --git a/apps/rosen/app/api/v1/withValidation.ts b/apps/rosen/app/api/v1/withValidation.ts index 96b9ee40..b832658d 100644 --- a/apps/rosen/app/api/v1/withValidation.ts +++ b/apps/rosen/app/api/v1/withValidation.ts @@ -1,4 +1,5 @@ import { NextRequest } from 'next/server'; + import { ValidationResult } from 'joi'; import NotFoundError from '@/_errors/NotFoundError'; diff --git a/apps/rosen/app/assets/TableRow.tsx b/apps/rosen/app/assets/TableRow.tsx index f45ffa07..31d6eff8 100644 --- a/apps/rosen/app/assets/TableRow.tsx +++ b/apps/rosen/app/assets/TableRow.tsx @@ -1,3 +1,5 @@ +import { useState, FC, useMemo } from 'react'; + import { AngleDown, AngleUp, OpenInNew } from '@rosen-bridge/icons'; import { Box, @@ -17,19 +19,17 @@ import { TableRow, WithExternalLink, } from '@rosen-bridge/ui-kit'; -import { useState, FC, useMemo } from 'react'; -import useSWR from 'swr'; +import { NETWORKS } from '@rosen-ui/constants'; import { fetcher } from '@rosen-ui/swr-helpers'; - -import { ApiAssetResponse, Assets } from '@/_types/api'; - import { getAddressUrl, getDecimalString, getTokenUrl, getTxURL, } from '@rosen-ui/utils'; -import { NETWORKS } from '@rosen-ui/constants'; +import useSWR from 'swr'; + +import { ApiAssetResponse, Assets } from '@/_types/api'; interface RowProps extends Assets { isLoading?: boolean; @@ -118,7 +118,7 @@ export const MobileRow: FC = (props) => { const rowStyles = useMemo( () => ({ - opacity: isLoading ? 0.3 : 1.0, + 'opacity': isLoading ? 0.3 : 1.0, '& > td': { border: 0, padding: 1, @@ -188,7 +188,7 @@ export const MobileRow: FC = (props) => { )} td': { border: 0, }, @@ -245,7 +245,7 @@ export const TabletRow: FC = (props) => { td': { border: 0 }, }} onClick={() => setExpanded(!open)} @@ -308,7 +308,7 @@ export const TabletRow: FC = (props) => { diff --git a/apps/rosen/app/assets/page.tsx b/apps/rosen/app/assets/page.tsx index ef06f6ec..46a56803 100644 --- a/apps/rosen/app/assets/page.tsx +++ b/apps/rosen/app/assets/page.tsx @@ -1,9 +1,10 @@ +'use client'; + /** * TODO: Convert this page to SSR mode * local:ergo/rosen-bridge/ui#307 */ - -'use client'; +import { MouseEvent, useCallback, useMemo, useState } from 'react'; import { Box, @@ -16,14 +17,13 @@ import { Typography, useTableDataPagination, } from '@rosen-bridge/ui-kit'; -import { MouseEvent, useCallback, useMemo, useState } from 'react'; +import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants'; +import { Network } from '@rosen-ui/types'; import { ApiAssetsResponse, Assets } from '@/_types/api'; import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow'; import TableSkeleton from './TableSkeleton'; -import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants'; -import { Network } from '@rosen-ui/types'; const getKey = (chain: Network | 'all') => (offset: number, limit: number) => { return [ diff --git a/apps/rosen/app/events/TableRow.tsx b/apps/rosen/app/events/TableRow.tsx index ae91ab3a..8e31bad6 100644 --- a/apps/rosen/app/events/TableRow.tsx +++ b/apps/rosen/app/events/TableRow.tsx @@ -1,7 +1,6 @@ -import { upperFirst } from 'lodash-es'; -import moment from 'moment'; import { useState, FC, useMemo } from 'react'; +import { AngleDown, AngleUp } from '@rosen-bridge/icons'; import { Button, EnhancedTableCell, @@ -10,11 +9,10 @@ import { Typography, Id, } from '@rosen-bridge/ui-kit'; - -import { AngleDown, AngleUp } from '@rosen-bridge/icons'; - import { Network } from '@rosen-ui/types'; import { getDecimalString, getTxURL } from '@rosen-ui/utils'; +import { upperFirst } from 'lodash-es'; +import moment from 'moment'; import { Event } from '@/_types/api'; diff --git a/apps/rosen/app/events/page.tsx b/apps/rosen/app/events/page.tsx index 62173b0e..a4acdb5a 100644 --- a/apps/rosen/app/events/page.tsx +++ b/apps/rosen/app/events/page.tsx @@ -1,10 +1,9 @@ +'use client'; + /** * TODO: Convert this page to SSR mode * local:ergo/rosen-bridge/ui#307 */ - -'use client'; - import { MouseEvent, useCallback, useMemo } from 'react'; import { @@ -14,11 +13,11 @@ import { useTableDataPagination, } from '@rosen-bridge/ui-kit'; +import { ApiEventResponse, Event } from '@/_types/api'; + import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow'; import TableSkeleton from './TableSkeleton'; -import { ApiEventResponse, Event } from '@/_types/api'; - const getKey = (offset: number, limit: number) => { return ['/v1/events', { offset, limit }]; }; diff --git a/apps/rosen/unitTests/utils/index.test.ts b/apps/rosen/unitTests/utils/index.test.ts index 7e0d451f..c66f2ea9 100644 --- a/apps/rosen/unitTests/utils/index.test.ts +++ b/apps/rosen/unitTests/utils/index.test.ts @@ -1,9 +1,8 @@ +import { NETWORKS, NETWORK_VALUES } from '@rosen-ui/constants'; import { describe, expect, it } from 'vitest'; import { getTokenNameAndId } from '@/_utils'; -import { NETWORKS, NETWORK_VALUES } from '@rosen-ui/constants'; - describe('getTokenNameAndId', () => { /** * @target getTokenNameAndId function it should return diff --git a/apps/rosen/vitest.config.ts b/apps/rosen/vitest.config.ts index d7b71664..4a95ec12 100644 --- a/apps/rosen/vitest.config.ts +++ b/apps/rosen/vitest.config.ts @@ -1,6 +1,5 @@ -import { defineConfig } from 'vitest/config'; - import { fileURLToPath } from 'url'; +import { defineConfig } from 'vitest/config'; export default defineConfig({ resolve: { diff --git a/package-lock.json b/package-lock.json index e6968904..330ea2e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ }, "devDependencies": { "@rosen-bridge/changeset-formatter": "^0.1.0", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@vitest/coverage-istanbul": "^1.3.1", "husky": "^8.0.0", "lint-staged": "^13.2.2", @@ -695,6 +696,46 @@ "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" } }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", + "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz", + "integrity": "sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.24.7", + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz", + "integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/helper-member-expression-to-functions": { "version": "7.24.8", "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.24.8.tgz", @@ -817,18 +858,33 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz", + "integrity": "sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/helper-string-parser": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.8.tgz", - "integrity": "sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", - "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -914,11 +970,12 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.6.tgz", - "integrity": "sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", + "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", + "license": "MIT", "dependencies": { - "@babel/types": "^7.25.6" + "@babel/types": "^7.26.0" }, "bin": { "parser": "bin/babel-parser.js" @@ -2517,13 +2574,13 @@ } }, "node_modules/@babel/types": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.6.tgz", - "integrity": "sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", + "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.24.8", - "@babel/helper-validator-identifier": "^7.24.7", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -9573,6 +9630,125 @@ "node": ">= 6" } }, + "node_modules/@trivago/prettier-plugin-sort-imports": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-4.3.0.tgz", + "integrity": "sha512-r3n0onD3BTOVUNPhR4lhVK4/pABGpbA7bW3eumZnYdKaHkf1qEC+Mag6DPbGNuuh0eG8AaYj+YqmVHSiGslaTQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/generator": "7.17.7", + "@babel/parser": "^7.20.5", + "@babel/traverse": "7.23.2", + "@babel/types": "7.17.0", + "javascript-natural-sort": "0.7.1", + "lodash": "^4.17.21" + }, + "peerDependencies": { + "@vue/compiler-sfc": "3.x", + "prettier": "2.x - 3.x" + }, + "peerDependenciesMeta": { + "@vue/compiler-sfc": { + "optional": true + } + } + }, + "node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/generator": { + "version": "7.17.7", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.7.tgz", + "integrity": "sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.17.0", + "jsesc": "^2.5.1", + "source-map": "^0.5.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/traverse": { + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/traverse/node_modules/@babel/generator": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", + "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.26.2", + "@babel/types": "^7.26.0", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/traverse/node_modules/@babel/types": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", + "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/traverse/node_modules/jsesc": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/types": { + "version": "7.17.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", + "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.16.7", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@ts-morph/common": { "version": "0.19.0", "dev": true, @@ -16007,6 +16183,13 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "node_modules/javascript-natural-sort": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", + "integrity": "sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==", + "dev": true, + "license": "MIT" + }, "node_modules/jest-environment-node": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", @@ -19403,6 +19586,8 @@ }, "node_modules/prettier": { "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "license": "MIT", "bin": { "prettier": "bin-prettier.js" @@ -22086,6 +22271,9 @@ }, "node_modules/to-fast-properties": { "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, "license": "MIT", "engines": { "node": ">=4" diff --git a/package.json b/package.json index db9568f9..b8db074a 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ }, "devDependencies": { "@rosen-bridge/changeset-formatter": "^0.1.0", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@vitest/coverage-istanbul": "^1.3.1", "husky": "^8.0.0", "lint-staged": "^13.2.2", From f650e00f84f38aa5ec099a45218cfc3da79fbbc0 Mon Sep 17 00:00:00 2001 From: Masood Abdolian Date: Wed, 13 Nov 2024 13:03:42 +0000 Subject: [PATCH 2/5] fix: Refactor default exports to named exports in JavaScript modules for enhanced code clarity and maintainability --- .changeset/curly-bobcats-hang.md | 5 +++++ apps/rosen/app/(bridge)/BridgeForm.tsx | 8 ++++---- apps/rosen/app/(bridge)/BridgeTransaction.tsx | 6 +++--- apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx | 6 +++--- apps/rosen/app/(bridge)/page.tsx | 6 ++---- apps/rosen/app/App.tsx | 6 ++---- apps/rosen/app/Toolbar.tsx | 4 +--- apps/rosen/app/_backend/assets/repository.ts | 4 ++-- apps/rosen/app/_backend/dataSource.ts | 4 +--- apps/rosen/app/_backend/events/repository.ts | 2 +- .../app/_backend/initialize-datasource-if-needed.ts | 2 +- apps/rosen/app/_errors/NotFoundError.ts | 4 +--- apps/rosen/app/_hooks/useBridgeForm.ts | 6 ++---- apps/rosen/app/_hooks/useMaxTransfer.ts | 6 +++--- apps/rosen/app/_hooks/useNetwork.ts | 2 +- apps/rosen/app/_hooks/useTokenBalance.ts | 8 +++----- apps/rosen/app/_hooks/useTransaction.ts | 4 ++-- apps/rosen/app/_hooks/useTransactionFees.ts | 4 +--- apps/rosen/app/_hooks/useTransactionFormData.ts | 4 +--- apps/rosen/app/_hooks/useWallet.ts | 4 +--- apps/rosen/app/_networks/bitcoin/index.ts | 4 +--- apps/rosen/app/_networks/cardano/index.ts | 4 +--- apps/rosen/app/_networks/ergo/index.ts | 4 +--- apps/rosen/app/_networks/ethereum/index.ts | 4 +--- apps/rosen/app/_networks/index.ts | 8 ++++---- apps/rosen/app/api/v1/assets/detail/[id]/route.ts | 2 +- apps/rosen/app/api/v1/assets/route.ts | 2 +- apps/rosen/app/api/v1/events/route.ts | 6 +++--- apps/rosen/app/api/v1/events/validations.ts | 8 +------- apps/rosen/app/api/v1/withValidation.ts | 6 ++---- apps/rosen/app/assets/TableSkeleton.tsx | 4 +--- apps/rosen/app/assets/page.tsx | 2 +- apps/rosen/app/dashboard/page.tsx | 6 +++--- apps/rosen/app/events/TableSkeleton.tsx | 4 +--- apps/rosen/app/events/page.tsx | 8 +++----- apps/rosen/app/layout.tsx | 12 +++++++----- apps/rosen/app/support/page.tsx | 6 +++--- 37 files changed, 75 insertions(+), 110 deletions(-) create mode 100644 .changeset/curly-bobcats-hang.md diff --git a/.changeset/curly-bobcats-hang.md b/.changeset/curly-bobcats-hang.md new file mode 100644 index 00000000..39642d5c --- /dev/null +++ b/.changeset/curly-bobcats-hang.md @@ -0,0 +1,5 @@ +--- +'@rosen-bridge/rosen-app': patch +--- + +Refactor default exports to named exports in JavaScript modules for enhanced code clarity and maintainability diff --git a/apps/rosen/app/(bridge)/BridgeForm.tsx b/apps/rosen/app/(bridge)/BridgeForm.tsx index b1e54331..4c1d019e 100644 --- a/apps/rosen/app/(bridge)/BridgeForm.tsx +++ b/apps/rosen/app/(bridge)/BridgeForm.tsx @@ -18,13 +18,13 @@ import { import { NETWORKS } from '@rosen-ui/constants'; import { getDecimalString } from '@rosen-ui/utils'; -import useBridgeForm from '@/_hooks/useBridgeForm'; +import { useBridgeForm } from '@/_hooks/useBridgeForm'; import { useMaxTransfer } from '@/_hooks/useMaxTransfer'; import { useNetwork } from '@/_hooks/useNetwork'; -import useTokenBalance from '@/_hooks/useTokenBalance'; +import { useTokenBalance } from '@/_hooks/useTokenBalance'; import { useTokenMap } from '@/_hooks/useTokenMap'; -import useTransactionFormData from '@/_hooks/useTransactionFormData'; -import useWallet from '@/_hooks/useWallet'; +import { useTransactionFormData } from '@/_hooks/useTransactionFormData'; +import { useWallet } from '@/_hooks/useWallet'; import { getTokenNameAndId } from '@/_utils'; import { UseAllAmount } from './UseAllAmount'; diff --git a/apps/rosen/app/(bridge)/BridgeTransaction.tsx b/apps/rosen/app/(bridge)/BridgeTransaction.tsx index ae56ef4d..f3ef6726 100644 --- a/apps/rosen/app/(bridge)/BridgeTransaction.tsx +++ b/apps/rosen/app/(bridge)/BridgeTransaction.tsx @@ -13,9 +13,9 @@ import { import { useNetwork } from '@/_hooks/useNetwork'; import { useTokenMap } from '@/_hooks/useTokenMap'; -import useTransactionFees from '@/_hooks/useTransactionFees'; -import useTransactionFormData from '@/_hooks/useTransactionFormData'; -import useWallet from '@/_hooks/useWallet'; +import { useTransactionFees } from '@/_hooks/useTransactionFees'; +import { useTransactionFormData } from '@/_hooks/useTransactionFormData'; +import { useWallet } from '@/_hooks/useWallet'; import { getTokenNameAndId } from '@/_utils'; import { ChooseWalletModal } from './ChooseWalletModal'; diff --git a/apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx b/apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx index 2b4f4b47..2ba44bf5 100644 --- a/apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx +++ b/apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx @@ -18,9 +18,9 @@ import { import { useNetwork } from '@/_hooks/useNetwork'; import { useTokenMap } from '@/_hooks/useTokenMap'; import { useTransaction } from '@/_hooks/useTransaction'; -import useTransactionFees from '@/_hooks/useTransactionFees'; -import useTransactionFormData from '@/_hooks/useTransactionFormData'; -import useWallet from '@/_hooks/useWallet'; +import { useTransactionFees } from '@/_hooks/useTransactionFees'; +import { useTransactionFormData } from '@/_hooks/useTransactionFormData'; +import { useWallet } from '@/_hooks/useWallet'; import { getTokenNameAndId } from '@/_utils'; interface ConnectOrSubmitButtonProps { diff --git a/apps/rosen/app/(bridge)/page.tsx b/apps/rosen/app/(bridge)/page.tsx index 4695b17c..eeea8f01 100644 --- a/apps/rosen/app/(bridge)/page.tsx +++ b/apps/rosen/app/(bridge)/page.tsx @@ -40,7 +40,7 @@ export interface BridgeForm { /** * bridge main layout */ -const RosenBridge = () => { +export default function RosenBridge() { const [chooseWalletsModalOpen, setChooseWalletsModalOpen] = useState(false); const methods = useForm({ @@ -82,6 +82,4 @@ const RosenBridge = () => { ); -}; - -export default RosenBridge; +} diff --git a/apps/rosen/app/App.tsx b/apps/rosen/app/App.tsx index 8b8ab4f5..fa7e70d4 100644 --- a/apps/rosen/app/App.tsx +++ b/apps/rosen/app/App.tsx @@ -19,7 +19,7 @@ import { theme } from '@/_theme/theme'; import { WalletContextProvider } from './_contexts/walletContext'; import { SideBar } from './SideBar'; -import Toolbar from './Toolbar'; +import { Toolbar } from './Toolbar'; const Root = styled('div')(({ theme }) => ({ width: '100vw', @@ -44,7 +44,7 @@ interface AppProps { children?: React.ReactNode; } -const App = ({ children }: AppProps) => { +export const App = ({ children }: AppProps) => { return ( @@ -67,5 +67,3 @@ const App = ({ children }: AppProps) => { ); }; - -export default App; diff --git a/apps/rosen/app/Toolbar.tsx b/apps/rosen/app/Toolbar.tsx index 27aac730..6b444428 100644 --- a/apps/rosen/app/Toolbar.tsx +++ b/apps/rosen/app/Toolbar.tsx @@ -18,7 +18,7 @@ const pageTitleMap: Record = { /** * render toolbar containing page title and some actions */ -const Toolbar = () => { +export const Toolbar = () => { const page = useSelectedLayoutSegment(); return ( @@ -28,5 +28,3 @@ const Toolbar = () => { /> ); }; - -export default Toolbar; diff --git a/apps/rosen/app/_backend/assets/repository.ts b/apps/rosen/app/_backend/assets/repository.ts index 1028b4d8..ecce1068 100644 --- a/apps/rosen/app/_backend/assets/repository.ts +++ b/apps/rosen/app/_backend/assets/repository.ts @@ -5,9 +5,9 @@ import { } from '@rosen-ui/asset-calculator'; import { Network } from '@rosen-ui/types'; -import NotFoundError from '@/_errors/NotFoundError'; +import { NotFoundError } from '@/_errors/NotFoundError'; -import dataSource from '../dataSource'; +import { dataSource } from '../dataSource'; import '../initialize-datasource-if-needed'; const bridgedAssetRepository = dataSource.getRepository(BridgedAssetEntity); diff --git a/apps/rosen/app/_backend/dataSource.ts b/apps/rosen/app/_backend/dataSource.ts index 704e93a0..84c6b296 100644 --- a/apps/rosen/app/_backend/dataSource.ts +++ b/apps/rosen/app/_backend/dataSource.ts @@ -18,7 +18,7 @@ import { migrations as assetCalculatorMigrations, } from '@rosen-ui/asset-calculator'; -const dataSource = new DataSource({ +export const dataSource = new DataSource({ type: 'postgres', url: process.env.POSTGRES_URL, ssl: process.env.POSTGRES_USE_SSL === 'true', @@ -39,5 +39,3 @@ const dataSource = new DataSource({ ...assetCalculatorMigrations.postgres, ], }); - -export default dataSource; diff --git a/apps/rosen/app/_backend/events/repository.ts b/apps/rosen/app/_backend/events/repository.ts index e0622541..db9410d4 100644 --- a/apps/rosen/app/_backend/events/repository.ts +++ b/apps/rosen/app/_backend/events/repository.ts @@ -3,7 +3,7 @@ import { BlockEntity } from '@rosen-bridge/scanner'; import { EventTriggerEntity } from '@rosen-bridge/watcher-data-extractor'; import { Network } from '@rosen-ui/types'; -import dataSource from '../dataSource'; +import { dataSource } from '../dataSource'; import '../initialize-datasource-if-needed'; const blockRepository = dataSource.getRepository(BlockEntity); diff --git a/apps/rosen/app/_backend/initialize-datasource-if-needed.ts b/apps/rosen/app/_backend/initialize-datasource-if-needed.ts index 1f3a5e36..cc45516a 100644 --- a/apps/rosen/app/_backend/initialize-datasource-if-needed.ts +++ b/apps/rosen/app/_backend/initialize-datasource-if-needed.ts @@ -1,4 +1,4 @@ -import dataSource from './dataSource'; +import { dataSource } from './dataSource'; if (!dataSource.isInitialized) { await dataSource.initialize(); diff --git a/apps/rosen/app/_errors/NotFoundError.ts b/apps/rosen/app/_errors/NotFoundError.ts index 2ba6e18b..0e1f90f3 100644 --- a/apps/rosen/app/_errors/NotFoundError.ts +++ b/apps/rosen/app/_errors/NotFoundError.ts @@ -1,3 +1 @@ -class NotFoundError extends Error {} - -export default NotFoundError; +export class NotFoundError extends Error {} diff --git a/apps/rosen/app/_hooks/useBridgeForm.ts b/apps/rosen/app/_hooks/useBridgeForm.ts index 8b8863dc..4e342e04 100644 --- a/apps/rosen/app/_hooks/useBridgeForm.ts +++ b/apps/rosen/app/_hooks/useBridgeForm.ts @@ -11,14 +11,14 @@ import { unwrap } from '@/_safeServerAction'; import { getMaxTransfer, getMinTransfer } from '@/_utils'; import { useTokenMap } from './useTokenMap'; -import useTransactionFormData from './useTransactionFormData'; +import { useTransactionFormData } from './useTransactionFormData'; /** * handles the form field registrations and form state changes * and validations */ -const useBridgeForm = () => { +export const useBridgeForm = () => { const { control, resetField, reset, setValue, formState, setFocus } = useTransactionFormData(); @@ -141,5 +141,3 @@ const useBridgeForm = () => { formState, }; }; - -export default useBridgeForm; diff --git a/apps/rosen/app/_hooks/useMaxTransfer.ts b/apps/rosen/app/_hooks/useMaxTransfer.ts index 13450036..f8a350bd 100644 --- a/apps/rosen/app/_hooks/useMaxTransfer.ts +++ b/apps/rosen/app/_hooks/useMaxTransfer.ts @@ -6,9 +6,9 @@ import { RosenAmountValue } from '@rosen-ui/types'; import { getMaxTransfer } from '@/_utils'; import { useNetwork } from './useNetwork'; -import useTokenBalance from './useTokenBalance'; -import useTransactionFormData from './useTransactionFormData'; -import useWallet from './useWallet'; +import { useTokenBalance } from './useTokenBalance'; +import { useTransactionFormData } from './useTransactionFormData'; +import { useWallet } from './useWallet'; /** * a hook version of `getMaxTransfer` util diff --git a/apps/rosen/app/_hooks/useNetwork.ts b/apps/rosen/app/_hooks/useNetwork.ts index b05e53f7..56776bc4 100644 --- a/apps/rosen/app/_hooks/useNetwork.ts +++ b/apps/rosen/app/_hooks/useNetwork.ts @@ -6,7 +6,7 @@ import { Network } from '@rosen-ui/types'; import { AvailableNetworks, availableNetworks } from '@/_networks'; -import useBridgeForm from './useBridgeForm'; +import { useBridgeForm } from './useBridgeForm'; import { useTokenMap } from './useTokenMap'; type BlackList = { diff --git a/apps/rosen/app/_hooks/useTokenBalance.ts b/apps/rosen/app/_hooks/useTokenBalance.ts index 3be931cc..865f71d9 100644 --- a/apps/rosen/app/_hooks/useTokenBalance.ts +++ b/apps/rosen/app/_hooks/useTokenBalance.ts @@ -4,8 +4,8 @@ import { TokenInfo } from '@rosen-ui/types'; import { RosenAmountValue } from '@rosen-ui/types'; import { Wallet } from '@rosen-ui/wallet-api'; -import useBridgeForm from './useBridgeForm'; -import useWallet from './useWallet'; +import { useBridgeForm } from './useBridgeForm'; +import { useWallet } from './useWallet'; interface UseTokenBalance { isLoading: boolean; @@ -18,7 +18,7 @@ interface UseTokenBalance { * returns the amount of currently selected asset * @returns CONTAINS A WRAPPED-VALUE */ -const useTokenBalance = () => { +export const useTokenBalance = () => { const [balanceState, setBalanceState] = useState({ isLoading: false, amount: 0n, @@ -65,5 +65,3 @@ const useTokenBalance = () => { return balanceState; }; - -export default useTokenBalance; diff --git a/apps/rosen/app/_hooks/useTransaction.ts b/apps/rosen/app/_hooks/useTransaction.ts index 677d097e..f945e7a2 100644 --- a/apps/rosen/app/_hooks/useTransaction.ts +++ b/apps/rosen/app/_hooks/useTransaction.ts @@ -7,8 +7,8 @@ import { getNonDecimalString } from '@rosen-ui/utils'; import { useNetwork } from './useNetwork'; import { useTokenMap } from './useTokenMap'; -import useTransactionFormData from './useTransactionFormData'; -import useWallet from './useWallet'; +import { useTransactionFormData } from './useTransactionFormData'; +import { useWallet } from './useWallet'; /** * a react hook to create and sign and submit transactions diff --git a/apps/rosen/app/_hooks/useTransactionFees.ts b/apps/rosen/app/_hooks/useTransactionFees.ts index e0cf6129..c2b0a37f 100644 --- a/apps/rosen/app/_hooks/useTransactionFees.ts +++ b/apps/rosen/app/_hooks/useTransactionFees.ts @@ -15,7 +15,7 @@ import { useTokenMap } from './useTokenMap'; * calculates the fees for a token swap between * two networks */ -const useTransactionFees = ( +export const useTransactionFees = ( sourceChain: Network | null, targetChain: Network | null, token: RosenChainToken | null, @@ -167,5 +167,3 @@ const useTransactionFees = ( return transactionFees; }; - -export default useTransactionFees; diff --git a/apps/rosen/app/_hooks/useTransactionFormData.ts b/apps/rosen/app/_hooks/useTransactionFormData.ts index d6afa1b3..e30c3240 100644 --- a/apps/rosen/app/_hooks/useTransactionFormData.ts +++ b/apps/rosen/app/_hooks/useTransactionFormData.ts @@ -8,7 +8,7 @@ import type { BridgeForm } from '@/(bridge)/page'; * provide access to the bridge form context and current form values */ -const useTransactionFormData = () => { +export const useTransactionFormData = () => { const { control, ...rest } = useFormContext(); const sourceValue = useWatch({ control, name: 'source' }) as Network | null; @@ -27,5 +27,3 @@ const useTransactionFormData = () => { ...rest, }; }; - -export default useTransactionFormData; diff --git a/apps/rosen/app/_hooks/useWallet.ts b/apps/rosen/app/_hooks/useWallet.ts index 41d318f0..bf073965 100644 --- a/apps/rosen/app/_hooks/useWallet.ts +++ b/apps/rosen/app/_hooks/useWallet.ts @@ -27,7 +27,7 @@ const toWalletDescriptor = (wallet: WalletBase): WalletDescriptor => { * handles the wallet connections for all the networks * and reconnect to the wallet on app startup */ -const useWallet = () => { +export const useWallet = () => { const walletGlobalContext = useContext(WalletContext); const isConnecting = useRef(false); const { get, set } = useLocalStorageManager(); @@ -127,5 +127,3 @@ const useWallet = () => { } : {}; }; - -export default useWallet; diff --git a/apps/rosen/app/_networks/bitcoin/index.ts b/apps/rosen/app/_networks/bitcoin/index.ts index c9bdecd7..bd2e0008 100644 --- a/apps/rosen/app/_networks/bitcoin/index.ts +++ b/apps/rosen/app/_networks/bitcoin/index.ts @@ -27,7 +27,7 @@ const config = { * providing access to network info and wallets and network specific * functionality */ -const BitcoinNetwork: BitcoinNetworkType = { +export const BitcoinNetwork: BitcoinNetworkType = { name: NETWORKS.BITCOIN, label: NETWORK_LABELS.BITCOIN, logo: BitcoinIcon, @@ -37,5 +37,3 @@ const BitcoinNetwork: BitcoinNetworkType = { getMaxTransfer: unwrap(getMaxTransfer), toSafeAddress: (address) => address, }; - -export default BitcoinNetwork; diff --git a/apps/rosen/app/_networks/cardano/index.ts b/apps/rosen/app/_networks/cardano/index.ts index 81e33274..dc8282fc 100644 --- a/apps/rosen/app/_networks/cardano/index.ts +++ b/apps/rosen/app/_networks/cardano/index.ts @@ -30,7 +30,7 @@ const config = { * providing access to network info and wallets and network specific * functionality */ -const CardanoNetwork: CardanoNetworkType = { +export const CardanoNetwork: CardanoNetworkType = { name: NETWORKS.CARDANO, label: NETWORK_LABELS.CARDANO, wallets: [ @@ -45,5 +45,3 @@ const CardanoNetwork: CardanoNetworkType = { getMaxTransfer: unwrap(getMaxTransfer), toSafeAddress: (address) => address, }; - -export default CardanoNetwork; diff --git a/apps/rosen/app/_networks/ergo/index.ts b/apps/rosen/app/_networks/ergo/index.ts index acb00bbd..55ca7552 100644 --- a/apps/rosen/app/_networks/ergo/index.ts +++ b/apps/rosen/app/_networks/ergo/index.ts @@ -19,7 +19,7 @@ const config = { * providing access to network info and wallets and network specific * functionality */ -const ErgoNetwork: ErgoNetworkType = { +export const ErgoNetwork: ErgoNetworkType = { name: NETWORKS.ERGO, label: NETWORK_LABELS.ERGO, wallets: [nautilusWalletCreator(config)], @@ -29,5 +29,3 @@ const ErgoNetwork: ErgoNetworkType = { getMaxTransfer: unwrap(getMaxTransfer), toSafeAddress: (address) => address, }; - -export default ErgoNetwork; diff --git a/apps/rosen/app/_networks/ethereum/index.ts b/apps/rosen/app/_networks/ethereum/index.ts index bcfc420b..5f485475 100644 --- a/apps/rosen/app/_networks/ethereum/index.ts +++ b/apps/rosen/app/_networks/ethereum/index.ts @@ -14,7 +14,7 @@ import { generateLockData, generateTxParameters } from './server'; * providing access to network info and wallets and network specific * functionality */ -const EthereumNetwork: EthereumNetworkType = { +export const EthereumNetwork: EthereumNetworkType = { name: NETWORKS.ETHEREUM, label: NETWORK_LABELS.ETHEREUM, wallets: [ @@ -30,5 +30,3 @@ const EthereumNetwork: EthereumNetworkType = { getMaxTransfer: unwrap(getMaxTransfer), toSafeAddress: (address) => address.toLowerCase(), }; - -export default EthereumNetwork; diff --git a/apps/rosen/app/_networks/index.ts b/apps/rosen/app/_networks/index.ts index 91de7c40..51b573ab 100644 --- a/apps/rosen/app/_networks/index.ts +++ b/apps/rosen/app/_networks/index.ts @@ -1,9 +1,9 @@ import { NETWORKS } from '@rosen-ui/constants'; -import BitcoinNetwork from './bitcoin'; -import CardanoNetwork from './cardano'; -import ErgoNetwork from './ergo'; -import EthereumNetwork from './ethereum'; +import { BitcoinNetwork } from './bitcoin'; +import { CardanoNetwork } from './cardano'; +import { ErgoNetwork } from './ergo'; +import { EthereumNetwork } from './ethereum'; export const availableNetworks = { [NETWORKS.ERGO]: ErgoNetwork, diff --git a/apps/rosen/app/api/v1/assets/detail/[id]/route.ts b/apps/rosen/app/api/v1/assets/detail/[id]/route.ts index 2f238cbe..07eec5e6 100644 --- a/apps/rosen/app/api/v1/assets/detail/[id]/route.ts +++ b/apps/rosen/app/api/v1/assets/detail/[id]/route.ts @@ -1,6 +1,6 @@ import { getAsset } from '@/_backend/assets'; -import withValidation from '../../../withValidation'; +import { withValidation } from '../../../withValidation'; import { validateGet } from './validations'; export const GET = withValidation(validateGet, (value) => getAsset(value.id)); diff --git a/apps/rosen/app/api/v1/assets/route.ts b/apps/rosen/app/api/v1/assets/route.ts index 56ce8fa8..b37e0f64 100644 --- a/apps/rosen/app/api/v1/assets/route.ts +++ b/apps/rosen/app/api/v1/assets/route.ts @@ -2,7 +2,7 @@ import { pick } from 'lodash-es'; import { getAllAssets } from '@/_backend/assets'; -import withValidation from '../withValidation'; +import { withValidation } from '../withValidation'; import { validateGet } from './validations'; export const GET = withValidation(validateGet, (value) => diff --git a/apps/rosen/app/api/v1/events/route.ts b/apps/rosen/app/api/v1/events/route.ts index 30e9e271..e37678dd 100644 --- a/apps/rosen/app/api/v1/events/route.ts +++ b/apps/rosen/app/api/v1/events/route.ts @@ -1,8 +1,8 @@ import { getEventsWithFullTokenData } from '@/_backend/events'; -import withValidation from '../withValidation'; -import EventsValidations from './validations'; +import { withValidation } from '../withValidation'; +import { validateGet } from './validations'; -export const GET = withValidation(EventsValidations.GET, (value) => +export const GET = withValidation(validateGet, (value) => getEventsWithFullTokenData(value.offset, value.limit), ); diff --git a/apps/rosen/app/api/v1/events/validations.ts b/apps/rosen/app/api/v1/events/validations.ts index 24a5cf7a..cbd365d0 100644 --- a/apps/rosen/app/api/v1/events/validations.ts +++ b/apps/rosen/app/api/v1/events/validations.ts @@ -15,12 +15,6 @@ const getQueryParamsSchema = Joi.object().keys({ * validate get requests * @param request */ -const validateGet = ({ nextUrl: { searchParams } }: NextRequest) => { +export const validateGet = ({ nextUrl: { searchParams } }: NextRequest) => { return getQueryParamsSchema.validate(Object.fromEntries(searchParams)); }; - -const EventsValidations = { - GET: validateGet, -}; - -export default EventsValidations; diff --git a/apps/rosen/app/api/v1/withValidation.ts b/apps/rosen/app/api/v1/withValidation.ts index b832658d..1a1a82bf 100644 --- a/apps/rosen/app/api/v1/withValidation.ts +++ b/apps/rosen/app/api/v1/withValidation.ts @@ -2,7 +2,7 @@ import { NextRequest } from 'next/server'; import { ValidationResult } from 'joi'; -import NotFoundError from '@/_errors/NotFoundError'; +import { NotFoundError } from '@/_errors/NotFoundError'; /** * a wrapper around handler returning a function which validates request, @@ -12,7 +12,7 @@ import NotFoundError from '@/_errors/NotFoundError'; * @param validator * @param handler */ -const withValidation = +export const withValidation = ( validator: ( request: NextRequest, @@ -40,5 +40,3 @@ const withValidation = return Response.json(JSON.stringify(error), { status: 500 }); } }; - -export default withValidation; diff --git a/apps/rosen/app/assets/TableSkeleton.tsx b/apps/rosen/app/assets/TableSkeleton.tsx index 0a760bc4..174cc526 100644 --- a/apps/rosen/app/assets/TableSkeleton.tsx +++ b/apps/rosen/app/assets/TableSkeleton.tsx @@ -13,7 +13,7 @@ interface TableSkeletonProps { numberOfItems: number; } -const TableSkeleton: FC = (props) => { +export const TableSkeleton: FC = (props) => { const renderMobileRow = useCallback( () => ( @@ -65,5 +65,3 @@ const TableSkeleton: FC = (props) => { /> ); }; - -export default TableSkeleton; diff --git a/apps/rosen/app/assets/page.tsx b/apps/rosen/app/assets/page.tsx index 46a56803..ea5a98c8 100644 --- a/apps/rosen/app/assets/page.tsx +++ b/apps/rosen/app/assets/page.tsx @@ -23,7 +23,7 @@ import { Network } from '@rosen-ui/types'; import { ApiAssetsResponse, Assets } from '@/_types/api'; import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow'; -import TableSkeleton from './TableSkeleton'; +import { TableSkeleton } from './TableSkeleton'; const getKey = (chain: Network | 'all') => (offset: number, limit: number) => { return [ diff --git a/apps/rosen/app/dashboard/page.tsx b/apps/rosen/app/dashboard/page.tsx index ab52d8d0..275e00d0 100644 --- a/apps/rosen/app/dashboard/page.tsx +++ b/apps/rosen/app/dashboard/page.tsx @@ -1,5 +1,5 @@ 'use client'; -const Dashboard = () => null; - -export default Dashboard; +export default function Dashboard() { + return null; +} diff --git a/apps/rosen/app/events/TableSkeleton.tsx b/apps/rosen/app/events/TableSkeleton.tsx index 0a760bc4..174cc526 100644 --- a/apps/rosen/app/events/TableSkeleton.tsx +++ b/apps/rosen/app/events/TableSkeleton.tsx @@ -13,7 +13,7 @@ interface TableSkeletonProps { numberOfItems: number; } -const TableSkeleton: FC = (props) => { +export const TableSkeleton: FC = (props) => { const renderMobileRow = useCallback( () => ( @@ -65,5 +65,3 @@ const TableSkeleton: FC = (props) => { /> ); }; - -export default TableSkeleton; diff --git a/apps/rosen/app/events/page.tsx b/apps/rosen/app/events/page.tsx index a4acdb5a..743e6ecd 100644 --- a/apps/rosen/app/events/page.tsx +++ b/apps/rosen/app/events/page.tsx @@ -16,13 +16,13 @@ import { import { ApiEventResponse, Event } from '@/_types/api'; import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow'; -import TableSkeleton from './TableSkeleton'; +import { TableSkeleton } from './TableSkeleton'; const getKey = (offset: number, limit: number) => { return ['/v1/events', { offset, limit }]; }; -const Events = () => { +export default function Events() { const { data, isLoading, @@ -121,6 +121,4 @@ const Events = () => { ); -}; - -export default Events; +} diff --git a/apps/rosen/app/layout.tsx b/apps/rosen/app/layout.tsx index 572800ec..1c74a2df 100644 --- a/apps/rosen/app/layout.tsx +++ b/apps/rosen/app/layout.tsx @@ -1,12 +1,16 @@ import { Metadata } from 'next'; -import App from './App'; +import { App } from './App'; export const metadata: Metadata = { title: 'Rosen Bridge', }; -const RootLayout = ({ children }: { children: React.ReactNode }) => { +export default function RootLayout({ + children, +}: { + children: React.ReactNode; +}) { return ( /** * TODO: get `lang` from url language path segment @@ -18,6 +22,4 @@ const RootLayout = ({ children }: { children: React.ReactNode }) => { ); -}; - -export default RootLayout; +} diff --git a/apps/rosen/app/support/page.tsx b/apps/rosen/app/support/page.tsx index 4c66d849..5e9233ee 100644 --- a/apps/rosen/app/support/page.tsx +++ b/apps/rosen/app/support/page.tsx @@ -1,5 +1,5 @@ 'use client'; -const Support = () => null; - -export default Support; +export default function Support() { + return null; +} From 524ad003aba072485b4f472a749cf3dd7ca530b3 Mon Sep 17 00:00:00 2001 From: Masood Abdolian Date: Thu, 14 Nov 2024 08:29:50 +0000 Subject: [PATCH 3/5] fix: Restore the .prettierrc file from root --- .prettierrc | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.prettierrc b/.prettierrc index dd317443..544138be 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,15 +1,3 @@ { - "quoteProps": "consistent", - "singleQuote": true, - "importOrder": [ - "^(@?react|@?next)", - "", - "^@/(.*)$", - "^[.](.*)" - ], - "importOrderCaseInsensitive": true, - "importOrderParserPlugins": ["typescript", "jsx"], - "importOrderSeparation": true, - "importOrderSortSpecifiers": false, - "plugins": ["@trivago/prettier-plugin-sort-imports"] + "singleQuote": true } From f9c84fdbd175b0d2b3f5ad81619c1074c265de45 Mon Sep 17 00:00:00 2001 From: Masood Abdolian Date: Sat, 16 Nov 2024 07:22:00 +0000 Subject: [PATCH 4/5] fix: Move the @trivago/prettier-plugin-sort-imports dependencies to the devDependencies section --- apps/rosen/package.json | 2 +- package-lock.json | 17 +++++++++++++++-- package.json | 1 - 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/rosen/package.json b/apps/rosen/package.json index 776e9132..e27342a9 100644 --- a/apps/rosen/package.json +++ b/apps/rosen/package.json @@ -43,7 +43,6 @@ "@rosen-ui/vespr-wallet": "^0.0.9", "@rosen-ui/wallet-api": "^1.0.3", "@rosen-ui/xdefi-wallet": "^1.0.1", - "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@upstash/ratelimit": "^1.2.1", "@vercel/kv": "^2.0.0", "buffer": "^6.0.3", @@ -60,6 +59,7 @@ "swr": "^2.2.0" }, "devDependencies": { + "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/lodash-es": "^4.17.10", "@types/node": "20.5.7", "@types/react": "18.2.12", diff --git a/package-lock.json b/package-lock.json index 53be3ab5..37da692b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ }, "devDependencies": { "@rosen-bridge/changeset-formatter": "^0.1.0", - "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@vitest/coverage-istanbul": "^1.3.1", "husky": "^8.0.0", "lint-staged": "^13.2.2", @@ -110,7 +109,6 @@ "@rosen-ui/vespr-wallet": "^0.0.9", "@rosen-ui/wallet-api": "^1.0.3", "@rosen-ui/xdefi-wallet": "^1.0.1", - "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@upstash/ratelimit": "^1.2.1", "@vercel/kv": "^2.0.0", "buffer": "^6.0.3", @@ -127,6 +125,7 @@ "swr": "^2.2.0" }, "devDependencies": { + "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/lodash-es": "^4.17.10", "@types/node": "20.5.7", "@types/react": "18.2.12", @@ -702,6 +701,7 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.24.7" @@ -714,6 +714,7 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz", "integrity": "sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==", + "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.24.7", @@ -727,6 +728,7 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz", "integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==", + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.24.7" @@ -861,6 +863,7 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz", "integrity": "sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==", + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.24.7" @@ -9626,6 +9629,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-4.3.0.tgz", "integrity": "sha512-r3n0onD3BTOVUNPhR4lhVK4/pABGpbA7bW3eumZnYdKaHkf1qEC+Mag6DPbGNuuh0eG8AaYj+YqmVHSiGslaTQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@babel/generator": "7.17.7", @@ -9649,6 +9653,7 @@ "version": "7.17.7", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.7.tgz", "integrity": "sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==", + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.17.0", @@ -9663,6 +9668,7 @@ "version": "7.23.2", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.22.13", @@ -9684,6 +9690,7 @@ "version": "7.26.2", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", + "dev": true, "license": "MIT", "dependencies": { "@babel/parser": "^7.26.2", @@ -9700,6 +9707,7 @@ "version": "7.26.0", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", + "dev": true, "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.25.9", @@ -9713,6 +9721,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, "license": "MIT", "bin": { "jsesc": "bin/jsesc" @@ -9725,6 +9734,7 @@ "version": "7.17.0", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", + "dev": true, "license": "MIT", "dependencies": { "@babel/helper-validator-identifier": "^7.16.7", @@ -16180,6 +16190,7 @@ "version": "0.7.1", "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", "integrity": "sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==", + "dev": true, "license": "MIT" }, "node_modules/jest-environment-node": { @@ -17021,6 +17032,7 @@ }, "node_modules/lodash": { "version": "4.17.21", + "dev": true, "license": "MIT" }, "node_modules/lodash-es": { @@ -22264,6 +22276,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, "license": "MIT", "engines": { "node": ">=4" diff --git a/package.json b/package.json index b8db074a..db9568f9 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ }, "devDependencies": { "@rosen-bridge/changeset-formatter": "^0.1.0", - "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@vitest/coverage-istanbul": "^1.3.1", "husky": "^8.0.0", "lint-staged": "^13.2.2", From 7e96139ebd8339ee04d64e763ff21746d3c772db Mon Sep 17 00:00:00 2001 From: Masood Abdolian Date: Sat, 16 Nov 2024 12:37:18 +0000 Subject: [PATCH 5/5] fix: Refactor the declaration functions into arrow functions within the Rosen App --- apps/rosen/app/(bridge)/page.tsx | 6 ++++-- apps/rosen/app/assets/page.tsx | 12 +++++++----- apps/rosen/app/dashboard/page.tsx | 6 +++--- apps/rosen/app/events/page.tsx | 6 ++++-- apps/rosen/app/layout.tsx | 10 ++++------ apps/rosen/app/support/page.tsx | 6 +++--- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/apps/rosen/app/(bridge)/page.tsx b/apps/rosen/app/(bridge)/page.tsx index eeea8f01..4695b17c 100644 --- a/apps/rosen/app/(bridge)/page.tsx +++ b/apps/rosen/app/(bridge)/page.tsx @@ -40,7 +40,7 @@ export interface BridgeForm { /** * bridge main layout */ -export default function RosenBridge() { +const RosenBridge = () => { const [chooseWalletsModalOpen, setChooseWalletsModalOpen] = useState(false); const methods = useForm({ @@ -82,4 +82,6 @@ export default function RosenBridge() { ); -} +}; + +export default RosenBridge; diff --git a/apps/rosen/app/assets/page.tsx b/apps/rosen/app/assets/page.tsx index ea5a98c8..b7d9735b 100644 --- a/apps/rosen/app/assets/page.tsx +++ b/apps/rosen/app/assets/page.tsx @@ -20,7 +20,7 @@ import { import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants'; import { Network } from '@rosen-ui/types'; -import { ApiAssetsResponse, Assets } from '@/_types/api'; +import { ApiAssetsResponse, Assets as AssetsModel } from '@/_types/api'; import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow'; import { TableSkeleton } from './TableSkeleton'; @@ -32,7 +32,7 @@ const getKey = (chain: Network | 'all') => (offset: number, limit: number) => { ]; }; -export default function Page() { +const Assets = () => { const [network, setNetwork] = useState('all'); const { @@ -66,12 +66,12 @@ export default function Page() { ); const renderMobileRow = useCallback( - (rowData: Assets) => , + (rowData: AssetsModel) => , [isLoading], ); const renderTabletRow = useCallback( - (rowData: Assets) => , + (rowData: AssetsModel) => , [isLoading], ); @@ -188,4 +188,6 @@ export default function Page() { ); -} +}; + +export default Assets; diff --git a/apps/rosen/app/dashboard/page.tsx b/apps/rosen/app/dashboard/page.tsx index 275e00d0..ab52d8d0 100644 --- a/apps/rosen/app/dashboard/page.tsx +++ b/apps/rosen/app/dashboard/page.tsx @@ -1,5 +1,5 @@ 'use client'; -export default function Dashboard() { - return null; -} +const Dashboard = () => null; + +export default Dashboard; diff --git a/apps/rosen/app/events/page.tsx b/apps/rosen/app/events/page.tsx index 743e6ecd..52c5532e 100644 --- a/apps/rosen/app/events/page.tsx +++ b/apps/rosen/app/events/page.tsx @@ -22,7 +22,7 @@ const getKey = (offset: number, limit: number) => { return ['/v1/events', { offset, limit }]; }; -export default function Events() { +const Events = () => { const { data, isLoading, @@ -121,4 +121,6 @@ export default function Events() { ); -} +}; + +export default Events; diff --git a/apps/rosen/app/layout.tsx b/apps/rosen/app/layout.tsx index 1c74a2df..ff364689 100644 --- a/apps/rosen/app/layout.tsx +++ b/apps/rosen/app/layout.tsx @@ -6,11 +6,7 @@ export const metadata: Metadata = { title: 'Rosen Bridge', }; -export default function RootLayout({ - children, -}: { - children: React.ReactNode; -}) { +const RootLayout = ({ children }: { children: React.ReactNode }) => { return ( /** * TODO: get `lang` from url language path segment @@ -22,4 +18,6 @@ export default function RootLayout({ ); -} +}; + +export default RootLayout; diff --git a/apps/rosen/app/support/page.tsx b/apps/rosen/app/support/page.tsx index 5e9233ee..4c66d849 100644 --- a/apps/rosen/app/support/page.tsx +++ b/apps/rosen/app/support/page.tsx @@ -1,5 +1,5 @@ 'use client'; -export default function Support() { - return null; -} +const Support = () => null; + +export default Support;