mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Update to eslint 1.2.1
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
"babel-eslint": "^4.0.5",
|
"babel-eslint": "^4.0.5",
|
||||||
"babel-loader": "^5.3.2",
|
"babel-loader": "^5.3.2",
|
||||||
"coveralls": "~2.10.0",
|
"coveralls": "~2.10.0",
|
||||||
"eslint": "^1.2.0",
|
"eslint": "^1.2.1",
|
||||||
"eventemitter2": "^0.4.14",
|
"eventemitter2": "^0.4.14",
|
||||||
"istanbul": "~0.3.5",
|
"istanbul": "~0.3.5",
|
||||||
"lodash": "^3.10.0",
|
"lodash": "^3.10.0",
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ const {Ed25519Pair} = require('./ed25519');
|
|||||||
const {K256Pair, accountPublicFromPublicGenerator} = require('./secp256k1');
|
const {K256Pair, accountPublicFromPublicGenerator} = require('./secp256k1');
|
||||||
const {decodeSeed, encodeNodePublic, decodeNodePublic, encodeAccountID} = codec;
|
const {decodeSeed, encodeNodePublic, decodeNodePublic, encodeAccountID} = codec;
|
||||||
|
|
||||||
function parseSeed(seed, type=KeyType.secp256k1) {
|
function parseSeed(seed, type = KeyType.secp256k1) {
|
||||||
if (typeof seed !== 'string') {
|
if (typeof seed !== 'string') {
|
||||||
return {bytes: seed, type};
|
return {bytes: seed, type};
|
||||||
}
|
}
|
||||||
return decodeSeed(seed);
|
return decodeSeed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyPair.fromSeed = function(seed, type=KeyType.secp256k1, options) {
|
KeyPair.fromSeed = function(seed, type = KeyType.secp256k1, options) {
|
||||||
if (typeof seed === 'string') {
|
if (typeof seed === 'string') {
|
||||||
const decoded = decodeSeed(seed);
|
const decoded = decodeSeed(seed);
|
||||||
const optionsArg = type;
|
const optionsArg = type;
|
||||||
@@ -47,8 +47,8 @@ function deriveValidator(seedBytes) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateWallet(opts={}) {
|
function generateWallet(opts = {}) {
|
||||||
const {type='secp256k1', random=brorand} = opts;
|
const {type = 'secp256k1', random = brorand} = opts;
|
||||||
const seedBytes = random(16);
|
const seedBytes = random(16);
|
||||||
return deriveWallet(seedBytes, type);
|
return deriveWallet(seedBytes, type);
|
||||||
}
|
}
|
||||||
@@ -62,8 +62,8 @@ function walletFromPhrase(phrase, type) {
|
|||||||
return walletFromSeed(seedFromPhrase(phrase), type);
|
return walletFromSeed(seedFromPhrase(phrase), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateValidatorKeys(opts={}) {
|
function generateValidatorKeys(opts = {}) {
|
||||||
const {random=brorand} = opts;
|
const {random = brorand} = opts;
|
||||||
return deriveValidator(random(16));
|
return deriveValidator(random(16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function deriveScalar(bytes, discrim) {
|
|||||||
* @return {bn.js} - 256 bit scalar value
|
* @return {bn.js} - 256 bit scalar value
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function deriveSecret(seed, opts={}) {
|
function deriveSecret(seed, opts = {}) {
|
||||||
const root = opts.validator;
|
const root = opts.validator;
|
||||||
const order = secp256k1.curve.n;
|
const order = secp256k1.curve.n;
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class K256Pair extends KeyPair {
|
|||||||
this.validator = options.validator;
|
this.validator = options.validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromSeed(seedBytes, opts={}) {
|
static fromSeed(seedBytes, opts = {}) {
|
||||||
return new K256Pair({seedBytes, validator: opts.validator});
|
return new K256Pair({seedBytes, validator: opts.validator});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,19 @@
|
|||||||
const hashjs = require('hash.js');
|
const hashjs = require('hash.js');
|
||||||
const Sha512 = require('./sha512');
|
const Sha512 = require('./sha512');
|
||||||
|
|
||||||
|
function unused() {}
|
||||||
|
|
||||||
function isVirtual(_, __, descriptor) {
|
function isVirtual(_, __, descriptor) {
|
||||||
|
unused(_, __);
|
||||||
|
|
||||||
descriptor.value = function() {
|
descriptor.value = function() {
|
||||||
throw new Error('virtual method not implemented ');
|
throw new Error('virtual method not implemented ');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function cached(_, name, descriptor) {
|
function cached(_, name, descriptor) {
|
||||||
|
unused(_);
|
||||||
|
|
||||||
const computer = descriptor.value;
|
const computer = descriptor.value;
|
||||||
const key = '_' + name;
|
const key = '_' + name;
|
||||||
descriptor.value = function() {
|
descriptor.value = function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user