Skip to content

Commit

Permalink
Merge pull request #85 from subquery/fix/eslint-error
Browse files Browse the repository at this point in the history
feat: add safe wallet support & public sale result
  • Loading branch information
HuberTRoy authored Feb 7, 2024
2 parents f603f1d + b1df126 commit 3a76c07
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
35 changes: 21 additions & 14 deletions src/components/Airdrop/Airdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Button, Table, TableProps } from 'antd';
import { BigNumber } from 'ethers';
import i18next from 'i18next';
import { uniqWith } from 'lodash-es';
import moment from 'moment';
import { useAccount } from 'wagmi';

import { TOKEN } from 'appConstants';
Expand Down Expand Up @@ -164,7 +165,14 @@ export const Airdrop: FC = () => {
const [nftSerices, setNftSerices] = useState<NftIpfs>({});
const [redeemLoading, setRedeemLoading] = useState<boolean>(false);
const [redeemable, setRedeemable] = useState<boolean>(false);
const [currentUserPublicSaleResult, setCurrentUserPublicSaleResult] = useState<number>(0);

const [currentUserPublicSaleResult, setCurrentUserPublicSaleResult] = useState<
{
category: string;
amount: number;
unlock: string;
}[]
>([]);

const accountUnclaimGifts = useQuery<IUnclaimedGifts>(
gql`
Expand Down Expand Up @@ -268,13 +276,14 @@ export const Airdrop: FC = () => {

const getPublicSaleResult = async () => {
if (!account) return;

try {
const res = await fetch(`https://sq-airdrop-backend.subquery.network/public-sale/token-claim/${account}`);

const text = await res.text();
if (res.status === 200) {
const json = await res.json();

setCurrentUserPublicSaleResult(+text);
setCurrentUserPublicSaleResult(json);
}
} catch (e) {
// don't care about this
}
Expand Down Expand Up @@ -486,16 +495,14 @@ export const Airdrop: FC = () => {
userNfts || { userNfts: { nodes: [], groupedAggregates: [] } },
redeemedNfts || { userRedeemedNfts: { nodes: [], groupedAggregates: [] } }
),
currentUserPublicSaleResult > 0
? {
id: <Typography>Public Sale Token Claim</Typography>,
sortedStatus: AirdropRoundStatus.LOCKED,
sortedNextMilestone: 'Unlock date: (Feb 22)',
amountString: `${currentUserPublicSaleResult} SQT`,
key: 'publicSale'
}
: null
].filter((i) => i);
...currentUserPublicSaleResult.map((i, index) => ({
id: <Typography>{i.category}</Typography>,
sortedStatus: AirdropRoundStatus.LOCKED,
sortedNextMilestone: `Unlock date: ${i.unlock !== '' ? moment(i.unlock).format('YYYY-MM-DD') : '-'}`,
amountString: `${i.amount} SQT`,
key: `publicSale${index}`
}))
];

const unlockSeriesIds = unClaimGifts?.userUnclaimedNfts.nodes.map((i) => i.seriesId) || [];
const canRedeemNfts = userNfts?.userNfts.nodes.filter((i) => !redeemNftsTokenIds.includes(i.id)) || [];
Expand Down
13 changes: 10 additions & 3 deletions src/conf/rainbowConf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@

import React from 'react';
import { connectorsForWallets, darkTheme, RainbowKitProvider } from '@rainbow-me/rainbowkit';
import { metaMaskWallet, rainbowWallet, talismanWallet, walletConnectWallet } from '@rainbow-me/rainbowkit/wallets';
import {
metaMaskWallet,
rainbowWallet,
safeWallet,
talismanWallet,
walletConnectWallet
} from '@rainbow-me/rainbowkit/wallets';
import { configureChains, createConfig, WagmiConfig } from 'wagmi';
import { base, baseSepolia } from 'wagmi/chains';
import { base, baseSepolia, polygon } from 'wagmi/chains';
import { publicProvider } from 'wagmi/providers/public';

import '@rainbow-me/rainbowkit/styles.css';

// goerli and mainnet just for get data actually not supported
const supportedChains = process.env.REACT_APP_NETWORK === 'testnet' ? [baseSepolia] : [base];
const supportedChains = process.env.REACT_APP_NETWORK === 'testnet' ? [polygon, baseSepolia] : [base];

// This should ok. It seems is a bug of Ts.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand All @@ -26,6 +32,7 @@ const connectors = connectorsForWallets([
{
groupName: 'Recommended',
wallets: [
safeWallet({ chains }),
metaMaskWallet({ projectId: 'c7ea561f79adc119587d163a68860570', chains }),
walletConnectWallet({ projectId: 'c7ea561f79adc119587d163a68860570', chains }),
talismanWalletConnector,
Expand Down
2 changes: 1 addition & 1 deletion stage.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
REACT_APP_DOMAIN=https://sq-airdrop-backend.subquery.network/
REACT_APP_AIRDROP_SUBQL=https://api.subquery.network/sq/subquery/kepler-network
REACT_APP_AIRDROP_GIFT_SUBQL=http://localhost:3000
REACT_APP_AIRDROP_GIFT_SUBQL=https://api.subquery.network/sq/subquery/airdrop-gifts-testnet
REACT_APP_NETWORK=testnet
REACT_APP_CLAIM_ENABLED=true
REACT_APP_DEPLOYMENT_ID=QmUwTD5dqQRRFcMCihJ4HHnMPfEvRpKpcFvGcTJjBpGg9T
Expand Down

0 comments on commit 3a76c07

Please sign in to comment.