hyperweb-io / hyperweb-io/ts-codegen

Token underscore and casing mismatch

Aperta
#105 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
TypeScript
Stelle
126
Fork
31
Merge medio
19m
PR unite (30g)
2

Descrizione

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
```bash
$ 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
```json
{
"$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 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. See also .",
"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"
}
}
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start by reproducing the `npx @cosmwasm/ts-codegen@latest generate` command against the provided schema and trace how `$ref` tokens are resolved. Check handling of the `Result_of_Array_of_Binary_or_ErrorResponse` definition and verify generation succeeds without manually renaming the schema definition.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
tooling
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.