Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Decoding error & not correct decoding of returned types containing i16. #105

Closed
Nradko opened this issue Aug 14, 2023 · 2 comments · Fixed by #118
Closed

Decoding error & not correct decoding of returned types containing i16. #105

Nradko opened this issue Aug 14, 2023 · 2 comments · Fixed by #118
Assignees
Labels
bug Something isn't working

Comments

@Nradko
Copy link

Nradko commented Aug 14, 2023

Bug Report

I have found that use.ink and the contracts-ui.substrate.io have problems decoding returned values from contracts containing i16 type.

To reproduce please check: https://github.com/Nradko/i16_issue

Current Behavior

case1

For the storage:

pub struct I16Issue {
    values_i16_tuple: [1,-1],
    values_i16_pair: [1,-1],
}

the returned value for getI16Tuples is:

[
    [
        '-65,535',
        '-1',
    ],
]

the returned value for getI16Pairs is:

[
    {
        value1: '-65,535',
        value2: '-1',
    },
]

case2

For the storage:

pub struct I16Issue {
    values_i16_tuple: [0,0],
    values_i16_pair: [0,0],
}

the returned value for getI16Tuples is:
Decoding error

the returned value for getI16Pairs is:
Decoding error

Expected Behavior

case1

the returned value for getI16Tuples is:

[
    [
        '1,
        '-1',
    ],
]

the returned value for getI16Pairs is:

[
    {
        value1: '1',
        value2: '-1',
    },
]

case2

the returned value for getI16Tuples is:

[
    {
        value1: '0',
        value2: '0',
    },
]

the returned value for getI16Pairs is:

[
    {
        value1: '0',
        value2: '0',
    },
]

Steps To Reproduce

  1. copy this repo
  2. build with cargo contract build
  3. deploy on some testnet using https://contracts-ui.substrate.io. (I have used AZERO testnet)

case1

  1. call pushI16 with args value1: 1, value2: -1
  2. call getI16Tuples to get the wrong Return value.

case2

  1. call pushI16 with args value1: 0, value2: -0
  2. call getI16Pair to get the wrong Return value.

Environment

  • rustc 1.69.0 (84c898d65 2023-04-16)
  • cargo-contract-contract 3.0.1-unknown-x86_64-unknown-linux-gnu
  • Browser: Firefox Browser Developer Edition
  • OS: Linux Mint 21
  • chain: aleph-testnet

Additional Information

https://github.com/Nradko/i16_issue

@peetzweg
Copy link
Collaborator

Fix is WIP in polkadot-js/common#1867

@peetzweg
Copy link
Collaborator

peetzweg commented Sep 6, 2023

The underlying bug for this issue has been resolved and fixed all the way up to @polkadotjs/api. However, a new version of the package is not yet release so we can't upgrade useink to it yet. We will do so as soon as possible.

polkadot-js/api#5702

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants