inkdevhub / swanky-cli

The all-in-one developer environment for Parity pallet-contracts based smart contracts!
https://docs.astar.network/docs/build/wasm/swanky-suite/cli/
MIT License
70 stars 29 forks source link

[BUG] Generating contract ts types throws an error when compiling contracts with the `--all` flag #200

Open ipapandinas opened 8 months ago

ipapandinas commented 8 months ago

Description

Contracts compilation using the --all flag throws an error after adding a new contract to my project with the contract new command. Using the --all flag with a single flipper contract after project init works fine as expected.

Steps to Reproduce

  1. swanky init test
  2. cd test
  3. swanky contract compile --all works - flipper contract's TS types Generated successfully
  4. swanky contract new hello --template flipper
  5. swanky contract compile --all throws the described error below

Expected vs. Actual Behavior

Expected: Compile both contracts flipper and hello successfully with TS types generated. Actual Behavior: Unable to compile any contracts.

Environment

Logs, Errors or Screenshots

swanky contract compile --all

The contract was built in DEBUG mode.

Your contract artifacts are ready. You can find them in: /test/target/ink/flipper

  - flipper.contract (code + metadata)
  - flipper.wasm (the contract's code)
  - flipper.json (the contract's metadata)
✔ flipper Contract compiled successfully
✔ Moving artifacts OK
✖ Error Generating flipper contract ts types
error:   ProcessError: Command failed with exit code 1: npx typechain-polkadot --in artifacts/flipper --out typedContracts/flipper
@polkadot/util has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 12.6.2  node_modules/@polkadot/util/cjs
    cjs 11.1.3  node_modules/@727-ventures/typechain-polkadot/node_modules/@polkadot/util/cjs
node_modules/@727-ventures/typechain-polkadot/src/utils/handlebars-helpers.ts:46
        throw new Error(`Unable to locate ${template}.hbs from ${rootDir}`);
        ^
Error: Unable to locate types-arguments.hbs from node_modules/@727-ventures/typechain-polkadot/src/utils/../templates
    at readTemplate (node_modules/@727-ventures/typechain-polkadot/src/utils/handlebars-helpers.ts:46:9)
    at Object.<anonymous> (node_modules/@727-ventures/typechain-polkadot/src/generators/types-arguments.ts:31:64)
    at Module.m._compile (node_modules/ts-node/src/index.ts:1618:23)
    at Object.require.extensions.<computed> [as .ts] (node_modules/ts-node/src/index.ts:1621:12)
Error Generating flipper contract ts types
    at makeError (file:///opt/homebrew/lib/node_modules/@astar-network/swanky-cli/node_modules/execa/lib/error.js:60:11)
    at handlePromise (file:///opt/homebrew/lib/node_modules/@astar-network/swanky-cli/node_modules/execa/index.js:124:26)
    at async generateTypes (file:///opt/homebrew/lib/node_modules/@astar-network/swanky-cli/dist/lib/command-utils.js:101:5)
    at async file:///opt/homebrew/lib/node_modules/@astar-network/swanky-cli/dist/commands/contract/compile.js:71:50
    at async Spinner.runCommand (file:///opt/homebrew/lib/node_modules/@astar-network/swanky-cli/dist/lib/spinner.js:29:25)
    at async CompileContract.run (file:///opt/homebrew/lib/node_modules/@astar-network/swanky-cli/dist/commands/contract/compile.js:71:13)
    at async CompileContract._run (/opt/homebrew/lib/node_modules/@astar-network/swanky-cli/node_modules/@oclif/core/lib/command.js:117:22)
    at async Config.runCommand (/opt/homebrew/lib/node_modules/@astar-network/swanky-cli/node_modules/@oclif/core/lib/config/config.js:329:25)
    at async run (/opt/homebrew/lib/node_modules/@astar-network/swanky-cli/node_modules/@oclif/core/lib/main.js:89:16)

Additional context

This error should be related to the package versions conflict. Upgrading @727-ventures/typechain-polkadot should fix this issue.