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

Fix: map bindings for nested maps #1213

Merged
merged 12 commits into from
Sep 6, 2022
Merged

Fix: map bindings for nested maps #1213

merged 12 commits into from
Sep 6, 2022

Conversation

krisbitney
Copy link
Contributor

@krisbitney krisbitney commented Sep 6, 2022

The map bindings for nested maps were incorrectly trying to access map values within the value field of the ABI. However, the bindings are written to access the map property. The map property exists at the same level of the object hierarchy as the value property, not within it.

This PR also fixes map key bindings for nested maps in assemblyscript (rust is already working correctly).

These fixes are tested by an update to the map-type wrapper test case.

Example ABI for nested generic map as return value from "simplePrice" method:

{
  "name": "simplePrice",
  "return": {
    "type": "Map<String, Map<String, BigNumber>>",
    "name": "simplePrice",
    "map": {
      "type": "Map<String, Map<String, BigNumber>>",
      "map": {
        "type": "Map<String, BigNumber>",
        "name": "simplePrice",
        "key": {
          "name": "simplePrice",
          "type": "String",
          "required": true,
          "kind": 4
        },
        "value": {
          "name": "simplePrice",
          "type": "BigNumber",
          "kind": 4
        },
        "required": true,
        "scalar": {
          "name": "simplePrice",
          "type": "BigNumber",
          "kind": 4
        },
        "kind": 262146
      },
      "kind": 262146,
      "name": "simplePrice",
      "key": {
        "name": "simplePrice",
        "type": "String",
        "required": true,
        "kind": 4
      },
      "value": {
        "type": "Map<String, BigNumber>",
        "name": "simplePrice",
        "key": {
          "name": "simplePrice",
          "type": "String",
          "required": true,
          "kind": 4
        },
        "value": {
          "name": "simplePrice",
          "type": "BigNumber",
          "kind": 4
        },
        "required": true,
        "scalar": {
          "name": "simplePrice",
          "type": "BigNumber",
          "kind": 4
        },
        "kind": 262146
      },
      "required": true
    },
    "required": true,
    "kind": 34
  },
  ...
}

@krisbitney krisbitney marked this pull request as draft September 6, 2022 06:05
@krisbitney krisbitney marked this pull request as ready for review September 6, 2022 06:15
@krisbitney krisbitney marked this pull request as draft September 6, 2022 06:24
@krisbitney krisbitney marked this pull request as ready for review September 6, 2022 07:02
@krisbitney krisbitney changed the title Fix: map bindings for nested maps when imported, in envs, or in arrays Fix: map bindings for nested maps Sep 6, 2022
dOrgJelli
dOrgJelli previously approved these changes Sep 6, 2022
@dOrgJelli dOrgJelli merged commit 4c14b66 into origin-dev Sep 6, 2022
@dOrgJelli dOrgJelli deleted the fix-map-binding branch April 10, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants