Skip to content

Commit

Permalink
add swap & fix bug (#3225)
Browse files Browse the repository at this point in the history
* add swap & fix bug

* add liquidity

* fix bug

* fix bug

* fix
  • Loading branch information
wow-sven authored Jan 26, 2025
1 parent 1d9251c commit a5d75bc
Show file tree
Hide file tree
Showing 37 changed files with 2,486 additions and 70 deletions.
1 change: 1 addition & 0 deletions infra/rooch-portal-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@iconify/react": "^5.0.1",
"@mui/lab": "^5.0.0-alpha.170",
"@mui/material": "^5.15.20",
"@mui/icons-material": "6.4.0",
"@mui/material-nextjs": "^5.15.11",
"@mui/x-data-grid": "^7.7.0",
"@mui/x-date-pickers": "^7.7.0",
Expand Down
5 changes: 4 additions & 1 deletion infra/rooch-portal-v2/src/app/apps/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import AppsView, { Project } from 'src/sections/apps/view';
import type { Project } from 'src/sections/apps/view';

import AppsView from 'src/sections/apps/view';

import { getAvatar } from '../../utils/avatar';

export const metadata = { title: `Apps` };
Expand Down
9 changes: 9 additions & 0 deletions infra/rooch-portal-v2/src/app/trade/liquidity/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import LiquidityPage from 'src/sections/trade/liquidity/view';

export const metadata = {
title: 'liquidity',
};

export default function Page() {
return <LiquidityPage />;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MarketplaceView from 'src/sections/trade/view';
import MarketplaceView from 'src/sections/trade/market/view';

export const metadata = {
title: 'Market | Orderbook',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HomeView from 'src/sections/trade/home-view';
import HomeView from 'src/sections/trade/market/home-view';

// ----------------------------------------------------------------------

Expand Down
15 changes: 15 additions & 0 deletions infra/rooch-portal-v2/src/app/trade/swap/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import WalletGuard from 'src/components/guard/WalletGuard';

import PoolView from 'src/sections/trade/swap/view';

export const metadata = {
title: 'swap',
};

export default function Page({ params }: { params: { tick: string } }) {
return (
<WalletGuard>
<PoolView />
</WalletGuard>
);
}
8 changes: 6 additions & 2 deletions infra/rooch-portal-v2/src/components/guard/WalletGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DashboardContent } from 'src/layouts/dashboard';
import { Iconify } from '../iconify';

export default function CustomWalletGuard({ children }: { children: ReactNode }) {
const { status } = useCurrentWallet();
const { status, wallet } = useCurrentWallet();

if (status === 'connected') {
return children;
Expand Down Expand Up @@ -47,7 +47,11 @@ export default function CustomWalletGuard({ children }: { children: ReactNode })
spacing={2}
>
<Iconify icon="solar:wallet-money-bold-duotone" width="64px" />
<WalletGuard onClick={() => {}}>
<WalletGuard
onClick={() => {
console.log('hahah');
}}
>
<Button variant="outlined">Connect</Button>
</WalletGuard>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Link from 'next/link';

import { yellow } from '@mui/material/colors';
import { Chip, Stack, Typography } from '@mui/material';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { BalanceInfoView } from '@roochnetwork/rooch-sdk';

import Link from 'next/link';
import BigNumber from 'bignumber.js';
import { useCurrentAddress } from '@roochnetwork/rooch-sdk-kit';

Expand Down
4 changes: 1 addition & 3 deletions infra/rooch-portal-v2/src/components/market/list-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ import {
InputAdornment,
} from '@mui/material';

import { toDust, fromDust, formatNumber, formatCoin } from 'src/utils/number';
import { toDust, fromDust, formatNumber } from 'src/utils/number';

import { warning, secondary } from 'src/theme/core';

import { toast } from 'src/components/snackbar';

import InscriptionCard from './inscription-card';
import { useNetworkVariable } from '../../hooks/use-networks';
import { formatUnitPrice } from '../../utils/marketplace';
import { GAS_COIN_DECIMALS } from '../../config/constant';

export default function ListDialog({
listDialogOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,56 @@





















































import { Box, Stack, Typography } from '@mui/material';

import { grey } from 'src/theme/core';
Expand Down
2 changes: 1 addition & 1 deletion infra/rooch-portal-v2/src/components/swap/swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function Swap({
() => [fromCoin?.coinType || '', toCoin?.coinType || ''],
[fromCoin?.coinType, toCoin?.coinType]
);
const memPool = useNetworkVariable('gasMarket').memPool
const {memPool} = useNetworkVariable('gasMarket')

const showDetails = useMemo(
() =>
Expand Down
6 changes: 6 additions & 0 deletions infra/rooch-portal-v2/src/hooks/use-networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const market = (network: 'test' | 'main') => ({
};
},
});
const dex = {
address: ROOCH_MULTI_SIG_ADDRESS,
};

const { networkConfig, useNetworkVariable, useNetworkVariables } = createNetworkConfig({
mainnet: {
Expand All @@ -71,6 +74,7 @@ const { networkConfig, useNetworkVariable, useNetworkVariables } = createNetwork
faucet: faucet('main'),
inviter,
market: market('main'),
dex,
},
},
testnet: {
Expand All @@ -94,6 +98,7 @@ const { networkConfig, useNetworkVariable, useNetworkVariables } = createNetwork
faucet: faucet('test'),
inviter,
market: market('test'),
dex,
},
},
localnet: {
Expand All @@ -117,6 +122,7 @@ const { networkConfig, useNetworkVariable, useNetworkVariables } = createNetwork
faucet: faucet('test'),
inviter,
market: market('test'),
dex,
},
},
});
Expand Down
34 changes: 23 additions & 11 deletions infra/rooch-portal-v2/src/layouts/config-nav-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ export const navData = [
{
title: 'Account',
path: paths.dashboard.account,
icon: <Iconify icon="solar:user-id-bold-duotone" />,
icon: <Iconify icon="solar:user-id-broken" />,
},
{
title: 'Assets',
path: paths.dashboard.assets,
icon: <Iconify icon="solar:wallet-money-bold-duotone" />,
icon: <Iconify icon="solar:wallet-2-broken" />,
},
{
title: 'Transactions',
path: paths.dashboard.transactions,
icon: <Iconify icon="solar:clipboard-list-bold-duotone" />,
icon: <Iconify icon="solar:list-up-broken" />,
},
{
title: 'Purchase Gas',
path: paths.dashboard['gas-swap'],
icon: <Iconify icon="solar:gas-station-bold-duotone" />,
icon: <Iconify icon="solar:gas-station-broken" />,
noAddressRequired: true,
},
{
title: 'Faucet',
path: paths.dashboard.faucet,
icon: <Iconify icon="solar:gift-bold-duotone" />,
icon: <Iconify icon="solar:gift-broken" />,
},
{
title: 'Invitation',
Expand All @@ -45,7 +45,7 @@ export const navData = [
{
title: 'Settings',
path: paths.dashboard.settings,
icon: <Iconify icon="solar:settings-bold-duotone" />,
icon: <Iconify icon="solar:settings-broken" />,
noAddressRequired: true,
connectWalletRequired: false,
},
Expand All @@ -59,8 +59,20 @@ export const navData = [
items: [
{
title: 'Marketplace',
path: paths.dashboard.trade,
icon: <Iconify icon="solar:star-fall-bold-duotone" />,
path: paths.dashboard.market,
icon: <Iconify icon="solar:cart-large-2-broken" />,
noAddressRequired: true,
},
{
title: 'Liquidity',
path: paths.dashboard.liquidity,
icon: <Iconify icon="solar:hand-money-broken" />,
noAddressRequired: true,
},
{
title: 'Swap',
path: paths.dashboard.swap,
icon: <Iconify icon="solar:money-bag-broken" />,
noAddressRequired: true,
},
],
Expand Down Expand Up @@ -88,13 +100,13 @@ export const navData = [
{
title: 'Search',
path: paths.dashboard.search,
icon: <Iconify icon="solar:card-search-bold-duotone" />,
icon: <Iconify icon="solar:card-search-broken" />,
noAddressRequired: true,
},
{
title: 'Apps',
path: paths.dashboard.apps,
icon: <Iconify icon="solar:widget-5-bold-duotone" />,
icon: <Iconify icon="solar:widget-5-broken" />,
noAddressRequired: true,
},
{
Expand All @@ -105,7 +117,7 @@ export const navData = [
icon: <Iconify icon="solar:infinity-line-duotone" />,
noAddressRequired: true,
},
]// .filter((item) => !(isMainNetwork() && item.title === 'Apps')),
], // .filter((item) => !(isMainNetwork() && item.title === 'Apps')),
},
].filter((item) => !(isMainNetwork() && item.subheader === 'Tokens'));
// .filter((item) => !(isMainNetwork() && (item.subheader === 'Tokens' || item.subheader === 'Trade')));
4 changes: 3 additions & 1 deletion infra/rooch-portal-v2/src/routes/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export const paths = {
assets: `${ROOTS.DASHBOARD}/assets`,
mint: `${ROOTS.DASHBOARD}/mint`,
transactions: `${ROOTS.DASHBOARD}/transactions`,
trade: `${ROOTS.DASHBOARD}/trade`,
market: `${ROOTS.DASHBOARD}/trade/market`,
liquidity: `${ROOTS.DASHBOARD}/trade/liquidity`,
swap: `${ROOTS.DASHBOARD}/trade/swap`,
apps: `${ROOTS.DASHBOARD}/apps`,
settings: `${ROOTS.DASHBOARD}/settings`,
search: `${ROOTS.DASHBOARD}/search`,
Expand Down
4 changes: 2 additions & 2 deletions infra/rooch-portal-v2/src/sections/apps/view.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use client';

import { useCurrentNetwork } from '@roochnetwork/rooch-sdk-kit';

import Typography from '@mui/material/Typography';
import { Box, Card, Stack, Button, CardHeader, CardContent } from '@mui/material';

import { CONFIG } from 'src/config-global';
import { DashboardContent } from 'src/layouts/dashboard';
import Badge from '@mui/material/Badge';
import { useCurrentNetwork } from '@roochnetwork/rooch-sdk-kit';

export interface Project {
id: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
import { Scrollbar } from '../../../components/scrollbar';
import { getUTCOffset } from '../../../utils/format-time';
import { formatCoin } from '../../../utils/format-number';
import { useNetworkVariable } from '../../../hooks/use-networks';
import { GAS_COIN_DECIMALS } from '../../../config/constant';
import { useNetworkVariable } from '../../../hooks/use-networks';
import TableSkeleton from '../../../components/skeleton/table-skeleton';
import { TableNoData, TableHeadCustom } from '../../../components/table';

Expand Down
2 changes: 1 addition & 1 deletion infra/rooch-portal-v2/src/sections/inviter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

import { useEffect } from 'react';

import { isValidAddress } from '@roochnetwork/rooch-sdk';

import { useRouter } from '../../routes/hooks';
import { INVITER_ADDRESS_KEY } from '../../utils/inviter';

Expand Down
Loading

0 comments on commit a5d75bc

Please sign in to comment.