Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Portal invite #3022

Merged
merged 7 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions infra/rooch-portal-v2/src/app/faucet/inviter/[address]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import WalletGuard from 'src/components/guard/WalletGuard';

import { InviterFaucetView } from 'src/sections/faucet/inviter';

export const metadata = { title: `Faucet` };

export default function Page({ params }: { params: { address: string } }) {
return <WalletGuard>
<InviterFaucetView inviterAddress={params.address} />
</WalletGuard>
}
7 changes: 7 additions & 0 deletions infra/rooch-portal-v2/src/app/invitation/[address]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { InvitationsView } from 'src/sections/invitations/index';

export const metadata = { title: `Invitation` };

export default function Page({ params }: { params: { address: string } }) {
return <InvitationsView />;
}
8 changes: 8 additions & 0 deletions infra/rooch-portal-v2/src/app/invitation/page..tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import { InvitationsView } from 'src/sections/invitations/index';

export const metadata = { title: `Invitation` };

export default function Page() {
return <InvitationsView />;
}
14 changes: 2 additions & 12 deletions infra/rooch-portal-v2/src/app/inviter/[address]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import WalletGuard from 'src/components/guard/WalletGuard';

import { SettingsView } from 'src/sections/settings/view';
import { InviterView } from 'src/sections/inviter/index';

export default function Page({ params }: { params: { address: string } }) {
// window.localStorage.setItem('inviter', params.address)
console.log(params)
return (
<WalletGuard>
<SettingsView />
</WalletGuard>
);
return <InviterView inviterAddress={params.address} />;
}



6 changes: 6 additions & 0 deletions infra/rooch-portal-v2/src/app/inviter/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

import { InviterView } from 'src/sections/inviter/index';

