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-578: Properly parse floating point amounts #1150

Merged
merged 21 commits into from
Jun 22, 2023
Merged

Conversation

pLabarta
Copy link
Contributor

Description of proposed changes

  • Added parseFloat into parseCTCString and implemented in commands which receive amounts as input

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

nathanwhit
nathanwhit previously approved these changes Jun 21, 2023
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.

Simple enough, LGTM!

AdaJane
AdaJane previously approved these changes Jun 21, 2023
@github-actions
Copy link

For full LLVM coverage report click here!

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.

bond still fails:

$ node dist/index.js bond -u ws://127.0.0.1:9946 -s "<mnemonic>"  -c <controller-address> -a 1000001.11 -r Staked

2023-06-21 14:43:24        API/INIT: RPC methods not decorated: creditcoin_hashrate, task_getOffchainNonceKey
2023-06-21 14:43:24        API/INIT: creditcoin-node/222: Not decorating unknown runtime apis: TaskApi/1
Creating bond transaction...
Controller address: 5EEoJZYPpTYGX1t3shaQbqhRmqvdvoaTycY1gJ4TB8spDgPp
Reward destination: Staked
Amount: 1000001.11
✔ Continue? … yes
Extra:  undefined
/home/gluwa/creditcoin-2.0/creditcoin-substrate/scripts/cc-cli/dist/utils/bond.js:19
        const amountInMicroUnits = BigInt(amount) * BigInt(1000000000000000000); // Multiply by to convert to micro units
                                   ^

RangeError: The number 1000001.11 cannot be converted to a BigInt because it is not an integer
    at BigInt (<anonymous>)
    at /home/gluwa/creditcoin-2.0/creditcoin-substrate/scripts/cc-cli/dist/utils/bond.js:19:36
    at Generator.next (<anonymous>)
    at /home/gluwa/creditcoin-2.0/creditcoin-substrate/scripts/cc-cli/dist/utils/bond.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/gluwa/creditcoin-2.0/creditcoin-substrate/scripts/cc-cli/dist/utils/bond.js:4:12)
    at bond (/home/gluwa/creditcoin-2.0/creditcoin-substrate/scripts/cc-cli/dist/utils/bond.js:15:12)
    at Command.<anonymous> (/home/gluwa/creditcoin-2.0/creditcoin-substrate/scripts/cc-cli/dist/commands/bond.js:58:50)
    at Generator.next (<anonymous>)
    at fulfilled (/home/gluwa/creditcoin-2.0/creditcoin-substrate/scripts/cc-cli/dist/commands/bond.js:5:58)

Node.js v18.1.0

scripts/cc-cli/src/commands/bond.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/commands/bond.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/commands/bond.ts Show resolved Hide resolved
scripts/cc-cli/src/commands/bond.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/commands/wizard.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/utils/balance.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/utils/balance.ts Show resolved Hide resolved
scripts/cc-cli/src/utils/balance.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/utils/balance.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/utils/promptContinue.ts Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Merging #1150 (827f7b3) into dev (f2f16fc) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##              dev    #1150   +/-   ##
=======================================
  Coverage   74.62%   74.62%           
=======================================
  Files          74       74           
  Lines       10686    10686           
=======================================
  Hits         7974     7974           
  Misses       2712     2712           

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

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.

Needs rebase, too many conflicts

scripts/cc-cli/src/commands/send.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/commands/wizard.ts Show resolved Hide resolved
scripts/cc-cli/yarn.lock Outdated Show resolved Hide resolved
scripts/cc-cli/src/utils/balance.ts Show resolved Hide resolved
scripts/cc-cli/src/commands/unbond.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/commands/unbond.ts Show resolved Hide resolved
scripts/cc-cli/src/commands/unbond.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/commands/wizard.ts Show resolved Hide resolved
scripts/cc-cli/src/commands/wizard.ts Show resolved Hide resolved
scripts/cc-cli/src/commands/send.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/commands/send.ts Outdated Show resolved Hide resolved
scripts/cc-cli/src/commands/send.ts Show resolved Hide resolved
@AdaJane AdaJane dismissed atodorov’s stale review June 22, 2023 22:11

Concerns resolved by new commits

@AdaJane AdaJane merged commit e90853a into dev Jun 22, 2023
29 checks passed
@AdaJane AdaJane deleted the cli-fix-float-parsing branch June 22, 2023 22:11
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.

6 participants