Concordium / concordium-node-sdk-js

TypeScript SDK for using the Concordium blockchain
http://developer.concordium.software/concordium-node-sdk-js/
Apache License 2.0
20 stars 16 forks source link

build dependent on module path #316

Closed parv0888 closed 9 months ago

parv0888 commented 10 months ago

Bug Description The generator uses https://github.com/Concordium/concordium-node-sdk-js/blob/eac464b8cdad81f1e189c87a6b4cb406f7eac79e/packages/ccd-js-gen/src/lib.ts#L62 hardcoded path extension which is .wasm.v1 which is okay for the default output file but causes issues with any other extension which the user might choose to generate.

Steps to Reproduce cargo concordium build --out ./module.wasm and use this wasm module file with ccd-js-gen cli npx ccd-js-gen --module ./module.wasm --out-dir ../generated

Expected Result should generate without any errors

Actual Result

/home/parv0888/work/work/concordium/concordium-rwa/node_modules/@ts-morph/common/dist/ts-morph-common.js:438
            throw new InvalidOperationError(typeof errorMessage === "string" ? errorMessage : errorMessage(), node);
                  ^

InvalidOperationError: A child syntax list was expected.

/home/parv0888/work/work/concordium/concordium-rwa/backend/generated/module.wasm.ts:7:1
> 7 | class Module.wasmModule {
    at Object.throwIfNullOrUndefined (/home/parv0888/work/work/concordium/concordium-rwa/node_modules/@ts-morph/common/dist/ts-morph-common.js:438:19)
    at ClassDeclaration.getChildSyntaxListOrThrow (/home/parv0888/work/work/concordium/concordium-rwa/node_modules/ts-morph/dist/ts-morph.js:3195:30)
    at insertIntoBracesOrSourceFileWithGetChildren (/home/parv0888/work/work/concordium/concordium-rwa/node_modules/ts-morph/dist/ts-morph.js:2514:42)
    at insertChildren (/home/parv0888/work/work/concordium/concordium-rwa/node_modules/ts-morph/dist/ts-morph.js:14477:12)
    at ClassDeclaration.insertConstructors (/home/parv0888/work/work/concordium/concordium-rwa/node_modules/ts-morph/dist/ts-morph.js:14103:20)
    at ClassDeclaration.insertConstructor (/home/parv0888/work/work/concordium/concordium-rwa/node_modules/ts-morph/dist/ts-morph.js:14099:25)
    at ClassDeclaration.addConstructor (/home/parv0888/work/work/concordium/concordium-rwa/node_modules/ts-morph/dist/ts-morph.js:14093:25)
    at generateModuleBaseCode (file:///home/parv0888/work/work/concordium/concordium-rwa/node_modules/@concordium/ccd-js-gen/lib/src/lib.js:167:10)
    at generateCode (file:///home/parv0888/work/work/concordium/concordium-rwa/node_modules/@concordium/ccd-js-gen/lib/src/lib.js:83:5)
    at async generateContractClients (file:///home/parv0888/work/work/concordium/concordium-rwa/node_modules/@concordium/ccd-js-gen/lib/src/lib.js:39:5)

Versions cargo concordium 3.1.4 ccd-js-gen ^1.0.1

limemloh commented 10 months ago

Thank you for reporting this. I agree that this is something that should be fixed, since the user might use another file extension.

I do want to remark that the tool cannot use arbitrary web assembly files and only supports concordium smart contract modules, which includes more information than just the web assembly. In other words, the tool does not work with files that are supposed to have the .wasm extension.