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

LIVE-1292 Cover Polkadot existential deposit edge case (#1953) #1957

Merged
16 commits merged into from
May 16, 2022

Conversation

ghost
Copy link

@ghost ghost commented May 12, 2022

Context (issues, jira)

https://ledgerhq.atlassian.net/browse/LIVE-1292

Description / Usage

When trying to emptied an account, it doesn't work.
This happens when the balance is at ~1 DOT, this is a limitation of the Polkadot blockchain.
The logic of Ledger Live Common was not adapted, this PR fix this.

This PR also contains a fix on the optimistic operation which does not contain the correct type when it is a send max.

Expectations

  • Test coverage: The changes of this PR are covered by test. Unit test were added with mocks when depending on a backend/device.
  • No impact: The changes of this PR have ZERO impact on the userland. Meaning, we can use these changes without modifying LLD/LLM at all. It will be a "noop" and the maintainers will be able to bump it without changing anything.

* Fix transaction mode mapping

Send max must be balances.transfer palletMethod instead of balances.transferKeepAlive

* Fix 1 DOT Polkadot limitation

On the Polkadot network, an address is only active when it holds a minimum amount, currently set at 1 DOT.
There's a limitation when you hold ~ 1 DOT.
Use recommended 1.1 DOT value.

* Improve code readability

Don't use ternary operator

* Split Existential Deposit and margin

Restore EXISTENTIAL_DEPOSIT, use new constant EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN to handle recommended margin
@ghost ghost self-requested a review as a code owner May 12, 2022 11:57
@vercel
Copy link

vercel bot commented May 12, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
ledger-live-common ✅ Ready (Inspect) Visit Preview May 16, 2022 at 10:26AM (UTC)

@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #1957 (e49c371) into develop (5b012ce) will increase coverage by 5.09%.
The diff coverage is 79.16%.

@@             Coverage Diff             @@
##           develop    #1957      +/-   ##
===========================================
+ Coverage    55.20%   60.30%   +5.09%     
===========================================
  Files          451      546      +95     
  Lines        20443    23436    +2993     
  Branches      5255     6068     +813     
===========================================
+ Hits         11286    14132    +2846     
- Misses        9128     9278     +150     
+ Partials        29       26       -3     
Impacted Files Coverage Δ
src/families/polkadot/js-getTransactionStatus.ts 45.39% <50.00%> (+37.39%) ⬆️
src/families/polkadot/js-signOperation.ts 77.14% <60.00%> (+43.34%) ⬆️
src/families/polkadot/specs.ts 67.94% <87.50%> (+43.29%) ⬆️
src/families/polkadot/logic.ts 68.68% <100.00%> (+23.78%) ⬆️
src/families/crypto_org/api/sdk.ts 16.85% <0.00%> (-78.66%) ⬇️
src/families/celo/hw-app-celo.ts 3.38% <0.00%> (-77.97%) ⬇️
src/families/bitcoin/js-signOperation.ts 21.53% <0.00%> (-75.39%) ⬇️
src/families/bitcoin/networks.ts 5.88% <0.00%> (-74.51%) ⬇️
src/families/celo/js-getFeesForTransaction.ts 26.66% <0.00%> (-73.34%) ⬇️
src/hw/signTransaction/ripple.ts 27.27% <0.00%> (-72.73%) ⬇️
... and 344 more

Continue to review full report at Codecov.

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

@ghost
Copy link
Author

ghost commented May 16, 2022

Bot says ✔️ !

@ghost ghost merged commit 663014c into develop May 16, 2022
@ghost ghost deleted the family/polkadot branch May 16, 2022 16:24
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants