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

ExtractSchema() does not consider or type #1303

Closed
psmolinsky opened this issue Jan 11, 2022 · 1 comment
Closed

ExtractSchema() does not consider or type #1303

psmolinsky opened this issue Jan 11, 2022 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@psmolinsky
Copy link

Description
Schema.ExtractSchema() method consider the or type to be as same as the pair type. This make them indistinguishable.

Steps To Reproduce

  1. Create a Schema with Michelson containing the or type and call the method.
const schema = new Schema({
    prim: 'or',
    args: [
        { prim: 'string' },
        { prim: 'nat' },
    ],
});

const extracted = schema.ExtractSchema();
  1. Returned value in extracted variable is:
{
    '0': 'string',
    '1': 'nat',
}
  1. Do the same with similar schema using the pair type:
const schema = new Schema({
    prim: 'pair',
    args: [
        { prim: 'string' },
        { prim: 'nat' },
    ],
});

const extracted = schema.ExtractSchema();
  1. It returns the same result:
{
    '0': 'string',
    '1': 'nat',
}

Expected behavior

The or type should be expressed in the extracted schema. For example:

{
    or: [
        'string',
        'nat',
    ],
}
@psmolinsky
Copy link
Author

One more remarks: What if the schema is ambiguous? Even without annotations. Please consider it...

const fooSchema = {
    prim: 'or',
    args: [
        { prim: 'int', annots: ['%add'] },
        { prim: 'int', annots: ['%remove'] },
    ],
}

@roxaneletourneau roxaneletourneau self-assigned this Jan 14, 2022
@roxaneletourneau roxaneletourneau added this to the v11.2 milestone Jan 14, 2022
roxaneletourneau added a commit that referenced this issue Jan 14, 2022
ExtractSchema is missing some important details (i.e. there is no distinction between "or" and
"pair" types, "option" type is not marked as optional). A new method called "generateSchema" has
been implemented and is intended to replace the "ExtractSchema" method. "generateSchema" provides a
more accurate and uniform schema representation.

BREAKING CHANGE: The schema representation is different between ExtractSchema and generateSchema
method. ExtractSchema will be marked as deprecated and the migration to generateSchema will incur
breaking change.

re #1252, re #1303, re #1304
roxaneletourneau added a commit that referenced this issue Jan 21, 2022
ExtractSchema is missing some important details (i.e. there is no distinction between "or" and
"pair" types, "option" type is not marked as optional). A new method called "generateSchema" has
been implemented and is intended to replace the "ExtractSchema" method. "generateSchema" provides a
more accurate and uniform schema representation.

BREAKING CHANGE: The schema representation is different between ExtractSchema and generateSchema
method. ExtractSchema will be marked as deprecated and the migration to generateSchema will incur
breaking change.

re #1252, re #1303, re #1304
@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

No branches or pull requests

2 participants