mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-10 04:45:05 +00:00
use provider instead of hardcoded connection
This commit is contained in:
parent
1a90a3034a
commit
0742f96e38
@ -257,6 +257,10 @@ class TestRunner {
|
||||
});
|
||||
}
|
||||
|
||||
executeTestFiile() {
|
||||
let embark = this.embark;
|
||||
}
|
||||
|
||||
runJSTests(files, options, cb) {
|
||||
async.waterfall([
|
||||
(next) => { // setup global namespace
|
||||
|
@ -34,7 +34,8 @@ class EmbarkWeb3 {
|
||||
}
|
||||
|
||||
async registerWeb3Object() {
|
||||
const web3 = new Web3("ws://localhost:8556");
|
||||
const provider = await this.events.request2("blockchain:client:provider", "ethereum");
|
||||
const web3 = new Web3(provider)
|
||||
await this.events.request2("runcode:register", 'web3', web3);
|
||||
}
|
||||
|
||||
@ -49,11 +50,13 @@ class EmbarkWeb3 {
|
||||
let contract = params.contract;
|
||||
let abi = JSON.stringify(contract.abiDefinition);
|
||||
let gasLimit = 6000000;
|
||||
let contractCode = Templates.vanilla_contract({ className: contract.className, abi: abi, contract: contract, gasLimit: gasLimit });
|
||||
const provider = await this.events.request2("blockchain:client:provider", "ethereum");
|
||||
let contractCode = Templates.vanilla_contract({ className: contract.className, abi: abi, contract: contract, gasLimit: gasLimit, provider: provider });
|
||||
|
||||
try {
|
||||
await this.events.request2('runcode:eval', contractCode);
|
||||
await this.events.request2('runcode:eval', contract.className);
|
||||
let result = await this.events.request2('runcode:eval', contract.className);
|
||||
result.currentProvider = provider;
|
||||
await this.events.request2("runcode:register", contract.className, result);
|
||||
cb();
|
||||
} catch (err) {
|
||||
@ -62,7 +65,7 @@ class EmbarkWeb3 {
|
||||
}
|
||||
|
||||
addWeb3Artifact(_params, cb) {
|
||||
let web3Code = Templates.web3_init({});
|
||||
let web3Code = Templates.web3_init({connectionList: this.config.contractsConfig.dappConnection});
|
||||
|
||||
this.events.request("pipeline:register", {
|
||||
path: [this.embarkConfig.generationDir, 'contracts'],
|
||||
|
@ -1,3 +1,5 @@
|
||||
console.dir("connection list TODO")
|
||||
console.dir(<%- connectionList %>)
|
||||
const Web3 = require('web3')
|
||||
const web3 = new Web3("ws://localhost:8556");
|
||||
module.exports = web3;
|
||||
|
@ -180,7 +180,7 @@ class EmbarkController {
|
||||
|
||||
let plugin = engine.plugins.createPlugin('cmdcontrollerplugin', {});
|
||||
plugin.registerActionForEvent("embark:engine:started", async (_params, cb) => {
|
||||
await engine.events.request2("blockchain:node:start", cb)
|
||||
await engine.events.request2("blockchain:node:start", engine.config.blockchainConfig, cb);
|
||||
});
|
||||
|
||||
engine.events.request('watcher:start');
|
||||
|
@ -12,6 +12,13 @@ class BlockchainClient {
|
||||
this.client = blockchainClient;
|
||||
})
|
||||
|
||||
// TODO: unclear currently if this belongs here so it's a bit hardcoded for now
|
||||
this.events.setCommandHandler("blockchain:client:provider", (clientName, cb) => {
|
||||
const Web3 = require('web3');
|
||||
var web3 = new Web3("ws://localhost:8556");
|
||||
cb(null, web3.currentProvider);
|
||||
})
|
||||
|
||||
// TODO: maybe not the ideal event to listen to?
|
||||
// for e.g, could wait for all stack components to be ready
|
||||
// TODO: probably better to have 2 stages in engine, services start, then connections, etc..
|
||||
|
@ -17,8 +17,9 @@ class Blockchain {
|
||||
this.blockchainNodes[clientName] = startCb
|
||||
})
|
||||
|
||||
this.events.setCommandHandler("blockchain:node:start", (cb) => {
|
||||
const clientName = this.blockchainConfig.client;
|
||||
this.events.setCommandHandler("blockchain:node:start", (blockchainConfig, cb) => {
|
||||
const clientName = blockchainConfig.client;
|
||||
// const clientName = this.blockchainConfig.client;
|
||||
const client = this.blockchainNodes[clientName];
|
||||
if (!client) return cb("client " + clientName + " not found");
|
||||
|
||||
|
@ -15,8 +15,10 @@ class EthereumBlockchainClient {
|
||||
return {};
|
||||
}
|
||||
|
||||
deployer(contract, done) {
|
||||
var web3 = new Web3("ws://localhost:8556")
|
||||
async deployer(contract, done) {
|
||||
let provider = await this.events.request2("blockchain:client:provider", "ethereum");
|
||||
var web3 = new Web3(provider)
|
||||
// var web3 = new Web3("ws://localhost:8556")
|
||||
web3.eth.getAccounts().then((accounts) => {
|
||||
let account = accounts[0];
|
||||
// let contractObject = this.blockchain.ContractObject({abi: contract.abiDefinition});
|
||||
|
Loading…
x
Reference in New Issue
Block a user