Open 0xekez opened 1 year ago
I also encountered this issue when generating schemas using the write_api
macro from cosmwasm_schema@1.2.0
.
write_api
seems to be generating a raw/
folder in schemas/
, and I was able to fix this by simply removing the folder manually.
What is the fix? Will it be handled by codegen, or should we build a script that removes the /raw
folder before using codegen?
I think it would be best to find a way to ignore the folder rather than removing it, as it may be useful for other applications.
I agree with @josefleventon
here's @Art3miX 's commit which updates schema generation to get around this bug: https://github.com/DA0-DA0/dao-contracts/pull/623/commits/39799dbf662302f532a12c4a2934f279b197a9fe#diff-248642ca59916d7dc7325c572244a549ffc6159c2b521f0ae2db2272d4b6fd9d
You can use this patch with patch-package module
diff --git a/node_modules/@cosmwasm/ts-codegen/main/utils/schemas.js b/node_modules/@cosmwasm/ts-codegen/main/utils/schemas.js
index 2d75272..f91933e 100644
--- a/node_modules/@cosmwasm/ts-codegen/main/utils/schemas.js
+++ b/node_modules/@cosmwasm/ts-codegen/main/utils/schemas.js
@@ -43,7 +43,7 @@ var readSchemas = /*#__PURE__*/function () {
fn = clean ? _cleanse.cleanse : function (str) {
return str;
};
- files = (0, _glob.sync)(schemaDir + '/**/*.json');
+ files = (0, _glob.sync)(schemaDir + '/*.json');
schemas = files.map(function (file) {
return JSON.parse((0, _fs.readFileSync)(file, 'utf-8'));
});
when generating the code for this spec, ts-codegen errors.
the specific type that this seems to be referring to is this one. ~this makes me suspect that the issue may be related to the build environment, and not this particular schema as that type does not seem to appear in this schema.~ update: @shanev has also seen this same error in the stargaze code.
to reproduce, one may install just
cargo install just
, and runjust gen
on this branch.