Skip to content

Contract schema tuple variants handling #236

Open
@MissingNO57

Description

@MissingNO57

_extract_msgs can't handle tuple variants and returns
'upload_logo' = {dict: 0} {}

Most of the contracts are using named fields

pub enum ExecuteMsg {
   UpdateMinter { new_minter: Option<String> },
}

This would be called like

{"update_minter" : {"new_minter": "something"}}

But for example cw20-base contract uses tuple variants that have no name:

pub enum ExecuteMsg {
    UploadLogo(Logo),
}

pub enum Logo {
    /// A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL.
    Url(String),
    /// Logo content stored on the blockchain. Enforce maximum size of 5KB on all variants
    Embedded(EmbeddedLogo),
}

In the case of tuple variant execution message would look like this:

  "upload_logo": {
    "url": "https://example.com/logo.png"
  }
}

This is named fields schema

...
 'properties' = {dict: 1} {'send': {'additionalProperties': False, 'properties': {'amount': {'$ref': '#/definitions/Uint128'}, 'contract': {'type': 'string'}, 'msg': {'$ref': '#/definitions/Binary'}}, 'required': ['amount', 'contract', 'msg'], 'type': 'object'}}
  'send' = {dict: 4} {'additionalProperties': False, 'properties': {'amount': {'$ref': '#/definitions/Uint128'}, 'contract': {'type': 'string'}, 'msg': {'$ref': '#/definitions/Binary'}}, 'required': ['amount', 'contract', 'msg'], 'type': 'object'}
...

This is a tuple variant schema:

...
 'properties' = {dict: 1} {'upload_logo': {'$ref': '#/definitions/Logo'}}
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions