NEARStudio icon indicating copy to clipboard operation
NEARStudio copied to clipboard

Pointing to a AlphaNet or a different DevNet

Open MaksymZavershynskyi opened this issue 5 years ago • 2 comments

NEARStudio should support being pointed to a different AlphaNet or DevNet by either:

  1. Change in a config file;
  2. UI element in the studio itself that allows connecting to a different *Net.

Currently, in order to run NEARStudio on the top of AlphaNet or a different DevNet we need to go through a multistep hacky process. Suppose we have AlphaNet/DevNet running on 34.208.224.21:3030 and we want to run studio locally on the laptop.

  1. Make sure that alice.near is in the initial authorities of the chain spec used by AlphaNet or DevNet;
  2. Clone https://github.com/nearprotocol/near-contract-helper to the local machine and modify in app.js local node connection to point to the AlphaNet/DevNet:
const localNodeConnection = new LocalNodeConnection('http://34.208.224.21:3030');
  1. Start near contract helper by setting its port to 3031:
export NEAR_CONTRACT_HELPER_PORT=3031
node app.js
  1. Clone https://github.com/nearprotocol/NEARStudio to the local machine and modify config.json:
"contractHelper": "http://127.0.0.1:3031",
"nodeUrl": "http://34.208.224.21:3030"
  1. Start near studio. Open "Hello World Example" template and modify doInitContract() function, to assign node URL
 // Getting config from cookies that are provided by the NEAR Studio.
  const config = await nearlib.dev.getConfig();
    config.nodeUrl = "http://34.208.224.21:3030";
    config.baseUrl = "http://127.0.0.1:3031";
    const options = {};
    options.nodeUrl = "http://34.208.224.21:3030";
    options.baseUrl = "http://127.0.0.1:3031";
  
  // Initializing connection to the NEAR DevNet.
  window.near = await nearlib.dev.connect(options);
  1. Save and press "Run"

MaksymZavershynskyi avatar Mar 18 '19 23:03 MaksymZavershynskyi

Why not 1) as implementation with a UI element that manipulates config file associated with it?

Also If it were local, I would expect I could pass in through cli flag of some sort by manipulating settings. E.g. -h is host and -p is port.

behaviary avatar Mar 19 '19 22:03 behaviary

@potatodepaulo Yes, that would be good to have.

MaksymZavershynskyi avatar Mar 19 '19 22:03 MaksymZavershynskyi