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

Support for cargo-contract 2.x #105

Closed kziemianek closed 1 year ago

kziemianek commented 1 year ago

Overview

New release of cargo-contract introduced at least one breaking change that breaks swanky-cli metadata.json is renamed to {contract_name}.json

and swanky tries to copy metadata.json

      fs.copyFile(
        path.resolve(contractPath, "target", "ink", "metadata.json"),
        path.resolve(ARTIFACTS_PATH, `${contractName}.json`),
      )

This problem occurs for projects migrating from ink 3.x to 4.x Both ink 4 and cargo-contract 2 were released yesterday.

Additionally templates point to ink 3.x so smart contracts doesn't compile for new users who might have cargo-contract 2 installed by default.

I think tool should switch to new versions of ink and cargo-contract and somehow support older. At least README should explicitly say which cargo-contract version is required (1.x) or force check it to not make new users upset

kziemianek commented 1 year ago

It turns out that there are also problems with ts types generation

npx typechain-polkadot --in ./artifacts --out ./typedContract
node_modules/@supercolony/typechain-polkadot/src/utils/abi.ts:13
    for (const method of abiJson.V3.spec.messages) {
                                 ^
TypeError: Cannot read properties of undefined (reading 'spec')