Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

[instant] Request account address and balance at mount #1232

Merged
merged 5 commits into from
Nov 9, 2018

Conversation

BMillman19
Copy link
Contributor

Description

  • Add a new function asyncData.fetchAccountInfoAndDispatchToStore() that kicks off a request for the account address and balance
  • This function drives state updates to the state.providerState.account object in redux

Testing instructions

  • Observe appropriate account states in redux inspector

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • Prefix PR title with [WIP] if necessary.
  • Prefix PR title with bracketed package name(s) corresponding to the changed package(s). For example: [sol-cov] Fixed bug.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • Add new entries to the relevant CHANGELOG.jsons.

store.dispatch(actions.setAccountStateError());
return;
}
if (!_.isEmpty(availableAddresses)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit (not necessary to change) but I'd prefer for this to follow the return pattern above, i.e.

if (_.isEmpty(availableAddresses)) {
   store.dispatch(actions.setAccountStateLocked());
   return;
}

... setAccountStateReady code ..

Copy link
Contributor

@steveklebanoff steveklebanoff left a comment

Choose a reason for hiding this comment

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

Besides the question about balance concurrency, looks good! 😃

store.dispatch(actions.setAccountStateLocked());
}
},
fetchAccountBalanceAndDispatchToStore: async (store: Store) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that we'd have a concurrency issue in which we'd dispatch a balance for an account that they have since changed? I feel like we may need a similar check here as we have for the buy quote.

Alternatively, part of me feels like balance fetching could be paired with address fetching. This could be easier to reason about -- we always get the address and the balance together, or the whole thing is considered "failed". I'm not married to this though, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are correct wrt to the balance update coming late issue

@coveralls
Copy link

coveralls commented Nov 8, 2018

Coverage Status

Coverage decreased (-0.009%) to 84.712% when pulling b147cd8 on feature/instant/account-state-change into 117e2f5 on development.

Copy link
Contributor

@fragosti fragosti left a comment

Choose a reason for hiding this comment

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

:megusta:

@steveklebanoff's last comment is interesting. It does feel like it would simplify things... but we rely on this account notion to distinguish between different "not ready" states right?

@BMillman19
Copy link
Contributor Author

@fragosti im inclined to leave the balance as optional in the AccountReady state because it is not core to the functionality of instant. Even if we did not have the balance, we would still be able to function normally, we would just not be able to do the "do you have enough ETH" validation, which is not a big deal because it will most likely be caught at the wallet layer

* development:
  [instant] Viewport specific errors (#1228)
  Added more comments
  Include wholeNumberSchema in sra-spec schemas
  chore(instant): fix linter
  Fix isNode
  fix(instant): update buy quote at start up in the case of default amount
  fix: apply css reset to overlay as well
  fix(website): turn off production flag when building locally
  chore: linter
  fix: progress bar
  fix: use fontSize prop in button
  feat: make instant resistant to external styles
  feat: add faux externall css file
  Add upstream issue
  Use const require instead of import
  Fix tslint issues
  Use detect-node
  Set curstom inspect printer in BigNumber
@BMillman19 BMillman19 merged commit 12bc6f5 into development Nov 9, 2018
@steveklebanoff
Copy link
Contributor

Thanks for the concurrency fix 🎉 !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants