stacks-archive / stacks-transactions-js

The JavaScript library for generating Stacks 2.0 transactions
19 stars 17 forks source link

[TESTNET BUG] ft-get-balance returns int instead of uint when called as read-only #100

Closed friedger closed 4 years ago

friedger commented 4 years ago

Describe the bug

The return value of ft-get-balance is an int instead of an uint, e.g. something like (ok 20) when called as read-only

Screenshot from 2020-06-29 01-27-23

Steps To Reproduce

  1. deploy fungible-token contract e.g. from https://github.com/friedger/clarity-js-sdk/blob/feature/jsonrcp/packages/clarity-tutorials/contracts/tokens/fungible-token.clar
  2. call read-only balance-of ST398K1WZTBVY6FE2YEHM6HP20VSNVSSPJTW0D53M
  3. see result (ok 20)

Expected behavior

result should be (ok u20)

Environment

using https://testnet-explorer.blockstack.org/sandbox?tab=contract-call

Additional context

Unit tests in clarity VM pass and handle uint values.


If you think this is eligible for a bug bounty, please check the relevant boxes below:

Critical, Launch Blocking Bugs

Consensus critical bugs

State corruption

Stolen funds

Take control and/or bring network to a halt

Major, Launch Blocking Bugs

Major bugs

Minor, Non-launch blocking bugs

Minor bugs

reedrosenbluth commented 4 years ago

On first glance I think that this isn't a bug with the Clarity VM and that the stacks-transactions-js library is just neglecting to include the u when converting uints to strings. Currently diving deeper and trying to test this hypothesis...

reedrosenbluth commented 4 years ago

Yup, this appears to be what's happening. Will put up a PR in stacks-transactions-js with this change soon.

friedger commented 4 years ago

@timstackblock is this a bug bounty bug?

timstackblock commented 4 years ago

Yes it is @friedger, @jdbender66 will contact you with more info in discord, thank you for the submission.