NEARStudio
NEARStudio copied to clipboard
Pointing to a AlphaNet or a different DevNet
NEARStudio should support being pointed to a different AlphaNet or DevNet by either:
- Change in a config file;
- 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.
- Make sure that
alice.near
is in the initial authorities of the chain spec used by AlphaNet or DevNet; - 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');
- Start near contract helper by setting its port to
3031
:
export NEAR_CONTRACT_HELPER_PORT=3031
node app.js
- 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"
- 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);
- Save and press "Run"
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.
@potatodepaulo Yes, that would be good to have.