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

Claim hooks part 0 #2032

Merged
merged 8 commits into from
Dec 23, 2021
Merged

Claim hooks part 0 #2032

merged 8 commits into from
Dec 23, 2021

Conversation

alfetopito
Copy link
Contributor

Summary

Added a couple of hooks and related stuff.

Right now it uses mocked data for the address 0x82850293A348107E798E5D366c10D1b566145Cd5 which has 2 hardcoded claims.
The address is also hardcoded for now, so you'll see the claims for it.

Also:

  • Added vCOW and GNO Token objects

  • Reverted useUserHasAvailableClaim and useUserUnclaimedAmount hooks to original versions on mod file and commented them out

  • Added their modded versions to the index file

  • Checking claims against the contract (Rinkeby only for now)

  • New hook useUserAvailableClaims that returns claims still available

  • Added utils fns hasPaidClaim and hasFreeClaim

    To Test

  1. On Rinkeby
  • CLAIM vCOW should be visible
  1. Click on CLAIM button
  • It should show 7850 as claimable

Note: Actual claiming does not yet work

Background

Optional: Give background information for changes you've made, that might be difficult to explain via comments

@alfetopito alfetopito requested a review from a team December 22, 2021 13:34
@alfetopito alfetopito self-assigned this Dec 22, 2021
@github-actions
Copy link
Contributor

  • 🔭 GP Swap: Gnosis Protocol v2 Swap UI

return []
}

return results.reduce<UserClaims>((acc, result, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this would be simpler as a filter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then I have to filter and map, while on reduce it's a single operation, no?

Of course, it has negligible performance impact. Will refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if I filter then map I'll lose the reference of the index.
If I map then filter I'll have to build another temporary data structure which is very similar to the current one.

I'd like to keep it as is if you don't mind

*
* @param account
*/
export function useUserHasAvailableClaim(account: Account): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better name is probably useUserCanClaim - this name is too long and too similar imo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that's the point, keep compatibility with existing hook

return CurrencyAmount.fromRawAmount(vCow, JSBI.BigInt(0))
}
const totalAmount = claims.reduce((acc, claim) => {
return JSBI.add(acc, JSBI.BigInt(claim.amount))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was already there, @anxolin did it =P

@alfetopito alfetopito merged commit 52b416f into claim Dec 23, 2021
@alfetopito alfetopito deleted the claim-hooks-0 branch December 23, 2021 10:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants