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

Adjusting command for `swanky contract compile` #156

Closed chunteng-web3 closed 1 year ago

chunteng-web3 commented 1 year ago

As I intrusively debug, the command used at #L137 of swanky-cli/packages/core/src/lib/command-utils.ts might be outdated.

The command used:

await execa.command(`npx typechain-polkadot --in ${TEMP_ARTIFACTS_PATH} --out ${TEMP_TYPED_CONTRACT_PATH}`);

but the correct command on Brushfam/typechain-polkadot is

npx @727-ventures/typechain-polkadot --in artifacts --out typed_contracts

Note: The only modification from me was made in 962fa24eebfa0b193bab54e491e5bc18584f2f46 while ad6de1bf494fcd198e9d8cfdf75990514842f098 was automatically generated by npx lerna publish --no-private

Please adjust as you wish.

With the modification, the ts gen seems running properly.

I called swanky contract compile CONTRACT_NAME this way:

../swanky-cli-fork/swanky-cli/packages/cli/bin/run contract compile aave_oracle -v

Image

codespool commented 1 year ago

On a closer look, I don't think this actually makes a difference: if you look under node_modules/.bin, you'll find typechain-polkadot and typechain-compiler executables, regardless of the prefix. npx will first look there. Did changing this in code make any difference for you?

chunteng-web3 commented 1 year ago

On a closer look, I don't think this actually makes a difference: if you look under node_modules/.bin, you'll find typechain-polkadot and typechain-compiler executables, regardless of the prefix. npx will first look there. Did changing this in code make any difference for you?

Yes it did as the command compiles contracts properly now while the latest release version (2.1.2) would not compile contracts on my laptop yesterday, and that's why I went to this fix.

However, as I tried with my desktop today, 2.1.2 is compiling properly now. Maybe anything relevant to caches?

codespool commented 1 year ago

Most probably. I believe what happened was, when you ran the npx command with the @727-ventures prefix, it just downloaded the newer 1.0.0-beta version. I was just testing it with a project, and it wouldn't compile until I:

Can you confirm you're able to do the same, without the changes in this PR?

(make sure to use:

"@727-ventures/typechain-polkadot": "1.0.0-beta.2",
"@727-ventures/typechain-types": "^1.0.0-beta.1", 
chunteng-web3 commented 1 year ago

Most probably. I believe what happened was, when you ran the npx command with the @727-ventures prefix, it just downloaded the newer 1.0.0-beta version. I was just testing it with a project, and it wouldn't compile until I:

  • deleted node_modules, and yarn.lock,
  • remove all direct dependencies to @polkadot/* packages
  • remove the resolutions field from package.json
  • reinstalled deps with yarn
  • ran the swanky compile again.

Can you confirm you're able to do the same, without the changes in this PR?

(make sure to use:

"@727-ventures/typechain-polkadot": "1.0.0-beta.2",
"@727-ventures/typechain-types": "^1.0.0-beta.1", 

Sure!

so this is my current package.json:

{
  "name": "aave-v2",
  "version": "1.0.0",
  "author": "chunteng-web3 <chunteng@astriddao.xyz>",
  "license": "MIT",
  "scripts": {
    "run-node": "swanky node start",
    "test": "mocha -r ts-node/register \"test/**/*.test.ts\" --exit --timeout 20000"
  },
  "engines": {
    "node": ">=18.0.0"
  },
  "dependencies": {
    "@727-ventures/typechain-polkadot": "1.0.0-beta.2",
    "@727-ventures/typechain-types": "^1.0.0-beta.1",
    "typescript": "^4.9.3"
  },
  "devDependencies": {
    "@types/chai": "^4.3.0",
    "@types/chai-as-promised": "^7.1.5",
    "@types/mocha": "^8.0.3",
    "chai": "^4.3.6",
    "chai-as-promised": "^7.1.1",
    "mocha": "10.1.0",
    "mochawesome": "^7.1.3",
    "ts-node": "^10.8.0",
    "ethereum-waffle": "3.0.2",
    "ethereumjs-util": "7.0.2",
    "bignumber.js": "^9.1.1",
    "lowdb": "1.0.0",
    "@types/lowdb": "1.0.9",
    "ethers": "^5.0.19"
  }
}

And it failed.

image

chunteng-web3 commented 1 year ago

I did the same thing again with 2.1.2, and it's passing.

image

codespool commented 1 year ago

oh, but that's ok - version 2.1.2 has a fix for that - what I meant, it works without the changes in this PR?

chunteng-web3 commented 1 year ago

oh, but that's ok - version 2.1.2 has a fix for that - what I meant, it works without the changes in this PR?

Yes it does as I was not using my local version of it.

codespool commented 1 year ago

Ok, in that case I'll close the pr 👍