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

Dispatch activateWalletTokens from TransactionListScene #5275

Merged
merged 6 commits into from
Sep 30, 2024

Conversation

samholmes
Copy link
Contributor

@samholmes samholmes commented Sep 25, 2024

This is to resolve an issue where the wallet state hasn't completed
checking if a newly added token is activated or not. This means the
user can enter the transaction list scene without activating the wallet.
In that case, we'll at least navigate in retrospect.

Watch for changes to the unactivedTokenIds property on the wallet.
If the tokenId within the transaction list appears in the
unactivedTokenids array, then we'll properly handle the activation
user journey.

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

)).catch(err => showError(err))
navigation.pop()
return
function activateWalletTokens(navigation: NavigationBase, wallet: EdgeCurrencyWallet, tokenIds?: string[]): ThunkAction<Promise<void>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the tokenIds argument should be mandatory, and should be EdgeTokenId[]. The function is only called from two places, so this change should be safe. Within the function, we pass tokenIds straight to the core, so it's up to the plugins to decide if they support mainnet activation or not.

Further down, when we do const tokensText, we could change the following line to const { currencyCode, displayName } = tokenId != null ? wallet.currencyConfig.allTokens[tokenId] : wallet.currencyInfo, and even our string formatting will work for mainnet coins.

return
function activateWalletTokens(navigation: NavigationBase, wallet: EdgeCurrencyWallet, tokenIds?: string[]): ThunkAction<Promise<void>> {
return async (_dispatch, getState) => {
if (tokenIds == null) throw new Error('Activating mainnet wallets unsupported')
Copy link
Contributor

Choose a reason for hiding this comment

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

If tokenIds are mandatory, this line goes away.

if (unactivatedTokenIds.some(unactivatedTokenId => unactivatedTokenId === tokenId)) {
// NOTE: It's safe to cast tokenId to string because we know it's in
// unactivatedTokenIds which is an array of strings.
await dispatch(activateWalletTokens(navigation, wallet, [tokenId as string]))
Copy link
Contributor

Choose a reason for hiding this comment

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

If we fix the typing, the cast simply goes away.

@samholmes samholmes force-pushed the sam/activate-tokens-lag branch 2 times, most recently from 0b8e6d1 to 76e0c50 Compare September 27, 2024 18:27
This is to resolve an issue where the wallet state hasn't completed
checking if a newly added token is activated or not. This means the
user can enter the transaction list scene without activating the wallet.
In that case, we'll at least navigate in retrospect.

Watch for changes to the `unactivedTokenIds` property on the wallet.
If the tokenId within the transaction list appears in the
`unactivedTokenids` array, then we'll properly handle the activation
user journey.
@samholmes samholmes merged commit aff0101 into develop Sep 30, 2024
2 checks passed
@samholmes samholmes deleted the sam/activate-tokens-lag branch September 30, 2024 18:41
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