Fixed type definitions using absolute path.
This commit is contained in:
parent
1ce4f75b0d
commit
e8c657ba70
@ -15,7 +15,6 @@ var bytes_1 = require("../utils/bytes");
|
||||
var properties_1 = require("../utils/properties");
|
||||
var web_1 = require("../utils/web");
|
||||
var types_1 = require("../utils/types");
|
||||
//export { EventFilter, Event, Listener, Log, TransactionRequest, TransactionResponse };
|
||||
var errors = __importStar(require("../utils/errors"));
|
||||
var allowedTransactionKeys = {
|
||||
data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true
|
||||
|
@ -26,7 +26,6 @@ var hash_1 = require("../utils/hash");
|
||||
var keccak256_1 = require("../utils/keccak256");
|
||||
var properties_1 = require("../utils/properties");
|
||||
var types_1 = require("../utils/types");
|
||||
//export { DeployDescription, EventDescription, FunctionDescription, Indexed };
|
||||
var errors = __importStar(require("../utils/errors"));
|
||||
var _Indexed = /** @class */ (function (_super) {
|
||||
__extends(_Indexed, _super);
|
||||
@ -37,8 +36,8 @@ var _Indexed = /** @class */ (function (_super) {
|
||||
}
|
||||
return _Indexed;
|
||||
}(types_1.Indexed));
|
||||
var _Description = /** @class */ (function () {
|
||||
function _Description(info) {
|
||||
var Description = /** @class */ (function () {
|
||||
function Description(info) {
|
||||
for (var key in info) {
|
||||
var value = info[key];
|
||||
if (value != null && typeof (value) === 'object') {
|
||||
@ -49,7 +48,7 @@ var _Description = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
return _Description;
|
||||
return Description;
|
||||
}());
|
||||
var _DeployDescription = /** @class */ (function (_super) {
|
||||
__extends(_DeployDescription, _super);
|
||||
@ -77,7 +76,7 @@ var _DeployDescription = /** @class */ (function (_super) {
|
||||
return null;
|
||||
};
|
||||
return _DeployDescription;
|
||||
}(_Description));
|
||||
}(Description));
|
||||
var _FunctionDescription = /** @class */ (function (_super) {
|
||||
__extends(_FunctionDescription, _super);
|
||||
function _FunctionDescription() {
|
||||
@ -112,14 +111,14 @@ var _FunctionDescription = /** @class */ (function (_super) {
|
||||
}
|
||||
};
|
||||
return _FunctionDescription;
|
||||
}(_Description));
|
||||
}(Description));
|
||||
var Result = /** @class */ (function (_super) {
|
||||
__extends(Result, _super);
|
||||
function Result() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return Result;
|
||||
}(_Description));
|
||||
}(Description));
|
||||
var _EventDescription = /** @class */ (function (_super) {
|
||||
__extends(_EventDescription, _super);
|
||||
function _EventDescription() {
|
||||
@ -218,21 +217,21 @@ var _EventDescription = /** @class */ (function (_super) {
|
||||
return result;
|
||||
};
|
||||
return _EventDescription;
|
||||
}(_Description));
|
||||
}(Description));
|
||||
var TransactionDescription = /** @class */ (function (_super) {
|
||||
__extends(TransactionDescription, _super);
|
||||
function TransactionDescription() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return TransactionDescription;
|
||||
}(_Description));
|
||||
}(Description));
|
||||
var LogDescription = /** @class */ (function (_super) {
|
||||
__extends(LogDescription, _super);
|
||||
function LogDescription() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return LogDescription;
|
||||
}(_Description));
|
||||
}(Description));
|
||||
function addMethod(method) {
|
||||
switch (method.type) {
|
||||
case 'constructor': {
|
||||
|
43
index.js
43
index.js
@ -1,4 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
@ -7,38 +10,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var contracts_1 = require("./contracts");
|
||||
exports.Contract = contracts_1.Contract;
|
||||
exports.Interface = contracts_1.Interface;
|
||||
var providers = __importStar(require("./providers"));
|
||||
exports.providers = providers;
|
||||
var utils = __importStar(require("./utils"));
|
||||
exports.utils = utils;
|
||||
var wallet_1 = require("./wallet");
|
||||
exports.HDNode = wallet_1.HDNode;
|
||||
exports.SigningKey = wallet_1.SigningKey;
|
||||
exports.Wallet = wallet_1.Wallet;
|
||||
var wordlists = __importStar(require("./wordlists"));
|
||||
exports.wordlists = wordlists;
|
||||
var types = __importStar(require("./utils/types"));
|
||||
exports.types = types;
|
||||
var errors = __importStar(require("./utils/errors"));
|
||||
exports.errors = errors;
|
||||
var _version_1 = require("./_version");
|
||||
exports.version = _version_1.version;
|
||||
var constants = utils.constants;
|
||||
exports.constants = constants;
|
||||
exports.ethers = {
|
||||
Wallet: wallet_1.Wallet,
|
||||
HDNode: wallet_1.HDNode,
|
||||
SigningKey: wallet_1.SigningKey,
|
||||
Contract: contracts_1.Contract,
|
||||
Interface: contracts_1.Interface,
|
||||
providers: providers,
|
||||
types: types,
|
||||
errors: errors,
|
||||
constants: constants,
|
||||
utils: utils,
|
||||
wordlists: wordlists,
|
||||
version: _version_1.version
|
||||
};
|
||||
var ethers = __importStar(require("./ethers"));
|
||||
exports.ethers = ethers;
|
||||
__export(require("./ethers"));
|
||||
|
@ -28,7 +28,6 @@ var transaction_1 = require("../utils/transaction");
|
||||
var utf8_1 = require("../utils/utf8");
|
||||
var web_1 = require("../utils/web");
|
||||
var types_1 = require("../utils/types");
|
||||
//export { Block, BlockTag, EventType, Filter, Listener, Log, TransactionReceipt, TransactionRequest, TransactionResponse };
|
||||
var errors = __importStar(require("../utils/errors"));
|
||||
//////////////////////////////
|
||||
// Request and Response Checking
|
||||
|
@ -72,8 +72,8 @@ class BigNumber extends _BigNumber {
|
||||
errors.throwError('overflow', errors.NUMERIC_FAULT, { operation: 'setValue', fault: 'overflow', details: error.message });
|
||||
}
|
||||
|
||||
} else if (value instanceof _BigNumber) {
|
||||
defineReadOnly(this, '_hex', value.toHexString());
|
||||
} else if (value instanceof BigNumber) {
|
||||
defineReadOnly(this, '_hex', value._hex);
|
||||
|
||||
} else if ((<any>value).toHexString) {
|
||||
defineReadOnly(this, '_hex', toHex(toBN((<any>value).toHexString())));
|
||||
@ -175,19 +175,13 @@ class BigNumber extends _BigNumber {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
export function isBigNumber(value: any): boolean {
|
||||
return (value instanceof BigNumber);
|
||||
}
|
||||
*/
|
||||
|
||||
export function bigNumberify(value: BigNumberish): _BigNumber {
|
||||
if (value instanceof BigNumber) { return value; }
|
||||
return new BigNumber(value);
|
||||
}
|
||||
|
||||
export const ConstantNegativeOne: _BigNumber = bigNumberify(-1);
|
||||
export const ConstantZero: _BigNumber = bigNumberify(0);
|
||||
export const ConstantOne: _BigNumber = bigNumberify(1);
|
||||
export const ConstantTwo: _BigNumber = bigNumberify(2);
|
||||
export const ConstantWeiPerEther: _BigNumber = bigNumberify('1000000000000000000');
|
||||
export const ConstantNegativeOne = bigNumberify(-1);
|
||||
export const ConstantZero = bigNumberify(0);
|
||||
export const ConstantOne = bigNumberify(1);
|
||||
export const ConstantTwo = bigNumberify(2);
|
||||
export const ConstantWeiPerEther = bigNumberify('1000000000000000000');
|
||||
|
@ -21,6 +21,8 @@ import { toUtf8Bytes, toUtf8String } from './utf8';
|
||||
import { formatEther, parseEther, formatUnits, parseUnits } from './units';
|
||||
import { fetchJson } from './web';
|
||||
|
||||
import * as types from './types';
|
||||
|
||||
import * as errors from './errors';
|
||||
|
||||
// NFKD (decomposed)
|
||||
@ -48,6 +50,7 @@ export {
|
||||
parseParamType,
|
||||
|
||||
constants,
|
||||
types,
|
||||
|
||||
RLP,
|
||||
|
||||
|
@ -13,7 +13,6 @@ import { recoverAddress } from '../utils/secp256k1';
|
||||
import { serialize as serializeTransaction } from '../utils/transaction';
|
||||
|
||||
import { Arrayish, BigNumber, BlockTag, HDNode, MinimalProvider, ProgressCallback, Signer, TransactionRequest, TransactionResponse, Wordlist } from '../utils/types';
|
||||
//export { BlockTag, ProgressCallback, Signer, TransactionRequest, TransactionResponse };
|
||||
|
||||
import * as errors from '../utils/errors';
|
||||
|
||||
|
@ -1,4 +1,14 @@
|
||||
'use strict';
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
@ -20,6 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var bn_js_1 = __importDefault(require("bn.js"));
|
||||
var bytes_1 = require("./bytes");
|
||||
var properties_1 = require("./properties");
|
||||
var types_1 = require("./types");
|
||||
var errors = __importStar(require("./errors"));
|
||||
var BN_1 = new bn_js_1.default.BN(-1);
|
||||
function toHex(bn) {
|
||||
@ -39,26 +50,28 @@ function toBN(value) {
|
||||
return bigNumberify(value)._bn;
|
||||
}
|
||||
function toBigNumber(bn) {
|
||||
return new _BigNumber(toHex(bn));
|
||||
return new BigNumber(toHex(bn));
|
||||
}
|
||||
var _BigNumber = /** @class */ (function () {
|
||||
function _BigNumber(value) {
|
||||
errors.checkNew(this, _BigNumber);
|
||||
var BigNumber = /** @class */ (function (_super) {
|
||||
__extends(BigNumber, _super);
|
||||
function BigNumber(value) {
|
||||
var _this = _super.call(this) || this;
|
||||
errors.checkNew(_this, BigNumber);
|
||||
if (typeof (value) === 'string') {
|
||||
if (bytes_1.isHexString(value)) {
|
||||
if (value == '0x') {
|
||||
value = '0x0';
|
||||
}
|
||||
properties_1.defineReadOnly(this, '_hex', value);
|
||||
properties_1.defineReadOnly(_this, '_hex', value);
|
||||
}
|
||||
else if (value[0] === '-' && bytes_1.isHexString(value.substring(1))) {
|
||||
properties_1.defineReadOnly(this, '_hex', value);
|
||||
properties_1.defineReadOnly(_this, '_hex', value);
|
||||
}
|
||||
else if (value.match(/^-?[0-9]*$/)) {
|
||||
if (value == '') {
|
||||
value = '0';
|
||||
}
|
||||
properties_1.defineReadOnly(this, '_hex', toHex(new bn_js_1.default.BN(value)));
|
||||
properties_1.defineReadOnly(_this, '_hex', toHex(new bn_js_1.default.BN(value)));
|
||||
}
|
||||
else {
|
||||
errors.throwError('invalid BigNumber string value', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
@ -69,26 +82,27 @@ var _BigNumber = /** @class */ (function () {
|
||||
errors.throwError('underflow', errors.NUMERIC_FAULT, { operation: 'setValue', fault: 'underflow', value: value, outputValue: parseInt(String(value)) });
|
||||
}
|
||||
try {
|
||||
properties_1.defineReadOnly(this, '_hex', toHex(new bn_js_1.default.BN(value)));
|
||||
properties_1.defineReadOnly(_this, '_hex', toHex(new bn_js_1.default.BN(value)));
|
||||
}
|
||||
catch (error) {
|
||||
errors.throwError('overflow', errors.NUMERIC_FAULT, { operation: 'setValue', fault: 'overflow', details: error.message });
|
||||
}
|
||||
}
|
||||
else if (value instanceof _BigNumber) {
|
||||
properties_1.defineReadOnly(this, '_hex', value.toHexString());
|
||||
else if (value instanceof types_1.BigNumber) {
|
||||
properties_1.defineReadOnly(_this, '_hex', value.toHexString());
|
||||
}
|
||||
else if (value.toHexString) {
|
||||
properties_1.defineReadOnly(this, '_hex', toHex(toBN(value.toHexString())));
|
||||
properties_1.defineReadOnly(_this, '_hex', toHex(toBN(value.toHexString())));
|
||||
}
|
||||
else if (bytes_1.isArrayish(value)) {
|
||||
properties_1.defineReadOnly(this, '_hex', toHex(new bn_js_1.default.BN(bytes_1.hexlify(value).substring(2), 16)));
|
||||
properties_1.defineReadOnly(_this, '_hex', toHex(new bn_js_1.default.BN(bytes_1.hexlify(value).substring(2), 16)));
|
||||
}
|
||||
else {
|
||||
errors.throwError('invalid BigNumber value', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(_BigNumber.prototype, "_bn", {
|
||||
Object.defineProperty(BigNumber.prototype, "_bn", {
|
||||
get: function () {
|
||||
if (this._hex[0] === '-') {
|
||||
return (new bn_js_1.default.BN(this._hex.substring(3), 16)).mul(BN_1);
|
||||
@ -98,56 +112,56 @@ var _BigNumber = /** @class */ (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
_BigNumber.prototype.fromTwos = function (value) {
|
||||
BigNumber.prototype.fromTwos = function (value) {
|
||||
return toBigNumber(this._bn.fromTwos(value));
|
||||
};
|
||||
_BigNumber.prototype.toTwos = function (value) {
|
||||
BigNumber.prototype.toTwos = function (value) {
|
||||
return toBigNumber(this._bn.toTwos(value));
|
||||
};
|
||||
_BigNumber.prototype.add = function (other) {
|
||||
BigNumber.prototype.add = function (other) {
|
||||
return toBigNumber(this._bn.add(toBN(other)));
|
||||
};
|
||||
_BigNumber.prototype.sub = function (other) {
|
||||
BigNumber.prototype.sub = function (other) {
|
||||
return toBigNumber(this._bn.sub(toBN(other)));
|
||||
};
|
||||
_BigNumber.prototype.div = function (other) {
|
||||
BigNumber.prototype.div = function (other) {
|
||||
var o = bigNumberify(other);
|
||||
if (o.isZero()) {
|
||||
errors.throwError('division by zero', errors.NUMERIC_FAULT, { operation: 'divide', fault: 'division by zero' });
|
||||
}
|
||||
return toBigNumber(this._bn.div(toBN(other)));
|
||||
};
|
||||
_BigNumber.prototype.mul = function (other) {
|
||||
BigNumber.prototype.mul = function (other) {
|
||||
return toBigNumber(this._bn.mul(toBN(other)));
|
||||
};
|
||||
_BigNumber.prototype.mod = function (other) {
|
||||
BigNumber.prototype.mod = function (other) {
|
||||
return toBigNumber(this._bn.mod(toBN(other)));
|
||||
};
|
||||
_BigNumber.prototype.pow = function (other) {
|
||||
BigNumber.prototype.pow = function (other) {
|
||||
return toBigNumber(this._bn.pow(toBN(other)));
|
||||
};
|
||||
_BigNumber.prototype.maskn = function (value) {
|
||||
BigNumber.prototype.maskn = function (value) {
|
||||
return toBigNumber(this._bn.maskn(value));
|
||||
};
|
||||
_BigNumber.prototype.eq = function (other) {
|
||||
BigNumber.prototype.eq = function (other) {
|
||||
return this._bn.eq(toBN(other));
|
||||
};
|
||||
_BigNumber.prototype.lt = function (other) {
|
||||
BigNumber.prototype.lt = function (other) {
|
||||
return this._bn.lt(toBN(other));
|
||||
};
|
||||
_BigNumber.prototype.lte = function (other) {
|
||||
BigNumber.prototype.lte = function (other) {
|
||||
return this._bn.lte(toBN(other));
|
||||
};
|
||||
_BigNumber.prototype.gt = function (other) {
|
||||
BigNumber.prototype.gt = function (other) {
|
||||
return this._bn.gt(toBN(other));
|
||||
};
|
||||
_BigNumber.prototype.gte = function (other) {
|
||||
BigNumber.prototype.gte = function (other) {
|
||||
return this._bn.gte(toBN(other));
|
||||
};
|
||||
_BigNumber.prototype.isZero = function () {
|
||||
BigNumber.prototype.isZero = function () {
|
||||
return this._bn.isZero();
|
||||
};
|
||||
_BigNumber.prototype.toNumber = function () {
|
||||
BigNumber.prototype.toNumber = function () {
|
||||
try {
|
||||
return this._bn.toNumber();
|
||||
}
|
||||
@ -156,23 +170,24 @@ var _BigNumber = /** @class */ (function () {
|
||||
}
|
||||
return null;
|
||||
};
|
||||
_BigNumber.prototype.toString = function () {
|
||||
BigNumber.prototype.toString = function () {
|
||||
return this._bn.toString(10);
|
||||
};
|
||||
_BigNumber.prototype.toHexString = function () {
|
||||
BigNumber.prototype.toHexString = function () {
|
||||
return this._hex;
|
||||
};
|
||||
return _BigNumber;
|
||||
}());
|
||||
function isBigNumber(value) {
|
||||
return (value instanceof _BigNumber);
|
||||
return BigNumber;
|
||||
}(types_1.BigNumber));
|
||||
/*
|
||||
export function isBigNumber(value: any): boolean {
|
||||
return (value instanceof BigNumber);
|
||||
}
|
||||
exports.isBigNumber = isBigNumber;
|
||||
*/
|
||||
function bigNumberify(value) {
|
||||
if (value instanceof _BigNumber) {
|
||||
if (value instanceof BigNumber) {
|
||||
return value;
|
||||
}
|
||||
return new _BigNumber(value);
|
||||
return new BigNumber(value);
|
||||
}
|
||||
exports.bigNumberify = bigNumberify;
|
||||
exports.ConstantNegativeOne = bigNumberify(-1);
|
||||
|
@ -2,6 +2,14 @@
|
||||
///////////////////////////////
|
||||
// Bytes
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
///////////////////////////////
|
||||
// BigNumber
|
||||
var BigNumber = /** @class */ (function () {
|
||||
function BigNumber() {
|
||||
}
|
||||
return BigNumber;
|
||||
}());
|
||||
exports.BigNumber = BigNumber;
|
||||
;
|
||||
;
|
||||
;
|
||||
@ -37,3 +45,11 @@ var Signer = /** @class */ (function () {
|
||||
return Signer;
|
||||
}());
|
||||
exports.Signer = Signer;
|
||||
///////////////////////////////
|
||||
// HDNode
|
||||
var HDNode = /** @class */ (function () {
|
||||
function HDNode() {
|
||||
}
|
||||
return HDNode;
|
||||
}());
|
||||
exports.HDNode = HDNode;
|
||||
|
@ -1,4 +1,14 @@
|
||||
'use strict';
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
@ -23,6 +33,7 @@ var hmac_1 = require("../utils/hmac");
|
||||
var properties_1 = require("../utils/properties");
|
||||
var secp256k1_1 = require("../utils/secp256k1");
|
||||
var sha2_1 = require("../utils/sha2");
|
||||
var types_1 = require("../utils/types");
|
||||
var errors = __importStar(require("../utils/errors"));
|
||||
// "Bitcoin seed"
|
||||
var MasterSecret = utf8_1.toUtf8Bytes('Bitcoin seed');
|
||||
@ -36,7 +47,8 @@ function getLowerMask(bits) {
|
||||
return (1 << bits) - 1;
|
||||
}
|
||||
exports.defaultPath = "m/44'/60'/0'/0/0";
|
||||
var HDNode = /** @class */ (function () {
|
||||
var HDNode = /** @class */ (function (_super) {
|
||||
__extends(HDNode, _super);
|
||||
/**
|
||||
* This constructor should not be called directly.
|
||||
*
|
||||
@ -45,15 +57,17 @@ var HDNode = /** @class */ (function () {
|
||||
* - fromSeed
|
||||
*/
|
||||
function HDNode(privateKey, chainCode, index, depth, mnemonic, path) {
|
||||
errors.checkNew(this, HDNode);
|
||||
properties_1.defineReadOnly(this, 'keyPair', new secp256k1_1.KeyPair(privateKey));
|
||||
properties_1.defineReadOnly(this, 'privateKey', this.keyPair.privateKey);
|
||||
properties_1.defineReadOnly(this, 'publicKey', this.keyPair.compressedPublicKey);
|
||||
properties_1.defineReadOnly(this, 'chainCode', bytes_1.hexlify(chainCode));
|
||||
properties_1.defineReadOnly(this, 'index', index);
|
||||
properties_1.defineReadOnly(this, 'depth', depth);
|
||||
properties_1.defineReadOnly(this, 'mnemonic', mnemonic);
|
||||
properties_1.defineReadOnly(this, 'path', path);
|
||||
var _this = _super.call(this) || this;
|
||||
errors.checkNew(_this, HDNode);
|
||||
properties_1.defineReadOnly(_this, 'keyPair', new secp256k1_1.KeyPair(privateKey));
|
||||
properties_1.defineReadOnly(_this, 'privateKey', _this.keyPair.privateKey);
|
||||
properties_1.defineReadOnly(_this, 'publicKey', _this.keyPair.compressedPublicKey);
|
||||
properties_1.defineReadOnly(_this, 'chainCode', bytes_1.hexlify(chainCode));
|
||||
properties_1.defineReadOnly(_this, 'index', index);
|
||||
properties_1.defineReadOnly(_this, 'depth', depth);
|
||||
properties_1.defineReadOnly(_this, 'mnemonic', mnemonic);
|
||||
properties_1.defineReadOnly(_this, 'path', path);
|
||||
return _this;
|
||||
}
|
||||
HDNode.prototype._derive = function (index) {
|
||||
// Public parent key -> public child key
|
||||
@ -124,8 +138,7 @@ var HDNode = /** @class */ (function () {
|
||||
return result;
|
||||
};
|
||||
return HDNode;
|
||||
}());
|
||||
exports.HDNode = HDNode;
|
||||
}(types_1.HDNode));
|
||||
function _fromSeed(seed, mnemonic) {
|
||||
var seedArray = bytes_1.arrayify(seed);
|
||||
if (seedArray.length < 16 || seedArray.length > 64) {
|
||||
|
@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
*
|
||||
*/
|
||||
var bytes_1 = require("../utils/bytes");
|
||||
var hdnode_1 = require("./hdnode");
|
||||
var properties_1 = require("../utils/properties");
|
||||
var secp256k1_1 = require("../utils/secp256k1");
|
||||
var types_1 = require("../utils/types");
|
||||
var errors = require("../utils/errors");
|
||||
var SigningKey = /** @class */ (function () {
|
||||
function SigningKey(privateKey) {
|
||||
errors.checkNew(this, SigningKey);
|
||||
var privateKeyBytes = null;
|
||||
if (privateKey instanceof hdnode_1.HDNode) {
|
||||
if (privateKey instanceof types_1.HDNode) {
|
||||
properties_1.defineReadOnly(this, 'mnemonic', privateKey.mnemonic);
|
||||
properties_1.defineReadOnly(this, 'path', privateKey.path);
|
||||
privateKeyBytes = bytes_1.arrayify(privateKey.privateKey);
|
||||
|
@ -69,6 +69,9 @@ var Wallet = /** @class */ (function (_super) {
|
||||
* Create a new instance of this Wallet connected to provider.
|
||||
*/
|
||||
Wallet.prototype.connect = function (provider) {
|
||||
if (!(provider instanceof types_1.MinimalProvider)) {
|
||||
errors.throwError('invalid provider', errors.INVALID_ARGUMENT, { argument: 'provider', value: provider });
|
||||
}
|
||||
return new Wallet(this.signingKey, provider);
|
||||
};
|
||||
Wallet.prototype.getAddress = function () {
|
||||
|
Loading…
Reference in New Issue
Block a user