export default function Page() {
return <InviterView />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ import { isSessionExpired } from 'src/utils/common';

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

export default function SessionKeyGuardButtonV1({ children, desc, callback }: { children?: ReactNode, desc?: string, callback?: () => Promise<void> }) {
export default function SessionKeyGuardButtonV1({
children,
desc,
callback,
}: {
children?: ReactNode;
desc?: string;
callback?: () => Promise<void>;
}) {
const sessionKey = useCurrentSession();
const { mutateAsync: createSessionKey } = useCreateSessionKey();
const [loading, setLoading] = useState(false);
Expand All @@ -27,13 +35,14 @@ export default function SessionKeyGuardButtonV1({ children, desc, callback }: {
}, [sessionKey]);

const handle = async () => {
setLoading(true)
if (sessionKey && !isCurrentSessionExpired) {
if (callback) {
await callback()
}
} else {
try {
setLoading(true);

try {
if (sessionKey && !isCurrentSessionExpired) {
if (callback) {
await callback();
}
} else {
await createSessionKey({
appName: 'rooch-portal',
appUrl: 'portal.rooch.network',
Expand All @@ -46,19 +55,19 @@ export default function SessionKeyGuardButtonV1({ children, desc, callback }: {
maxInactiveInterval: 60 * 60 * 8,
});
if (callback) {
await callback()
await callback();
}
} catch (error) {
if (error.message) {
toast.error(error.message);
return;
}
toast.error(String(error));
}
} catch (error) {
if (error.message) {
toast.error(error.message);
return;
}
toast.error(String(error));
} finally {
setLoading(false);
}

setLoading(false)
}
};

return sessionKey && !isCurrentSessionExpired && children ? (
children
Expand All @@ -70,9 +79,7 @@ export default function SessionKeyGuardButtonV1({ children, desc, callback }: {
loading={loading}
onClick={handle}
>
{
desc || 'Create Session Key'
}
{desc || 'Create Session Key'}
</LoadingButton>
);
}
13 changes: 8 additions & 5 deletions infra/rooch-portal-v2/src/hooks/use-networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,44 @@ const { networkConfig, useNetworkVariable, useNetworkVariables } = createNetwork
variables: {
roochOperatingAddress: ROOCH_NFT_OPERATING_ADDRESS,
mintAddress: ROOCH_MINT_OPERATING_ADDRESS,
btcGasAddress: 'bc1prcajaj9n7e29u4dfp33x3hcf52yqeegspdpcd79pqu4fpr6llx4sugkfjt',
btcGasAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
gasMarketAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
faucetUrl: FAUCET_MAINNET,
faucetAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
faucetObject: '0xd5723eda84f691ae2623da79312c7909b1737c5b3866ecc5dbd6aa21718ff15d',
BTCMemPool: 'https://mempool.space/tx/',
twitterOracleAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
inviterCA: ['0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3', 'invitation', 'InvitationConf'],
},
},
testnet: {
url: getRoochNodeUrl('testnet'),
variables: {
roochOperatingAddress: ROOCH_NFT_OPERATING_ADDRESS,
mintAddress: ROOCH_MINT_OPERATING_ADDRESS,
btcGasAddress: 'tb1prcajaj9n7e29u4dfp33x3hcf52yqeegspdpcd79pqu4fpr6llx4stqqxgy',
gasMarketAddress: '0x872502737008ac71c4c008bb3846a688bfd9fa54c6724089ea51b72f813dc71e',
btcGasAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
gasMarketAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e 744c13f2d9998bf76cc3',
faucetUrl: FAUCET_TESTNET,
faucetAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
faucetObject: '0xd5723eda84f691ae2623da79312c7909b1737c5b3866ecc5dbd6aa21718ff15d',
BTCMemPool: 'https://mempool.space/testnet/tx/',
twitterOracleAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
inviterCA: ['0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3', 'invitation', 'InvitationConf'],
},
},
localnet: {
url: getRoochNodeUrl('localnet'),
variables: {
roochOperatingAddress: ROOCH_NFT_OPERATING_ADDRESS,
mintAddress: ROOCH_MINT_OPERATING_ADDRESS,
btcGasAddress: 'tb1prcajaj9n7e29u4dfp33x3hcf52yqeegspdpcd79pqu4fpr6llx4stqqxgy',
gasMarketAddress: '0x872502737008ac71c4c008bb3846a688bfd9fa54c6724089ea51b72f813dc71e',
btcGasAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
gasMarketAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
faucetUrl: FAUCET_TESTNET,
faucetAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
faucetObject: '0xd5723eda84f691ae2623da79312c7909b1737c5b3866ecc5dbd6aa21718ff15d',
BTCMemPool: 'https://mempool.space/testnet/tx/',
twitterOracleAddress: '0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3',
inviterCA: ['0x701c21bf1c8cd5af8c42983890d8ca55e7a820171b8e744c13f2d9998bf76cc3', 'invitation', 'InvitationConf'],
},
},
});
Expand Down
6 changes: 6 additions & 0 deletions infra/rooch-portal-v2/src/layouts/config-nav-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export const navData = [
icon: <Iconify icon="solar:gift-bold-duotone" />,
// noAddressRequired: true,
},
{
title: 'Invitation',
path: paths.dashboard.invitation,
icon: <Iconify icon="solar:letter-broken" />,
// noAddressRequired: true,
},
{
title: 'Settings',
path: paths.dashboard.settings,
Expand Down
1 change: 1 addition & 0 deletions infra/rooch-portal-v2/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const apiDomains = [
getRoochNodeUrl('testnet'),
'https://test-faucet.rooch.network',
'https://main-faucet.rooch.network',
'http://127.0.0.1:6868',
];
const isProduction = process.env.NODE_ENV === 'production';

Expand Down
1 change: 1 addition & 0 deletions infra/rooch-portal-v2/src/routes/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const paths = {
settings: `${ROOTS.DASHBOARD}/settings`,
search: `${ROOTS.DASHBOARD}/search`,
faucet: `${ROOTS.DASHBOARD}/faucet`,
invitation: `${ROOTS.DASHBOARD}/invitation`,
'gas-swap': `${ROOTS.DASHBOARD}/gas-swap`,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function AssetRowItem({ row, isWalletOwner, onOpenTransferModal }
<TableRow>
<TableCell width="300px">
<Box sx={{ gap: 1, display: 'flex', alignItems: 'center' }}>
{/* {row.icon_url && <Image src={row.icon_url} alt={row.symbol} width={48} height={48} />} */}
{row.icon_url ? (
<Box
component="span"
Expand Down
Loading
Loading