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

Token underscore and casing mismatch #105

Open
NoahSaso opened this issue Apr 29, 2023 · 0 comments
Open

Token underscore and casing mismatch #105

NoahSaso opened this issue Apr 29, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@NoahSaso
Copy link
Collaborator

The issue seems to be that ts-codegen looks for ResultOfArrayOfBinaryOrErrorResponse when the name is Result_of_Array_of_Binary_or_ErrorResponse. When I replaced all occurrences of Result_of_Array_of_Binary_or_ErrorResponse with ResultOfArrayOfBinaryOrErrorResponse, it worked perfectly.

Log

$ npx @cosmwasm/ts-codegen@latest generate --schema ./schema/raw --out ./ts --name polytone-listener

? [plugin] which plugins? client, recoil
? [bundle] enable bundle? No
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

MissingPointerError: Token "ResultOfArrayOfBinaryOrErrorResponse" does not exist.
    at Pointer.resolve (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/pointer.js:89:13)
    at $Ref.resolve (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/ref.js:115:20)
    at $Refs._resolve (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/refs.js:156:15)
    at dereference$Ref (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:125:23)
    at crawl (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:72:26)
    at crawl (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:84:28)
    at crawl (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:84:28)
    at crawl (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:84:28)
    at dereference$Ref (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:145:24)
    at crawl (/Users/noah/.npm/_npx/ec1f3a70f0367caf/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:72:26) {
  code: 'EMISSINGPOINTER',
  source: '/Users/noah/Developer/cosmos/daodao/polytone/contracts/accessories/listener/',
  path: null,
  toJSON: [Function: toJSON],
  [Symbol(nodejs.util.inspect.custom)]: [Function: inspect]
}

Schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "ExecuteMsg",
  "oneOf": [
    {
      "description": "Stores the callback in state and makes it queryable.",
      "type": "object",
      "required": [
        "callback"
      ],
      "properties": {
        "callback": {
          "$ref": "#/definitions/CallbackMessage"
        }
      },
      "additionalProperties": false
    }
  ],
  "definitions": {
    "Addr": {
      "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
      "type": "string"
    },
    "Attribute": {
      "description": "An key value pair that is used in the context of event attributes in logs",
      "type": "object",
      "required": [
        "key",
        "value"
      ],
      "properties": {
        "key": {
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      }
    },
    "Binary": {
      "description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>. See also <https://github.com/CosmWasm/cosmwasm/blob/main/docs/MESSAGE_TYPES.md>.",
      "type": "string"
    },
    "Callback": {
      "oneOf": [
        {
          "description": "Result of executing the requested query, or an error.\n\nresult[i] corresponds to the i'th query and contains the base64 encoded query response.",
          "type": "object",
          "required": [
            "query"
          ],
          "properties": {
            "query": {
              "$ref": "#/definitions/Result_of_Array_of_Binary_or_ErrorResponse"
            }
          },
          "additionalProperties": false
        },
        {
          "description": "Result of executing the requested messages, or an error.\n\n14/04/23: if a submessage errors the reply handler can see `codespace: wasm, code: 5`, but not the actual error. as a result, we can't return good errors for Execution and this error string will only tell you the error's codespace. for example, an out-of-gas error is code 11 and looks like `codespace: sdk, code: 11`.",
          "type": "object",
          "required": [
            "execute"
          ],
          "properties": {
            "execute": {
              "$ref": "#/definitions/Result_of_ExecutionResponse_or_String"
            }
          },
          "additionalProperties": false
        },
        {
          "description": "An error occured that could not be recovered from. The only known way that this can occur is message handling running out of gas, in which case the error will be `codespace: sdk, code: 11`.\n\nThis error is not named becuase it could also occur due to a panic or unhandled error during message processing. We don't expect this to happen and have carefully written the code to avoid it.",
          "type": "object",
          "required": [
            "fatal_error"
          ],
          "properties": {
            "fatal_error": {
              "type": "string"
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "CallbackMessage": {
      "description": "Executed on the callback receiver upon message completion. When being executed, the message will be tagged with \"callback\":\n\n```json {\"callback\": { \"initiator\": ..., \"initiator_msg\": ..., \"result\": ..., }} ```",
      "type": "object",
      "required": [
        "initiator",
        "initiator_msg",
        "result"
      ],
      "properties": {
        "initiator": {
          "description": "Initaitor on the note chain.",
          "allOf": [
            {
              "$ref": "#/definitions/Addr"
            }
          ]
        },
        "initiator_msg": {
          "description": "Message sent by the initaitor. This _must_ be base64 encoded or execution will fail.",
          "allOf": [
            {
              "$ref": "#/definitions/Binary"
            }
          ]
        },
        "result": {
          "description": "Data from the host chain.",
          "allOf": [
            {
              "$ref": "#/definitions/Callback"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "ErrorResponse": {
      "type": "object",
      "required": [
        "error",
        "message_index"
      ],
      "properties": {
        "error": {
          "description": "The error that occured executing the message.",
          "type": "string"
        },
        "message_index": {
          "description": "The index of the first message who's execution failed.",
          "allOf": [
            {
              "$ref": "#/definitions/Uint64"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "Event": {
      "description": "A full [*Cosmos SDK* event].\n\nThis version uses string attributes (similar to [*Cosmos SDK* StringEvent]), which then get magically converted to bytes for Tendermint somewhere between the Rust-Go interface, JSON deserialization and the `NewEvent` call in Cosmos SDK.\n\n[*Cosmos SDK* event]: https://docs.cosmos.network/main/core/events.html [*Cosmos SDK* StringEvent]: https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/base/abci/v1beta1/abci.proto#L56-L70",
      "type": "object",
      "required": [
        "attributes",
        "type"
      ],
      "properties": {
        "attributes": {
          "description": "The attributes to be included in the event.\n\nYou can learn more about these from [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/main/core/events.html",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Attribute"
          }
        },
        "type": {
          "description": "The event type. This is renamed to \"ty\" because \"type\" is reserved in Rust. This sucks, we know.",
          "type": "string"
        }
      }
    },
    "ExecutionResponse": {
      "type": "object",
      "required": [
        "executed_by",
        "result"
      ],
      "properties": {
        "executed_by": {
          "description": "The address on the remote chain that executed the messages.",
          "type": "string"
        },
        "result": {
          "description": "Index `i` corresponds to the result of executing the `i`th message.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/SubMsgResponse"
          }
        }
      },
      "additionalProperties": false
    },
    "Result_of_Array_of_Binary_or_ErrorResponse": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "Ok"
          ],
          "properties": {
            "Ok": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Binary"
              }
            }
          }
        },
        {
          "type": "object",
          "required": [
            "Err"
          ],
          "properties": {
            "Err": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      ]
    },
    "Result_of_ExecutionResponse_or_String": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "Ok"
          ],
          "properties": {
            "Ok": {
              "$ref": "#/definitions/ExecutionResponse"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "Err"
          ],
          "properties": {
            "Err": {
              "type": "string"
            }
          }
        }
      ]
    },
    "SubMsgResponse": {
      "description": "The information we get back from a successful sub message execution, with full Cosmos SDK events.",
      "type": "object",
      "required": [
        "events"
      ],
      "properties": {
        "data": {
          "anyOf": [
            {
              "$ref": "#/definitions/Binary"
            },
            {
              "type": "null"
            }
          ]
        },
        "events": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Event"
          }
        }
      }
    },
    "Uint64": {
      "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```",
      "type": "string"
    }
  }
}
@NoahSaso NoahSaso added the bug Something isn't working label Apr 29, 2023
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
None yet
Development

No branches or pull requests

1 participant