From 02bcca1fd7649c4cadbcd0a503f26a6a3e507b2f Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Mon, 5 Feb 2024 09:53:50 +0800 Subject: [PATCH 1/6] fix: eslint --- src/components/Airdrop/Airdrop.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Airdrop/Airdrop.tsx b/src/components/Airdrop/Airdrop.tsx index a0a5882..e176ef2 100644 --- a/src/components/Airdrop/Airdrop.tsx +++ b/src/components/Airdrop/Airdrop.tsx @@ -6,7 +6,7 @@ import { formatEther } from '@ethersproject/units'; import { openNotification, Spinner, Tag, Typography } from '@subql/components'; import { renderAsyncArray } from '@subql/react-hooks'; import { mergeAsync } from '@subql/react-hooks/dist/utils'; -import { useMount, useRequest } from 'ahooks'; +import { useMount } from 'ahooks'; import { Button, Table, TableProps } from 'antd'; import { BigNumber } from 'ethers'; import i18next from 'i18next'; From 7438c5d9303da8b06197a13b19d609cc1efc58a0 Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Mon, 5 Feb 2024 11:48:48 +0800 Subject: [PATCH 2/6] fix: testnet --- stage.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage.env b/stage.env index 9be2bdb..d54ca92 100644 --- a/stage.env +++ b/stage.env @@ -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 From 827c550b5c976d04850c10c14081149afa0cdfd5 Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Mon, 5 Feb 2024 14:06:16 +0800 Subject: [PATCH 3/6] feat: add safe support --- src/conf/rainbowConf.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/conf/rainbowConf.tsx b/src/conf/rainbowConf.tsx index d222d63..124e943 100644 --- a/src/conf/rainbowConf.tsx +++ b/src/conf/rainbowConf.tsx @@ -3,7 +3,13 @@ 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 { publicProvider } from 'wagmi/providers/public'; @@ -26,6 +32,7 @@ const connectors = connectorsForWallets([ { groupName: 'Recommended', wallets: [ + safeWallet({ chains }), metaMaskWallet({ projectId: 'c7ea561f79adc119587d163a68860570', chains }), walletConnectWallet({ projectId: 'c7ea561f79adc119587d163a68860570', chains }), talismanWalletConnector, From 1fb24859518c8978f2089ed8eaea1918c4038713 Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Mon, 5 Feb 2024 16:05:58 +0800 Subject: [PATCH 4/6] feat: public sale result --- src/components/Airdrop/Airdrop.tsx | 34 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/components/Airdrop/Airdrop.tsx b/src/components/Airdrop/Airdrop.tsx index e176ef2..65a719f 100644 --- a/src/components/Airdrop/Airdrop.tsx +++ b/src/components/Airdrop/Airdrop.tsx @@ -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'; @@ -164,7 +165,14 @@ export const Airdrop: FC = () => { const [nftSerices, setNftSerices] = useState({}); const [redeemLoading, setRedeemLoading] = useState(false); const [redeemable, setRedeemable] = useState(false); - const [currentUserPublicSaleResult, setCurrentUserPublicSaleResult] = useState(0); + + const [currentUserPublicSaleResult, setCurrentUserPublicSaleResult] = useState< + { + category: string; + amount: number; + unlock: string; + }[] + >([]); const accountUnclaimGifts = useQuery( gql` @@ -272,9 +280,11 @@ export const Airdrop: FC = () => { 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 } @@ -486,16 +496,14 @@ export const Airdrop: FC = () => { userNfts || { userNfts: { nodes: [], groupedAggregates: [] } }, redeemedNfts || { userRedeemedNfts: { nodes: [], groupedAggregates: [] } } ), - currentUserPublicSaleResult > 0 - ? { - id: Public Sale Token Claim, - sortedStatus: AirdropRoundStatus.LOCKED, - sortedNextMilestone: 'Unlock date: (Feb 22)', - amountString: `${currentUserPublicSaleResult} SQT`, - key: 'publicSale' - } - : null - ].filter((i) => i); + ...currentUserPublicSaleResult.map((i, index) => ({ + id: {i.category}, + 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)) || []; From 28c3ec99eeaec8ea8e9ff7b7f680792aa021aac0 Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Tue, 6 Feb 2024 09:15:21 +0800 Subject: [PATCH 5/6] test: safe wallet --- src/conf/rainbowConf.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/rainbowConf.tsx b/src/conf/rainbowConf.tsx index 124e943..6721117 100644 --- a/src/conf/rainbowConf.tsx +++ b/src/conf/rainbowConf.tsx @@ -11,13 +11,13 @@ import { 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 From b1df126ec1aa56fa97dcfcfc917d5c161f32c2ee Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Wed, 7 Feb 2024 13:55:21 +0800 Subject: [PATCH 6/6] fix: merge --- src/components/Airdrop/Airdrop.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Airdrop/Airdrop.tsx b/src/components/Airdrop/Airdrop.tsx index 65a719f..f731b45 100644 --- a/src/components/Airdrop/Airdrop.tsx +++ b/src/components/Airdrop/Airdrop.tsx @@ -276,7 +276,6 @@ 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}`);