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

Claim hooks 3 #2056

Merged
merged 16 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/custom/abis/types/VCow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ interface VCowInterface extends ethers.utils.Interface {
"claimMany(uint256[],uint8[],address[],uint256[],uint256[],bytes32[][],uint256[])": FunctionFragment;
"isClaimed(uint256)": FunctionFragment;
"merkleRoot()": FunctionFragment;
"deploymentTimestamp()": FunctionFragment;
"gnoPrice()": FunctionFragment;
"usdcPrice()": FunctionFragment;
"wethPrice()": FunctionFragment;
};

encodeFunctionData(
Expand Down Expand Up @@ -58,11 +62,25 @@ interface VCowInterface extends ethers.utils.Interface {
functionFragment: "merkleRoot",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "deploymentTimestamp",
values?: undefined
): string;
encodeFunctionData(functionFragment: "gnoPrice", values?: undefined): string;
encodeFunctionData(functionFragment: "usdcPrice", values?: undefined): string;
encodeFunctionData(functionFragment: "wethPrice", values?: undefined): string;

decodeFunctionResult(functionFragment: "claim", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "claimMany", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "isClaimed", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "merkleRoot", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "deploymentTimestamp",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "gnoPrice", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "usdcPrice", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "wethPrice", data: BytesLike): Result;

events: {
"Claimed(uint256,uint8,address,uint256,uint256)": EventFragment;
Expand Down Expand Up @@ -152,6 +170,14 @@ export class VCow extends BaseContract {
): Promise<[boolean]>;

merkleRoot(overrides?: CallOverrides): Promise<[string]>;

deploymentTimestamp(overrides?: CallOverrides): Promise<[BigNumber]>;

gnoPrice(overrides?: CallOverrides): Promise<[BigNumber]>;

usdcPrice(overrides?: CallOverrides): Promise<[BigNumber]>;

wethPrice(overrides?: CallOverrides): Promise<[BigNumber]>;
};

claim(
Expand Down Expand Up @@ -179,6 +205,14 @@ export class VCow extends BaseContract {

merkleRoot(overrides?: CallOverrides): Promise<string>;

deploymentTimestamp(overrides?: CallOverrides): Promise<BigNumber>;

gnoPrice(overrides?: CallOverrides): Promise<BigNumber>;

usdcPrice(overrides?: CallOverrides): Promise<BigNumber>;

wethPrice(overrides?: CallOverrides): Promise<BigNumber>;

callStatic: {
claim(
index: BigNumberish,
Expand All @@ -204,6 +238,14 @@ export class VCow extends BaseContract {
isClaimed(index: BigNumberish, overrides?: CallOverrides): Promise<boolean>;

merkleRoot(overrides?: CallOverrides): Promise<string>;

deploymentTimestamp(overrides?: CallOverrides): Promise<BigNumber>;

gnoPrice(overrides?: CallOverrides): Promise<BigNumber>;

usdcPrice(overrides?: CallOverrides): Promise<BigNumber>;

wethPrice(overrides?: CallOverrides): Promise<BigNumber>;
};

filters: {
Expand Down Expand Up @@ -270,6 +312,14 @@ export class VCow extends BaseContract {
): Promise<BigNumber>;

merkleRoot(overrides?: CallOverrides): Promise<BigNumber>;

deploymentTimestamp(overrides?: CallOverrides): Promise<BigNumber>;

gnoPrice(overrides?: CallOverrides): Promise<BigNumber>;

usdcPrice(overrides?: CallOverrides): Promise<BigNumber>;

wethPrice(overrides?: CallOverrides): Promise<BigNumber>;
};

populateTransaction: {
Expand Down Expand Up @@ -300,5 +350,15 @@ export class VCow extends BaseContract {
): Promise<PopulatedTransaction>;

merkleRoot(overrides?: CallOverrides): Promise<PopulatedTransaction>;

deploymentTimestamp(
overrides?: CallOverrides
): Promise<PopulatedTransaction>;

gnoPrice(overrides?: CallOverrides): Promise<PopulatedTransaction>;

usdcPrice(overrides?: CallOverrides): Promise<PopulatedTransaction>;

wethPrice(overrides?: CallOverrides): Promise<PopulatedTransaction>;
};
}
52 changes: 52 additions & 0 deletions src/custom/abis/types/factories/VCow__factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,58 @@ const _abi = [
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "deploymentTimestamp",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "gnoPrice",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "usdcPrice",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "wethPrice",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
];

export class VCow__factory {
Expand Down
52 changes: 52 additions & 0 deletions src/custom/abis/vCow.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,57 @@
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "deploymentTimestamp",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gnoPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "usdcPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "wethPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
]
52 changes: 39 additions & 13 deletions src/custom/pages/Claim/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
FREE_CLAIM_TYPES,
ClaimType,
useClaimCallback,
useInvestmentStillAvailable,
useAirdropStillAvailable,
} from 'state/claim/hooks'
import { ButtonPrimary, ButtonSecondary } from 'components/Button'
import Circle from 'assets/images/blue-loader.svg'
Expand Down Expand Up @@ -90,7 +92,7 @@ export default function Claim() {
const [claimConfirmed, setClaimConfirmed] = useState<boolean>(false)
const [claimAttempting, setClaimAttempting] = useState<boolean>(false)
const [claimSubmitted, setClaimSubmitted] = useState<boolean>(false)
const [claimedAmmount, setClaimedAmmount] = useState<number>(0)
const [claimedAmount, setClaimedAmount] = useState<number>(0)

// investment
const [isInvestFlowActive, setIsInvestFlowActive] = useState<boolean>(false)
Expand All @@ -113,7 +115,7 @@ export default function Claim() {
// get total unclaimed ammount
const unclaimedAmount = useUserUnclaimedAmount(activeClaimAccount)

const hasClaims = useMemo(() => userClaimData.length, [userClaimData])
const hasClaims = useMemo(() => userClaimData.length > 0, [userClaimData])
const isAirdropOnly = useMemo(() => !hasPaidClaim(userClaimData), [userClaimData])

// handle table select change
Expand All @@ -124,6 +126,10 @@ export default function Claim() {
const typeToCurrencyMap = useMemo(() => getTypeToCurrencyMap(chainId), [chainId])
const typeToPriceMap = useMemo(() => getTypeToPriceMap(), [])

// checks regarding investment time window
const isInvestmentStillAvailable = useInvestmentStillAvailable()
const isAirdropStillAvailable = useAirdropStillAvailable()

// claim callback
const { claimCallback } = useClaimCallback(activeClaimAccount)

Expand Down Expand Up @@ -202,6 +208,15 @@ export default function Claim() {
setIsInvestFlowActive(true)
}
}
console.log(
`Claim/index::`,
`[unclaimedAmount ${unclaimedAmount?.toFixed(2)}]`,
`[hasClaims ${hasClaims}]`,
`[activeClaimAccount ${activeClaimAccount}]`,
`[isAirdropOnly ${isAirdropOnly}]`,
`[isInvestmentStillAvailable ${isInvestmentStillAvailable}]`,
`[isAirdropStillAvailable ${isAirdropStillAvailable}]`
)

// on account change
useEffect(() => {
Expand Down Expand Up @@ -320,16 +335,21 @@ export default function Claim() {

{/* START -- IS Airdrop only (simple) ----------------------------------------------------- */}
{!!activeClaimAccount && !!hasClaims && !!isAirdropOnly && !claimAttempting && !claimConfirmed && (
<IntroDescription>
<p>
<Trans>
Thank you for being a supporter of CowSwap and the CoW protocol. As an important member of the CowSwap
Community you may claim vCOW to be used for voting and governance. You can claim your tokens until{' '}
<i>[XX-XX-XXXX - XX:XX GMT]</i>
<ExternalLink href="https://cow.fi/">Read more about vCOW</ExternalLink>
</Trans>
</p>
</IntroDescription>
<>
<IntroDescription>
<p>
<Trans>
Thank you for being a supporter of CowSwap and the CoW protocol. As an important member of the CowSwap
Community you may claim vCOW to be used for voting and governance. You can claim your tokens until{' '}
<i>[XX-XX-XXXX - XX:XX GMT]</i>
<ExternalLink href="https://cow.fi/">Read more about vCOW</ExternalLink>
</Trans>
</p>
</IntroDescription>

{/* TODO: this is temporary to show the flag, find a better way to show it */}
{!isAirdropStillAvailable && <h3>WARNING: investment window is over!!!</h3>}
</>
)}
{/* END -- IS Airdrop only (simple) ---------------------------------------- */}

Expand Down Expand Up @@ -364,7 +384,7 @@ export default function Claim() {
<h3>You have successfully claimed</h3>
</Trans>
<Trans>
<p>{claimedAmmount} vCOW</p>
<p>{claimedAmount} vCOW</p>
</Trans>
<Trans>
<span role="img" aria-label="party-hat">
Expand Down Expand Up @@ -406,6 +426,10 @@ export default function Claim() {
!(claimAttempting || claimConfirmed) && (
<ClaimBreakdown>
<h2>vCOW claim breakdown</h2>

{/* TODO: this is temporary to show the flag, find a better way to show it */}
{!isInvestmentStillAvailable && <h3>WARNING: investment window is over!!!</h3>}

<ClaimTable>
<table>
<thead>
Expand Down Expand Up @@ -620,6 +644,7 @@ export default function Claim() {
)}
{/* END -- Investing vCOW flow (advanced) ----------------------------------------------------- */}

{/* START -- CLAIM button OR other actions */}
<FooterNavButtons>
{/* General claim vCOW button (no invest) */}
{!!activeClaimAccount && !!hasClaims && !isInvestFlowActive && !claimAttempting && !claimConfirmed ? (
Expand Down Expand Up @@ -668,6 +693,7 @@ export default function Claim() {
</>
)}
</FooterNavButtons>
{/* END -- CLAIM button OR other actions */}
</PageWrapper>
)
}
Loading