Skip to content

Commit

Permalink
Fix/inviter (rooch-network#2951)
Browse files Browse the repository at this point in the history
* fix inviter & faucet to purchase gas

* fix
  • Loading branch information
wow-sven authored Nov 24, 2024
1 parent eaf717f commit 267f714
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
11 changes: 10 additions & 1 deletion infra/rooch-portal-v2/src/app/inviter/[address]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import WalletGuard from 'src/components/guard/WalletGuard';

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

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



32 changes: 23 additions & 9 deletions infra/rooch-portal-v2/src/sections/faucet/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ import { DashboardContent } from 'src/layouts/dashboard';

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

import { paths } from '../../routes/paths'

const FAUCET_NOT_OPEN= 'Faucet Not Open'
const INVALID_UTXO = 'Invalid UTXO'
const FAUCET_NOT_ENOUGH_RGAS = 'Faucet Not enough RGas'
const ALREADY_CLAIMED = 'Already Claimed'
const UTXO_VALUE_IS_ZERO = 'UTXO Value Is Zero'

const ERROR_MSG: Record<string, string> = {
1: 'Faucet Not Open',
2: 'Invalid UTXO',
3: 'Faucet Not Enough RGas',
4: 'Already Claimed',
5: 'UTXO Value Is Zero',
1: FAUCET_NOT_OPEN,
2: INVALID_UTXO,
3: FAUCET_NOT_ENOUGH_RGAS,
4: ALREADY_CLAIMED,
5: UTXO_VALUE_IS_ZERO,
};

export function FaucetView({ address }: { address: string }) {
Expand Down Expand Up @@ -104,6 +112,12 @@ export function FaucetView({ address }: { address: string }) {
}, [address, client, faucetAddress, faucetObject, viewRoochAddress]);

const fetchFaucet = async () => {

if (errorMsg === ALREADY_CLAIMED) {
router.push(paths.dashboard['gas-swap'])
return
}

setFaucetStatus(true);
try {
const payload = JSON.stringify({
Expand Down Expand Up @@ -169,16 +183,16 @@ export function FaucetView({ address }: { address: string }) {
</Box>
</Stack>
{errorMsg
? 'You cannot claim gas, Please make sure the current address has a valid utxo and try again'
: ''}
? errorMsg === ALREADY_CLAIMED ? 'You Already Claimed RGAS'
: 'You cannot claim gas, Please make sure the current address has a valid utxo and try again' : ''}
<LoadingButton
variant="soft"
color="primary"
disabled={errorMsg !== undefined}
disabled={errorMsg !== undefined && errorMsg !== ALREADY_CLAIMED}
loading={isPending || faucetStatus}
onClick={fetchFaucet}
>
{errorMsg || `Claim: ${claimGas} RGas`}
{errorMsg === ALREADY_CLAIMED ? 'Purchase RGas' : errorMsg || `Claim: ${claimGas} RGas`}
</LoadingButton>
</Stack>
</CardContent>
Expand Down

0 comments on commit 267f714

Please sign in to comment.