Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

Commit

Permalink
> modified: es6/webz.js
Browse files Browse the repository at this point in the history
>	modified:   es6/zil/index.js
>	modified:   lib/webz.js
>	modified:   lib/zil/index.js
>	modified:   package.json
  • Loading branch information
CapCap_ghostcorn authored and CapCap_ghostcorn committed Aug 28, 2018
1 parent 49cbcc2 commit 217b0fb
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 49 deletions.
8 changes: 0 additions & 8 deletions es6/webz.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ class Webz {
generateWallet = walletName => this.zil.generateWallet(walletName)

getNetworkType = () => {}

getAccounts = (pubkeyArray) => {
if (!util.isArray(pubkeyArray) && pubkeyArray.length === 0) throw Error('Input has to be non-empty Array')
const newPubkeyArray = pubkeyArray.map(d => util.isPubkey(d)).filter(t => !!t)
if (newPubkeyArray.length !== pubkeyArray.length) throw Error('one or some public key(s) inputted is invalid')
const resultArray = pubkeyArray.map(k => util.getAddressFromPublicKey(k))
return resultArray || []
}
}

export default Webz
20 changes: 20 additions & 0 deletions es6/zil/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getPubKeyFromPrivateKey,
isString
} from '../util'
import config from '../util/config'
import ZilObjects from './Objects'

const mapObjectToMethods = (main) => {
Expand All @@ -21,6 +22,7 @@ const mapObjectToMethods = (main) => {
class Zil {
constructor(Webz) {
this.messanger = Webz.messanger
this.config = config
mapObjectToMethods(this)
}

Expand All @@ -42,6 +44,24 @@ class Zil {
}
return Wallet
}

get defaultBlock() {
return this.config.defaultBlock
}

set defaultBlock(block) {
this.config.defaultBlock = block
return block
}

get defaultAccount() {
return this.config.defaultAccount
}

set defaultAccount(account) {
this.config.defaultAccount = account
return account
}
}

export default Zil
14 changes: 0 additions & 14 deletions lib/webz.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ var Webz = function Webz(args) {

this.getNetworkType = function () {};

this.getAccounts = function (pubkeyArray) {
if (!util.isArray(pubkeyArray) && pubkeyArray.length === 0) throw Error('Input has to be non-empty Array');
var newPubkeyArray = pubkeyArray.map(function (d) {
return util.isPubkey(d);
}).filter(function (t) {
return !!t;
});
if (newPubkeyArray.length !== pubkeyArray.length) throw Error('one or some public key(s) inputted is invalid');
var resultArray = pubkeyArray.map(function (k) {
return util.getAddressFromPublicKey(k);
});
return resultArray || [];
};

validateArgs(args, {}, { nodeUrl: [util.isUrl] });
this.url = args || config.defaultNodeUrl;
//
Expand Down
84 changes: 58 additions & 26 deletions lib/zil/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _assign = require('babel-runtime/core-js/object/assign');

var _assign2 = _interopRequireDefault(_assign);
Expand All @@ -18,6 +22,10 @@ var _method2 = _interopRequireDefault(_method);

var _util = require('../util');

var _config = require('../util/config');

var _config2 = _interopRequireDefault(_config);

var _Objects = require('./Objects');

var _Objects2 = _interopRequireDefault(_Objects);
Expand All @@ -35,33 +43,57 @@ var mapObjectToMethods = function mapObjectToMethods(main) {
});
};

var Zil = function Zil(Webz) {
(0, _classCallCheck3.default)(this, Zil);

this.generateWallet = function (walletName) {
if (!(0, _util.isString)(walletName)) throw Error('walletName has to be String');
var walletPrivateKey = (0, _util.generatePrivateKey)();
var walletPublicKey = walletPrivateKey ? (0, _util.getPubKeyFromPrivateKey)(walletPrivateKey) : null;
var walletAddress = walletPrivateKey ? (0, _util.getAddressFromPrivateKey)(walletPrivateKey) : null;
var Wallet = {
walletName: walletName,
walletPublicKey: walletPublicKey,
walletPrivateKey: walletPrivateKey,
walletAddress: walletAddress
var Zil = function () {
function Zil(Webz) {
(0, _classCallCheck3.default)(this, Zil);

this.generateWallet = function (walletName) {
if (!(0, _util.isString)(walletName)) throw Error('walletName has to be String');
var walletPrivateKey = (0, _util.generatePrivateKey)();
var walletPublicKey = walletPrivateKey ? (0, _util.getPubKeyFromPrivateKey)(walletPrivateKey) : null;
var walletAddress = walletPrivateKey ? (0, _util.getAddressFromPrivateKey)(walletPrivateKey) : null;
var Wallet = {
walletName: walletName,
walletPublicKey: walletPublicKey,
walletPrivateKey: walletPrivateKey,
walletAddress: walletAddress
};
return Wallet;
};
return Wallet;
};

this.messanger = Webz.messanger;
mapObjectToMethods(this);
}

/**
* generate Key pairs and use WalletName as input param to identify
* @param {[type]} walletName [description]
* @return {[type]} [description]
*/
;

this.messanger = Webz.messanger;
this.config = _config2.default;
mapObjectToMethods(this);
}

/**
* generate Key pairs and use WalletName as input param to identify
* @param {[type]} walletName [description]
* @return {[type]} [description]
*/


(0, _createClass3.default)(Zil, [{
key: 'defaultBlock',
get: function get() {
return this.config.defaultBlock;
},
set: function set(block) {
this.config.defaultBlock = block;
return block;
}
}, {
key: 'defaultAccount',
get: function get() {
return this.config.defaultAccount;
},
set: function set(account) {
this.config.defaultAccount = account;
return account;
}
}]);
return Zil;
}();

exports.default = Zil;
module.exports = exports.default;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webz.js",
"version": "0.0.16",
"version": "0.0.17",
"description": "Zilliqa Javascript Libraries",
"main": "lib/index.js",
"browser": "dist/Webz.browser.js",
Expand Down

0 comments on commit 217b0fb

Please sign in to comment.