diff --git a/frontend/src/features/airdrop/airdropService.js b/frontend/src/features/airdrop/airdropService.js index 9edd7d87b..504f5263a 100644 --- a/frontend/src/features/airdrop/airdropService.js +++ b/frontend/src/features/airdrop/airdropService.js @@ -9,6 +9,11 @@ const getClaimRecords = (baseURL, address) => { return Axios.get(uri) } +const getAirdropDetails = (address) => { + const uri = `https://api.resolute.vitwit.com/passage-airdrop-details/airdrop-check?address=${address}` + return Axios.get(uri) +} + const getClaimParams = (baseURL) => { const uri = `${cleanURL(baseURL)}${claimParamsURL}` return Axios.get(uri) @@ -17,6 +22,7 @@ const getClaimParams = (baseURL) => { const result = { claimRecords: getClaimRecords, params: getClaimParams, + airdropDetails: getAirdropDetails, } export default result; \ No newline at end of file diff --git a/frontend/src/features/airdrop/airdropSlice.js b/frontend/src/features/airdrop/airdropSlice.js index 98624a945..727c02b58 100644 --- a/frontend/src/features/airdrop/airdropSlice.js +++ b/frontend/src/features/airdrop/airdropSlice.js @@ -1,128 +1,164 @@ -import airdropService from './airdropService'; -import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'; -import { fee, signAndBroadcastClaimMsg } from '../../txns/execute'; -import { AirdropClaim } from '../../txns/passage'; -import { setError, setTxHash } from '../common/commonSlice'; +import airdropService from "./airdropService"; +import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; +import { fee, signAndBroadcastClaimMsg } from "../../txns/execute"; +import { AirdropClaim } from "../../txns/passage"; +import { setError, setTxHash } from "../common/commonSlice"; const initialState = { - claimRecords: {}, - status: '', - claimStatus: '', - errMsg: '', - params: {}, - tx: { - status: 'idle' - } -} + claimRecords: {}, + status: "", + claimStatus: "", + errMsg: "", + params: {}, + tx: { + status: "idle", + }, + airdropDetails: {}, + airdropDetailsStatus: "", +}; + +export const getAirdropDetails = createAsyncThunk( + "airdrop/airdrop-details", + async (data) => { + const response = await airdropService.airdropDetails(data.address); + return response.data; + } +); export const getClaimRecords = createAsyncThunk( - 'airdrop/claim-records', - async (data) => { - const response = await airdropService.claimRecords(data.baseURL, data.address); - return response.data; - } + "airdrop/claim-records", + async (data) => { + const response = await airdropService.claimRecords( + data.baseURL, + data.address + ); + return response.data; + } ); export const getClaimParams = createAsyncThunk( - 'airdrop/claim-params', - async (data) => { - const response = await airdropService.params(data.baseURL); - return response.data; - } + "airdrop/claim-params", + async (data) => { + const response = await airdropService.params(data.baseURL); + return response.data; + } ); export const txClaimAction = createAsyncThunk( - 'airdrop/claim-tx-1', - async (data, { rejectWithValue, fulfillWithValue, dispatch }) => { - try { - const msg = AirdropClaim(data.address) - const result = await signAndBroadcastClaimMsg(data.address, [msg], fee(data.denom, data.feeAmount, 200000),data.chainId, data.rpc, data.memo) - if (result?.code === 0) { - dispatch(setTxHash({ - hash: result?.transactionHash - })) - return fulfillWithValue({ txHash: result?.transactionHash }); - } else { - dispatch(setError({ - type: 'error', - message: result?.rawLog - })) - return rejectWithValue(result?.rawLog); - } - } catch (error) { - dispatch(setError({ - type: 'error', - message: error.message - })) - return rejectWithValue(error.message) - } + "airdrop/claim-tx-1", + async (data, { rejectWithValue, fulfillWithValue, dispatch }) => { + try { + const msg = AirdropClaim(data.address); + const result = await signAndBroadcastClaimMsg( + data.address, + [msg], + fee(data.denom, data.feeAmount, 200000), + data.chainId, + data.rpc, + data.memo + ); + if (result?.code === 0) { + dispatch( + setTxHash({ + hash: result?.transactionHash, + }) + ); + return fulfillWithValue({ txHash: result?.transactionHash }); + } else { + dispatch( + setError({ + type: "error", + message: result?.rawLog, + }) + ); + return rejectWithValue(result?.rawLog); + } + } catch (error) { + dispatch( + setError({ + type: "error", + message: error.message, + }) + ); + return rejectWithValue(error.message); } -) + } +); export const airdropSlice = createSlice({ - name: 'airdrop', - initialState, - reducers: { - resetState: (state) => { - state.status = '' - state.errMsg = '' - state.claimRecords = {} - state.params = {} - state.claimStatus = '' - }, - resetClaimRecords: (state) => { - state.claimRecords = {} - } + name: "airdrop", + initialState, + reducers: { + resetState: (state) => { + state.status = ""; + state.errMsg = ""; + state.claimRecords = {}; + state.params = {}; + state.claimStatus = ""; }, + resetClaimRecords: (state) => { + state.claimRecords = {}; + }, + }, - extraReducers: (builder) => { - builder - .addCase(getClaimRecords.pending, (state) => { - state.claimStatus = 'pending'; - state.errMsg = '' - - }) - .addCase(getClaimRecords.fulfilled, (state, action) => { - state.claimStatus = 'idle'; - state.claimRecords = action.payload.claim_record - state.errMsg = '' - }) - .addCase(getClaimRecords.rejected, (state, action) => { - state.claimStatus = 'rejected'; - state.claimRecords = {} - state.errMsg = action.error.message - }) - - .addCase(getClaimParams.pending, (state) => { - state.status = 'pending'; - state.errMsg = '' + extraReducers: (builder) => { + builder + .addCase(getClaimRecords.pending, (state) => { + state.claimStatus = "pending"; + state.errMsg = ""; + }) + .addCase(getClaimRecords.fulfilled, (state, action) => { + state.claimStatus = "idle"; + state.claimRecords = action.payload.claim_record; + state.errMsg = ""; + }) + .addCase(getClaimRecords.rejected, (state, action) => { + state.claimStatus = "rejected"; + state.claimRecords = {}; + state.errMsg = action.error.message; + }) - }) - .addCase(getClaimParams.fulfilled, (state, action) => { - state.status = 'idle'; - state.params = action.payload.params - state.errMsg = '' - }) - .addCase(getClaimParams.rejected, (state, action) => { - state.status = 'rejected'; - state.params = {} - state.errMsg = action.error.message - }) + .addCase(getClaimParams.pending, (state) => { + state.status = "pending"; + state.errMsg = ""; + }) + .addCase(getClaimParams.fulfilled, (state, action) => { + state.status = "idle"; + state.params = action.payload.params; + state.errMsg = ""; + }) + .addCase(getClaimParams.rejected, (state, action) => { + state.status = "rejected"; + state.params = {}; + state.errMsg = action.error.message; + }) - .addCase(txClaimAction.pending, (state) => { - state.tx.status = `pending` + .addCase(txClaimAction.pending, (state) => { + state.tx.status = `pending`; + }) + .addCase(txClaimAction.fulfilled, (state, _) => { + state.tx.status = `idle`; + }) + .addCase(txClaimAction.rejected, (state, _) => { + state.tx.status = `rejected`; + }) - }) - .addCase(txClaimAction.fulfilled, (state, _) => { - state.tx.status = `idle` - }) - .addCase(txClaimAction.rejected, (state, _) => { - state.tx.status = `rejected` - }) - } + .addCase(getAirdropDetails.pending, (state) => { + state.airdropDetails = {}; + state.airdropDetailsStatus = "pending"; + }) -}) + .addCase(getAirdropDetails.rejected, (state, _) => { + state.airdropDetails = {}; + state.airdropDetailsStatus = "rejected"; + }) + .addCase(getAirdropDetails.fulfilled, (state, action) => { + state.airdropDetails = action.payload; + state.airdropDetailsStatus = "fulfilled"; + }); + }, +}); export const { resetState, resetClaimRecords } = airdropSlice.actions; export default airdropSlice.reducer; diff --git a/frontend/src/pages/passage/AirdropEligibility.jsx b/frontend/src/pages/passage/AirdropEligibility.jsx index 504cbc149..8973e100e 100644 --- a/frontend/src/pages/passage/AirdropEligibility.jsx +++ b/frontend/src/pages/passage/AirdropEligibility.jsx @@ -15,6 +15,7 @@ import { getClaimParams, txClaimAction, resetClaimRecords, + getAirdropDetails, } from "../../features/airdrop/airdropSlice"; import { useNavigate, useParams } from "react-router-dom"; import { resetError, setError } from "../../features/common/commonSlice"; @@ -24,6 +25,14 @@ import AlertTitle from "@mui/material/AlertTitle"; import CustomizedDialogs from "../../components/passage/disclaimer"; import "./../common.css"; import { networks } from "../../utils/chainsInfo"; +import { + Box, + Table, + TableBody, + TableContainer, + TableHead, +} from "@mui/material"; +import { StyledTableCell, StyledTableRow } from "../../components/CustomTable"; function getPasgNetwork(pathParams) { for (let i = 0; i < networks.length; i++) { @@ -71,6 +80,10 @@ export default function AirdropEligibility() { const status = useSelector((state) => state.airdrop.claimStatus); const errMsg = useSelector((state) => state.airdrop.errMsg); const txStatus = useSelector((state) => state.airdrop.tx.status); + const detailsStatus = useSelector( + (state) => state.airdrop.airdropDetailsStatus + ); + const airdropDetails = useSelector((state) => state.airdrop.airdropDetails); const walletAddress = useSelector( (state) => state.wallet.networks?.[nameToChainIDs[pathParams?.networkName]] @@ -91,6 +104,10 @@ export default function AirdropEligibility() { navigate(path); } + const handleGOTOStaking = () => { + navigate(`/${pathParams?.networkName}/staking`); + }; + useEffect(() => { if (chainInfo.showAirdrop) { dispatch(resetError()); @@ -156,6 +173,11 @@ export default function AirdropEligibility() { address: address, }) ); + dispatch( + getAirdropDetails({ + address: address, + }) + ); } }; @@ -300,6 +322,93 @@ export default function AirdropEligibility() { claim. + + {detailsStatus === "fulfilled" ? ( + + + Airdrop breakdown + + + + + + + Airdrop Category + + + No. of NFTs + + + Total Airdrop + + + + + + + Town 1  + + + {airdropDetails?.town1_nfts} + + + {( + parseFloat(airdropDetails?.town1_amount) / + 10 ** 6 + ).toLocaleString() || 0} +   PASG + + + + + Town 2  + + + {airdropDetails?.town2_nfts} + + + {( + parseFloat(airdropDetails?.town2_amount) / + 10 ** 6 + ).toLocaleString() || 0} +   PASG + + + +
+
+
+ ) : null} ) : ( @@ -435,14 +544,28 @@ export default function AirdropEligibility() { ) )} - - #2 Stake your initial airdrop until 14 months from genesis and - recieve +50% of your initial token claim - + + + #2 Stake your initial airdrop until 14 months from genesis + and recieve +50% of your initial token claim + + + Click here to stake + +