mirror of https://github.com/embarklabs/embark.git
Merge pull request #384 from embark-framework/chores/test-allpligin-apis
Small fixes for plugin APIs
This commit is contained in:
commit
17c33ad075
|
@ -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 || {};
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -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));
|
||||
}}));
|
||||
});
|
||||
|
|
|
@ -324,7 +324,9 @@ class Embark {
|
|||
|
||||
if (cmdPlugins.length > 0) {
|
||||
cmdPlugin = cmdPlugins.find((pluginCmd) => {
|
||||
return pluginCmd.name == platform;
|
||||
return pluginCmd.uploadCmds.some(uploadCmd => {
|
||||
return uploadCmd.cmd === platform;
|
||||
});
|
||||
});
|
||||
}
|
||||
if (!cmdPlugin) {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
pragma solidity ^0.4.18;
|
||||
contract PluginStorage {
|
||||
address public simpleStorageAddress;
|
||||
address simpleStorageAddress2;
|
||||
|
||||
function PluginStorage(address addr) public {
|
||||
simpleStorageAddress = addr;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
console.log('File added to the pipeline using embark.addFileToPipeline');
|
|
@ -1,4 +1,4 @@
|
|||
var Haml = require('haml');
|
||||
const Haml = require('haml');
|
||||
|
||||
module.exports = function (embark) {
|
||||
embark.registerServiceCheck('PluginService', function (cb) {
|
||||
|
@ -6,7 +6,42 @@ module.exports = function(embark) {
|
|||
});
|
||||
|
||||
embark.registerPipeline((embark.pluginConfig.files || ['**/*.haml']), function (opts) {
|
||||
var source = opts.source;
|
||||
return Haml.render(source);
|
||||
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");
|
||||
});
|
||||
|
||||
};
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
});
|
|
@ -13,8 +13,6 @@ describe("Token", function() {
|
|||
var contractsConfig = {
|
||||
"ZAMyLib": {
|
||||
},
|
||||
"Token": {
|
||||
},
|
||||
"SimpleStorage": {
|
||||
args: [100]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue