Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/contracts/code_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const Templates = {
class CodeGenerator {
constructor(options) {
this.blockchainConfig = options.blockchainConfig || {};
this.rpcHost = this.blockchainConfig.rpcHost || '';
this.rpcPort = this.blockchainConfig.rpcPort || '';
this.contractsConfig = options.contractsConfig || {};
this.storageConfig = options.storageConfig || {};
this.communicationConfig = options.communicationConfig || {};
Expand Down
12 changes: 6 additions & 6 deletions lib/contracts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,17 @@ class Deploy {

// calling each beforeDeploy handler declared by the plugin
async.eachSeries(plugin.beforeDeploy, (beforeDeployFn, eachCb) => {
function beforeDeployCb(resObj){
contract.code = resObj.contractCode;
eachCb();
}
beforeDeployFn({
embarkDeploy: self,
pluginConfig: plugin.pluginConfig,
deploymentAccount: deploymentAccount,
contract: contract,
callback:
(function(resObj){
contract.code = resObj.contractCode;
eachCb();
})
});
callback: beforeDeployCb
}, beforeDeployCb);
}, () => {
//self.logger.info('All beforeDeploy handlers of the plugin has processed.');
eachPluginCb();
Expand Down
4 changes: 2 additions & 2 deletions lib/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Config.prototype.loadFiles = function(files) {
}
});
filesFromPlugins.filter(function(file) {
if (utils.fileMatchesPattern(files, file.intendedPath)) {
if ((file.intendedPath && utils.fileMatchesPattern(files, file.intendedPath)) || utils.fileMatchesPattern(files, file.file)) {
readFiles.push(file);
}
});
Expand All @@ -301,7 +301,7 @@ Config.prototype.loadPluginContractFiles = function() {
contractsPlugins.forEach(function(plugin) {
plugin.contractsFiles.forEach(function(file) {
var filename = file.replace('./','');
self.contractsFiles.push(new File({filename: filename, type: File.types.custom, resolver: function(callback) {
self.contractsFiles.push(new File({filename: filename, type: File.types.custom, path: filename, resolver: function(callback) {
callback(plugin.loadPluginFile(file));
}}));
});
Expand Down
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ class Embark {

if (cmdPlugins.length > 0) {
cmdPlugin = cmdPlugins.find((pluginCmd) => {
return pluginCmd.name == platform;
return pluginCmd.uploadCmds.some(uploadCmd => {
return uploadCmd.cmd === platform;
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now have access to the uploadCmd object, we should probably refactor the below lines to use uploadCmd.cb() instead of cmdPlugin.uploadCmds[0].cb():
https://github.com/embark-framework/embark/blob/7ebaa7aacadc0f4fd4602c5124c84a9a4de36986/lib/index.js#L342

});
}
if (!cmdPlugin) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma solidity ^0.4.18;
contract PluginStorage {
address public simpleStorageAddress;
address simpleStorageAddress2;

function PluginStorage(address addr) public {
simpleStorageAddress = addr;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('File added to the pipeline using embark.addFileToPipeline');
47 changes: 41 additions & 6 deletions test_apps/test_app/extensions/embark-service/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
var Haml = require('haml');
const Haml = require('haml');

module.exports = function(embark) {
embark.registerServiceCheck('PluginService', function(cb) {
module.exports = function (embark) {
embark.registerServiceCheck('PluginService', function (cb) {
cb({name: "ServiceName", status: "on"});
});

embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function(opts) {
var source = opts.source;
return Haml.render(source);
embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function (opts) {
return Haml.render(opts.source);
});

embark.registerContractConfiguration({
"default": {
"contracts": {
"PluginStorage": {
"args": ["$SimpleStorage"]
}
}
}
});
embark.addContractFile("./contracts/pluginSimpleStorage.sol");

embark.addFileToPipeline('./fileInPipeline.js');
embark.addFileToPipeline('./fileInPipeline.js', 'js/fileInPipeline.js');

embark.registerBeforeDeploy(function (options, callback) {
// Just calling register to prove it works. We don't actually want to change the contracts
callback({contractCode: options.contract.code});
});

embark.registerClientWeb3Provider(function(options) {
return "web3 = new Web3(new Web3.providers.HttpProvider('http://" + options.rpcHost + ":" + options.rpcPort + "'));";
});

embark.registerConsoleCommand((cmd) => {
if (cmd === "hello") {
return "hello there!";
}
// continue to embark or next plugin;
return false;
});

embark.events.on("contractsDeployed", function() {
embark.logger.info("plugin says: your contracts have been deployed");
});

};
4 changes: 2 additions & 2 deletions test_apps/test_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
},
"dependencies": {
"bootstrap": "^3.3.6",
"embark-service": "./extensions/embark-service",
"embark-service": "file:extensions/embark-service",
"jquery": "^1.11.3",
"react": "^16.0.0",
"react-bootstrap": "^0.32.0",
"react-dom": "^16.2.0",
"zeppelin-solidity": "^1.8.0"
"zeppelin-solidity": "1.8.0"
}
}
26 changes: 26 additions & 0 deletions test_apps/test_app/test/plugin_storage_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*global contract, before, EmbarkSpec, PluginStorage, SimpleStorage, it*/
const assert = require('assert');

contract("PluginSimpleStorage", function () {
this.timeout(0);

before((done) => {
const contractsConfig = {
"SimpleStorage": {
args: [100]
},
"PluginStorage": {
args: ["$SimpleStorage"]
}
};
EmbarkSpec.deployAll(contractsConfig, () => {
done();
});
});

it("set SimpleStorage address", async function () {
let result = await PluginStorage.methods.simpleStorageAddress().call();
assert.equal(result.toString(), SimpleStorage.options.address);
});

});
2 changes: 0 additions & 2 deletions test_apps/test_app/test/token_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ describe("Token", function() {
var contractsConfig = {
"ZAMyLib": {
},
"Token": {
},
"SimpleStorage": {
args: [100]
},
Expand Down