Skip to content
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

Merged
merged 54 commits into from
Mar 28, 2024

Conversation

dievazqu
Copy link
Contributor

@dievazqu dievazqu commented Mar 19, 2024

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:

  • [y] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

@dievazqu dievazqu changed the title Diego/reclaim functionality feat(escrow): Reclaim button sheet Mar 19, 2024
@dievazqu dievazqu changed the title feat(escrow): Reclaim button sheet feat(escrow): Reclaim botton sheet Mar 19, 2024
@dievazqu dievazqu changed the title feat(escrow): Reclaim botton sheet feat(escrow): Reclaim bottom sheet Mar 19, 2024
Copy link
Collaborator

@kathaypacific kathaypacific left a 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!

@@ -685,6 +686,10 @@ function nativeBottomSheets(BottomSheet: typeof RootStack) {
name={Screens.FiatExchangeCurrencyBottomSheet}
component={FiatExchangeCurrencyBottomSheet}
/>
<BottomSheet.Screen
Copy link
Collaborator

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() {
Copy link
Collaborator

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()
Copy link
Collaborator

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(
Copy link
Collaborator

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?

Suggested change
const fetchEscrowData = useAsync(
const fetchJumpstartDepositData = useAsync(

})
}

const ReclaimButton = () => (
Copy link
Collaborator

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...

Suggested change
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}
Copy link
Collaborator

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 = () => (
Copy link
Collaborator

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?

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 86.74699% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 85.78%. Comparing base (8f08231) to head (b7eef06).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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     
Files Coverage Δ
src/abis/IWalletJumpstart.ts 100.00% <ø> (ø)
src/navigator/Screens.tsx 100.00% <100.00%> (ø)
src/transactions/feed/TransactionDetails.tsx 100.00% <100.00%> (ø)
src/transactions/feed/TransactionDetailsScreen.tsx 90.80% <100.00%> (-2.12%) ⬇️
src/transactions/transferFeedUtils.ts 88.19% <100.00%> (-0.15%) ⬇️
src/transactions/utils.ts 100.00% <ø> (ø)
src/web3/networkConfig.ts 100.00% <100.00%> (ø)
src/transactions/feed/TransferFeedItem.tsx 89.13% <69.23%> (-5.32%) ⬇️
...actions/feed/JumpstartTransactionDetailsScreen.tsx 93.67% <93.67%> (ø)
src/jumpstart/fetchClaimStatus.ts 35.00% <35.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f08231...b7eef06. Read the comment docs.

Copy link
Collaborator

@kathaypacific kathaypacific left a 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({
Copy link
Collaborator

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 () => {
Copy link
Collaborator

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`)
Copy link
Collaborator

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?

@@ -2219,5 +2221,6 @@
"contactSupport": "Contact Support",
"dismiss": "Dismiss"
}
}
},
"jumpstartReclaimDescription": "Reclaiming your link incurs a network gas fee, would you like to proceed?"
Copy link
Collaborator

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?

Base automatically changed from diego/jumpstart-feed-items to main March 21, 2024 17:00
@kathaypacific kathaypacific added this pull request to the merge queue Mar 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 28, 2024
@kathaypacific kathaypacific added this pull request to the merge queue Mar 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 28, 2024
@kathaypacific kathaypacific changed the title feat(escrow): Reclaim bottom sheet feat(jumpstart): Reclaim bottom sheet Mar 28, 2024
@kathaypacific kathaypacific added this pull request to the merge queue Mar 28, 2024
@kathaypacific kathaypacific changed the title feat(jumpstart): Reclaim bottom sheet feat(jumpstart): add reclaim bottom sheet Mar 28, 2024
Merged via the queue into main with commit 94ea0c4 Mar 28, 2024
18 checks passed
@kathaypacific kathaypacific deleted the diego/reclaim-functionality branch March 28, 2024 13:10
shottah pushed a commit to zed-io/kolektivo that referenced this pull request May 15, 2024
### 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants