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

Jon/fix/earn-2 #5370

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Jon/fix/earn-2 #5370

wants to merge 5 commits into from

Conversation

Jon-edge
Copy link
Collaborator

@Jon-edge Jon-edge commented Nov 22, 2024

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)

Specifically for wallets created from this scene
From Discover tab only, in case they have an open stake position already.
Copy link
Contributor

@peachbits peachbits left a comment

Choose a reason for hiding this comment

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

There's a bug introduced with parallelizing fetchStakePosition calls where the discover cards aren't shown until all of the stake positions are fetched. If you separate the discover cards from the portfolio cards then you could generate the discover cards very quickly and then loop over the fetchStakePosition promises in batches or whatever. To get the cards quickly

const [stakePlugins, setStakePlugins] = React.useState<StakePlugin[]>(() => [])

  useAsyncEffect(
    async () => {
      const out = []
      for (const pluginId of Object.keys(currencyConfigMap)) {
        const moarPlugins = await getStakePlugins(pluginId)
        out.push(...moarPlugins)
      }
      setStakePlugins(out)
    },
    [],
    'EarnScene Initialize Stake Plugins'
  )

For the discover card list, loop over these stake plugins and call getPolicies. For portfolio card list, loop over these stake plugins and call getPolicies with the wallet as part of the filter and then do the work to call fetchStakePosition.

@Jon-edge Jon-edge force-pushed the jon/fix/earn-2 branch 3 times, most recently from d4987d5 to 21ec4f7 Compare November 27, 2024 04:36

const renderPortfolioItem = (portfolioStakeInfo: PortfolioStakeInfo, currencyInfo: EdgeCurrencyInfo) => {
const { stakePlugin, stakePolicy, walletStakeInfos } = portfolioStakeInfo

const handlePress = async () => {
let walletId: string | undefined
let stakePosition

const matchingWallets = wallets.filter((wallet: EdgeCurrencyWallet) => wallet.currencyInfo.pluginId === currencyInfo.pluginId)
if (matchingWallets.length === 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

One last tiny change then we should get this back in QAs hands: we don't need to look at matchingWallets in renderPortfolioItem since we already have walletStakeInfos. Remove matchingWallets and replace the length check with walletStakeInfos

Copy link
Collaborator Author

@Jon-edge Jon-edge Nov 30, 2024

Choose a reason for hiding this comment

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

I remember doing this intentionally for new positions from new wallets but I will have to check what the exact situation was and if it's still applicable

Copy link
Contributor

@peachbits peachbits left a comment

Choose a reason for hiding this comment

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

Approved, assuming the last requested change is made

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