Skip to content

Commit

Permalink
Merge branch '422-revise-the-prettier-configuration-to-ensure-that-im…
Browse files Browse the repository at this point in the history
…ports-are-sorted' into 'dev'

Resolve "Revise the Prettier configuration to ensure that imports are sorted"

Closes #422

See merge request ergo/rosen-bridge/ui!350
  • Loading branch information
vorujack committed Nov 16, 2024
2 parents 724ece0 + 9e40c6a commit 0230e3c
Show file tree
Hide file tree
Showing 53 changed files with 366 additions and 179 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-crews-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/rosen-app': minor
---

Revise the Prettier configuration to ensure that imports are sorted
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode"]
}
20 changes: 20 additions & 0 deletions apps/rosen/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"quoteProps": "consistent",
"singleQuote": true,
"importOrder": [
"^(@?react|@?next)",
"<THIRD_PARTY_MODULES>",
"^@/(.*)$",
"^[.](.*)"
],
"importOrderCaseInsensitive": true,
"importOrderParserPlugins": [
"typescript",
"jsx",
"classProperties",
"[\"decorators\", { \"decoratorsBeforeExport\": true }]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": false,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
18 changes: 9 additions & 9 deletions apps/rosen/app/(bridge)/BridgeForm.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -290,7 +290,7 @@ export const BridgeForm = () => {
),
}}
inputProps={{
style: { fontSize: '2rem' },
'style': { fontSize: '2rem' },
'aria-label': 'amount input',
}}
variant="filled"
Expand Down
5 changes: 3 additions & 2 deletions apps/rosen/app/(bridge)/BridgeTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use client';

import { Dispatch, SetStateAction } from 'react';

import {
Alert,
Amount,
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion apps/rosen/app/(bridge)/ConnectOrSubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion apps/rosen/app/(bridge)/UseAllAmount.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SyncProblem } from '@rosen-bridge/icons';
import {
Button,
CircularProgress,
Expand All @@ -7,7 +8,6 @@ import {
SvgIcon,
Typography,
} from '@rosen-bridge/ui-kit';
import { SyncProblem } from '@rosen-bridge/icons';

export interface UseAllAmountProps {
error: boolean;
Expand Down
24 changes: 12 additions & 12 deletions apps/rosen/app/(bridge)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 5 additions & 6 deletions apps/rosen/app/App.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions apps/rosen/app/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {

const pageTitleMap: Record<string, string> = {
'(bridge)': 'Rosen Bridge',
events: 'Events',
assets: 'Assets',
dashboard: 'Dashboard',
support: 'Support',
transactions: 'Transactions',
'events': 'Events',
'assets': 'Assets',
'dashboard': 'Dashboard',
'support': 'Support',
'transactions': 'Transactions',
};

/**
Expand Down
10 changes: 5 additions & 5 deletions apps/rosen/app/_actions/calculateFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!,
Expand All @@ -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 () =>
Expand Down
4 changes: 2 additions & 2 deletions apps/rosen/app/_actions/validateAddress.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions apps/rosen/app/_backend/assets/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion apps/rosen/app/_backend/events/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions apps/rosen/app/_backend/events/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
1 change: 1 addition & 0 deletions apps/rosen/app/_backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fs from 'fs';
import path from 'path';

import { wrap } from '@/_safeServerAction';

/**
Expand Down
12 changes: 5 additions & 7 deletions apps/rosen/app/_hooks/useBridgeForm.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions apps/rosen/app/_hooks/useMaxTransfer.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
5 changes: 3 additions & 2 deletions apps/rosen/app/_hooks/useNetwork.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 2 additions & 3 deletions apps/rosen/app/_hooks/useTokenBalance.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions apps/rosen/app/_hooks/useTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions apps/rosen/app/_hooks/useTransactionFees.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down
Loading

0 comments on commit 0230e3c

Please sign in to comment.