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

Schema deserializes map nat-nat as MichelsonMap<string, BigNumber> instead of MichelsonMap<BigNumber, BigNumber> #1140

Closed
psmolinsky opened this issue Oct 28, 2021 · 0 comments · Fixed by #1299
Assignees
Labels
bug Something isn't working
Milestone

Comments

@psmolinsky
Copy link

Description

The class Schema deserializes Michelson corresponding to a map with nat key and nat value as Michelson<string, BigNumber>. However, nat is usually deserialized to BigNumber so it should be Michelson<BigNumber, BigNumber>.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Run this code:
import { Schema } from '@taquito/michelson-encoder';

const schema = new Schema({
    prim: 'map',
    args: [
        { prim: 'nat' },
        { prim: 'nat' },
    ],
});
const michelson = [{
    prim: 'Elt',
    args: [
        { int: '0' },
        { int: '1000000000000' }
    ]
}];

const value = schema.Execute(michelson);
const entry = Array.from(value.entries())[0];

console.log('Entry:', entry);
console.log('Key type:', typeof entry[0]);
  1. It output on console:
Entry: [ '123', BigNumber { s: 1, e: 2, c: [ 456 ] } ]
Key type: string

Expected behavior

It should output:

Entry: [ BigNumber { s: 1, e: 2, c: [ 123 ] }, BigNumber { s: 1, e: 2, c: [ 456 ] } ]
Key type: object
@psmolinsky psmolinsky added the bug Something isn't working label Oct 28, 2021
@roxaneletourneau roxaneletourneau added this to the v11.1 milestone Nov 4, 2021
@roxaneletourneau roxaneletourneau modified the milestones: v11.1, v11.2 Dec 8, 2021
@dsawali dsawali self-assigned this Dec 15, 2021
@dsawali dsawali removed their assignment Dec 17, 2021
@roxaneletourneau roxaneletourneau self-assigned this Jan 10, 2022
roxaneletourneau added a commit that referenced this issue Jan 10, 2022
Fixed a bug where decoding MichelsonMap keys of type nat would return a string instead of a
BigNumber.

fix #1140
@ac10n ac10n moved this to Done in Taquito Dev Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants