-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Claim as X #6193
Merged
Merged
Claim as X #6193
Changes from 83 commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
a2d6822
progress
benisgold c13988a
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold e5bae77
progress
benisgold aac6130
progress
benisgold 60a73f2
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 7c84da5
testing
benisgold 21c64e6
progress
benisgold cda4fed
progress
benisgold 7460833
crosschain quote working
benisgold 3606a67
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 402daf0
claim + crosschainswap rap worked
benisgold bd3c346
raps logic is done
benisgold 853610a
delete v2
benisgold 2da4b13
cleanup
benisgold c4dc4bc
working on dropdowns
benisgold f9091b5
little dropdown refactor
benisgold 1df2591
useDropdownMenu hook
benisgold b48a2c2
refactoring
benisgold 257b159
working on dropdown
benisgold ffda496
basically done with ui refactor
benisgold 7df4103
fixes
benisgold 7c6101e
claim as x is working
benisgold ab1a2fc
context work
benisgold 6188258
progress
benisgold 8486d61
gas
benisgold 1567415
enormous refactor, need to fix some things
benisgold c989327
gas fixes
benisgold 4d5664c
pretty sure i fixed quotes
benisgold 8d34e00
functional
benisgold 1f7ef8c
wrapping things up
benisgold 5f3e715
cleaning up
benisgold bcca162
fixes
benisgold e090638
more fixes
benisgold e819399
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold bede077
fix formatting
benisgold 7dbe664
lint
benisgold 4f91665
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold ff7a615
gas and quote state fixes
benisgold 07d9e1d
rm logs
benisgold 417dbfa
error messages
benisgold 9fafef9
error messages + i18n
benisgold 4dd4b4b
fix bug that allowed button press w/o token/chain selected
benisgold f0f702d
disable watched wallets
benisgold d2221c3
error logging in executeClaim
benisgold bfb9f86
i18n
benisgold e2d61b0
slippage
benisgold 38485be
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 4f83347
add comments to transaction context
benisgold 84ca209
comments
benisgold 0f37430
erge branch 'develop' of https://github.com/rainbow-me/rainbow into @…
benisgold 76ab7f7
rainbow fee
benisgold c17c60e
adjust rainbow fee
benisgold 4a33e9e
gas improvements
benisgold 5d5767a
forgot to undo this
benisgold eb94ed9
fix gas race condition
benisgold ab9e67d
fix swap data assetToSell bug
benisgold 4e09866
rm comment
benisgold a43c5e5
improve error logging in raps
benisgold 3276da4
nit
benisgold 7a2bab3
temp, merging develop
benisgold feab384
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold ccb2333
fix gas estimation
benisgold a75fb52
rm unused imports
benisgold 08a088e
rm console log
benisgold 86d0ba7
rm dai, wbtc, add usdc
benisgold 27c2768
fix quote amount + fix gas estimation throttling
benisgold 57304ce
rename txState to gasState
benisgold 9e1b1ce
more gas fixes
benisgold ca5d31c
network icons for dropdown menu
benisgold 7f8aaca
fix populateSwap util and some other minor things
benisgold 9926097
fix analyticsId
benisgold 77c4501
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 8975cdc
fix scenario where user does not have native asset for gas calculations
benisgold 3743c90
fix context menu ordering on android
benisgold 06a9f7d
fix gas estimation
benisgold f15a655
undo obsolete change
benisgold 48f6179
fix analytics
benisgold a5fbefe
Claimables followups (#6301)
benisgold a4e0d64
fix hook usage
benisgold 93a7e45
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 256e71c
lint
benisgold e4fd27a
wallet screen fix
benisgold 59c8e38
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 9307b62
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 3554880
dont throw errors in rap creation
benisgold 08f5aca
remove claimable asset from dropdown if network is not compatible
benisgold 0a1b9c1
rm unnecessary useCallback dep
benisgold 06f2093
show wallet error alert if can't load wallet
benisgold 149c19b
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 9afef38
fix approval target
benisgold 29410e4
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React from 'react'; | ||
import React, { useMemo } from 'react'; | ||
import { Box, Inline, Stack, Text } from '@/design-system'; | ||
import { useAccountSettings } from '@/hooks'; | ||
import { useClaimables } from '@/resources/addys/claimables/query'; | ||
|
@@ -7,41 +7,85 @@ import { ButtonPressAnimation } from '@/components/animations'; | |
import { deviceUtils } from '@/utils'; | ||
import Routes from '@/navigation/routesNames'; | ||
import { ExtendedState } from './core/RawRecyclerList'; | ||
import { convertAmountToNativeDisplayWorklet } from '@/helpers/utilities'; | ||
import { convertAmountAndPriceToNativeDisplay, convertAmountToNativeDisplayWorklet, convertRawAmountToBalance } from '@/helpers/utilities'; | ||
import { analyticsV2 } from '@/analytics'; | ||
import { ChainBadge } from '@/components/coin-icon'; | ||
import { useNativeAsset } from '@/utils/ethereumUtils'; | ||
import { ChainId } from '@/chains/types'; | ||
import { usePoints } from '@/resources/points'; | ||
|
||
const RAINBOW_ICON_URL = 'https://rainbowme-res.cloudinary.com/image/upload/v1694722625/dapps/rainbow-icon-large.png'; | ||
|
||
export const Claimable = React.memo(function Claimable({ uniqueId, extendedState }: { uniqueId: string; extendedState: ExtendedState }) { | ||
const { accountAddress, nativeCurrency } = useAccountSettings(); | ||
const { navigate } = extendedState; | ||
|
||
const isETHRewards = uniqueId === 'rainbow-eth-rewards'; | ||
|
||
const eth = useNativeAsset({ chainId: ChainId.mainnet }); | ||
|
||
const { data = [] } = useClaimables( | ||
{ | ||
address: accountAddress, | ||
currency: nativeCurrency, | ||
}, | ||
{ | ||
select: data => data?.filter(claimable => claimable.uniqueId === uniqueId), | ||
enabled: !isETHRewards, | ||
} | ||
); | ||
|
||
const { data: points } = usePoints({ | ||
walletAddress: accountAddress, | ||
}); | ||
|
||
const [claimable] = data; | ||
if (!claimable) return null; | ||
const claimableETHRewardsRawAmount = points?.points?.user?.rewards?.claimable; | ||
|
||
if (isETHRewards) { | ||
if (!claimableETHRewardsRawAmount) return null; | ||
} else { | ||
if (!claimable) return null; | ||
} | ||
|
||
const { display: claimableETHRewardsDisplay, amount: claimableETHRewardsAmount } = isETHRewards | ||
? convertRawAmountToBalance(claimableETHRewardsRawAmount ?? '0', { | ||
decimals: 18, | ||
symbol: 'ETH', | ||
}) | ||
: { display: undefined, amount: undefined }; | ||
|
||
const nativeDisplay = convertAmountToNativeDisplayWorklet( | ||
isETHRewards | ||
? convertAmountAndPriceToNativeDisplay(claimableETHRewardsAmount ?? '0', eth?.price?.value || 0, nativeCurrency)?.amount | ||
: claimable?.value.nativeAsset.amount, | ||
nativeCurrency, | ||
true | ||
); | ||
|
||
if (isETHRewards) { | ||
if (!claimableETHRewardsDisplay) return null; | ||
} | ||
|
||
const nativeDisplay = convertAmountToNativeDisplayWorklet(claimable.value.nativeAsset.amount, nativeCurrency, true); | ||
if (!nativeDisplay) return null; | ||
|
||
return ( | ||
<Box | ||
as={ButtonPressAnimation} | ||
onPress={() => { | ||
analyticsV2.track(analyticsV2.event.claimablePanelOpened, { | ||
claimableType: claimable.type, | ||
claimableId: claimable.uniqueId, | ||
chainId: claimable.chainId, | ||
asset: { symbol: claimable.asset.symbol, address: claimable.asset.address }, | ||
amount: claimable.value.claimAsset.amount, | ||
usdValue: claimable.value.usd, | ||
}); | ||
navigate(Routes.CLAIM_CLAIMABLE_PANEL, { claimable }); | ||
if (!isETHRewards) { | ||
analyticsV2.track(analyticsV2.event.claimablePanelOpened, { | ||
claimableType: claimable?.type, | ||
claimableId: claimable?.analyticsId, | ||
chainId: claimable?.chainId, | ||
asset: { symbol: claimable?.asset.symbol, address: claimable?.asset.address }, | ||
amount: claimable?.value.claimAsset.amount, | ||
usdValue: claimable?.value.usd, | ||
}); | ||
navigate(Routes.CLAIM_CLAIMABLE_PANEL, { claimable }); | ||
} else { | ||
navigate(Routes.CLAIM_REWARDS_PANEL); | ||
} | ||
}} | ||
scaleTo={0.96} | ||
paddingHorizontal="20px" | ||
|
@@ -51,8 +95,9 @@ export const Claimable = React.memo(function Claimable({ uniqueId, extendedState | |
> | ||
<Inline alignVertical="center" space="12px"> | ||
<Box borderRadius={11} borderWidth={1} borderColor={{ custom: 'rgba(0, 0, 0, 0.03)' }}> | ||
<FasterImageView source={{ url: claimable.iconUrl }} style={{ height: 40, width: 40 }} /> | ||
<FasterImageView source={{ url: isETHRewards ? RAINBOW_ICON_URL : claimable?.iconUrl }} style={{ height: 40, width: 40 }} /> | ||
</Box> | ||
<ChainBadge chainId={isETHRewards ? ChainId.mainnet : claimable?.chainId} position="absolute" size="small" forceDark={true} /> | ||
<Stack space={{ custom: 11 }}> | ||
<Text | ||
weight="semibold" | ||
|
@@ -62,10 +107,10 @@ export const Claimable = React.memo(function Claimable({ uniqueId, extendedState | |
numberOfLines={1} | ||
style={{ maxWidth: deviceUtils.dimensions.width - 220 }} | ||
> | ||
{claimable.name} | ||
{isETHRewards ? 'Rainbow ETH Rewards' : claimable?.name} | ||
</Text> | ||
<Text weight="semibold" color="labelTertiary" size="13pt"> | ||
{claimable.value.claimAsset.display} | ||
{isETHRewards ? claimableETHRewardsDisplay : claimable?.value.claimAsset.display} | ||
</Text> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if |
||
</Stack> | ||
</Inline> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ActionProps, RapActionResult } from '../references'; | ||
import { executeClaim } from '@/screens/claimables/transaction/claim'; | ||
|
||
export async function claimClaimable({ wallet, parameters }: ActionProps<'claimClaimable'>): Promise<RapActionResult> { | ||
const { claimTx, asset } = parameters; | ||
|
||
return executeClaim({ asset, claimTx, wallet }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if
claimable?.name
is undefined here? Maybe will cause a crash