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

Unexpected values received for types i8 and i16 from ink! contract #5483

Closed
3 of 7 tasks
sharma66mahesh opened this issue Feb 14, 2023 · 8 comments
Closed
3 of 7 tasks

Comments

@sharma66mahesh
Copy link

  • I'm submitting a ...
  • Bug report
  • What is the current behavior and expected behavior?
    Upon uploading this ink! contract, I was expecting to receive the values of the variables my_i8 and my_i16 to be 127 and 32767 as it was set in the ink! contract respectively.

However, I received -129 and -32769 as the values for my_i8 and my_i16 respectively.

The following is the output of querying the contract's get method:

{"msg":"ICE/SNOW Network","u8Arr":"0x010203","value":"0x7fffffffffffffffffffffffffffffff","isTrue":true,"myAccount":"npRm3oLNUahbPgUnwjPYw9oLWdEigk6aHzwtvj4nibfAJMYVo","myBalance":123123123123,"myHash":"0xe0d83c067d9abf593a8089ef1f21fc30fafb02a8dd67a862f8ca47eb158735b9","myVec":[-65535,-65534,-65533,-65532,-65531,-65530,-65529,-65528,-65527,-65526,-65525],"myStruct":{"id":1,"status":"Invalid","strArr":["Str1","Str2"]},"myIntStruct":{"myU8":255,"myU16":65535,"myU32":4294967295,"myU64":"0xffffffffffffffff","myU128":"0xffffffffffffffffffffffffffffffff","myI8":-129,"myI16":-32769,"myI32":2147483647,"myI64":"0x7fffffffffffffff","myI128":"0x7fffffffffffffffffffffffffffffff"}}
  • What is the motivation for changing the behavior?

  • Please tell us about your environment:

    • Version: polkadot-v0.9.36, @polkadot-js/api v9.13.6, @polkadot-js/api-contract v9.13.6

    • Environment:

      • Node.js
      • Browser
      • Other (limited support for other environments)
    • Language:

      • JavaScript
      • TypeScript (include tsc --version)
      • Other
@cmichi
Copy link

cmichi commented Feb 16, 2023

@statictype @DoubleOTheven Any idea?

@DoubleOTheven
Copy link

Hey @sharma66mahesh, would you please share the metadata for that contract?

I would try updating polkadotjs to the latest version in the mean time

@sharma66mahesh
Copy link
Author

@DoubleOTheven Here is the link to the compiled contract:
https://easyupload.io/m/ggzozt

@DoubleOTheven
Copy link

@sharma66mahesh Thanks for sharing

  1. I tested on Contracts on Rococo and it is exactly as you said.
  2. I also tested on a local React app and decoded the raw values. Same result:
{
  "myIntStruct": ​​{
    "myI16": "-32,769"
    "myI8": "-129"
    // ... omitted
​​  }
  // ...omitted
}

It looks like i8 and i16 values are not correctly decoded from the raw response. i64 IS, however. I will ping the dev team on internal comms.

@jacogr
Copy link
Member

jacogr commented Mar 12, 2023

Closing on the back of #5506 which seems like it would be the root cause. Comments to "still an issue on latest" would re-open.

@jacogr jacogr closed this as completed Mar 12, 2023
@statictype
Copy link
Member

still an issue on latest

@jacogr
Copy link
Member

jacogr commented Nov 18, 2023

#5702 addresses the root causes (tracing back to the common repo).

@jacogr jacogr closed this as completed Nov 18, 2023
@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants