-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat(jumpstart): add reclaim bottom sheet #5125
Conversation
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.
i wasn't sure if this PR is ready for review (it's not in draft) but i left some early comments anyway 🙈 looking good!
src/navigator/Navigator.tsx
Outdated
@@ -685,6 +686,10 @@ function nativeBottomSheets(BottomSheet: typeof RootStack) { | |||
name={Screens.FiatExchangeCurrencyBottomSheet} | |||
component={FiatExchangeCurrencyBottomSheet} | |||
/> | |||
<BottomSheet.Screen |
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.
curious why you chose a screen over a bottom sheet component directly inside the transaction details component? it seems like the only place that needs to launch this bottom sheet is the details screen (the components we have registered as screens so far are ones that can launched from many places...)
|
||
const transactionString = JSON.stringify(reclaimTx) | ||
|
||
async function onConfirm() { |
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.
we haven't been terribly consistent about this but i think it is a bad pattern to trigger async functions on button presses because then we don't handle rejected promises well (and don't necessarily await the outcome before moving on). i started using the useAsyncCallback hook to handle this, maybe we can do something similar here? it would also enable the loading state out of the box.
const handleProceed = useAsyncCallback( |
Logger.debug(TAG, 'Reclaiming', { reclaimTx, networkId, tokenAmount }) | ||
// TODO: Send transaction | ||
navigateBack() | ||
navigateHome() |
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.
maybe just navigateHome is okay here?
const walletAddress = useSelector(walletAddressSelector) | ||
const jumpstartContractAddress = getJumpstartContractAddress(transfer.networkId) | ||
|
||
const fetchEscrowData = useAsync( |
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.
nit: can we be consistent with how we call this feature 😅 jumpstart rather than escrow?
const fetchEscrowData = useAsync( | |
const fetchJumpstartDepositData = useAsync( |
}) | ||
} | ||
|
||
const ReclaimButton = () => ( |
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.
i think declaring new components with this syntax is bad for performance because these are recreated on every re-render...
const ReclaimButton = () => ( | |
const ReclaimButton = ( |
alternatively, why not just use this render block directly inside the render function? i'd argue that it's easier to read the render function this way, because you don't need to jump around to understand the components
) : ( | ||
<Button | ||
showLoading={fetchEscrowData.loading} | ||
disabled={fetchEscrowData.loading} |
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.
we need a separate loading button right? otherwise when loading whether a user can reclaim, the button will show "Claim" + loader?
if (!token) { | ||
// should never happen | ||
Logger.error(TAG, 'Token is undefined') | ||
return null | ||
} | ||
|
||
// TODO: Add reclaim button | ||
const ClaimedLabel = () => ( |
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.
i wonder if you can use the Button component with disabled
and touchableStyle
set to the green background? maybe you also need to set the color of the font with fontStyle
but then it'd ensure that this disabled button won't look different from the enabled / loading buttons?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5125 +/- ##
==========================================
- Coverage 85.80% 85.78% -0.02%
==========================================
Files 742 745 +3
Lines 30104 30217 +113
Branches 5189 5210 +21
==========================================
+ Hits 25831 25922 +91
- Misses 4037 4058 +21
- Partials 236 237 +1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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.
i think this is looking great, just small nit comments (but the blocking one is really the test coverage 😅)
storeOverrides?: RecursivePartial<RootState> | ||
transaction: TokenTransfer | ||
}) { | ||
const store = createMockStore({ |
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.
nit: we don't really need to create a fancy mock store right? the identity and recipients stores are not relevant for this test?
expect(getElementText(amountValue)).toBe('10.00 cUSD') | ||
}) | ||
|
||
it('handles jumpstart received transactions correctly', async () => { |
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.
can we add some tests for the claim button states?
|
||
const claimed = erc20Claim[3] | ||
|
||
Logger.debug(`Reward deposited in ${transactionHash} ${claimed ? 'was' : 'was NOT'} claimed`) |
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.
nit: to make the logs easier to read, can we add a TAG
in all the log statements?
locales/base/translation.json
Outdated
@@ -2219,5 +2221,6 @@ | |||
"contactSupport": "Contact Support", | |||
"dismiss": "Dismiss" | |||
} | |||
} | |||
}, | |||
"jumpstartReclaimDescription": "Reclaiming your link incurs a network gas fee, would you like to proceed?" |
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.
nit: could we create an object to group the translations under? i think you'll need to add error messages (the generic fetch + the failed to reclaim ones) and it'd be easier to understand where those errors belong to if they're grouped within a jumpstartReclaim
key?
### Description This PR adds the reclaim button to the escrow deposits. It checks if the escrow was claimed and open the bottom sheet, but it doesn't execute the transaction. ### Test plan Emulator ### Related issues - Fixes RET-1003 ### Backwards compatibility Y ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [y] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added) --------- Co-authored-by: Kathy Luo <kathyluo18@gmail.com>
Description
This PR adds the reclaim button to the escrow deposits.
It checks if the escrow was claimed and open the bottom sheet, but it doesn't execute the transaction.
Test plan
Emulator
Related issues
Backwards compatibility
Y
Network scalability
If a new NetworkId and/or Network are added in the future, the changes in this PR will: