Skip to content
This repository was archived by the owner on Apr 18, 2021. It is now read-only.

--network option for 'vvisp console' command doesn't work #128

Closed
nujabes403 opened this issue Mar 17, 2019 · 0 comments
Closed

--network option for 'vvisp console' command doesn't work #128

nujabes403 opened this issue Mar 17, 2019 · 0 comments

Comments

@nujabes403
Copy link
Contributor

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

vvisp console --network devnet command doesn't work.

This is a part of content in truffle-config.js.

  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*' // eslint-disable-line camelcase
    },
    coverage: {
      host: 'localhost',
      network_id: '*', // eslint-disable-line camelcase
      port: 8555,
      gas: 0xfffffffffff,
      gasPrice: 0x01
    },
    ganache: {
      host: 'localhost',
      port: 8545,
      network_id: '*' // eslint-disable-line camelcase
    },
    devnet: {
      host: 'satoshi.klaytn.net',
      port: 8551,
      gas: 0xfffffff,
      gasPrice: 0x5d21dba00
    }
  },

Since vvisp console command has a addNetworkOption in packages/vvisp/commands/console.js path, it should support --network option.

However, the provider of contract instance file generated from vvisp gen-script is not same with the option provided with --network.

To check the current provider of contract instance, I added console.log in generated contract instance file, for example contractApis/back/js/Count.js.

module.exports = function(_contractAddr = '') {
  const web3 = web3Store.get();
  
  console.log(web3.currentProvider, 'web3 currentProvider') // added console.log in this line
  const contract = new web3.eth.Contract(JSON.parse(abi));
  contract.options.address = _contractAddr;

After adding console.log, I ran vvisp console --network devnet command.

❯ vvisp console --network devnet
'state.vvisp.json' does not existing in current path(/Users/hoonilkim/work2/myDapp2)

Run 'vvisp deploy-service' command to create state.vvisp.json and rerun 'vvisp console' again, 
or enter the address of the currently registered contract

Available contract contracts:
Count

Enter the address of Count: 0xb527119DFEd10A61f3B71A3e4E93e7276BA5F9FB
Available contract contracts:

Index				Contract				Address
[0]				Count				0xb527119DFEd10A61f3B71A3e4E93e7276BA5F9FB


If you are wondering how to use it, type help command.
Use exit or Ctrl-c to exit
>> call Count count
HttpProvider {
  host: 'http://localhost:8545',
  httpAgent: 
   Agent {
     domain: null,
     _events: { free: [Function] },
     _eventsCount: 1,
     _maxListeners: undefined,
     defaultPort: 80,
     protocol: 'http:',
     options: { keepAlive: false, path: null },
     requests: {},
     sockets: {},
     freeSockets: {},
     keepAliveMsecs: 1000,
     keepAlive: false,
     maxSockets: Infinity,
     maxFreeSockets: 256 },
  timeout: 0,
  headers: undefined,
  connected: false } 'web3 currentProvider'

Like above logs, it shows 'http://localhost:8545' as a host which doesn't match with the devnet network(http://satoshi.klaytn.net:8551).

Expected behavior

contract instance have a provider which same with the one provided by --network option.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


vvisp version: X.Y.Z


Environment:
- Node version: v8.11.3
- Operating system: os x high sierra

Others:

JhChoy added a commit to nujabes403/HAECHI-CLI that referenced this issue Mar 19, 2019
@JhChoy JhChoy closed this as completed in f9dca62 Mar 19, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant