Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Real airdrop repo (#2052)
Browse files Browse the repository at this point in the history
* Removed hardcoded claims from hooks

* Added the real airdrop repo and a const for the branch name

* Added helper function getClaimsRepoPath to have the path based on chainId

* Added helper function getClaimKey

* Maybe 'thing in array' is not a thing in JS. Let's go for .includes instead

* Further customized claim fetching functions to work with multiple networks

* Commented out the whole hooksMod file. Don't think it's needed anymore

* Temporary changes to claim page to integrate the claim checking

* Removed completely the custom claim/hooks/hooksMod file

* Refactoring Boolean conditions

Co-authored-by: David <[email protected]>

Co-authored-by: Leandro <[email protected]>
Co-authored-by: David <[email protected]>
  • Loading branch information
3 people authored Jan 5, 2022
1 parent 8d53e6b commit c053cf2
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 266 deletions.
82 changes: 52 additions & 30 deletions src/custom/pages/Claim/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ import {
Steps,
TokenLogo,
} from './styled'
import {
// ClaimInput,
// useClaimCallback,
useUserAvailableClaims,
useUserHasAvailableClaim,
useUserUnclaimedAmount,
} from 'state/claim/hooks'
import { formatSmart } from 'utils/format'
import { hasFreeClaim, hasPaidClaim } from 'state/claim/hooks/utils'

export default function Claim() {
const { account, chainId } = useActiveWeb3React()
Expand All @@ -52,21 +61,34 @@ export default function Claim() {
const [inputAddress, setInputAddress] = useState('')
const [isInputAddressValid, setIsInputAddressValid] = useState(false)
const [activeClaimAccount, setActiveClaimAccount] = useState('')
const [isAirdropOnly, setIsAirdropOnly] = useState(false)
const [hasClaims, setHasClaims] = useState(false)
// const [isAirdropOnly, setIsAirdropOnly] = useState(false)
// const [hasClaims, setHasClaims] = useState(false)
const [isInvestFlowActive, setIsInvestFlowActive] = useState(false)
const [isInvestFlowStep, setIsInvestFlowStep] = useState(0)
const [claimConfirmed, setClaimConfirmed] = useState(false)
const [claimAttempting, setClaimAttempting] = useState(false)
const [claimSubmitted, setClaimSubmitted] = useState(false)
const [unclaimedAmount, setUnclaimedAmount] = useState(0)
// const [unclaimedAmount, setUnclaimedAmount] = useState(0)
const activeClaimAccountENS = 'TestAccount.eth'
// =========================================

const userClaims = useUserAvailableClaims(activeClaimAccount || account)
const isAirdropOnly = hasFreeClaim(userClaims) && !hasPaidClaim(userClaims)
const unclaimedAmount = useUserUnclaimedAmount(activeClaimAccount || account)
const hasClaims = useUserHasAvailableClaim(activeClaimAccount || account)
// const { claimCallback } = useClaimCallback(activeClaimAccount || account)
// const claimInput = userClaims.map<ClaimInput>(({ index }) => ({ index }))

console.log(
`Claim/index::[unclaimedAmount ${unclaimedAmount?.toFixed(
2
)}] [hasClaims ${hasClaims}] [activeClaimAccount ${activeClaimAccount}] [isAirdropOnly ${isAirdropOnly}]`
)

useEffect(() => {
setIsInputAddressValid(isAddress(inputAddress))
setHasClaims(unclaimedAmount > 0 ? true : false)
}, [inputAddress, unclaimedAmount, claimConfirmed])
// setHasClaims(unclaimedAmount > 0 ? true : false)
}, [inputAddress])

return (
<PageWrapper>
Expand Down Expand Up @@ -106,20 +128,20 @@ export default function Claim() {
<td>activeClaimAccountENS</td>
<td>{activeClaimAccountENS}</td>
</tr>
<tr>
<td>hasClaims</td>
<td>
{' '}
<button onClick={() => setHasClaims(!hasClaims)}>Toggle ({String(hasClaims)})</button>
</td>
</tr>
<tr>
<td>isAirdropOnly</td>
<td>
{' '}
<button onClick={() => setIsAirdropOnly(!isAirdropOnly)}>Toggle ({String(isAirdropOnly)})</button>
</td>
</tr>
{/*<tr>*/}
{/* <td>hasClaims</td>*/}
{/* <td>*/}
{/* {' '}*/}
{/* <button onClick={() => setHasClaims(!hasClaims)}>Toggle ({String(hasClaims)})</button>*/}
{/* </td>*/}
{/*</tr>*/}
{/*<tr>*/}
{/* <td>isAirdropOnly</td>*/}
{/* <td>*/}
{/* {' '}*/}
{/* <button onClick={() => setIsAirdropOnly(!isAirdropOnly)}>Toggle ({String(isAirdropOnly)})</button>*/}
{/* </td>*/}
{/*</tr>*/}
<tr>
<td>isInvestFlowActive</td>
<td>
Expand Down Expand Up @@ -156,15 +178,15 @@ export default function Claim() {
<button onClick={() => setClaimSubmitted(!claimSubmitted)}>Toggle ({String(claimSubmitted)})</button>
</td>
</tr>
<tr>
<td>unclaimedAmount</td>
<td>
{' '}
<button onClick={() => setUnclaimedAmount(unclaimedAmount < 1 ? 39234238586 : 0)}>
Toggle ({String(unclaimedAmount)})
</button>
</td>
</tr>
{/*<tr>*/}
{/* <td>unclaimedAmount</td>*/}
{/* <td>*/}
{/* {' '}*/}
{/* <button onClick={() => setUnclaimedAmount(unclaimedAmount < 1 ? 39234238586 : 0)}>*/}
{/* Toggle ({String(unclaimedAmount)})*/}
{/* </button>*/}
{/* </td>*/}
{/*</tr>*/}
</tbody>
</table>
</Demo>
Expand Down Expand Up @@ -209,7 +231,7 @@ export default function Claim() {
<div>
<ClaimTotal>
<b>Total available to claim</b>
<p>{unclaimedAmount} vCOW</p>
<p>{formatSmart(unclaimedAmount)} vCOW</p>
</ClaimTotal>
</div>
)}
Expand Down Expand Up @@ -278,7 +300,7 @@ export default function Claim() {
<h3>{claimConfirmed ? 'Claimed!' : 'Claiming'}</h3>
{!claimConfirmed && (
<p>
<Trans>{unclaimedAmount} vCOW</Trans>
<Trans>{formatSmart(unclaimedAmount)} vCOW</Trans>
</p>
)}

Expand Down
228 changes: 0 additions & 228 deletions src/custom/state/claim/hooks/hooksMod.ts

This file was deleted.

Loading

0 comments on commit c053cf2

Please sign in to comment.