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

CSUB-612: Check TX total cost (incl fees) before sending #1194

Merged
merged 7 commits into from
Jul 19, 2023

Conversation

pLabarta
Copy link
Contributor

@pLabarta pLabarta commented Jul 7, 2023

Description of proposed changes

This PR introduces some utils for checking TX fees. The main one is requireEnoughFundsToSend which calculates the account balance after sending the transaction and checks if it's able to maintain the existential deposit (1 CTC). It also implements it in all commands that submit extrinsics.


Practical tips for PR review & merge:

  • All GitHub Actions report PASS
  • Newly added code/functions have unit tests
    • Coverage tools report all newly added lines as covered
    • The positive scenario is exercised
    • Negative scenarios are exercised, e.g. assert on all possible errors
    • Assert on events triggered if applicable
    • Assert on changes made to storage if applicable
  • Modified behavior/functions - try to make sure above test items are covered
  • Integration tests are added if applicable/needed

@pLabarta pLabarta marked this pull request as ready for review July 7, 2023 19:57
@github-actions
Copy link

github-actions bot commented Jul 7, 2023

For full LLVM coverage report click here!

atodorov
atodorov previously approved these changes Jul 11, 2023
Copy link
Contributor

@atodorov atodorov left a comment

Choose a reason for hiding this comment

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

Looks good to me now:

[gluwa@fedora cc-cli]$ node dist/index.js chill  -u ws://127.0.0.1:9946 
✔ Specify a seed phrase for the Controller account … *******************************************************************************
Creating chill transaction...
Caller 5Eq3uWk9WAzPt4RRVXg1cuNWZN7StujipUg5V7Kme1YN2P7F has insufficient funds to send the transaction and maintain existential deposit; transaction cancelled.

Copy link
Contributor

@nathanwhit nathanwhit left a comment

Choose a reason for hiding this comment

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

One typo, otherwise LGTM

scripts/cc-cli/src/utils/tx.ts Outdated Show resolved Hide resolved
atodorov
atodorov previously approved these changes Jul 14, 2023
nathanwhit
nathanwhit previously approved these changes Jul 14, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2023

Codecov Report

Merging #1194 (0d38b36) into dev (496db30) will decrease coverage by 59.86%.
The diff coverage is 25.71%.

@@            Coverage Diff             @@
##              dev   #1194       +/-   ##
==========================================
- Coverage   69.52%   9.67%   -59.86%     
==========================================
  Files         100      25       -75     
  Lines       11765     765    -11000     
  Branches       87      89        +2     
==========================================
- Hits         8180      74     -8106     
+ Misses       3585     691     -2894     
Impacted Files Coverage Δ
scripts/cc-cli/src/commands/distributeRewards.ts 0.00% <0.00%> (ø)
scripts/cc-cli/src/commands/send.ts 0.00% <0.00%> (ø)
scripts/cc-cli/src/commands/setKeys.ts 0.00% <0.00%> (ø)
scripts/cc-cli/src/commands/unbond.ts 0.00% <0.00%> (ø)
scripts/cc-cli/src/commands/withdrawUnbonded.ts 0.00% <0.00%> (ø)
scripts/cc-cli/src/commands/wizard.ts 0.00% <0.00%> (ø)
scripts/cc-cli/src/utils/bond.ts 0.00% <0.00%> (ø)
scripts/cc-cli/src/utils/validate.ts 0.00% <0.00%> (ø)
scripts/cc-cli/src/utils/tx.ts 27.65% <50.00%> (+27.65%) ⬆️

... and 76 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

atodorov
atodorov previously approved these changes Jul 17, 2023
@pLabarta pLabarta requested a review from AdaJane July 17, 2023 17:41
@pLabarta pLabarta merged commit ffb077b into dev Jul 19, 2023
34 checks passed
@pLabarta pLabarta deleted the cli-check-tx-fee branch July 19, 2023 12:24
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.

5 participants