Skip to content

question: TypeError: Cannot create property 'title' on boolean 'true' #139

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

Closed
dzmitry-lahoda opened this issue Apr 17, 2024 · 6 comments
Closed

Comments

@dzmitry-lahoda
Copy link

dzmitry-lahoda commented Apr 17, 2024

I did not had bug, just got it now (tried old and latest version of generator):

/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/utils/schemas.js:72
                Types[typ].definitions[key].title = key;
                                                  ^

TypeError: Cannot create property 'title' on boolean 'true'
    at findAndParseTypes (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/utils/schemas.js:72:51)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async TypesPlugin.doRender (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/plugins/types.js:46:26)
    at async TypesPlugin.render (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/plugins/plugin-base.js:56:25)
    at async TSBuilder.render (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/builder/builder.js:114:25)
    at async TSBuilder.process (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/builder/builder.js:109:13)
    at async TSBuilder.build (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/builder/builder.js:97:9)
    at async exports.default (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/index.js:40:5)
    at async exports.default [as generate] (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/commands/generate.js:165:5)
    at async cli (/home/dz/github.com/ComposableFi/composable-vm/contracts/cosmwasm/node_modules/@cosmwasm/ts-codegen/cli.js:18:9)

Node.js v20.11.1

I updated version of CW from 1.2.X to 1.5.X. Also added some more msgs into contract.

@dzmitry-lahoda
Copy link
Author

@dzmitry-lahoda
Copy link
Author

found root cause

#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(
    all(
        feature = "json-schema", // all(feature = "json-schema", not(target_arch = "wasm32")),
        not(feature = "xcm")
    ),
    derive(schemars::JsonSchema)
)]
pub enum ForeignAssetId {
    IbcIcs20(PrefixedDenom),

    // `xcm::VersionedMultiLocation` not validated, until XCM supports std wasm or CW no_std (or copy paste)
    Xcm(serde_cw_value::Value),
}

so it cannot type object with type JSON (in rust it is serde_cw_value::Value)

@dzmitry-lahoda
Copy link
Author

replaced with binary for now (XCM serde is SCALE).

observation that python model generator from schema fails on same JSON schema.

either shemars are buggy, or serde_cw_value gives buggy schema, or ts/py generators have bug, or have serde_cw_value as type in schema is useless

@dzmitry-lahoda dzmitry-lahoda changed the title bug: TypeError: Cannot create property 'title' on boolean 'true' question: TypeError: Cannot create property 'title' on boolean 'true' Apr 18, 2024
@pyramation
Copy link
Collaborator

so does it work now? sounds like a Rust issue?

Can you provide a schema?

@dzmitry-lahoda
Copy link
Author

so does it work now? sounds like a Rust issue?

@pyramation I does not look like exactly Rust issue. Let me explain.

I have cosmwasm contract with kind of valid JSON schema. I generate json file with schema out of it.

But ts generator fails to generate typescript code.

As soon as it can be agreed that JSON schema here is valid https://github.com/ComposableFi/composable-vm/blob/c38dd934eff95f5ca73faa5e1a77bd785a6f1562/schema/cvm-runtime.json#L950 , ts gen should not fail.

@dzmitry-lahoda
Copy link
Author

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

No branches or pull requests

2 participants