From ce296ba9335322ee01b0f22923803a3ba2086929 Mon Sep 17 00:00:00 2001 From: Leandro Date: Fri, 14 Jan 2022 15:43:17 -0800 Subject: [PATCH 1/4] Remove left over from merge --- src/custom/pages/Claim/ClaimsTable.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/custom/pages/Claim/ClaimsTable.tsx b/src/custom/pages/Claim/ClaimsTable.tsx index bb2656ef7..38484e75a 100644 --- a/src/custom/pages/Claim/ClaimsTable.tsx +++ b/src/custom/pages/Claim/ClaimsTable.tsx @@ -90,8 +90,6 @@ const ClaimsTableRow = ({ Ends in: 28 days, 10h, 50m - {type === ClaimType.Airdrop ? 'No' : '4 years (linear)'} - 28 days, 10h, 50m ) } From 6d3deb8987cfb3efe3db2d2791a9c8789948e6e3 Mon Sep 17 00:00:00 2001 From: Leandro Date: Fri, 14 Jan 2022 15:43:36 -0800 Subject: [PATCH 2/4] Invert sorting to have free claims on top --- src/custom/state/claim/hooks/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custom/state/claim/hooks/index.ts b/src/custom/state/claim/hooks/index.ts index e669a4fe1..d5be6e875 100644 --- a/src/custom/state/claim/hooks/index.ts +++ b/src/custom/state/claim/hooks/index.ts @@ -781,5 +781,5 @@ export function useUserEnhancedClaimData(account: Account): EnhancedUserClaimDat } function _sortTypes(a: UserClaimData, b: UserClaimData): number { - return Number(isFreeClaim(a.type)) - Number(isFreeClaim(b.type)) + return Number(isFreeClaim(b.type)) - Number(isFreeClaim(a.type)) } From bb9c0cbfe8822ba3e8c759e2fcf48302d9bed814 Mon Sep 17 00:00:00 2001 From: Leandro Date: Fri, 14 Jan 2022 15:43:57 -0800 Subject: [PATCH 3/4] Adjusting typesto make optional parameters optional --- src/custom/pages/Claim/types.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/custom/pages/Claim/types.ts b/src/custom/pages/Claim/types.ts index 69b90a08e..a9d30e3ea 100644 --- a/src/custom/pages/Claim/types.ts +++ b/src/custom/pages/Claim/types.ts @@ -12,9 +12,9 @@ export type ClaimCommonTypes = { // Enhanced UserClaimData with useful additional properties export type EnhancedUserClaimData = UserClaimData & { - currencyAmount: CurrencyAmount | undefined - claimAmount: CurrencyAmount | undefined - price: Price | undefined - cost: CurrencyAmount | undefined + currencyAmount?: CurrencyAmount | undefined + claimAmount?: CurrencyAmount | undefined + price?: Price | undefined + cost?: CurrencyAmount | undefined isFree: boolean } From 4cd2934637c57a27e4dc73938690b7ab02ad5544 Mon Sep 17 00:00:00 2001 From: Leandro Date: Fri, 14 Jan 2022 15:44:38 -0800 Subject: [PATCH 4/4] Fixed bug with free claims being filtered out --- src/custom/state/claim/hooks/index.ts | 41 +++++++++++++-------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/custom/state/claim/hooks/index.ts b/src/custom/state/claim/hooks/index.ts index d5be6e875..c1a3475c3 100644 --- a/src/custom/state/claim/hooks/index.ts +++ b/src/custom/state/claim/hooks/index.ts @@ -749,34 +749,33 @@ export function useUserEnhancedClaimData(account: Account): EnhancedUserClaimDat const chainId = supportedChainId(preCheckChainId) if (!chainId) return [] - return sorted.reduce((acc, claim) => { - const tokenAndAmount = claimTypeToTokenAmount(claim.type, chainId) - - if (!tokenAndAmount) return acc - - const price = new Price({ - baseAmount: ONE_VCOW, - quoteAmount: CurrencyAmount.fromRawAmount(tokenAndAmount.token, tokenAndAmount.amount), - }).invert() - - // get the currency amount using the price base currency (remember price was inverted) and claim amount - const currencyAmount = CurrencyAmount.fromRawAmount(price.baseCurrency, claim.amount) + return sorted.map((claim) => { const claimAmount = CurrencyAmount.fromRawAmount(ONE_VCOW.currency, claim.amount) - // e.g 1000 vCow / 20 GNO = 50 GNO cost - const cost = currencyAmount.divide(price) + const tokenAndAmount = claimTypeToTokenAmount(claim.type, chainId) - acc.push({ + const data: EnhancedUserClaimData = { ...claim, isFree: isFreeClaim(claim.type), - currencyAmount, claimAmount, - price, - cost, - }) + } + + if (!tokenAndAmount) { + return data + } else { + data.price = new Price({ + baseAmount: ONE_VCOW, + quoteAmount: CurrencyAmount.fromRawAmount(tokenAndAmount.token, tokenAndAmount.amount), + }).invert() + // get the currency amount using the price base currency (remember price was inverted) and claim amount + data.currencyAmount = CurrencyAmount.fromRawAmount(data.price.baseCurrency, claim.amount) - return acc - }, []) + // e.g 1000 vCow / 20 GNO = 50 GNO cost + data.cost = data.currencyAmount.divide(data.price) + + return data + } + }) }, [preCheckChainId, sorted]) }