titan-suite / cli

CLI for Titan Suite
https://titan-suite.com
Apache License 2.0
14 stars 1 forks source link

Unable to compile any contracts #8

Closed maxsam4 closed 6 years ago

maxsam4 commented 6 years ago

OS : Ubuntu 18.04 LTS

Node : v8.10.0

Npm : 3.5.2

$ npm list -g --depth 0 /usr/local/lib +-- @angular/cli@6.2.1 +-- @titan-suite/cli@0.1.7 +-- remixd@0.1.8-alpha.5 `-- truffle@4.1.14

Commands run ./aion.sh

titan init

titan unpack

titan compile -d path/to/contracts/Example.sol

Error

$ titan compile -d contracts/Example.sol (node:23938) Error Plugin: @titan-suite/cli: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/package.json module: @oclif/config@1.7.6 plugin: @titan-suite/cli root: /usr/local/lib/node_modules/@titan-suite/cli See more details with DEBUG= (node:23938) Error Plugin: @oclif/plugin-help: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/package.json module: @oclif/config@1.7.6 plugin: @oclif/plugin-help root: /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help See more details with DEBUG=

Error with debug

$ DEBUG= titan compile -d contracts/Example.sol @oclif/config reading core plugin /usr/local/lib/node_modules/@titan-suite/cli +0ms @oclif/config loadJSON /usr/local/lib/node_modules/@titan-suite/cli/package.json +0ms @oclif/config loadJSON /usr/local/lib/node_modules/@titan-suite/cli/oclif.manifest.json +2ms (node:24495) Error Plugin: @titan-suite/cli: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/package.json module: @oclif/config@1.7.6 plugin: @titan-suite/cli root: /usr/local/lib/node_modules/@titan-suite/cli See more details with DEBUG= Error Plugin: @titan-suite/cli: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/package.json at Plugin.warn (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/config/lib/plugin.js:173:19) at Plugin.load (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/config/lib/plugin.js:35:18) at module: @oclif/config@1.7.6 plugin: @titan-suite/cli root: /usr/local/lib/node_modules/@titan-suite/cli See more details with DEBUG= @oclif/config loadJSON /usr/local/lib/node_modules/@titan-suite/cli/.oclif.manifest.json +2ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +1ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +20ms @oclif/config:@titan-suite/cli loading IDs from /usr/local/lib/node_modules/@titan-suite/cli/lib/commands +0ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config:@titan-suite/cli found commands [ 'compile', 'console', 'deploy', 'init', 'lint', 'test', 'unlock', 'unpack' ] +8ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +10ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/compile.js +2ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +201ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/console.js +201ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +4ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/deploy.js +5ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +166ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +1ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/init.js +167ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +2ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/lint.js +1ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +1ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/test.js +1ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +46ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/unlock.js +47ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +1ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/unpack.js +0ms @oclif/config reading user plugins pjson /home/max/.local/share/@titan-suite/cli/package.json +0ms @oclif/config loadJSON /home/max/.local/share/@titan-suite/cli/package.json +8ms @oclif/config loading plugins [ '@oclif/plugin-help' ] +20ms @oclif/config reading core plugin /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help +0ms @oclif/config loadJSON /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/package.json +20ms @oclif/config loadJSON /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/oclif.manifest.json +2ms (node:24495) Error Plugin: @oclif/plugin-help: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/package.json module: @oclif/config@1.7.6 plugin: @oclif/plugin-help root: /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help See more details with DEBUG= Error Plugin: @oclif/plugin-help: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/package.json at Plugin.warn (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/config/lib/plugin.js:173:19) at Plugin.load (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/config/lib/plugin.js:35:18) at module: @oclif/config@1.7.6 plugin: @oclif/plugin-help root: /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help See more details with DEBUG=* @oclif/config:@oclif/plugin-help using manifest from /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/oclif.manifest.json +0ms @oclif/config config done +3ms @oclif/config start init hook +0ms @oclif/config init hook done +1ms titan init version: @oclif/command@1.5.1 argv: [ 'compile', '-d', 'contracts/Example.sol' ] +0ms @oclif/config runCommand compile [ '-d', 'contracts/Example.sol' ] +8ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +11ms @oclif/config loadJSONSync /usr/local/lib/node_modules/@titan-suite/cli/tsconfig.json +0ms @oclif/config:@titan-suite/cli require /usr/local/lib/node_modules/@titan-suite/cli/lib/commands/compile.js +42ms @oclif/config start prerun hook +2ms @oclif/config prerun hook done +0ms titan:compile init version: @oclif/command@1.5.1 argv: [ '-d', 'contracts/Example.sol' ] +0ms

I have tried reinstalling Titan CLI and Aion node but it didn't help.

ToJen commented 6 years ago

Hey, are you passing the correct path

maxsam4 commented 6 years ago

Yes, I am. The only thing different from documentation of aion is that I am on Ubuntu bionic rather than xenial.

ToJen commented 6 years ago

Are you able to deploy the contract?

maxsam4 commented 6 years ago

The contacts didn't compile so I didn't try deploying. Build folder was empty after trying to compile.

Also, iirc, in the default aion config, rpc was disabled. Had to enable it.

maxsam4 commented 6 years ago

Error Plugin: @titan-suite/cli: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/package.json

This seems to be of interest. You might wanna focus on it first.

ToJen commented 6 years ago

The build folder is created only after deploying. I've just tested the command on a fresh install on a new system without getting an error. What version of node and npm are you running?

maxsam4 commented 6 years ago

The build folder is created only after deploying. I've just tested the command on a fresh install on a new system without getting an error. What version of node and npm are you running?

They are mentioned in the opening post. I'll try deploying and a few other things later today, and get back to you.

Meanwhile, why do you need aion node to be running for compilation and why are build files not generated on compilation?

maxsam4 commented 6 years ago

Deploying didn't work either. Here are the logs

aion dApp/titan-default$ titan deploy contracts/Example.sol (node:3689) Error Plugin: @titan-suite/cli: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/package.json module: @oclif/config@1.7.6 plugin: @titan-suite/cli root: /usr/local/lib/node_modules/@titan-suite/cli See more details with DEBUG= (node:3689) Error Plugin: @oclif/plugin-help: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/package.json module: @oclif/config@1.7.6 plugin: @oclif/plugin-help root: /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help See more details with DEBUG= ? Choose a contract to deploy (Use arrow keys) (node:3689) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'value' of undefined at ListPrompt.getCurrentValue (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/inquirer/lib/prompts/list.js:121:53) at MapSubscriber._next (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/rxjs/internal/operators/map.js:49:35) at MapSubscriber.Subscriber.next (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/rxjs/internal/Subscriber.js:68:18) at TakeSubscriber._next (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/rxjs/internal/operators/take.js:54:30) at TakeSubscriber.Subscriber.next (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/rxjs/internal/Subscriber.js:68:18) at Interface.handler (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/rxjs/internal/observable/fromEvent.js:22:28) at emitOne (events.js:121:20) at Interface.emit (events.js:211:7) at Interface._onLine (readline.js:282:10) at Interface._line (readline.js:631:8) (node:3689) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:3689) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

and

aion dApp/titan-default$ titan deploy (node:3717) Error Plugin: @titan-suite/cli: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/package.json module: @oclif/config@1.7.6 plugin: @titan-suite/cli root: /usr/local/lib/node_modules/@titan-suite/cli See more details with DEBUG= (node:3717) Error Plugin: @oclif/plugin-help: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/package.json module: @oclif/config@1.7.6 plugin: @oclif/plugin-help root: /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help See more details with DEBUG= TypeError: Cannot read property 'endsWith' of undefined at contractPath (/usr/local/lib/node_modules/@titan-suite/cli/lib/utils/index.js:34:35) at Object.exports.readContract (/usr/local/lib/node_modules/@titan-suite/cli/lib/utils/index.js:38:47) at Deploy. (/usr/local/lib/node_modules/@titan-suite/cli/lib/commands/deploy.js:74:33) at Generator.next () at /usr/local/lib/node_modules/@titan-suite/cli/node_modules/tslib/tslib.js:107:75 at new Promise () at Object.__awaiter (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/tslib/tslib.js:103:16) at Deploy.run (/usr/local/lib/node_modules/@titan-suite/cli/lib/commands/deploy.js:72:24) at Deploy._run (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/command/lib/command.js:29:31) at

ToJen commented 6 years ago

Can you try updating npm to the latest and try again? You could test this in a docker container if you don't want to modify your global npm package.

maxsam4 commented 6 years ago

Tried using node 10 with nvm but it didn't help. Then, I edited the package.json files that were throwing the error to add the files array as in this repo's package.json. It subdued all the errors but it still didn't compile the contracts. It was like nothing was happening when I tried compiling.

ToJen commented 6 years ago

Meanwhile, why do you need aion node to be running for compilation and why are build files not generated on compilation?

AION uses Solidity version 0.4.9 and a fork of web3@0.20.x which used to compile using web3.eth.compile.solidity instead of solc. They are working on upgrading their library to be compatible with web3v1.0.

ToJen commented 6 years ago

It subdued all the errors but it still didn't compile the contracts. It was like nothing was happening when I tried compiling

This is strange, let's take a different approach. Try cloning this repo, then

Then let me know what happens

maxsam4 commented 6 years ago

Then let me know what happens

Same thing. Compilation does nothing, when I try to deploy, it says select a contract but there is no contract to select from. Error pops up when i press enter

$ ./bin/run compile -d test/contracts/Example.sol 
$ ./bin/run deploy test/contracts/Example.sol 
? Choose a contract to deploy (Use arrow keys)
(node:7384) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'value' of undefined
    at ListPrompt.getCurrentValue (/home/max/aion/cli/node_modules/inquirer/lib/prompts/list.js:121:53)
    at MapSubscriber._next (/home/max/aion/cli/node_modules/rxjs/internal/operators/map.js:49:35)
    at MapSubscriber.Subscriber.next (/home/max/aion/cli/node_modules/rxjs/internal/Subscriber.js:68:18)
    at TakeSubscriber._next (/home/max/aion/cli/node_modules/rxjs/internal/operators/take.js:54:30)
    at TakeSubscriber.Subscriber.next (/home/max/aion/cli/node_modules/rxjs/internal/Subscriber.js:68:18)
    at Interface.handler (/home/max/aion/cli/node_modules/rxjs/internal/observable/fromEvent.js:22:28)
    at Interface.emit (events.js:187:15)
    at Interface.EventEmitter.emit (domain.js:442:20)
    at Interface._onLine (readline.js:290:10)
    at Interface._line (readline.js:638:8)
(node:7384) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7384) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

btw, here is the titanrc file I am using

module.exports = {
    "host": "http://127.0.0.1",
    "port": 8545,
    "defaultAccount": "",
    "password": "PLAT4life"
}

I don't exactly remember where I got it from. I don't even remember setting a password to be honest. I am running a local private node. removing the default password changes nothing.

ToJen commented 6 years ago

What does your contract look like?

maxsam4 commented 6 years ago

https://github.com/titan-suite/cli/blob/master/test/contracts/Example.sol

maxsam4 commented 6 years ago

I ran yarn test and all tests failed

titan$ yarn test
yarn run v1.9.4
$ titan test

  a] Compile and deploy
    1) should compile contract
    2) should deploy contract

  b] Test contract function
    3) should return 10

  0 passing (1s)
  3 failing

  1) a] Compile and deploy
       should compile contract:
     TypeError: Cannot read property 'info' of undefined
      at Context.it (test/testExample.js:28:19)
      at <anonymous>
      at process._tickDomainCallback (internal/process/next_tick.js:228:7)

  2) a] Compile and deploy
       should deploy contract:
     Error: the string "unlock fail" was thrown, throw an Error :)
      at <anonymous>
      at process._tickDomainCallback (internal/process/next_tick.js:228:7)

  3) b] Test contract function
       should return 10:
     TypeError: Cannot read property 'add' of undefined
      at Context.it (test/testExample.js:48:24)

error Command failed with exit code 255.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ToJen commented 6 years ago

Have you been able to connect to your node and deploy contracts there through other means?

ToJen commented 6 years ago

What happens when you do titan console or even ./bin/run console?

maxsam4 commented 6 years ago

What happens when you do titan console or even ./bin/run console?

$ titan console
(node:11966) Error Plugin: @titan-suite/cli: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/package.json
module: @oclif/config@1.7.6
plugin: @titan-suite/cli
root: /usr/local/lib/node_modules/@titan-suite/cli
See more details with DEBUG=*
(node:11966) Error Plugin: @oclif/plugin-help: files attribute must be specified in /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help/package.json
module: @oclif/config@1.7.6
plugin: @oclif/plugin-help
root: /usr/local/lib/node_modules/@titan-suite/cli/node_modules/@oclif/plugin-help
See more details with DEBUG=*

console@http://127.0.0.1:8545$  web3.version.ethereum
'0'
console@http://127.0.0.1:8545$ web3.isConnected()
true
console@http://127.0.0.1:8545$  web3.currentProvider
HttpProvider { host: 'http://127.0.0.1:8545', timeout: 0 }
console@http://127.0.0.1:8545$ web3.eth.getCompilers()
[ 'solidity' ]
console@http://127.0.0.1:8545$ web3.eth.compile.solidity("contract Test { uint8 a; }")
Error: Internal error
    at Object.InvalidResponse (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/aion-web3/lib/web3/errors.js:38:16)
    at RequestManager.send (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/aion-web3/lib/web3/requestmanager.js:61:22)
    at Object.send [as solidity] (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/aion-web3/lib/web3/method.js:145:58)
console@http://127.0.0.1:8545$ web3.eth.compile.solidity("contract Test { uint8 a; }")
{}
console@http://127.0.0.1:8545$ web3.eth.compile.solidity("contract Test { uint8 a; }")
{}
console@http://127.0.0.1:8545$ web3.eth.compile.solidity("contract Test { uint8 a; }")
{}
console@http://127.0.0.1:8545$ web3.eth.compile.solidity("contract Test { uint8 a; }")
Error: Internal error
    at Object.InvalidResponse (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/aion-web3/lib/web3/errors.js:38:16)
    at RequestManager.send (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/aion-web3/lib/web3/requestmanager.js:61:22)
    at Object.send [as solidity] (/usr/local/lib/node_modules/@titan-suite/cli/node_modules/aion-web3/lib/web3/method.js:145:58)
console@http://127.0.0.1:8545$ 

If I try to compile one after another without any break, I get empty response from web3. If I wait a few seconds between the commands, I get that error. Tried with titan console and the console.js file in the aion node's web3 folder. same result. Seems like it's an issue with the node/aion's web3. commands like web3.currentProvider show that the node is connected to the console. Tried blockNumber as well and it's working.

aion-127.0.0.1:8545> web3.eth.blockNumber
948
ToJen commented 6 years ago

Could this be related to https://github.com/aionnetwork/aion/issues/628?

maxsam4 commented 6 years ago

Seems like it is.

ToJen commented 6 years ago

Have you tried it on 16.04? This may be an issue with the AION node and not the cli?

ToJen commented 6 years ago

Closing this due to inactivity.