Skip to content

Commit

Permalink
Merge pull request #210 from PhyrexTsai/master
Browse files Browse the repository at this point in the history
v0.1.13
  • Loading branch information
PhyrexTsai committed Dec 16, 2019
2 parents 6b453bf + 2c775ca commit 91da88e
Show file tree
Hide file tree
Showing 20 changed files with 263 additions and 55 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ The KAIZEN Platform is currently in experimental alpha.
- [Sia](https://sia.tech/) - Decentralized file storage
- [NOIA](http://noia.network/) - Decentralized CDN
- [Near](https://nearprotocol.com/) - Scalable decentralized application
- [Tellor](https://tellor.io/) - Decentralized oracle service

## <a name="instances"></a>鈿欙笍 Instances
- [NYM](http://nymtech.net/) - Decentralized privacy
Expand Down
1 change: 1 addition & 0 deletions README_KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The KAIZEN Platform is currently in experimental alpha.
- [Sia](https://sia.tech/) - Decentralized file storage
- [NOIA](http://noia.network/) - Decentralized CDN
- [Near](https://nearprotocol.com/) - Scalable decentralized application
- [Tellor](https://tellor.io/) - Decentralized oracle service

## <a name="instances"></a>鈿欙笍 鞚胳姢韯挫姢
- [NYM](http://nymtech.net/) - Decentralized privacy
Expand Down
1 change: 1 addition & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ KAIZEN Platform 鐩墠姝e湪 Alpha 闅庢
- [Sia](https://sia.tech/) - Decentralized file storage
- [NOIA](http://noia.network/) - Decentralized CDN
- [Near](https://nearprotocol.com/) - Scalable decentralized application
- [Tellor](https://tellor.io/) - Decentralized oracle service

## <a name="instances"></a>鈿欙笍 瀵︿緥
- [NYM](http://nymtech.net/) - Decentralized privacy
Expand Down
35 changes: 21 additions & 14 deletions build/components/Contracts/Deploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ function builder(yargs) {
alias: 'u',
type: 'string',
describe: 'URL of the template contract'
}).option('network', {
alias: 'n',
type: 'string',
describe: 'Network of the template contract',
choices: ['development', 'deploy'],
default: 'development'
}).example('kaizen contracts deploy -u https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20').demandOption(['url'], '').epilogue('Please enter the url of the template contract\n\n' + 'Support contract template:\n\n'.underline.yellow + 'Chainlink'.underline.yellow + ' - Chainlink Oracle Service, ' + 'https://github.com/PortalNetwork/kaizen-contracts/tree/master/Chainlink'.underline.yellow + '\n' + 'ERC20'.underline.yellow + ' - ERC20 Token Standard, ' + 'https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20'.underline.yellow + '\n' + 'ERC721'.underline.yellow + ' - ERC721 Token Standard, ' + 'https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC721'.underline.yellow + '\n' + 'NuCypher'.underline.yellow + ' - NuCypher Contracts, ' + 'https://github.com/PortalNetwork/kaizen-contracts/tree/master/NuCypher'.underline.yellow + '\n');
}

Expand All @@ -40,14 +46,14 @@ function _handler() {
_handler = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(argv) {
var repoUrl, kaizenrc, _kaizenrc, privateKey, provider, networkId, _getFilePath, owner, repo, branch, template, zipFilePath, processing, result;
var repoUrl, network, kaizenrc, _kaizenrc, privateKey, provider, networkId, _getFilePath, owner, repo, branch, template, deployNetwork, zipFilePath, processing, result;

return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
repoUrl = argv.url;
repoUrl = argv.url, network = argv.network;
kaizenrc = fsx.readJsonSync(path.resolve(__dirname, '../../../../.kaizenrc'));
_kaizenrc = _objectSpread({}, kaizenrc), privateKey = _kaizenrc.privateKey, provider = _kaizenrc.provider, networkId = _kaizenrc.networkId;

Expand All @@ -62,13 +68,14 @@ function _handler() {
console.log("Contract deploying, this may take a while...".yellow);
Spinner.start();
_getFilePath = getFilePath(repoUrl), owner = _getFilePath.owner, repo = _getFilePath.repo, branch = _getFilePath.branch, template = _getFilePath.template;
deployNetwork = template === 'Chainlink' ? 'cldev' : deployNetwork;
zipFilePath = "https://github.com/".concat(owner, "/").concat(repo, "/raw/").concat(branch, "/").concat(template, ".zip");
_context.next = 12;
_context.next = 13;
return download(zipFilePath, '.', {
extract: true
});

case 12:
case 13:
Spinner.stop();
Spinner.start();
console.log("Setup environment variable...".yellow); // Setup environment variable
Expand All @@ -80,39 +87,39 @@ function _handler() {
Spinner.stop();
Spinner.start();
console.log("Installing modules...".yellow);
_context.next = 23;
_context.next = 24;
return ExecuteCommand("cd ".concat(template, " && npm i"));

case 23:
case 24:
processing = _context.sent;
Spinner.stop();
console.log(processing); // Build and deploy contracts

console.log("Deploying contracts...".yellow);
_context.next = 29;
return ExecuteCommand("cd ".concat(template, " && ./node_modules/.bin/truffle deploy --network deployment"));
_context.next = 30;
return ExecuteCommand("cd ".concat(template, " && ./node_modules/.bin/truffle migrate --network ").concat(deployNetwork));

case 29:
case 30:
result = _context.sent;
console.log(result);
fsx.removeSync("./".concat(template));
Log.SuccessLog("\nDeploy Contract ".concat(template, " Successfully"));
_context.next = 40;
_context.next = 41;
break;

case 35:
_context.prev = 35;
case 36:
_context.prev = 36;
_context.t0 = _context["catch"](0);
Spinner.stop();
Log.ErrorLog('\nUnable to deploy sontract');
console.error(_context.t0);

case 40:
case 41:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 35]]);
}, _callee, this, [[0, 36]]);
}));
return _handler.apply(this, arguments);
}
Expand Down
47 changes: 30 additions & 17 deletions build/components/Plugins/Install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var siaHandler = require('./sia.js');

var nearHandler = require('./near.js');

var tellorHandler = require('./tellor.js');

function builder(yargs) {
return yargs.positional('plugin', {
alias: 'p',
Expand Down Expand Up @@ -76,7 +78,7 @@ function _handler() {

case 8:
_context.t0 = plugin;
_context.next = _context.t0 === 'bluzelle' ? 11 : _context.t0 === 'nkn' ? 18 : _context.t0 === 'noia' ? 25 : _context.t0 === 'icon' ? 32 : _context.t0 === 'orbit' ? 39 : _context.t0 === 'arweave' ? 46 : _context.t0 === 'band' ? 53 : _context.t0 === 'fluence' ? 60 : _context.t0 === 'sia' ? 67 : _context.t0 === 'near' ? 74 : 81;
_context.next = _context.t0 === 'bluzelle' ? 11 : _context.t0 === 'nkn' ? 18 : _context.t0 === 'noia' ? 25 : _context.t0 === 'icon' ? 32 : _context.t0 === 'orbit' ? 39 : _context.t0 === 'arweave' ? 46 : _context.t0 === 'band' ? 53 : _context.t0 === 'fluence' ? 60 : _context.t0 === 'sia' ? 67 : _context.t0 === 'near' ? 74 : _context.t0 === 'tellor' ? 81 : 88;
break;

case 11:
Expand All @@ -88,7 +90,7 @@ function _handler() {
case 15:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 18:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -99,7 +101,7 @@ function _handler() {
case 22:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 25:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -110,7 +112,7 @@ function _handler() {
case 29:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 32:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -121,7 +123,7 @@ function _handler() {
case 36:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 39:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -132,7 +134,7 @@ function _handler() {
case 43:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 46:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -143,7 +145,7 @@ function _handler() {
case 50:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 53:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -154,7 +156,7 @@ function _handler() {
case 57:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 60:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -165,7 +167,7 @@ function _handler() {
case 64:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 67:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -176,7 +178,7 @@ function _handler() {
case 71:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 74:
Log.NormalLog('Installing plugin, please wait a second...');
Expand All @@ -187,28 +189,39 @@ function _handler() {
case 78:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 82);
return _context.abrupt("break", 89);

case 81:
Log.NormalLog('Installing plugin, please wait a second...');
Spinner.start();
_context.next = 85;
return tellorHandler();

case 85:
Spinner.stop();
Log.SuccessLog("Install plugin ".concat(plugin, " Successfully"));
return _context.abrupt("break", 89);

case 88:
Log.NormalLog('Plugin not support yet');

case 82:
_context.next = 89;
case 89:
_context.next = 96;
break;

case 84:
_context.prev = 84;
case 91:
_context.prev = 91;
_context.t1 = _context["catch"](0);
Spinner.stop();
Log.ErrorLog('something went wrong!');
console.error(_context.t1);

case 89:
case 96:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 84]]);
}, _callee, this, [[0, 91]]);
}));
return _handler.apply(this, arguments);
}
Expand Down
47 changes: 47 additions & 0 deletions build/components/Plugins/Install/tellor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use strict";

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

var path = require('path');

var fsx = require('fs-extra');

var ExecuteCommand = require('../../../lib/ExecuteCommand');

module.exports =
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var configPath, userConfig;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return ExecuteCommand('npm install usingtellor');

case 2:
// update user's kaizen config
configPath = path.resolve('./', 'kaizen.json');
userConfig = fsx.existsSync(configPath) ? fsx.readJsonSync(configPath) : {};

if (!userConfig.plugins) {
userConfig.plugins = [];
}

if (userConfig.plugins.includes('tellor') === false) {
userConfig.plugins.push('tellor');
}

fsx.outputJsonSync(path.resolve('./', 'kaizen.json'), userConfig);

case 7:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
3 changes: 2 additions & 1 deletion build/components/Plugins/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ function _handler() {
Log.NormalLog('fluence'.underline.yellow + ' - Fluence information');
Log.NormalLog('sia'.underline.yellow + ' - Sia information');
Log.NormalLog('near'.underline.yellow + ' - Near information');
Log.NormalLog('tellor'.underline.yellow + ' - Tellor information');
Log.NormalLog("\nTo install a plugin run " + "'kaizen plugins install <plugin-name-here>'".yellow);
Log.NormalLog("\nIt will be automatically downloaded and added to your " + "'package.json'".yellow + " and " + "'kaizen.json'".yellow + " file\n");

case 13:
case 14:
case "end":
return _context.stop();
}
Expand Down

0 comments on commit 91da88e

Please sign in to comment.