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

[Wallet] Fix escrow failing randomly with local currency #5039

Merged
merged 3 commits into from
Sep 10, 2020

Conversation

jeanregisser
Copy link
Contributor

Description

This PR fixes sending an invite with an escrowed payment failing randomly when using a local currency.

See details in #3000

Other changes

  • Fixed dynamic link generation never returning and leaving the UI in loading state indefinitely (underlying error was Invalid domainURIPrefix scheme. Scheme needs to be https)

Tested

Added new test. Invite with escrow works.

Related issues

Backwards compatibility

Yes

@@ -48,5 +48,5 @@ export function convertLocalAmountToDollars(
// If the user enters `2.99` cUSD, this function has no impact
// and `2.99` is still displayed in the confirmation screen.
export function convertDollarsToMaxSupportedPrecision(amount: BigNumber) {
return new BigNumber(amount.toPrecision(18, BigNumber.ROUND_UP))
return new BigNumber(amount.toFixed(18, BigNumber.ROUND_UP))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was all my bad, I misunderstood the behavior of toPrecision when I implemented this.

It doesn't limit the number to X decimals, but to X significant digits.
See https://mikemcl.github.io/bignumber.js/#toP and https://en.wikipedia.org/wiki/Significant_figures#Significant_figures_rules_explained

toFixed does what we want.

@jeanregisser jeanregisser requested a review from a team September 10, 2020 15:52
Copy link
Contributor

@jmrossy jmrossy left a comment

Choose a reason for hiding this comment

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

Nice catch!

@jeanregisser jeanregisser added automerge Have PR merge automatically when checks pass wallet labels Sep 10, 2020
@mergify mergify bot merged commit 65270e4 into master Sep 10, 2020
@mergify mergify bot deleted the jeanregisser/fix-escrow-failing-with-local-currency branch September 10, 2020 17:13
jeanregisser added a commit that referenced this pull request Sep 10, 2020
### Description

This PR fixes sending an invite with an escrowed payment failing randomly when using a local currency.

See details in #3000

### Other changes

- Fixed dynamic link generation never returning and leaving the UI in loading state indefinitely (underlying error was `Invalid domainURIPrefix scheme. Scheme needs to be https`)

### Tested

Added new test. Invite with escrow works.

### Related issues

- Fixes #3000

### Backwards compatibility

Yes
@Lss-Ankit
Copy link

Hi @jeanregisser i have tried to repro issue on test flight build v1.1.0 (21) and able to repro issue.
Also, i have verified issue using latest Android build v1.1.0 (1004294311) and IOS test flight build v1.1.0(23) and found that issue is fixed.

  • User is able to send invitation with decimal escrow payment with selected local currency.
    Note: i have verified task with selecting CAD and EUR currency.

Please let me know if you want to verify anything else.

ewilz pushed a commit to ewilz/celo-monorepo that referenced this pull request Sep 29, 2020
### Description

This PR fixes sending an invite with an escrowed payment failing randomly when using a local currency.

See details in celo-org#3000

### Other changes

- Fixed dynamic link generation never returning and leaving the UI in loading state indefinitely (underlying error was `Invalid domainURIPrefix scheme. Scheme needs to be https`)

### Tested

Added new test. Invite with escrow works.

### Related issues

- Fixes celo-org#3000

### Backwards compatibility

Yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error transferring to escrow when using local currency
4 participants