@waves/blockchain-api
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -1,5 +0,10 @@ | ||
import request from '../../tools/request'; | ||
import query from '../../tools/query'; | ||
export function dataKey(base, address, key, options) { | ||
return request({ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = __importDefault(require("../../tools/request")); | ||
var query_1 = __importDefault(require("../../tools/query")); | ||
function dataKey(base, address, key, options) { | ||
return request_1.default({ | ||
base: base, | ||
@@ -9,4 +14,5 @@ url: "/addresses/data/" + address + "/" + encodeURIComponent(key) | ||
} | ||
export function scriptInfoMeta(base, address, options) { | ||
return request({ | ||
exports.dataKey = dataKey; | ||
function scriptInfoMeta(base, address, options) { | ||
return request_1.default({ | ||
base: base, | ||
@@ -16,4 +22,5 @@ url: "/addresses/scriptInfo/" + address + "/meta" | ||
} | ||
export function balanceDetails(base, address, options) { | ||
return request({ | ||
exports.scriptInfoMeta = scriptInfoMeta; | ||
function balanceDetails(base, address, options) { | ||
return request_1.default({ | ||
base: base, | ||
@@ -23,4 +30,5 @@ url: "/addresses/balance/details/" + address | ||
} | ||
export function balanceConfirmations(base, address, confirmations, options) { | ||
return request({ | ||
exports.balanceDetails = balanceDetails; | ||
function balanceConfirmations(base, address, confirmations, options) { | ||
return request_1.default({ | ||
base: base, | ||
@@ -30,5 +38,6 @@ url: "/addresses/balance/" + address + "/" + confirmations | ||
} | ||
exports.balanceConfirmations = balanceConfirmations; | ||
// TODO effectiveBalanceConfirmations | ||
export function scriptInfo(base, address, options) { | ||
return request({ | ||
function scriptInfo(base, address, options) { | ||
return request_1.default({ | ||
base: base, | ||
@@ -38,18 +47,23 @@ url: "/addresses/scriptInfo/" + address | ||
} | ||
export function data(base, address, params, options) { | ||
exports.scriptInfo = scriptInfo; | ||
function data(base, address, params, options) { | ||
if (params === void 0) { params = Object.create(null); } | ||
return request({ | ||
return request_1.default({ | ||
base: base, | ||
url: "/addresses/data/" + address + query(params) | ||
url: "/addresses/data/" + address + query_1.default(params) | ||
}); | ||
} | ||
export function validate(base, address, options) { | ||
return request({ base: base, url: "/addresses/validate/" + address }); | ||
exports.data = data; | ||
function validate(base, address, options) { | ||
return request_1.default({ base: base, url: "/addresses/validate/" + address }); | ||
} | ||
export function balance(base, address, options) { | ||
return request({ base: base, url: "/addresses/balance/" + address }); | ||
exports.validate = validate; | ||
function balance(base, address, options) { | ||
return request_1.default({ base: base, url: "/addresses/balance/" + address }); | ||
} | ||
export function buildAddress(base, publicKey, options) { | ||
return request({ base: base, url: "/addresses/publicKey/" + publicKey }); | ||
exports.balance = balance; | ||
function buildAddress(base, publicKey, options) { | ||
return request_1.default({ base: base, url: "/addresses/publicKey/" + publicKey }); | ||
} | ||
exports.buildAddress = buildAddress; | ||
//# sourceMappingURL=index.js.map |
@@ -1,8 +0,14 @@ | ||
import request from '../../tools/request'; | ||
import { toArray } from '../../tools/utils'; | ||
export function details(base, assetId) { | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = __importDefault(require("../../tools/request")); | ||
var utils_1 = require("../../tools/utils"); | ||
function details(base, assetId) { | ||
var isOnce = !Array.isArray(assetId); | ||
return Promise.all(toArray(assetId).map(function (id) { return request({ base: base, url: "/assets/details/" + id }); })) | ||
return Promise.all(utils_1.toArray(assetId).map(function (id) { return request_1.default({ base: base, url: "/assets/details/" + id }); })) | ||
.then(function (list) { return isOnce ? list[0] : list; }); | ||
} | ||
exports.details = details; | ||
/** | ||
@@ -23,5 +29,6 @@ * TODO | ||
*/ | ||
export function assetsBalance(base, address) { | ||
return request({ base: base, url: "/assets/balance/" + address }); | ||
function assetsBalance(base, address) { | ||
return request_1.default({ base: base, url: "/assets/balance/" + address }); | ||
} | ||
exports.assetsBalance = assetsBalance; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,7 @@ | ||
import request from '../../tools/request'; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = __importDefault(require("../../tools/request")); | ||
//GET /blocks/headers/seq/{from}/{to} TODO | ||
@@ -8,5 +13,6 @@ //Block header range | ||
*/ | ||
export function headersLast(base, options) { | ||
return request({ base: base, url: '/blocks/headers/last' }); | ||
function headersLast(base, options) { | ||
return request_1.default({ base: base, url: '/blocks/headers/last' }); | ||
} | ||
exports.headersLast = headersLast; | ||
//GET /blocks/height/{signature} TODO | ||
@@ -19,5 +25,6 @@ //Block height | ||
*/ | ||
export function headersAt(base, height, options) { | ||
return request({ base: base, url: "/blocks/headers/at/" + height }); | ||
function headersAt(base, height, options) { | ||
return request_1.default({ base: base, url: "/blocks/headers/at/" + height }); | ||
} | ||
exports.headersAt = headersAt; | ||
/** | ||
@@ -28,5 +35,6 @@ * GET /blocks/at/{height} | ||
*/ | ||
export function blockAt(base, height) { | ||
return request({ base: base, url: "/blocks/at/" + height }); | ||
function blockAt(base, height) { | ||
return request_1.default({ base: base, url: "/blocks/at/" + height }); | ||
} | ||
exports.blockAt = blockAt; | ||
//GET /blocks/seq/{from}/{to} TODO | ||
@@ -48,5 +56,6 @@ //Block range | ||
*/ | ||
export function height(base) { | ||
return request({ base: base, url: '/blocks/height' }); | ||
function height(base) { | ||
return request_1.default({ base: base, url: '/blocks/height' }); | ||
} | ||
exports.height = height; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,7 @@ | ||
import request from '../../tools/request'; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = __importDefault(require("../../tools/request")); | ||
/** | ||
@@ -6,5 +11,6 @@ * GET /leasing/active/{address} | ||
*/ | ||
export function active(base, address) { | ||
return request({ base: base, url: "/leasing/active/" + address }); | ||
function active(base, address) { | ||
return request_1.default({ base: base, url: "/leasing/active/" + address }); | ||
} | ||
exports.active = active; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,7 @@ | ||
import request from '../../tools/request'; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = __importDefault(require("../../tools/request")); | ||
/** | ||
@@ -6,5 +11,6 @@ * GET /blockchain/rewards | ||
*/ | ||
export function rewards(base, height) { | ||
return request({ base: base, url: height ? "/blockchain/rewards/" + height : '/blockchain/rewards' }); | ||
function rewards(base, height) { | ||
return request_1.default({ base: base, url: height ? "/blockchain/rewards/" + height : '/blockchain/rewards' }); | ||
} | ||
exports.rewards = rewards; | ||
//# sourceMappingURL=index.js.map |
@@ -10,6 +10,2 @@ import { IWithProofs, TTransaction, TTransactionFromAPI, TTransactionMap } from '@waves/ts-types'; | ||
/** | ||
* POST /transactions/calculateFee | ||
* Calculate transaction fee | ||
*/ | ||
/** | ||
* TODO | ||
@@ -19,2 +15,6 @@ * POST /transactions/sign/{signerAddress} | ||
*/ | ||
/** | ||
* POST /transactions/calculateFee | ||
* Calculate transaction fee | ||
*/ | ||
export declare function calculateFee<T extends keyof TTransactionMap<TLong>>(base: string, tx: Partial<TTransactionMap<TLong>[T]> & { | ||
@@ -21,0 +21,0 @@ type: T; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
@@ -12,7 +13,11 @@ __assign = Object.assign || function(t) { | ||
}; | ||
import { TRANSACTION_STATUSES } from '../../constants'; | ||
import { height } from '../blocks'; | ||
import request from '../../tools/request'; | ||
import query from '../../tools/query'; | ||
import stringify from '../../tools/stringify'; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var constants_1 = require("../../constants"); | ||
var blocks_1 = require("../blocks"); | ||
var request_1 = __importDefault(require("../../tools/request")); | ||
var query_1 = __importDefault(require("../../tools/query")); | ||
var stringify_1 = __importDefault(require("../../tools/stringify")); | ||
/** | ||
@@ -24,6 +29,2 @@ * TODO | ||
/** | ||
* POST /transactions/calculateFee | ||
* Calculate transaction fee | ||
*/ | ||
/** | ||
* TODO | ||
@@ -33,4 +34,8 @@ * POST /transactions/sign/{signerAddress} | ||
*/ | ||
export function calculateFee(base, tx) { | ||
return request({ | ||
/** | ||
* POST /transactions/calculateFee | ||
* Calculate transaction fee | ||
*/ | ||
function calculateFee(base, tx) { | ||
return request_1.default({ | ||
base: base, | ||
@@ -40,3 +45,3 @@ url: '/transactions/calculateFee', | ||
method: 'POST', | ||
body: stringify(tx), | ||
body: stringify_1.default(tx), | ||
headers: { | ||
@@ -48,2 +53,3 @@ 'Content-Type': 'application/json' | ||
} | ||
exports.calculateFee = calculateFee; | ||
/** | ||
@@ -61,6 +67,6 @@ * TODO | ||
*/ | ||
export function transactions(base, address, limit, after, retry) { | ||
return request({ | ||
function transactions(base, address, limit, after, retry) { | ||
return request_1.default({ | ||
base: base, | ||
url: "/transactions/address/" + address + "/limit/" + limit + query({ after: after }) | ||
url: "/transactions/address/" + address + "/limit/" + limit + query_1.default({ after: after }) | ||
}).then(function (_a) { | ||
@@ -71,2 +77,3 @@ var list = _a[0]; | ||
} | ||
exports.transactions = transactions; | ||
/** | ||
@@ -76,5 +83,6 @@ * GET /transactions/unconfirmed/info/{id} | ||
*/ | ||
export function unconfirmedInfo(base, id) { | ||
return request({ base: base, url: "/transactions/unconfirmed/info/" + id }); | ||
function unconfirmedInfo(base, id) { | ||
return request_1.default({ base: base, url: "/transactions/unconfirmed/info/" + id }); | ||
} | ||
exports.unconfirmedInfo = unconfirmedInfo; | ||
/** | ||
@@ -89,6 +97,7 @@ * TODO | ||
*/ | ||
export function info(base, id) { | ||
return request({ base: base, url: "/transactions/info/" + id }); | ||
function info(base, id) { | ||
return request_1.default({ base: base, url: "/transactions/info/" + id }); | ||
} | ||
export function status(base, list) { | ||
exports.info = info; | ||
function status(base, list) { | ||
var DEFAULT_STATUS = { | ||
@@ -99,13 +108,13 @@ id: '', | ||
inUTX: false, | ||
status: TRANSACTION_STATUSES.NOT_FOUND | ||
status: constants_1.TRANSACTION_STATUSES.NOT_FOUND | ||
}; | ||
var loadAllTxInfo = list.map(function (id) { | ||
return unconfirmedInfo(base, id) | ||
.then(function () { return (__assign(__assign({}, DEFAULT_STATUS), { id: id, status: TRANSACTION_STATUSES.UNCONFIRMED, inUTX: true })); }) | ||
.then(function () { return (__assign(__assign({}, DEFAULT_STATUS), { id: id, status: constants_1.TRANSACTION_STATUSES.UNCONFIRMED, inUTX: true })); }) | ||
.catch(function () { return info(base, id) | ||
.then(function (tx) { return (__assign(__assign({}, DEFAULT_STATUS), { id: id, status: TRANSACTION_STATUSES.IN_BLOCKCHAIN, height: tx.height })); }); }) | ||
.then(function (tx) { return (__assign(__assign({}, DEFAULT_STATUS), { id: id, status: constants_1.TRANSACTION_STATUSES.IN_BLOCKCHAIN, height: tx.height })); }); }) | ||
.catch(function () { return (__assign(__assign({}, DEFAULT_STATUS), { id: id })); }); | ||
}); | ||
return Promise.all([ | ||
height(base), | ||
blocks_1.height(base), | ||
Promise.all(loadAllTxInfo) | ||
@@ -116,12 +125,13 @@ ]).then(function (_a) { | ||
height: height, | ||
statuses: statuses.map(function (item) { return (__assign(__assign({}, item), { confirmations: item.status === TRANSACTION_STATUSES.IN_BLOCKCHAIN ? height - item.height : item.confirmations })); }) | ||
statuses: statuses.map(function (item) { return (__assign(__assign({}, item), { confirmations: item.status === constants_1.TRANSACTION_STATUSES.IN_BLOCKCHAIN ? height - item.height : item.confirmations })); }) | ||
}); | ||
}); | ||
} | ||
export function broadcast(base, tx) { | ||
return request({ | ||
exports.status = status; | ||
function broadcast(base, tx) { | ||
return request_1.default({ | ||
base: base, url: '/transactions/broadcast', | ||
options: { | ||
method: 'POST', | ||
body: stringify(tx), | ||
body: stringify_1.default(tx), | ||
headers: { | ||
@@ -133,2 +143,3 @@ 'Content-Type': 'application/json' | ||
} | ||
exports.broadcast = broadcast; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,4 @@ | ||
export var TYPE_MAP = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TYPE_MAP = { | ||
3: 'issue', | ||
@@ -17,3 +19,3 @@ 4: 'transfer', | ||
}; | ||
export var NAME_MAP = { | ||
exports.NAME_MAP = { | ||
'issue': 3, | ||
@@ -34,3 +36,3 @@ 'transfer': 4, | ||
}; | ||
export var TRANSACTION_STATUSES = { | ||
exports.TRANSACTION_STATUSES = { | ||
IN_BLOCKCHAIN: 'in_blockchain', | ||
@@ -37,0 +39,0 @@ UNCONFIRMED: 'unconfirmed', |
@@ -1,20 +0,32 @@ | ||
import * as addressesModule from './api-node/addresses'; | ||
import * as blocksModule from './api-node/blocks'; | ||
import * as transactionsModule from './api-node/transactions'; | ||
import * as leasingModule from './api-node/leasing'; | ||
import query from './tools/query'; | ||
import resolve from './tools/resolve'; | ||
import request from './tools/request'; | ||
import broadcast from './tools/transactions/broadcast'; | ||
import getAssetsByTransaction from './tools/adresses/getAssetsByTransaction'; | ||
import getAssetIdListByTx from './tools/adresses/getAssetIdListByTx'; | ||
import getTransactionsWithAssets from './tools/adresses/getTransactionsWithAssets'; | ||
import availableSponsoredBalances from './tools/adresses/availableSponsoredBalances'; | ||
import wait from './tools/transactions/wait'; | ||
import parse from './tools/parse'; | ||
import getNetworkByte from './tools/blocks/getNetworkByte'; | ||
import getNetworkCode from './tools/blocks/getNetworkCode'; | ||
import createWatch from './tools/adresses/watch'; | ||
import * as toolsUtilsModule from './tools/utils'; | ||
export function create(base) { | ||
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var addressesModule = __importStar(require("./api-node/addresses")); | ||
var blocksModule = __importStar(require("./api-node/blocks")); | ||
var transactionsModule = __importStar(require("./api-node/transactions")); | ||
var leasingModule = __importStar(require("./api-node/leasing")); | ||
var query_1 = __importDefault(require("./tools/query")); | ||
var resolve_1 = __importDefault(require("./tools/resolve")); | ||
var request_1 = __importDefault(require("./tools/request")); | ||
var broadcast_1 = __importDefault(require("./tools/transactions/broadcast")); | ||
var getAssetsByTransaction_1 = __importDefault(require("./tools/adresses/getAssetsByTransaction")); | ||
var getAssetIdListByTx_1 = __importDefault(require("./tools/adresses/getAssetIdListByTx")); | ||
var getTransactionsWithAssets_1 = __importDefault(require("./tools/adresses/getTransactionsWithAssets")); | ||
var availableSponsoredBalances_1 = __importDefault(require("./tools/adresses/availableSponsoredBalances")); | ||
var wait_1 = __importDefault(require("./tools/transactions/wait")); | ||
var parse_1 = __importDefault(require("./tools/parse")); | ||
var getNetworkByte_1 = __importDefault(require("./tools/blocks/getNetworkByte")); | ||
var getNetworkCode_1 = __importDefault(require("./tools/blocks/getNetworkCode")); | ||
var watch_1 = __importDefault(require("./tools/adresses/watch")); | ||
var toolsUtilsModule = __importStar(require("./tools/utils")); | ||
function create(base) { | ||
var addresses = wrapRecord(base, addressesModule); | ||
@@ -26,21 +38,21 @@ var blocks = wrapRecord(base, blocksModule); | ||
transactions: { | ||
broadcast: wrapRequest(base, broadcast), | ||
wait: wrapRequest(base, wait) | ||
broadcast: wrapRequest(base, broadcast_1.default), | ||
wait: wrapRequest(base, wait_1.default) | ||
}, | ||
blocks: { | ||
getNetworkByte: wrapRequest(base, getNetworkByte), | ||
getNetworkCode: wrapRequest(base, getNetworkCode) | ||
getNetworkByte: wrapRequest(base, getNetworkByte_1.default), | ||
getNetworkCode: wrapRequest(base, getNetworkCode_1.default) | ||
}, | ||
addresses: { | ||
createWatch: wrapRequest(base, createWatch), | ||
getAssetsByTransaction: wrapRequest(base, getAssetsByTransaction), | ||
getAssetIdListByTx: getAssetIdListByTx, | ||
getTransactionsWithAssets: wrapRequest(base, getTransactionsWithAssets), | ||
availableSponsoredBalances: wrapRequest(base, availableSponsoredBalances) | ||
createWatch: wrapRequest(base, watch_1.default), | ||
getAssetsByTransaction: wrapRequest(base, getAssetsByTransaction_1.default), | ||
getAssetIdListByTx: getAssetIdListByTx_1.default, | ||
getTransactionsWithAssets: wrapRequest(base, getTransactionsWithAssets_1.default), | ||
availableSponsoredBalances: wrapRequest(base, availableSponsoredBalances_1.default) | ||
}, | ||
utils: toolsUtilsModule, | ||
query: query, | ||
resolve: resolve, | ||
request: request, | ||
parse: parse | ||
query: query_1.default, | ||
resolve: resolve_1.default, | ||
request: request_1.default, | ||
parse: parse_1.default | ||
}; | ||
@@ -55,3 +67,4 @@ return { | ||
} | ||
export default create; | ||
exports.create = create; | ||
exports.default = create; | ||
function wrapRecord(base, hash) { | ||
@@ -58,0 +71,0 @@ return Object.keys(hash).reduce(function (acc, methodName) { |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=interface.js.map |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.nodeApi=e():t.nodeApi=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){!function(t){"use strict";var e=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,r=Math.floor,i="[BigNumber Error] ",o=i+"Number primitive has more than 15 significant digits: ",u=1e14,s=14,c=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],a=1e7,l=1e9;function h(t){var e=0|t;return t>0||t===e?e:e-1}function p(t){for(var e,n,r=1,i=t.length,o=t[0]+"";r<i;){for(e=t[r++]+"",n=s-e.length;n--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function d(t,e){var n,r,i=t.c,o=e.c,u=t.s,s=e.s,c=t.e,f=e.e;if(!u||!s)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-s:u;if(u!=s)return u;if(n=u<0,r=c==f,!i||!o)return r?0:!i^n?1:-1;if(!r)return c>f^n?1:-1;for(s=(c=i.length)<(f=o.length)?c:f,u=0;u<s;u++)if(i[u]!=o[u])return i[u]>o[u]^n?1:-1;return c==f?0:c>f^n?1:-1}function g(t,e,n,o){if(t<e||t>n||t!==r(t))throw Error(i+(o||"Argument")+("number"==typeof t?t<e||t>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function m(t){var e=t.c.length-1;return h(t.e/s)==e&&t.c[e]%2!=0}function b(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function v(t,e,n){var r,i;if(e<0){for(i=n+".";++e;i+=n);t=i+t}else if(++e>(r=t.length)){for(i=n,e-=r;--e;i+=n);t+=i}else e<r&&(t=t.slice(0,e)+"."+t.slice(e));return t}var y=function t(y){var w,O,N,_,A,B,E,I,R,U=q.prototype={constructor:q,toString:null,valueOf:null},D=new q(1),T=20,F=4,L=-7,S=21,P=-1e7,j=1e7,x=!1,M=1,C=0,k={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz";function q(t,n){var i,u,f,a,l,h,p,d,m=this;if(!(m instanceof q))return new q(t,n);if(null==n){if(t&&!0===t._isBigNumber)return m.s=t.s,void(!t.c||t.e>j?m.c=m.e=null:t.e<P?m.c=[m.e=0]:(m.e=t.e,m.c=t.c.slice()));if((h="number"==typeof t)&&0*t==0){if(m.s=1/t<0?(t=-t,-1):1,t===~~t){for(a=0,l=t;l>=10;l/=10,a++);return void(a>j?m.c=m.e=null:(m.e=a,m.c=[t]))}d=String(t)}else{if(!e.test(d=String(t)))return N(m,d,h);m.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(a=d.indexOf("."))>-1&&(d=d.replace(".","")),(l=d.search(/e/i))>0?(a<0&&(a=l),a+=+d.slice(l+1),d=d.substring(0,l)):a<0&&(a=d.length)}else{if(g(n,2,H.length,"Base"),10==n)return $(m=new q(t),T+m.e+1,F);if(d=String(t),h="number"==typeof t){if(0*t!=0)return N(m,d,h,n);if(m.s=1/t<0?(d=d.slice(1),-1):1,q.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(o+t)}else m.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1;for(i=H.slice(0,n),a=l=0,p=d.length;l<p;l++)if(i.indexOf(u=d.charAt(l))<0){if("."==u){if(l>a){a=p;continue}}else if(!f&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){f=!0,l=-1,a=0;continue}return N(m,String(t),h,n)}h=!1,(a=(d=O(d,n,10,m.s)).indexOf("."))>-1?d=d.replace(".",""):a=d.length}for(l=0;48===d.charCodeAt(l);l++);for(p=d.length;48===d.charCodeAt(--p););if(d=d.slice(l,++p)){if(p-=l,h&&q.DEBUG&&p>15&&(t>c||t!==r(t)))throw Error(o+m.s*t);if((a=a-l-1)>j)m.c=m.e=null;else if(a<P)m.c=[m.e=0];else{if(m.e=a,m.c=[],l=(a+1)%s,a<0&&(l+=s),l<p){for(l&&m.c.push(+d.slice(0,l)),p-=s;l<p;)m.c.push(+d.slice(l,l+=s));l=s-(d=d.slice(l)).length}else l-=p;for(;l--;d+="0");m.c.push(+d)}}else m.c=[m.e=0]}function G(t,e,n,r){var i,o,u,s,c;if(null==n?n=F:g(n,0,8),!t.c)return t.toString();if(i=t.c[0],u=t.e,null==e)c=p(t.c),c=1==r||2==r&&(u<=L||u>=S)?b(c,u):v(c,u,"0");else if(o=(t=$(new q(t),e,n)).e,s=(c=p(t.c)).length,1==r||2==r&&(e<=o||o<=L)){for(;s<e;c+="0",s++);c=b(c,o)}else if(e-=u,c=v(c,o,"0"),o+1>s){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=o-s)>0)for(o+1==s&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function J(t,e){for(var n,r=1,i=new q(t[0]);r<t.length;r++){if(!(n=new q(t[r])).s){i=n;break}e.call(i,n)&&(i=n)}return i}function W(t,e,n){for(var r=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,r++);return(n=r+n*s-1)>j?t.c=t.e=null:n<P?t.c=[t.e=0]:(t.e=n,t.c=e),t}function $(t,e,i,o){var c,a,l,h,p,d,g,m=t.c,b=f;if(m){t:{for(c=1,h=m[0];h>=10;h/=10,c++);if((a=e-c)<0)a+=s,l=e,g=(p=m[d=0])/b[c-l-1]%10|0;else if((d=n((a+1)/s))>=m.length){if(!o)break t;for(;m.length<=d;m.push(0));p=g=0,c=1,l=(a%=s)-s+1}else{for(p=h=m[d],c=1;h>=10;h/=10,c++);g=(l=(a%=s)-s+c)<0?0:p/b[c-l-1]%10|0}if(o=o||e<0||null!=m[d+1]||(l<0?p:p%b[c-l-1]),o=i<4?(g||o)&&(0==i||i==(t.s<0?3:2)):g>5||5==g&&(4==i||o||6==i&&(a>0?l>0?p/b[c-l]:0:m[d-1])%10&1||i==(t.s<0?8:7)),e<1||!m[0])return m.length=0,o?(e-=t.e+1,m[0]=b[(s-e%s)%s],t.e=-e||0):m[0]=t.e=0,t;if(0==a?(m.length=d,h=1,d--):(m.length=d+1,h=b[s-a],m[d]=l>0?r(p/b[c-l]%b[l])*h:0),o)for(;;){if(0==d){for(a=1,l=m[0];l>=10;l/=10,a++);for(l=m[0]+=h,h=1;l>=10;l/=10,h++);a!=h&&(t.e++,m[0]==u&&(m[0]=1));break}if(m[d]+=h,m[d]!=u)break;m[d--]=0,h=1}for(a=m.length;0===m[--a];m.pop());}t.e>j?t.c=t.e=null:t.e<P&&(t.c=[t.e=0])}return t}function V(t){var e,n=t.e;return null===n?t.toString():(e=p(t.c),e=n<=L||n>=S?b(e,n):v(e,n,"0"),t.s<0?"-"+e:e)}return q.clone=t,q.ROUND_UP=0,q.ROUND_DOWN=1,q.ROUND_CEIL=2,q.ROUND_FLOOR=3,q.ROUND_HALF_UP=4,q.ROUND_HALF_DOWN=5,q.ROUND_HALF_EVEN=6,q.ROUND_HALF_CEIL=7,q.ROUND_HALF_FLOOR=8,q.EUCLID=9,q.config=q.set=function(t){var e,n;if(null!=t){if("object"!=typeof t)throw Error(i+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(g(n=t[e],0,l,e),T=n),t.hasOwnProperty(e="ROUNDING_MODE")&&(g(n=t[e],0,8,e),F=n),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((n=t[e])&&n.pop?(g(n[0],-l,0,e),g(n[1],0,l,e),L=n[0],S=n[1]):(g(n,-l,l,e),L=-(S=n<0?-n:n))),t.hasOwnProperty(e="RANGE"))if((n=t[e])&&n.pop)g(n[0],-l,-1,e),g(n[1],1,l,e),P=n[0],j=n[1];else{if(g(n,-l,l,e),!n)throw Error(i+e+" cannot be zero: "+n);P=-(j=n<0?-n:n)}if(t.hasOwnProperty(e="CRYPTO")){if((n=t[e])!==!!n)throw Error(i+e+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw x=!n,Error(i+"crypto unavailable");x=n}else x=n}if(t.hasOwnProperty(e="MODULO_MODE")&&(g(n=t[e],0,9,e),M=n),t.hasOwnProperty(e="POW_PRECISION")&&(g(n=t[e],0,l,e),C=n),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(n=t[e]))throw Error(i+e+" not an object: "+n);k=n}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(n=t[e])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(i+e+" invalid: "+n);H=n}}return{DECIMAL_PLACES:T,ROUNDING_MODE:F,EXPONENTIAL_AT:[L,S],RANGE:[P,j],CRYPTO:x,MODULO_MODE:M,POW_PRECISION:C,FORMAT:k,ALPHABET:H}},q.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!q.DEBUG)return!0;var e,n,o=t.c,c=t.e,f=t.s;t:if("[object Array]"=={}.toString.call(o)){if((1===f||-1===f)&&c>=-l&&c<=l&&c===r(c)){if(0===o[0]){if(0===c&&1===o.length)return!0;break t}if((e=(c+1)%s)<1&&(e+=s),String(o[0]).length==e){for(e=0;e<o.length;e++)if((n=o[e])<0||n>=u||n!==r(n))break t;if(0!==n)return!0}}}else if(null===o&&null===c&&(null===f||1===f||-1===f))return!0;throw Error(i+"Invalid BigNumber: "+t)},q.maximum=q.max=function(){return J(arguments,U.lt)},q.minimum=q.min=function(){return J(arguments,U.gt)},q.random=(_=9007199254740992*Math.random()&2097151?function(){return r(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,o,u,c,a,h=0,p=[],d=new q(D);if(null==t?t=T:g(t,0,l),c=n(t/s),x)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(c*=2));h<c;)(a=131072*e[h]+(e[h+1]>>>11))>=9e15?(o=crypto.getRandomValues(new Uint32Array(2)),e[h]=o[0],e[h+1]=o[1]):(p.push(a%1e14),h+=2);h=c/2}else{if(!crypto.randomBytes)throw x=!1,Error(i+"crypto unavailable");for(e=crypto.randomBytes(c*=7);h<c;)(a=281474976710656*(31&e[h])+1099511627776*e[h+1]+4294967296*e[h+2]+16777216*e[h+3]+(e[h+4]<<16)+(e[h+5]<<8)+e[h+6])>=9e15?crypto.randomBytes(7).copy(e,h):(p.push(a%1e14),h+=7);h=c/7}if(!x)for(;h<c;)(a=_())<9e15&&(p[h++]=a%1e14);for(c=p[--h],t%=s,c&&t&&(a=f[s-t],p[h]=r(c/a)*a);0===p[h];p.pop(),h--);if(h<0)p=[u=0];else{for(u=-1;0===p[0];p.splice(0,1),u-=s);for(h=1,a=p[0];a>=10;a/=10,h++);h<s&&(u-=s-h)}return d.e=u,d.c=p,d}),q.sum=function(){for(var t=1,e=arguments,n=new q(e[0]);t<e.length;)n=n.plus(e[t++]);return n},O=function(){function t(t,e,n,r){for(var i,o,u=[0],s=0,c=t.length;s<c;){for(o=u.length;o--;u[o]*=e);for(u[0]+=r.indexOf(t.charAt(s++)),i=0;i<u.length;i++)u[i]>n-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/n|0,u[i]%=n)}return u.reverse()}return function(e,n,r,i,o){var u,s,c,f,a,l,h,d,g=e.indexOf("."),m=T,b=F;for(g>=0&&(f=C,C=0,e=e.replace(".",""),l=(d=new q(n)).pow(e.length-g),C=f,d.c=t(v(p(l.c),l.e,"0"),10,r,"0123456789"),d.e=d.c.length),c=f=(h=t(e,n,r,o?(u=H,"0123456789"):(u="0123456789",H))).length;0==h[--f];h.pop());if(!h[0])return u.charAt(0);if(g<0?--c:(l.c=h,l.e=c,l.s=i,h=(l=w(l,d,m,b,r)).c,a=l.r,c=l.e),g=h[s=c+m+1],f=r/2,a=a||s<0||null!=h[s+1],a=b<4?(null!=g||a)&&(0==b||b==(l.s<0?3:2)):g>f||g==f&&(4==b||a||6==b&&1&h[s-1]||b==(l.s<0?8:7)),s<1||!h[0])e=a?v(u.charAt(1),-m,u.charAt(0)):u.charAt(0);else{if(h.length=s,a)for(--r;++h[--s]>r;)h[s]=0,s||(++c,h=[1].concat(h));for(f=h.length;!h[--f];);for(g=0,e="";g<=f;e+=u.charAt(h[g++]));e=v(e,c,u.charAt(0))}return e}}(),w=function(){function t(t,e,n){var r,i,o,u,s=0,c=t.length,f=e%a,l=e/a|0;for(t=t.slice();c--;)s=((i=f*(o=t[c]%a)+(r=l*o+(u=t[c]/a|0)*f)%a*a+s)/n|0)+(r/a|0)+l*u,t[c]=i%n;return s&&(t=[s].concat(t)),t}function e(t,e,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;i<n;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function n(t,e,n,r){for(var i=0;n--;)t[n]-=i,i=t[n]<e[n]?1:0,t[n]=i*r+t[n]-e[n];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(i,o,c,f,a){var l,p,d,g,m,b,v,y,w,O,N,_,A,B,E,I,R,U=i.s==o.s?1:-1,D=i.c,T=o.c;if(!(D&&D[0]&&T&&T[0]))return new q(i.s&&o.s&&(D?!T||D[0]!=T[0]:T)?D&&0==D[0]||!T?0*U:U/0:NaN);for(w=(y=new q(U)).c=[],U=c+(p=i.e-o.e)+1,a||(a=u,p=h(i.e/s)-h(o.e/s),U=U/s|0),d=0;T[d]==(D[d]||0);d++);if(T[d]>(D[d]||0)&&p--,U<0)w.push(1),g=!0;else{for(B=D.length,I=T.length,d=0,U+=2,(m=r(a/(T[0]+1)))>1&&(T=t(T,m,a),D=t(D,m,a),I=T.length,B=D.length),A=I,N=(O=D.slice(0,I)).length;N<I;O[N++]=0);R=T.slice(),R=[0].concat(R),E=T[0],T[1]>=a/2&&E++;do{if(m=0,(l=e(T,O,I,N))<0){if(_=O[0],I!=N&&(_=_*a+(O[1]||0)),(m=r(_/E))>1)for(m>=a&&(m=a-1),v=(b=t(T,m,a)).length,N=O.length;1==e(b,O,v,N);)m--,n(b,I<v?R:T,v,a),v=b.length,l=1;else 0==m&&(l=m=1),v=(b=T.slice()).length;if(v<N&&(b=[0].concat(b)),n(O,b,N,a),N=O.length,-1==l)for(;e(T,O,I,N)<1;)m++,n(O,I<N?R:T,N,a),N=O.length}else 0===l&&(m++,O=[0]);w[d++]=m,O[0]?O[N++]=D[A]||0:(O=[D[A]],N=1)}while((A++<B||null!=O[0])&&U--);g=null!=O[0],w[0]||w.splice(0,1)}if(a==u){for(d=1,U=w[0];U>=10;U/=10,d++);$(y,c+(y.e=d+p*s-1)+1,f,g)}else y.e=p,y.r=+g;return y}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,B=/^([^.]+)\.$/,E=/^\.([^.]+)$/,I=/^-?(Infinity|NaN)$/,R=/^\s*\+(?=[\w.])|^\s+|\s+$/g,N=function(t,e,n,r){var o,u=n?e:e.replace(R,"");if(I.test(u))t.s=isNaN(u)?null:u<0?-1:1;else{if(!n&&(u=u.replace(A,(function(t,e,n){return o="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=o?t:e})),r&&(o=r,u=u.replace(B,"$1").replace(E,"0.$1")),e!=u))return new q(u,o);if(q.DEBUG)throw Error(i+"Not a"+(r?" base "+r:"")+" number: "+e);t.s=null}t.c=t.e=null},U.absoluteValue=U.abs=function(){var t=new q(this);return t.s<0&&(t.s=1),t},U.comparedTo=function(t,e){return d(this,new q(t,e))},U.decimalPlaces=U.dp=function(t,e){var n,r,i,o=this;if(null!=t)return g(t,0,l),null==e?e=F:g(e,0,8),$(new q(o),t+o.e+1,e);if(!(n=o.c))return null;if(r=((i=n.length-1)-h(this.e/s))*s,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},U.dividedBy=U.div=function(t,e){return w(this,new q(t,e),T,F)},U.dividedToIntegerBy=U.idiv=function(t,e){return w(this,new q(t,e),0,1)},U.exponentiatedBy=U.pow=function(t,e){var o,u,c,f,a,l,h,p,d=this;if((t=new q(t)).c&&!t.isInteger())throw Error(i+"Exponent not an integer: "+V(t));if(null!=e&&(e=new q(e)),a=t.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!t.c||!t.c[0])return p=new q(Math.pow(+V(d),a?2-m(t):+V(t))),e?p.mod(e):p;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new q(NaN);(u=!l&&d.isInteger()&&e.isInteger())&&(d=d.mod(e))}else{if(t.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||a&&d.c[1]>=24e7:d.c[0]<8e13||a&&d.c[0]<=9999975e7)))return f=d.s<0&&m(t)?-0:0,d.e>-1&&(f=1/f),new q(l?1/f:f);C&&(f=n(C/s+2))}for(a?(o=new q(.5),l&&(t.s=1),h=m(t)):h=(c=Math.abs(+V(t)))%2,p=new q(D);;){if(h){if(!(p=p.times(d)).c)break;f?p.c.length>f&&(p.c.length=f):u&&(p=p.mod(e))}if(c){if(0===(c=r(c/2)))break;h=c%2}else if($(t=t.times(o),t.e+1,1),t.e>14)h=m(t);else{if(0==(c=+V(t)))break;h=c%2}d=d.times(d),f?d.c&&d.c.length>f&&(d.c.length=f):u&&(d=d.mod(e))}return u?p:(l&&(p=D.div(p)),e?p.mod(e):f?$(p,C,F,void 0):p)},U.integerValue=function(t){var e=new q(this);return null==t?t=F:g(t,0,8),$(e,e.e+1,t)},U.isEqualTo=U.eq=function(t,e){return 0===d(this,new q(t,e))},U.isFinite=function(){return!!this.c},U.isGreaterThan=U.gt=function(t,e){return d(this,new q(t,e))>0},U.isGreaterThanOrEqualTo=U.gte=function(t,e){return 1===(e=d(this,new q(t,e)))||0===e},U.isInteger=function(){return!!this.c&&h(this.e/s)>this.c.length-2},U.isLessThan=U.lt=function(t,e){return d(this,new q(t,e))<0},U.isLessThanOrEqualTo=U.lte=function(t,e){return-1===(e=d(this,new q(t,e)))||0===e},U.isNaN=function(){return!this.s},U.isNegative=function(){return this.s<0},U.isPositive=function(){return this.s>0},U.isZero=function(){return!!this.c&&0==this.c[0]},U.minus=function(t,e){var n,r,i,o,c=this,f=c.s;if(e=(t=new q(t,e)).s,!f||!e)return new q(NaN);if(f!=e)return t.s=-e,c.plus(t);var a=c.e/s,l=t.e/s,p=c.c,d=t.c;if(!a||!l){if(!p||!d)return p?(t.s=-e,t):new q(d?c:NaN);if(!p[0]||!d[0])return d[0]?(t.s=-e,t):new q(p[0]?c:3==F?-0:0)}if(a=h(a),l=h(l),p=p.slice(),f=a-l){for((o=f<0)?(f=-f,i=p):(l=a,i=d),i.reverse(),e=f;e--;i.push(0));i.reverse()}else for(r=(o=(f=p.length)<(e=d.length))?f:e,f=e=0;e<r;e++)if(p[e]!=d[e]){o=p[e]<d[e];break}if(o&&(i=p,p=d,d=i,t.s=-t.s),(e=(r=d.length)-(n=p.length))>0)for(;e--;p[n++]=0);for(e=u-1;r>f;){if(p[--r]<d[r]){for(n=r;n&&!p[--n];p[n]=e);--p[n],p[r]+=u}p[r]-=d[r]}for(;0==p[0];p.splice(0,1),--l);return p[0]?W(t,p,l):(t.s=3==F?-1:1,t.c=[t.e=0],t)},U.modulo=U.mod=function(t,e){var n,r,i=this;return t=new q(t,e),!i.c||!t.s||t.c&&!t.c[0]?new q(NaN):!t.c||i.c&&!i.c[0]?new q(i):(9==M?(r=t.s,t.s=1,n=w(i,t,0,3),t.s=r,n.s*=r):n=w(i,t,0,M),(t=i.minus(n.times(t))).c[0]||1!=M||(t.s=i.s),t)},U.multipliedBy=U.times=function(t,e){var n,r,i,o,c,f,l,p,d,g,m,b,v,y,w,O=this,N=O.c,_=(t=new q(t,e)).c;if(!(N&&_&&N[0]&&_[0]))return!O.s||!t.s||N&&!N[0]&&!_||_&&!_[0]&&!N?t.c=t.e=t.s=null:(t.s*=O.s,N&&_?(t.c=[0],t.e=0):t.c=t.e=null),t;for(r=h(O.e/s)+h(t.e/s),t.s*=O.s,(l=N.length)<(g=_.length)&&(v=N,N=_,_=v,i=l,l=g,g=i),i=l+g,v=[];i--;v.push(0));for(y=u,w=a,i=g;--i>=0;){for(n=0,m=_[i]%w,b=_[i]/w|0,o=i+(c=l);o>i;)n=((p=m*(p=N[--c]%w)+(f=b*p+(d=N[c]/w|0)*m)%w*w+v[o]+n)/y|0)+(f/w|0)+b*d,v[o--]=p%y;v[o]=n}return n?++r:v.splice(0,1),W(t,v,r)},U.negated=function(){var t=new q(this);return t.s=-t.s||null,t},U.plus=function(t,e){var n,r=this,i=r.s;if(e=(t=new q(t,e)).s,!i||!e)return new q(NaN);if(i!=e)return t.s=-e,r.minus(t);var o=r.e/s,c=t.e/s,f=r.c,a=t.c;if(!o||!c){if(!f||!a)return new q(i/0);if(!f[0]||!a[0])return a[0]?t:new q(f[0]?r:0*i)}if(o=h(o),c=h(c),f=f.slice(),i=o-c){for(i>0?(c=o,n=a):(i=-i,n=f),n.reverse();i--;n.push(0));n.reverse()}for((i=f.length)-(e=a.length)<0&&(n=a,a=f,f=n,e=i),i=0;e;)i=(f[--e]=f[e]+a[e]+i)/u|0,f[e]=u===f[e]?0:f[e]%u;return i&&(f=[i].concat(f),++c),W(t,f,c)},U.precision=U.sd=function(t,e){var n,r,i,o=this;if(null!=t&&t!==!!t)return g(t,1,l),null==e?e=F:g(e,0,8),$(new q(o),t,e);if(!(n=o.c))return null;if(r=(i=n.length-1)*s+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return t&&o.e+1>r&&(r=o.e+1),r},U.shiftedBy=function(t){return g(t,-c,c),this.times("1e"+t)},U.squareRoot=U.sqrt=function(){var t,e,n,r,i,o=this,u=o.c,s=o.s,c=o.e,f=T+4,a=new q("0.5");if(1!==s||!u||!u[0])return new q(!s||s<0&&(!u||u[0])?NaN:u?o:1/0);if(0==(s=Math.sqrt(+V(o)))||s==1/0?(((e=p(u)).length+c)%2==0&&(e+="0"),s=Math.sqrt(+e),c=h((c+1)/2)-(c<0||c%2),n=new q(e=s==1/0?"1e"+c:(e=s.toExponential()).slice(0,e.indexOf("e")+1)+c)):n=new q(s+""),n.c[0])for((s=(c=n.e)+f)<3&&(s=0);;)if(i=n,n=a.times(i.plus(w(o,i,f,1))),p(i.c).slice(0,s)===(e=p(n.c)).slice(0,s)){if(n.e<c&&--s,"9999"!=(e=e.slice(s-3,s+1))&&(r||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||($(n,n.e+T+2,1),t=!n.times(n).eq(o));break}if(!r&&($(i,i.e+T+2,0),i.times(i).eq(o))){n=i;break}f+=4,s+=4,r=1}return $(n,n.e+T+1,F,t)},U.toExponential=function(t,e){return null!=t&&(g(t,0,l),t++),G(this,t,e,1)},U.toFixed=function(t,e){return null!=t&&(g(t,0,l),t=t+this.e+1),G(this,t,e)},U.toFormat=function(t,e,n){var r,o=this;if(null==n)null!=t&&e&&"object"==typeof e?(n=e,e=null):t&&"object"==typeof t?(n=t,t=e=null):n=k;else if("object"!=typeof n)throw Error(i+"Argument not an object: "+n);if(r=o.toFixed(t,e),o.c){var u,s=r.split("."),c=+n.groupSize,f=+n.secondaryGroupSize,a=n.groupSeparator||"",l=s[0],h=s[1],p=o.s<0,d=p?l.slice(1):l,g=d.length;if(f&&(u=c,c=f,f=u,g-=u),c>0&&g>0){for(u=g%c||c,l=d.substr(0,u);u<g;u+=c)l+=a+d.substr(u,c);f>0&&(l+=a+d.slice(u)),p&&(l="-"+l)}r=h?l+(n.decimalSeparator||"")+((f=+n.fractionGroupSize)?h.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):h):l}return(n.prefix||"")+r+(n.suffix||"")},U.toFraction=function(t){var e,n,r,o,u,c,a,l,h,d,g,m,b=this,v=b.c;if(null!=t&&(!(a=new q(t)).isInteger()&&(a.c||1!==a.s)||a.lt(D)))throw Error(i+"Argument "+(a.isInteger()?"out of range: ":"not an integer: ")+V(a));if(!v)return new q(b);for(e=new q(D),h=n=new q(D),r=l=new q(D),m=p(v),u=e.e=m.length-b.e-1,e.c[0]=f[(c=u%s)<0?s+c:c],t=!t||a.comparedTo(e)>0?u>0?e:h:a,c=j,j=1/0,a=new q(m),l.c[0]=0;d=w(a,e,0,1),1!=(o=n.plus(d.times(r))).comparedTo(t);)n=r,r=o,h=l.plus(d.times(o=h)),l=o,e=a.minus(d.times(o=e)),a=o;return o=w(t.minus(n),r,0,1),l=l.plus(o.times(h)),n=n.plus(o.times(r)),l.s=h.s=b.s,g=w(h,r,u*=2,F).minus(b).abs().comparedTo(w(l,n,u,F).minus(b).abs())<1?[h,r]:[l,n],j=c,g},U.toNumber=function(){return+V(this)},U.toPrecision=function(t,e){return null!=t&&g(t,1,l),G(this,t,e,2)},U.toString=function(t){var e,n=this,r=n.s,i=n.e;return null===i?r?(e="Infinity",r<0&&(e="-"+e)):e="NaN":(null==t?e=i<=L||i>=S?b(p(n.c),i):v(p(n.c),i,"0"):10===t?e=v(p((n=$(new q(n),T+i+1,F)).c),n.e,"0"):(g(t,2,H.length,"Base"),e=O(v(p(n.c),i,"0"),10,t,r,!0)),r<0&&n.c[0]&&(e="-"+e)),e},U.valueOf=U.toJSON=function(){return V(this)},U._isBigNumber=!0,U[Symbol.toStringTag]="BigNumber",U[Symbol.for("nodejs.util.inspect.custom")]=U.valueOf,null!=y&&q.set(y),q}(),w=function(){return(w=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},O=function(){function t(){this.format=t.DEFAULT_FORMAT,y.config({FORMAT:this.format})}return t.prototype.set=function(t){"FORMAT"in t&&(this.format=w({},this.format,t.FORMAT),t.FORMAT=this.format),y.config(t)},t.DEFAULT_FORMAT={prefix:"",decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0,suffix:""},t}();t.BigNumber=function(){function t(e){"object"==typeof e&&t.isBigNumber(e)?this.bn=e.bn.plus(0):this.bn=t.toBigNumberJs(e)}return t.prototype.clone=function(){return new t(this)},t.prototype.add=function(e){return new t(this.bn.plus(t.toBigNumberJs(e)))},t.prototype.sub=function(e){return new t(this.bn.minus(t.toBigNumberJs(e)))},t.prototype.mul=function(e){return new t(this.bn.times(t.toBigNumberJs(e)))},t.prototype.div=function(e){return new t(this.bn.div(t.toBigNumberJs(e)))},t.prototype.pow=function(e){return new t(this.bn.pow(t.toBigNumberJs(e)))},t.prototype.abs=function(){return new t(this.bn.abs())},t.prototype.mod=function(e){return new t(this.bn.mod(t.toBigNumberJs(e)))},t.prototype.roundTo=function(e,n){return void 0===e&&(e=0),void 0===n&&(n=4),new t(this.bn.dp(e||0,n))},t.prototype.eq=function(e){return this.bn.eq(t.toBigNumberJs(e))},t.prototype.lt=function(e){return this.bn.lt(t.toBigNumberJs(e))},t.prototype.gt=function(e){return this.bn.gt(t.toBigNumberJs(e))},t.prototype.lte=function(e){return this.bn.lte(t.toBigNumberJs(e))},t.prototype.gte=function(e){return this.bn.gte(t.toBigNumberJs(e))},t.prototype.isNaN=function(){return this.bn.isNaN()},t.prototype.isFinite=function(){return this.bn.isFinite()},t.prototype.isZero=function(){return this.eq(0)},t.prototype.isPositive=function(){return this.gt(0)},t.prototype.isNegative=function(){return this.lt(0)},t.prototype.isInt=function(){return this.bn.isInteger()},t.prototype.getDecimalsCount=function(){return this.bn.dp()},t.prototype.isEven=function(){return this.mod(2).eq(0)},t.prototype.isOdd=function(){return!this.isEven()},t.prototype.toBytes=function(){if(!this.isInt())throw new Error("Cant create bytes from number with decimals!");var e=this.isNegative(),n=e?"1":"0",r=t._toLength(64,this.bn.plus(n).abs().toString(2).replace("-","")).split(""),i=[];do{i.push(parseInt(r.splice(0,8).join(""),2))}while(r.length);return e?Uint8Array.from(i.map((function(t){return 255-t}))):Uint8Array.from(i)},t.prototype.toFormat=function(t,e,n){return this.bn.toFormat(t,e,n)},t.prototype.toFixed=function(t,e){return null==t?this.bn.toFixed():this.bn.toFixed(t,e)},t.prototype.toString=function(){return this.toFixed()},t.prototype.toNumber=function(){return this.bn.toNumber()},t.prototype.toJSON=function(){return this.bn.toFixed()},t.prototype.valueOf=function(){return this.bn.valueOf()},t.fromBytes=function(e){if(8!==e.length)throw new Error("Wrong bytes length! Need 8 bytes!");var n=e[0]>127,r=Array.from(e).map((function(t){return n?255-t:t})).map((function(e){return t._toLength(8,e.toString(2))})).join(""),i=new t(new y(r,2));return n?i.mul(-1).sub(1):i},t.max=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.toBigNumber(e).reduce((function(t,e){return t.gte(e)?t:e}))},t.min=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.toBigNumber(e).reduce((function(t,e){return t.lte(e)?t:e}))},t.sum=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.toBigNumber(e).reduce((function(t,e){return t.add(e)}))},t.isBigNumber=function(e){return e&&"object"==typeof e&&(e instanceof t||Object.entries(t.prototype).filter((function(t){return"_"!==t[0].charAt(0)})).every((function(t){var n=t[0],r=t[1];return n in e&&typeof r==typeof e[n]})))},t.toBigNumber=function(e){return Array.isArray(e)?e.map((function(e){return new t(e)})):new t(e)},t.toBigNumberJs=function(e){return y.isBigNumber(e)?e:e instanceof t?e.bn:new y(e)},t._toLength=function(t,e){return new Array(t).fill("0",0,t).concat(e.split("")).slice(-t).join("")},t.MAX_VALUE=new t("9223372036854775807"),t.MIN_VALUE=new t("-9223372036854775808"),t.MAX_UNSIGNED_VALUE=new t("18446744073709551615"),t.config=new O,t}(),function(t){!function(t){t[t.ROUND_UP=0]="ROUND_UP",t[t.ROUND_DOWN=1]="ROUND_DOWN",t[t.ROUND_CEIL=2]="ROUND_CEIL",t[t.ROUND_FLOOR=3]="ROUND_FLOOR",t[t.ROUND_HALF_UP=4]="ROUND_HALF_UP",t[t.ROUND_HALF_DOWN=5]="ROUND_HALF_DOWN",t[t.ROUND_HALF_EVEN=6]="ROUND_HALF_EVEN",t[t.ROUND_HALF_CEIL=7]="ROUND_HALF_CEIL",t[t.ROUND_HALF_FLOOR=8]="ROUND_HALF_FLOOR"}(t.ROUND_MODE||(t.ROUND_MODE={}))}(t.BigNumber||(t.BigNumber={}));var N=t.BigNumber;t.default=N,Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e,n){"use strict";e.__esModule=!0,function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(3))},function(t,e,n){"use strict";var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();t.exports=e=r.fetch,e.default=r.fetch.bind(r),e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){function t(){this._events=Object.create(null)}return t.prototype.hasListeners=function(t){return!(!this._events[t]||!this._events[t].length)},t.prototype.getActiveEvents=function(){var t=this;return Object.keys(this._events).filter((function(e){return t.hasListeners(e)}))},t.prototype.trigger=function(t,e){this._events[t]&&(this._events[t]=this._events[t].filter((function(t){try{t.handler.call(t.context,e)}catch(t){}return!t.once})),this._events[t].length||delete this._events[t])},t.prototype.on=function(t,e,n){this._on(t,e,n,!1)},t.prototype.once=function(t,e,n){this._on(t,e,n,!0)},t.prototype.off=function(t,e){var n=this,r="string"==typeof t?t:null,i="function"==typeof e?e:"function"==typeof t?t:null;r?i?r in this._events&&(this._events[r]=this._events[r].filter((function(t){return t.handler!==i}))):delete this._events[r]:Object.keys(this._events).forEach((function(t){n.off(t,i)}))},t.prototype._on=function(t,e,n,r){this._events[t]||(this._events[t]=[]),this._events[t].push({handler:e,context:n,once:r})},t}();e.EventEmitter=r},function(t,e,n){"use strict";n.r(e);var r={};n.r(r),n.d(r,"dataKey",(function(){return g})),n.d(r,"scriptInfoMeta",(function(){return m})),n.d(r,"balanceDetails",(function(){return b})),n.d(r,"balanceConfirmations",(function(){return v})),n.d(r,"scriptInfo",(function(){return y})),n.d(r,"data",(function(){return w})),n.d(r,"validate",(function(){return O})),n.d(r,"balance",(function(){return N})),n.d(r,"buildAddress",(function(){return _}));var i={};n.r(i),n.d(i,"headersLast",(function(){return A})),n.d(i,"headersAt",(function(){return B})),n.d(i,"blockAt",(function(){return E})),n.d(i,"height",(function(){return I}));var o={};n.r(o),n.d(o,"calculateFee",(function(){return k})),n.d(o,"transactions",(function(){return H})),n.d(o,"unconfirmedInfo",(function(){return q})),n.d(o,"info",(function(){return G})),n.d(o,"status",(function(){return J})),n.d(o,"broadcast",(function(){return W}));var u={};n.r(u),n.d(u,"active",(function(){return $}));var s={};n.r(s),n.d(s,"toArray",(function(){return V})),n.d(s,"head",(function(){return z})),n.d(s,"wait",(function(){return X})),n.d(s,"prop",(function(){return K})),n.d(s,"keys",(function(){return Y})),n.d(s,"entries",(function(){return Z})),n.d(s,"values",(function(){return Q})),n.d(s,"assign",(function(){return tt})),n.d(s,"map",(function(){return et})),n.d(s,"filter",(function(){return nt})),n.d(s,"indexBy",(function(){return rt})),n.d(s,"uniq",(function(){return it})),n.d(s,"switchTransactionByType",(function(){return ot})),n.d(s,"pipe",(function(){return st}));var c=function(t,e){return new URL(t,e).toString()},f=new RegExp('((?!\\\\)"\\w+"):\\s*(-?[\\d|\\.]{14,})',"g"),a=function(t){return JSON.parse(t.replace(f,'$1:"$2"'))},l="function"==typeof fetch?fetch:n(2),h=function(t){return l(c(t.url,t.base),function(t){void 0===t&&(t=Object.create(null));return t.credentials="include",t}(t.options)).then(p)};function p(t){return t.text().then((function(e){return t.ok?a(e):Promise.reject(function(t){try{return JSON.parse(t)}catch(e){return t}}(e))}))}var d=function(t,e){void 0===e&&(e=Object.create(null));var n=Object.keys(t).map((function(e){return[e,t[e]]})).map((function(t){var n=t[0],r=t[1];return[n,Object.prototype.hasOwnProperty.call(e,n)?e[n](r):r]})).filter((function(t){t[0];return null!=t[1]})).map((function(t){return t[0]+"="+t[1]})).join("&");return n.length?"?"+n:""};function g(t,e,n,r){return h({base:t,url:"/addresses/data/"+e+"/"+encodeURIComponent(n)})}function m(t,e,n){return h({base:t,url:"/addresses/scriptInfo/"+e+"/meta"})}function b(t,e,n){return h({base:t,url:"/addresses/balance/details/"+e})}function v(t,e,n,r){return h({base:t,url:"/addresses/balance/"+e+"/"+n})}function y(t,e,n){return h({base:t,url:"/addresses/scriptInfo/"+e})}function w(t,e,n,r){return void 0===n&&(n=Object.create(null)),h({base:t,url:"/addresses/data/"+e+d(n)})}function O(t,e,n){return h({base:t,url:"/addresses/validate/"+e})}function N(t,e,n){return h({base:t,url:"/addresses/balance/"+e})}function _(t,e,n){return h({base:t,url:"/addresses/publicKey/"+e})}function A(t,e){return h({base:t,url:"/blocks/headers/last"})}function B(t,e,n){return h({base:t,url:"/blocks/headers/at/"+e})}function E(t,e){return h({base:t,url:"/blocks/at/"+e})}function I(t){return h({base:t,url:"/blocks/height"})}var R=4,U=5,D=6,T=7,F=11,L=14,S=15,P=16,j={IN_BLOCKCHAIN:"in_blockchain",UNCONFIRMED:"unconfirmed",NOT_FOUND:"not_found"},x=new RegExp('(?!\\\\)"('+["value","amount","matcherFee","price","fee","minSponsoredAssetFee","quantity","sellMatcherFee","buyMatcherFee"].join("|")+')":\\s*"(-?\\d+)"',"g"),M=function(t){return JSON.stringify(t).replace(x,'"$1":$2')},C=function(){return(C=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function k(t,e){return h({base:t,url:"/transactions/calculateFee",options:{method:"POST",body:M(e),headers:{"Content-Type":"application/json"}}})}function H(t,e,n,r,i){return h({base:t,url:"/transactions/address/"+e+"/limit/"+n+d({after:r})}).then((function(t){return t[0]}))}function q(t,e){return h({base:t,url:"/transactions/unconfirmed/info/"+e})}function G(t,e){return h({base:t,url:"/transactions/info/"+e})}function J(t,e){var n={id:"",confirmations:-1,height:-1,inUTX:!1,status:j.NOT_FOUND},r=e.map((function(e){return q(t,e).then((function(){return C(C({},n),{id:e,status:j.UNCONFIRMED,inUTX:!0})})).catch((function(){return G(t,e).then((function(t){return C(C({},n),{id:e,status:j.IN_BLOCKCHAIN,height:t.height})}))})).catch((function(){return C(C({},n),{id:e})}))}));return Promise.all([I(t),Promise.all(r)]).then((function(t){var e=t[0].height,n=t[1];return{height:e,statuses:n.map((function(t){return C(C({},t),{confirmations:t.status===j.IN_BLOCKCHAIN?e-t.height:t.confirmations})}))}}))}function W(t,e){return h({base:t,url:"/transactions/broadcast",options:{method:"POST",body:M(e),headers:{"Content-Type":"application/json"}}})}function $(t,e){return h({base:t,url:"/leasing/active/"+e})}function V(t){return Array.isArray(t)?t:[t]}function z(t){return t[0]}function X(t){return new Promise((function(e){setTimeout(e,t)}))}function K(t){return function(e){return e[t]}}var Y=function(t){return Object.keys(t)},Z=function(t){return Y(t).map((function(e){return[e,t[e]]}))},Q=function(t){return Y(t).map((function(e){return t[e]}))},tt=function(t,e){return Z(e).reduce((function(e,n){var r=n[0],i=n[1];return t[r]=i,t}),t)};function et(t){return function(e){return e.map(t)}}function nt(t){return function(e){return e.filter(t)}}function rt(t,e){return e.reduce((function(e,n){return e[t(n)]=n,e}),{})}var it=function(t){return Y(t.reduce((function(t,e){return t[e]=e,t}),Object.create(null)))};function ot(t){return function(e){return t[e.type]&&"function"==typeof t[e.type]?t[e.type](e):void 0}}var ut,st=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return t.reduce((function(t,e){return e(t)}),e)}},ct=function(t,e,n){var r=!Array.isArray(e),i=Date.now(),o=[],u=n&&n.confirmations||0,s=n&&n.maxWaitTime||0,c=n&&n.requestInterval||250,f=function(e){return J(t,e.map(K("id"))).then((function(t){var n=rt(K("id"),t.statuses);if(e.some((function(t){return n[t.id].status===j.NOT_FOUND})))throw new Error("One transaction is not in blockchain!");var r=e.filter((function(t){return!(n[t.id].confirmations>=u)||(o.push(t),!1)}));if(r.length)return s&&Date.now()-i>s?Promise.reject("Timeout error!"):X(c).then((function(){return f(r)}))}))};return f(V(e)).then((function(){return r?z(o):o}))},ft=function(){return(ft=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},at={chain:!1,confirmations:-1,maxWaitTime:0,requestInterval:0},lt=function(t,e,n){var r=ft(ft({},at),n||{}),i=!Array.isArray(e),o=r.confirmations>0?1:0;return(r.chain?function(t,e,n){return new Promise((function(r,i){var o=e.slice().reverse(),u=[],s=function(){if(!o.length)return r(u),null;var e=o.pop();W(t,e).then((function(e){return ct(t,e,n)})).then((function(t){u.push(t),s()}),i)};s()}))}(t,V(e),ft(ft({},r),{confirmations:o})):function(t,e){return Promise.all(e.map((function(e){return W(t,e)})))}(t,V(e))).then((function(e){return r.confirmations<=0?e:ct(t,e,r)})).then((function(t){return i?z(t):t}))};var ht=ot(((ut={})[R]=function(t){return[t.assetId,t.feeAssetId]},ut[D]=function(t){return[t.assetId]},ut[U]=function(t){return[t.assetId]},ut[T]=function(t){return[t.buyOrder.assetPair.amountAsset,t.buyOrder.assetPair.priceAsset,t.buyOrder.matcherFeeAssetId,t.sellOrder.matcherFeeAssetId]},ut[F]=function(t){return[t.assetId]},ut[S]=function(t){return[t.assetId]},ut[L]=function(t){return[t.assetId]},ut[P]=function(t){return(t.payment||[]).map(K("assetId"))},ut)),pt=function(t){var e=V(t).reduce((function(t,e){return t.concat(ht(e)||[])}),[]);return st(nt(Boolean),it)(e)},dt=function(t,e){return function(t,e){var n=!Array.isArray(e);return Promise.all(V(e).map((function(e){return h({base:t,url:"/assets/details/"+e})}))).then((function(t){return n?t[0]:t}))}(t,pt(e)).then((function(t){return rt(K("assetId"),t)}))},gt=function(t,e,n,r){return H(t,e,n,r).then((function(e){return dt(t,e).then((function(t){return{transactions:e,assets:t}}))}))},mt=n(0),bt=function(t,e,n){return function(t,e){return h({base:t,url:"/assets/balance/"+e})}(t,e).then(st(K("balances"),nt(function(t){return function(e){return e.minSponsoredAssetFee&&mt.BigNumber.toBigNumber(e.sponsorBalance||0).gte(t)&&mt.BigNumber.toBigNumber(t).div(.001*Math.pow(10,8)).mul(e.minSponsoredAssetFee).lte(e.balance)||!1}}(n)),et(function(t){var e=mt.BigNumber.toBigNumber(t).div(.001*Math.pow(10,8));return function(n){return{assetId:n.assetId,wavesFee:t,assetFee:mt.BigNumber.toBigNumber(n.minSponsoredAssetFee).mul(e).toFixed()}}}(n))))};for(var vt=function(t){return A(t).then((function(t){return function(t){var e,n,r,i,o;if(0===t.length)return new Uint8Array(0);o=void 0,i=void 0,e=[0],o=0;for(;o<t.length;){if(!((n=t[o])in wt))throw"Base58.decode received unacceptable input. Character '"+n+"' is not in the Base58 alphabet.";for(i=0;i<e.length;)e[i]*=58,i++;for(e[0]+=wt[n],r=0,i=0;i<e.length;)e[i]+=r,r=e[i]>>8,e[i]&=255,++i;for(;r;)e.push(255&r),r>>=8;o++}o=0;for(;"1"===t[o]&&o<t.length-1;)e.push(0),o++;return new Uint8Array(e.reverse())}(t.generator)[1]}))},yt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",wt={},Ot=0;Ot<yt.length;Ot++)wt[yt.charAt(Ot)]=Ot;var Nt=function(t){return vt(t).then((function(t){return String.fromCharCode(t)}))},_t=n(1),At=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],u=0,s=o.length;u<s;u++,i++)r[i]=o[u];return r},Bt=function(){function t(t,e,n,r){var i,o;this._emitter=new _t.EventEmitter,this._timer=null,this.address=e,this._interval=r||1e3,this._base=t,this._lastBlock={lastId:(null===(i=n)||void 0===i?void 0:i.id)||"",height:(null===(o=n)||void 0===o?void 0:o.height)||0,transactions:n?[n]:[]},this._addTimeout()}return t.prototype.on=function(t,e){this._emitter.on(t,e)},t.prototype.once=function(t,e){this._emitter.once(t,e)},t.prototype.off=function(t,e){this._emitter.off(t,e)},t.prototype._run=function(){var e=this;this._timer&&clearTimeout(this._timer);var n=function(){return e._addTimeout()};H(this._base,this.address,1).then((function(r){var i=r[0];if(!i)return e._addTimeout(),null;e.getTransactionsInHeight(i,310).then((function(n){var r,i=t._groupByHeight(n),o=Y(i).map(Number).sort((function(t,e){return e-t})),u=o[0],s=o[1];if(e._lastBlock.height){var c=rt(K("id"),e._lastBlock.transactions),f=t._getTransactionsToDispatch(At(i[u],i[s]||[]),c,e._lastBlock.lastId);e._lastBlock.height!==u?e._lastBlock={height:u,lastId:i[s]&&i[s].length?i[s][0].id:"",transactions:i[u]}:(r=e._lastBlock.transactions).push.apply(r,f),f.length&&e._emitter.trigger("change-state",f)}else e._lastBlock={height:u,lastId:i[s]&&i[s].length?i[s][0].id:"",transactions:i[u]},e._emitter.trigger("change-state",n);e._addTimeout()}),n)})).catch(n)},t.prototype.getTransactionsInHeight=function(e,n){var r=this,i=e.height,o=function(e){return e.length>=n?Promise.resolve(e):H(r._base,r.address,e.length+100).then((function(n){if(e.length===n.length)return e;var r=t._groupByHeight(n),u=Y(r).map(Number).sort((function(t,e){return e-t})),s=u[0],c=u[1];return s===i&&c?At(r[s],[r[c][0]]):o(n)}))};return o([e])},t.prototype._addTimeout=function(){var t=this;this._timer=setTimeout((function(){t._run()}),this._interval)},t._groupByHeight=function(t){return t.reduce((function(t,e){return t[e.height]?t[e.height].push(e):t[e.height]=[e],t}),Object.create(null))},t._getTransactionsToDispatch=function(t,e,n){for(var r=[],i=0;i<t.length;i++){var o=t[i];if(o.id===n)break;e[o.id]||r.push(o)}return r},t}(),Et=function(t,e,n){return H(t,e,1).then((function(r){var i=r[0];return new Bt(t,e,i,n)}))};function It(t){return{addresses:Rt(t,r),blocks:Rt(t,i),transactions:Rt(t,o),leasing:Rt(t,u),tools:{transactions:{broadcast:Ut(t,lt),wait:Ut(t,ct)},blocks:{getNetworkByte:Ut(t,vt),getNetworkCode:Ut(t,Nt)},addresses:{createWatch:Ut(t,Et),getAssetsByTransaction:Ut(t,dt),getAssetIdListByTx:pt,getTransactionsWithAssets:Ut(t,gt),availableSponsoredBalances:Ut(t,bt)},utils:s,query:d,resolve:c,request:h,parse:a}}}n.d(e,"create",(function(){return It}));e.default=It;function Rt(t,e){return Object.keys(e).reduce((function(n,r){return n[r]=Ut(t,e[r]),n}),{})}function Ut(t,e){return e.bind(null,t)}}])})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.nodeApi=t():e.nodeApi=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=13)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toArray=function(e){return Array.isArray(e)?e:[e]},t.head=function(e){return e[0]},t.wait=function(e){return new Promise((function(t){setTimeout(t,e)}))},t.prop=function(e){return function(t){return t[e]}},t.keys=function(e){return Object.keys(e)},t.entries=function(e){return t.keys(e).map((function(t){return[t,e[t]]}))},t.values=function(e){return t.keys(e).map((function(t){return e[t]}))},t.assign=function(e,n){return t.entries(n).reduce((function(t,n){var r=n[0],i=n[1];return e[r]=i,e}),e)},t.map=function(e){return function(t){return t.map(e)}},t.filter=function(e){return function(t){return t.filter(e)}},t.indexBy=function(e,t){return t.reduce((function(t,n){return t[e(n)]=n,t}),{})},t.uniq=function(e){return t.keys(e.reduce((function(e,t){return e[t]=t,e}),Object.create(null)))},t.switchTransactionByType=function(e){return function(t){return e[t.type]&&"function"==typeof e[t.type]?e[t.type](t):void 0}},t.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return e.reduce((function(e,t){return t(e)}),t)}}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(6)),o=r(n(7)),u="function"==typeof fetch?fetch:n(15);function s(e){return e.text().then((function(t){return e.ok?o.default(t):Promise.reject(function(e){try{return JSON.parse(e)}catch(t){return e}}(t))}))}t.default=function(e){return u(i.default(e.url,e.base),function(e){void 0===e&&(e=Object.create(null));return e.credentials="include",e}(e.options)).then(s)}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(5),u=n(4),s=i(n(1)),a=i(n(3)),c=i(n(16));function f(e,t){return s.default({base:e,url:"/transactions/unconfirmed/info/"+t})}function l(e,t){return s.default({base:e,url:"/transactions/info/"+t})}t.calculateFee=function(e,t){return s.default({base:e,url:"/transactions/calculateFee",options:{method:"POST",body:c.default(t),headers:{"Content-Type":"application/json"}}})},t.transactions=function(e,t,n,r,i){return s.default({base:e,url:"/transactions/address/"+t+"/limit/"+n+a.default({after:r})}).then((function(e){return e[0]}))},t.unconfirmedInfo=f,t.info=l,t.status=function(e,t){var n={id:"",confirmations:-1,height:-1,inUTX:!1,status:o.TRANSACTION_STATUSES.NOT_FOUND},i=t.map((function(t){return f(e,t).then((function(){return r(r({},n),{id:t,status:o.TRANSACTION_STATUSES.UNCONFIRMED,inUTX:!0})})).catch((function(){return l(e,t).then((function(e){return r(r({},n),{id:t,status:o.TRANSACTION_STATUSES.IN_BLOCKCHAIN,height:e.height})}))})).catch((function(){return r(r({},n),{id:t})}))}));return Promise.all([u.height(e),Promise.all(i)]).then((function(e){var t=e[0].height,n=e[1];return{height:t,statuses:n.map((function(e){return r(r({},e),{confirmations:e.status===o.TRANSACTION_STATUSES.IN_BLOCKCHAIN?t-e.height:e.confirmations})}))}}))},t.broadcast=function(e,t){return s.default({base:e,url:"/transactions/broadcast",options:{method:"POST",body:c.default(t),headers:{"Content-Type":"application/json"}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){void 0===t&&(t=Object.create(null));var n=Object.keys(e).map((function(t){return[t,e[t]]})).map((function(e){var n=e[0],r=e[1];return[n,Object.prototype.hasOwnProperty.call(t,n)?t[n](r):r]})).filter((function(e){e[0];return null!=e[1]})).map((function(e){return e[0]+"="+e[1]})).join("&");return n.length?"?"+n:""}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(1));t.headersLast=function(e,t){return i.default({base:e,url:"/blocks/headers/last"})},t.headersAt=function(e,t,n){return i.default({base:e,url:"/blocks/headers/at/"+t})},t.blockAt=function(e,t){return i.default({base:e,url:"/blocks/at/"+t})},t.height=function(e){return i.default({base:e,url:"/blocks/height"})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TYPE_MAP={3:"issue",4:"transfer",5:"reissue",6:"burn",7:"exchange",8:"lease",9:"cancelLease",10:"alias",11:"massTransfer",12:"data",13:"setScript",14:"sponsorship",15:"setAssetScript",16:"invoke"},t.NAME_MAP={issue:3,transfer:4,reissue:5,burn:6,exchange:7,lease:8,cancelLease:9,alias:10,massTransfer:11,data:12,setScript:13,sponsorship:14,setAssetScript:15,invoke:16},t.TRANSACTION_STATUSES={IN_BLOCKCHAIN:"in_blockchain",UNCONFIRMED:"unconfirmed",NOT_FOUND:"not_found"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return new URL(e,t).toString()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=new RegExp('((?!\\\\)"\\w+"):\\s*(-?[\\d|\\.]{14,})',"g");t.default=function(e){return JSON.parse(e.replace(r,'$1:"$2"'))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(2),o=n(5);t.default=function(e,t,n){var u=!Array.isArray(t),s=Date.now(),a=[],c=n&&n.confirmations||0,f=n&&n.maxWaitTime||0,l=n&&n.requestInterval||250,h=function(t){return i.status(e,t.map(r.prop("id"))).then((function(e){var n=r.indexBy(r.prop("id"),e.statuses);if(t.some((function(e){return n[e.id].status===o.TRANSACTION_STATUSES.NOT_FOUND})))throw new Error("One transaction is not in blockchain!");var i=t.filter((function(e){return!(n[e.id].confirmations>=c)||(a.push(e),!1)}));if(i.length)return f&&Date.now()-s>f?Promise.reject("Timeout error!"):r.wait(l).then((function(){return h(i)}))}))};return h(r.toArray(t)).then((function(){return u?r.head(a):a}))}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(10),o=r(n(11)),u=n(0);t.default=function(e,t){return i.details(e,o.default(t)).then((function(e){return u.indexBy(u.prop("assetId"),e)}))}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(1)),o=n(0);t.details=function(e,t){var n=!Array.isArray(t);return Promise.all(o.toArray(t).map((function(t){return i.default({base:e,url:"/assets/details/"+t})}))).then((function(e){return n?e[0]:e}))},t.assetsBalance=function(e,t){return i.default({base:e,url:"/assets/balance/"+t})}},function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),o=n(5),u=i.switchTransactionByType(((r={})[o.NAME_MAP.transfer]=function(e){return[e.assetId,e.feeAssetId]},r[o.NAME_MAP.burn]=function(e){return[e.assetId]},r[o.NAME_MAP.reissue]=function(e){return[e.assetId]},r[o.NAME_MAP.exchange]=function(e){return[e.buyOrder.assetPair.amountAsset,e.buyOrder.assetPair.priceAsset,e.buyOrder.matcherFeeAssetId,e.sellOrder.matcherFeeAssetId]},r[o.NAME_MAP.massTransfer]=function(e){return[e.assetId]},r[o.NAME_MAP.setAssetScript]=function(e){return[e.assetId]},r[o.NAME_MAP.sponsorship]=function(e){return[e.assetId]},r[o.NAME_MAP.invoke]=function(e){return(e.payment||[]).map(i.prop("assetId"))},r));t.default=function(e){var t=i.toArray(e).reduce((function(e,t){return e.concat(u(t)||[])}),[]);return i.pipe(i.filter(Boolean),i.uniq)(t)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(4);t.default=function(e){return r.headersLast(e).then((function(e){return function(e){var t,n,r,i,u;if(0===e.length)return new Uint8Array(0);u=void 0,i=void 0,t=[0],u=0;for(;u<e.length;){if(!((n=e[u])in o))throw"Base58.decode received unacceptable input. Character '"+n+"' is not in the Base58 alphabet.";for(i=0;i<t.length;)t[i]*=58,i++;for(t[0]+=o[n],r=0,i=0;i<t.length;)t[i]+=r,r=t[i]>>8,t[i]&=255,++i;for(;r;)t.push(255&r),r>>=8;u++}u=0;for(;"1"===e[u]&&u<e.length-1;)t.push(0),u++;return new Uint8Array(t.reverse())}(e.generator)[1]}))};for(var i="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",o={},u=0;u<i.length;u++)o[i.charAt(u)]=u},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(14)),u=r(n(4)),s=r(n(2)),a=r(n(17)),c=i(n(3)),f=i(n(6)),l=i(n(1)),h=i(n(18)),p=i(n(9)),d=i(n(11)),g=i(n(19)),b=i(n(20)),m=i(n(8)),_=i(n(7)),v=i(n(12)),y=i(n(22)),O=i(n(23)),N=r(n(0));function w(e){return{addresses:A(e,o),blocks:A(e,u),transactions:A(e,s),leasing:A(e,a),tools:{transactions:{broadcast:E(e,h.default),wait:E(e,m.default)},blocks:{getNetworkByte:E(e,v.default),getNetworkCode:E(e,y.default)},addresses:{createWatch:E(e,O.default),getAssetsByTransaction:E(e,p.default),getAssetIdListByTx:d.default,getTransactionsWithAssets:E(e,g.default),availableSponsoredBalances:E(e,b.default)},utils:N,query:c.default,resolve:f.default,request:l.default,parse:_.default}}}function A(e,t){return Object.keys(t).reduce((function(n,r){return n[r]=E(e,t[r]),n}),{})}function E(e,t){return t.bind(null,e)}t.create=w,t.default=w},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(1)),o=r(n(3));t.dataKey=function(e,t,n,r){return i.default({base:e,url:"/addresses/data/"+t+"/"+encodeURIComponent(n)})},t.scriptInfoMeta=function(e,t,n){return i.default({base:e,url:"/addresses/scriptInfo/"+t+"/meta"})},t.balanceDetails=function(e,t,n){return i.default({base:e,url:"/addresses/balance/details/"+t})},t.balanceConfirmations=function(e,t,n,r){return i.default({base:e,url:"/addresses/balance/"+t+"/"+n})},t.scriptInfo=function(e,t,n){return i.default({base:e,url:"/addresses/scriptInfo/"+t})},t.data=function(e,t,n,r){return void 0===n&&(n=Object.create(null)),i.default({base:e,url:"/addresses/data/"+t+o.default(n)})},t.validate=function(e,t,n){return i.default({base:e,url:"/addresses/validate/"+t})},t.balance=function(e,t,n){return i.default({base:e,url:"/addresses/balance/"+t})},t.buildAddress=function(e,t,n){return i.default({base:e,url:"/addresses/publicKey/"+t})}},function(e,t,n){"use strict";var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,t.default=r.fetch.bind(r),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=new RegExp('(?!\\\\)"('+["value","amount","matcherFee","price","fee","minSponsoredAssetFee","quantity","sellMatcherFee","buyMatcherFee"].join("|")+')":\\s*"(-?\\d+)"',"g");t.default=function(e){return JSON.stringify(e).replace(r,'"$1":$2')}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(1));t.active=function(e,t){return i.default({base:e,url:"/leasing/active/"+t})}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),u=n(0),s=i(n(8)),a={chain:!1,confirmations:-1,maxWaitTime:0,requestInterval:0};t.default=function(e,t,n){var i=r(r({},a),n||{}),c=!Array.isArray(t),f=i.confirmations>0?1:0;return(i.chain?function(e,t,n){return new Promise((function(r,i){var u=t.slice().reverse(),a=[],c=function(){if(!u.length)return r(a),null;var t=u.pop();o.broadcast(e,t).then((function(t){return s.default(e,t,n)})).then((function(e){a.push(e),c()}),i)};c()}))}(e,u.toArray(t),r(r({},i),{confirmations:f})):function(e,t){return Promise.all(t.map((function(t){return o.broadcast(e,t)})))}(e,u.toArray(t))).then((function(t){return i.confirmations<=0?t:s.default(e,t,i)})).then((function(e){return c?u.head(e):e}))}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o=r(n(9));t.default=function(e,t,n,r){return i.transactions(e,t,n,r).then((function(t){return o.default(e,t).then((function(e){return{transactions:t,assets:e}}))}))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(21),i=n(10),o=n(0);t.default=function(e,t,n){return i.assetsBalance(e,t).then(o.pipe(o.prop("balances"),o.filter(function(e){return function(t){return t.minSponsoredAssetFee&&r.BigNumber.toBigNumber(t.sponsorBalance||0).gte(e)&&r.BigNumber.toBigNumber(e).div(.001*Math.pow(10,8)).mul(t.minSponsoredAssetFee).lte(t.balance)||!1}}(n)),o.map(function(e){var t=r.BigNumber.toBigNumber(e).div(.001*Math.pow(10,8));return function(n){return{assetId:n.assetId,wavesFee:e,assetFee:r.BigNumber.toBigNumber(n.minSponsoredAssetFee).mul(t).toFixed()}}}(n))))}},function(e,t,n){!function(e){"use strict";var t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,r=Math.floor,i="[BigNumber Error] ",o=i+"Number primitive has more than 15 significant digits: ",u=1e14,s=14,a=9007199254740991,c=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],f=1e7,l=1e9;function h(e){var t=0|e;return e>0||e===t?t:t-1}function p(e){for(var t,n,r=1,i=e.length,o=e[0]+"";r<i;){for(t=e[r++]+"",n=s-t.length;n--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function d(e,t){var n,r,i=e.c,o=t.c,u=e.s,s=t.s,a=e.e,c=t.e;if(!u||!s)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-s:u;if(u!=s)return u;if(n=u<0,r=a==c,!i||!o)return r?0:!i^n?1:-1;if(!r)return a>c^n?1:-1;for(s=(a=i.length)<(c=o.length)?a:c,u=0;u<s;u++)if(i[u]!=o[u])return i[u]>o[u]^n?1:-1;return a==c?0:a>c^n?1:-1}function g(e,t,n,o){if(e<t||e>n||e!==r(e))throw Error(i+(o||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return h(e.e/s)==t&&e.c[t]%2!=0}function m(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function _(e,t,n){var r,i;if(t<0){for(i=n+".";++t;i+=n);e=i+e}else if(++t>(r=e.length)){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var v=function e(v){var y,O,N,w,A,E,M,T,B,P=q.prototype={constructor:q,toString:null,valueOf:null},S=new q(1),D=20,j=4,I=-7,R=21,U=-1e7,F=1e7,L=!1,x=1,k=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz";function q(e,n){var i,u,c,f,l,h,p,d,b=this;if(!(b instanceof q))return new q(e,n);if(null==n){if(e&&!0===e._isBigNumber)return b.s=e.s,void(!e.c||e.e>F?b.c=b.e=null:e.e<U?b.c=[b.e=0]:(b.e=e.e,b.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(b.s=1/e<0?(e=-e,-1):1,e===~~e){for(f=0,l=e;l>=10;l/=10,f++);return void(f>F?b.c=b.e=null:(b.e=f,b.c=[e]))}d=String(e)}else{if(!t.test(d=String(e)))return N(b,d,h);b.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(f=d.indexOf("."))>-1&&(d=d.replace(".","")),(l=d.search(/e/i))>0?(f<0&&(f=l),f+=+d.slice(l+1),d=d.substring(0,l)):f<0&&(f=d.length)}else{if(g(n,2,H.length,"Base"),10==n)return $(b=new q(e),D+b.e+1,j);if(d=String(e),h="number"==typeof e){if(0*e!=0)return N(b,d,h,n);if(b.s=1/e<0?(d=d.slice(1),-1):1,q.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(o+e)}else b.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1;for(i=H.slice(0,n),f=l=0,p=d.length;l<p;l++)if(i.indexOf(u=d.charAt(l))<0){if("."==u){if(l>f){f=p;continue}}else if(!c&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){c=!0,l=-1,f=0;continue}return N(b,String(e),h,n)}h=!1,(f=(d=O(d,n,10,b.s)).indexOf("."))>-1?d=d.replace(".",""):f=d.length}for(l=0;48===d.charCodeAt(l);l++);for(p=d.length;48===d.charCodeAt(--p););if(d=d.slice(l,++p)){if(p-=l,h&&q.DEBUG&&p>15&&(e>a||e!==r(e)))throw Error(o+b.s*e);if((f=f-l-1)>F)b.c=b.e=null;else if(f<U)b.c=[b.e=0];else{if(b.e=f,b.c=[],l=(f+1)%s,f<0&&(l+=s),l<p){for(l&&b.c.push(+d.slice(0,l)),p-=s;l<p;)b.c.push(+d.slice(l,l+=s));l=s-(d=d.slice(l)).length}else l-=p;for(;l--;d+="0");b.c.push(+d)}}else b.c=[b.e=0]}function G(e,t,n,r){var i,o,u,s,a;if(null==n?n=j:g(n,0,8),!e.c)return e.toString();if(i=e.c[0],u=e.e,null==t)a=p(e.c),a=1==r||2==r&&(u<=I||u>=R)?m(a,u):_(a,u,"0");else if(o=(e=$(new q(e),t,n)).e,s=(a=p(e.c)).length,1==r||2==r&&(t<=o||o<=I)){for(;s<t;a+="0",s++);a=m(a,o)}else if(t-=u,a=_(a,o,"0"),o+1>s){if(--t>0)for(a+=".";t--;a+="0");}else if((t+=o-s)>0)for(o+1==s&&(a+=".");t--;a+="0");return e.s<0&&i?"-"+a:a}function J(e,t){for(var n,r=1,i=new q(e[0]);r<e.length;r++){if(!(n=new q(e[r])).s){i=n;break}t.call(i,n)&&(i=n)}return i}function W(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*s-1)>F?e.c=e.e=null:n<U?e.c=[e.e=0]:(e.e=n,e.c=t),e}function $(e,t,i,o){var a,f,l,h,p,d,g,b=e.c,m=c;if(b){e:{for(a=1,h=b[0];h>=10;h/=10,a++);if((f=t-a)<0)f+=s,l=t,g=(p=b[d=0])/m[a-l-1]%10|0;else if((d=n((f+1)/s))>=b.length){if(!o)break e;for(;b.length<=d;b.push(0));p=g=0,a=1,l=(f%=s)-s+1}else{for(p=h=b[d],a=1;h>=10;h/=10,a++);g=(l=(f%=s)-s+a)<0?0:p/m[a-l-1]%10|0}if(o=o||t<0||null!=b[d+1]||(l<0?p:p%m[a-l-1]),o=i<4?(g||o)&&(0==i||i==(e.s<0?3:2)):g>5||5==g&&(4==i||o||6==i&&(f>0?l>0?p/m[a-l]:0:b[d-1])%10&1||i==(e.s<0?8:7)),t<1||!b[0])return b.length=0,o?(t-=e.e+1,b[0]=m[(s-t%s)%s],e.e=-t||0):b[0]=e.e=0,e;if(0==f?(b.length=d,h=1,d--):(b.length=d+1,h=m[s-f],b[d]=l>0?r(p/m[a-l]%m[l])*h:0),o)for(;;){if(0==d){for(f=1,l=b[0];l>=10;l/=10,f++);for(l=b[0]+=h,h=1;l>=10;l/=10,h++);f!=h&&(e.e++,b[0]==u&&(b[0]=1));break}if(b[d]+=h,b[d]!=u)break;b[d--]=0,h=1}for(f=b.length;0===b[--f];b.pop());}e.e>F?e.c=e.e=null:e.e<U&&(e.c=[e.e=0])}return e}function V(e){var t,n=e.e;return null===n?e.toString():(t=p(e.c),t=n<=I||n>=R?m(t,n):_(t,n,"0"),e.s<0?"-"+t:t)}return q.clone=e,q.ROUND_UP=0,q.ROUND_DOWN=1,q.ROUND_CEIL=2,q.ROUND_FLOOR=3,q.ROUND_HALF_UP=4,q.ROUND_HALF_DOWN=5,q.ROUND_HALF_EVEN=6,q.ROUND_HALF_CEIL=7,q.ROUND_HALF_FLOOR=8,q.EUCLID=9,q.config=q.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(i+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(g(n=e[t],0,l,t),D=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(g(n=e[t],0,8,t),j=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(g(n[0],-l,0,t),g(n[1],0,l,t),I=n[0],R=n[1]):(g(n,-l,l,t),I=-(R=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)g(n[0],-l,-1,t),g(n[1],1,l,t),U=n[0],F=n[1];else{if(g(n,-l,l,t),!n)throw Error(i+t+" cannot be zero: "+n);U=-(F=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(i+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!n,Error(i+"crypto unavailable");L=n}else L=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(g(n=e[t],0,9,t),x=n),e.hasOwnProperty(t="POW_PRECISION")&&(g(n=e[t],0,l,t),k=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(i+t+" not an object: "+n);C=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(i+t+" invalid: "+n);H=n}}return{DECIMAL_PLACES:D,ROUNDING_MODE:j,EXPONENTIAL_AT:[I,R],RANGE:[U,F],CRYPTO:L,MODULO_MODE:x,POW_PRECISION:k,FORMAT:C,ALPHABET:H}},q.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!q.DEBUG)return!0;var t,n,o=e.c,a=e.e,c=e.s;e:if("[object Array]"=={}.toString.call(o)){if((1===c||-1===c)&&a>=-l&&a<=l&&a===r(a)){if(0===o[0]){if(0===a&&1===o.length)return!0;break e}if((t=(a+1)%s)<1&&(t+=s),String(o[0]).length==t){for(t=0;t<o.length;t++)if((n=o[t])<0||n>=u||n!==r(n))break e;if(0!==n)return!0}}}else if(null===o&&null===a&&(null===c||1===c||-1===c))return!0;throw Error(i+"Invalid BigNumber: "+e)},q.maximum=q.max=function(){return J(arguments,P.lt)},q.minimum=q.min=function(){return J(arguments,P.gt)},q.random=(w=9007199254740992*Math.random()&2097151?function(){return r(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,o,u,a,f,h=0,p=[],d=new q(S);if(null==e?e=D:g(e,0,l),a=n(e/s),L)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(a*=2));h<a;)(f=131072*t[h]+(t[h+1]>>>11))>=9e15?(o=crypto.getRandomValues(new Uint32Array(2)),t[h]=o[0],t[h+1]=o[1]):(p.push(f%1e14),h+=2);h=a/2}else{if(!crypto.randomBytes)throw L=!1,Error(i+"crypto unavailable");for(t=crypto.randomBytes(a*=7);h<a;)(f=281474976710656*(31&t[h])+1099511627776*t[h+1]+4294967296*t[h+2]+16777216*t[h+3]+(t[h+4]<<16)+(t[h+5]<<8)+t[h+6])>=9e15?crypto.randomBytes(7).copy(t,h):(p.push(f%1e14),h+=7);h=a/7}if(!L)for(;h<a;)(f=w())<9e15&&(p[h++]=f%1e14);for(a=p[--h],e%=s,a&&e&&(f=c[s-e],p[h]=r(a/f)*f);0===p[h];p.pop(),h--);if(h<0)p=[u=0];else{for(u=-1;0===p[0];p.splice(0,1),u-=s);for(h=1,f=p[0];f>=10;f/=10,h++);h<s&&(u-=s-h)}return d.e=u,d.c=p,d}),q.sum=function(){for(var e=1,t=arguments,n=new q(t[0]);e<t.length;)n=n.plus(t[e++]);return n},O=function(){function e(e,t,n,r){for(var i,o,u=[0],s=0,a=e.length;s<a;){for(o=u.length;o--;u[o]*=t);for(u[0]+=r.indexOf(e.charAt(s++)),i=0;i<u.length;i++)u[i]>n-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/n|0,u[i]%=n)}return u.reverse()}return function(t,n,r,i,o){var u,s,a,c,f,l,h,d,g=t.indexOf("."),b=D,m=j;for(g>=0&&(c=k,k=0,t=t.replace(".",""),l=(d=new q(n)).pow(t.length-g),k=c,d.c=e(_(p(l.c),l.e,"0"),10,r,"0123456789"),d.e=d.c.length),a=c=(h=e(t,n,r,o?(u=H,"0123456789"):(u="0123456789",H))).length;0==h[--c];h.pop());if(!h[0])return u.charAt(0);if(g<0?--a:(l.c=h,l.e=a,l.s=i,h=(l=y(l,d,b,m,r)).c,f=l.r,a=l.e),g=h[s=a+b+1],c=r/2,f=f||s<0||null!=h[s+1],f=m<4?(null!=g||f)&&(0==m||m==(l.s<0?3:2)):g>c||g==c&&(4==m||f||6==m&&1&h[s-1]||m==(l.s<0?8:7)),s<1||!h[0])t=f?_(u.charAt(1),-b,u.charAt(0)):u.charAt(0);else{if(h.length=s,f)for(--r;++h[--s]>r;)h[s]=0,s||(++a,h=[1].concat(h));for(c=h.length;!h[--c];);for(g=0,t="";g<=c;t+=u.charAt(h[g++]));t=_(t,a,u.charAt(0))}return t}}(),y=function(){function e(e,t,n){var r,i,o,u,s=0,a=e.length,c=t%f,l=t/f|0;for(e=e.slice();a--;)s=((i=c*(o=e[a]%f)+(r=l*o+(u=e[a]/f|0)*c)%f*f+s)/n|0)+(r/f|0)+l*u,e[a]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(i,o,a,c,f){var l,p,d,g,b,m,_,v,y,O,N,w,A,E,M,T,B,P=i.s==o.s?1:-1,S=i.c,D=o.c;if(!(S&&S[0]&&D&&D[0]))return new q(i.s&&o.s&&(S?!D||S[0]!=D[0]:D)?S&&0==S[0]||!D?0*P:P/0:NaN);for(y=(v=new q(P)).c=[],P=a+(p=i.e-o.e)+1,f||(f=u,p=h(i.e/s)-h(o.e/s),P=P/s|0),d=0;D[d]==(S[d]||0);d++);if(D[d]>(S[d]||0)&&p--,P<0)y.push(1),g=!0;else{for(E=S.length,T=D.length,d=0,P+=2,(b=r(f/(D[0]+1)))>1&&(D=e(D,b,f),S=e(S,b,f),T=D.length,E=S.length),A=T,N=(O=S.slice(0,T)).length;N<T;O[N++]=0);B=D.slice(),B=[0].concat(B),M=D[0],D[1]>=f/2&&M++;do{if(b=0,(l=t(D,O,T,N))<0){if(w=O[0],T!=N&&(w=w*f+(O[1]||0)),(b=r(w/M))>1)for(b>=f&&(b=f-1),_=(m=e(D,b,f)).length,N=O.length;1==t(m,O,_,N);)b--,n(m,T<_?B:D,_,f),_=m.length,l=1;else 0==b&&(l=b=1),_=(m=D.slice()).length;if(_<N&&(m=[0].concat(m)),n(O,m,N,f),N=O.length,-1==l)for(;t(D,O,T,N)<1;)b++,n(O,T<N?B:D,N,f),N=O.length}else 0===l&&(b++,O=[0]);y[d++]=b,O[0]?O[N++]=S[A]||0:(O=[S[A]],N=1)}while((A++<E||null!=O[0])&&P--);g=null!=O[0],y[0]||y.splice(0,1)}if(f==u){for(d=1,P=y[0];P>=10;P/=10,d++);$(v,a+(v.e=d+p*s-1)+1,c,g)}else v.e=p,v.r=+g;return v}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,M=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g,N=function(e,t,n,r){var o,u=n?t:t.replace(B,"");if(T.test(u))e.s=isNaN(u)?null:u<0?-1:1;else{if(!n&&(u=u.replace(A,(function(e,t,n){return o="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=o?e:t})),r&&(o=r,u=u.replace(E,"$1").replace(M,"0.$1")),t!=u))return new q(u,o);if(q.DEBUG)throw Error(i+"Not a"+(r?" base "+r:"")+" number: "+t);e.s=null}e.c=e.e=null},P.absoluteValue=P.abs=function(){var e=new q(this);return e.s<0&&(e.s=1),e},P.comparedTo=function(e,t){return d(this,new q(e,t))},P.decimalPlaces=P.dp=function(e,t){var n,r,i,o=this;if(null!=e)return g(e,0,l),null==t?t=j:g(t,0,8),$(new q(o),e+o.e+1,t);if(!(n=o.c))return null;if(r=((i=n.length-1)-h(this.e/s))*s,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},P.dividedBy=P.div=function(e,t){return y(this,new q(e,t),D,j)},P.dividedToIntegerBy=P.idiv=function(e,t){return y(this,new q(e,t),0,1)},P.exponentiatedBy=P.pow=function(e,t){var o,u,a,c,f,l,h,p,d=this;if((e=new q(e)).c&&!e.isInteger())throw Error(i+"Exponent not an integer: "+V(e));if(null!=t&&(t=new q(t)),f=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])return p=new q(Math.pow(+V(d),f?2-b(e):+V(e))),t?p.mod(t):p;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new q(NaN);(u=!l&&d.isInteger()&&t.isInteger())&&(d=d.mod(t))}else{if(e.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||f&&d.c[1]>=24e7:d.c[0]<8e13||f&&d.c[0]<=9999975e7)))return c=d.s<0&&b(e)?-0:0,d.e>-1&&(c=1/c),new q(l?1/c:c);k&&(c=n(k/s+2))}for(f?(o=new q(.5),l&&(e.s=1),h=b(e)):h=(a=Math.abs(+V(e)))%2,p=new q(S);;){if(h){if(!(p=p.times(d)).c)break;c?p.c.length>c&&(p.c.length=c):u&&(p=p.mod(t))}if(a){if(0===(a=r(a/2)))break;h=a%2}else if($(e=e.times(o),e.e+1,1),e.e>14)h=b(e);else{if(0==(a=+V(e)))break;h=a%2}d=d.times(d),c?d.c&&d.c.length>c&&(d.c.length=c):u&&(d=d.mod(t))}return u?p:(l&&(p=S.div(p)),t?p.mod(t):c?$(p,k,j,void 0):p)},P.integerValue=function(e){var t=new q(this);return null==e?e=j:g(e,0,8),$(t,t.e+1,e)},P.isEqualTo=P.eq=function(e,t){return 0===d(this,new q(e,t))},P.isFinite=function(){return!!this.c},P.isGreaterThan=P.gt=function(e,t){return d(this,new q(e,t))>0},P.isGreaterThanOrEqualTo=P.gte=function(e,t){return 1===(t=d(this,new q(e,t)))||0===t},P.isInteger=function(){return!!this.c&&h(this.e/s)>this.c.length-2},P.isLessThan=P.lt=function(e,t){return d(this,new q(e,t))<0},P.isLessThanOrEqualTo=P.lte=function(e,t){return-1===(t=d(this,new q(e,t)))||0===t},P.isNaN=function(){return!this.s},P.isNegative=function(){return this.s<0},P.isPositive=function(){return this.s>0},P.isZero=function(){return!!this.c&&0==this.c[0]},P.minus=function(e,t){var n,r,i,o,a=this,c=a.s;if(t=(e=new q(e,t)).s,!c||!t)return new q(NaN);if(c!=t)return e.s=-t,a.plus(e);var f=a.e/s,l=e.e/s,p=a.c,d=e.c;if(!f||!l){if(!p||!d)return p?(e.s=-t,e):new q(d?a:NaN);if(!p[0]||!d[0])return d[0]?(e.s=-t,e):new q(p[0]?a:3==j?-0:0)}if(f=h(f),l=h(l),p=p.slice(),c=f-l){for((o=c<0)?(c=-c,i=p):(l=f,i=d),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(r=(o=(c=p.length)<(t=d.length))?c:t,c=t=0;t<r;t++)if(p[t]!=d[t]){o=p[t]<d[t];break}if(o&&(i=p,p=d,d=i,e.s=-e.s),(t=(r=d.length)-(n=p.length))>0)for(;t--;p[n++]=0);for(t=u-1;r>c;){if(p[--r]<d[r]){for(n=r;n&&!p[--n];p[n]=t);--p[n],p[r]+=u}p[r]-=d[r]}for(;0==p[0];p.splice(0,1),--l);return p[0]?W(e,p,l):(e.s=3==j?-1:1,e.c=[e.e=0],e)},P.modulo=P.mod=function(e,t){var n,r,i=this;return e=new q(e,t),!i.c||!e.s||e.c&&!e.c[0]?new q(NaN):!e.c||i.c&&!i.c[0]?new q(i):(9==x?(r=e.s,e.s=1,n=y(i,e,0,3),e.s=r,n.s*=r):n=y(i,e,0,x),(e=i.minus(n.times(e))).c[0]||1!=x||(e.s=i.s),e)},P.multipliedBy=P.times=function(e,t){var n,r,i,o,a,c,l,p,d,g,b,m,_,v,y,O=this,N=O.c,w=(e=new q(e,t)).c;if(!(N&&w&&N[0]&&w[0]))return!O.s||!e.s||N&&!N[0]&&!w||w&&!w[0]&&!N?e.c=e.e=e.s=null:(e.s*=O.s,N&&w?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=h(O.e/s)+h(e.e/s),e.s*=O.s,(l=N.length)<(g=w.length)&&(_=N,N=w,w=_,i=l,l=g,g=i),i=l+g,_=[];i--;_.push(0));for(v=u,y=f,i=g;--i>=0;){for(n=0,b=w[i]%y,m=w[i]/y|0,o=i+(a=l);o>i;)n=((p=b*(p=N[--a]%y)+(c=m*p+(d=N[a]/y|0)*b)%y*y+_[o]+n)/v|0)+(c/y|0)+m*d,_[o--]=p%v;_[o]=n}return n?++r:_.splice(0,1),W(e,_,r)},P.negated=function(){var e=new q(this);return e.s=-e.s||null,e},P.plus=function(e,t){var n,r=this,i=r.s;if(t=(e=new q(e,t)).s,!i||!t)return new q(NaN);if(i!=t)return e.s=-t,r.minus(e);var o=r.e/s,a=e.e/s,c=r.c,f=e.c;if(!o||!a){if(!c||!f)return new q(i/0);if(!c[0]||!f[0])return f[0]?e:new q(c[0]?r:0*i)}if(o=h(o),a=h(a),c=c.slice(),i=o-a){for(i>0?(a=o,n=f):(i=-i,n=c),n.reverse();i--;n.push(0));n.reverse()}for((i=c.length)-(t=f.length)<0&&(n=f,f=c,c=n,t=i),i=0;t;)i=(c[--t]=c[t]+f[t]+i)/u|0,c[t]=u===c[t]?0:c[t]%u;return i&&(c=[i].concat(c),++a),W(e,c,a)},P.precision=P.sd=function(e,t){var n,r,i,o=this;if(null!=e&&e!==!!e)return g(e,1,l),null==t?t=j:g(t,0,8),$(new q(o),e,t);if(!(n=o.c))return null;if(r=(i=n.length-1)*s+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&o.e+1>r&&(r=o.e+1),r},P.shiftedBy=function(e){return g(e,-a,a),this.times("1e"+e)},P.squareRoot=P.sqrt=function(){var e,t,n,r,i,o=this,u=o.c,s=o.s,a=o.e,c=D+4,f=new q("0.5");if(1!==s||!u||!u[0])return new q(!s||s<0&&(!u||u[0])?NaN:u?o:1/0);if(0==(s=Math.sqrt(+V(o)))||s==1/0?(((t=p(u)).length+a)%2==0&&(t+="0"),s=Math.sqrt(+t),a=h((a+1)/2)-(a<0||a%2),n=new q(t=s==1/0?"1e"+a:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+a)):n=new q(s+""),n.c[0])for((s=(a=n.e)+c)<3&&(s=0);;)if(i=n,n=f.times(i.plus(y(o,i,c,1))),p(i.c).slice(0,s)===(t=p(n.c)).slice(0,s)){if(n.e<a&&--s,"9999"!=(t=t.slice(s-3,s+1))&&(r||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||($(n,n.e+D+2,1),e=!n.times(n).eq(o));break}if(!r&&($(i,i.e+D+2,0),i.times(i).eq(o))){n=i;break}c+=4,s+=4,r=1}return $(n,n.e+D+1,j,e)},P.toExponential=function(e,t){return null!=e&&(g(e,0,l),e++),G(this,e,t,1)},P.toFixed=function(e,t){return null!=e&&(g(e,0,l),e=e+this.e+1),G(this,e,t)},P.toFormat=function(e,t,n){var r,o=this;if(null==n)null!=e&&t&&"object"==typeof t?(n=t,t=null):e&&"object"==typeof e?(n=e,e=t=null):n=C;else if("object"!=typeof n)throw Error(i+"Argument not an object: "+n);if(r=o.toFixed(e,t),o.c){var u,s=r.split("."),a=+n.groupSize,c=+n.secondaryGroupSize,f=n.groupSeparator||"",l=s[0],h=s[1],p=o.s<0,d=p?l.slice(1):l,g=d.length;if(c&&(u=a,a=c,c=u,g-=u),a>0&&g>0){for(u=g%a||a,l=d.substr(0,u);u<g;u+=a)l+=f+d.substr(u,a);c>0&&(l+=f+d.slice(u)),p&&(l="-"+l)}r=h?l+(n.decimalSeparator||"")+((c=+n.fractionGroupSize)?h.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):h):l}return(n.prefix||"")+r+(n.suffix||"")},P.toFraction=function(e){var t,n,r,o,u,a,f,l,h,d,g,b,m=this,_=m.c;if(null!=e&&(!(f=new q(e)).isInteger()&&(f.c||1!==f.s)||f.lt(S)))throw Error(i+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+V(f));if(!_)return new q(m);for(t=new q(S),h=n=new q(S),r=l=new q(S),b=p(_),u=t.e=b.length-m.e-1,t.c[0]=c[(a=u%s)<0?s+a:a],e=!e||f.comparedTo(t)>0?u>0?t:h:f,a=F,F=1/0,f=new q(b),l.c[0]=0;d=y(f,t,0,1),1!=(o=n.plus(d.times(r))).comparedTo(e);)n=r,r=o,h=l.plus(d.times(o=h)),l=o,t=f.minus(d.times(o=t)),f=o;return o=y(e.minus(n),r,0,1),l=l.plus(o.times(h)),n=n.plus(o.times(r)),l.s=h.s=m.s,g=y(h,r,u*=2,j).minus(m).abs().comparedTo(y(l,n,u,j).minus(m).abs())<1?[h,r]:[l,n],F=a,g},P.toNumber=function(){return+V(this)},P.toPrecision=function(e,t){return null!=e&&g(e,1,l),G(this,e,t,2)},P.toString=function(e){var t,n=this,r=n.s,i=n.e;return null===i?r?(t="Infinity",r<0&&(t="-"+t)):t="NaN":(null==e?t=i<=I||i>=R?m(p(n.c),i):_(p(n.c),i,"0"):10===e?t=_(p((n=$(new q(n),D+i+1,j)).c),n.e,"0"):(g(e,2,H.length,"Base"),t=O(_(p(n.c),i,"0"),10,e,r,!0)),r<0&&n.c[0]&&(t="-"+t)),t},P.valueOf=P.toJSON=function(){return V(this)},P._isBigNumber=!0,P[Symbol.toStringTag]="BigNumber",P[Symbol.for("nodejs.util.inspect.custom")]=P.valueOf,null!=v&&q.set(v),q}(),y=function(){return(y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},O=function(){function e(){this.format=e.DEFAULT_FORMAT,v.config({FORMAT:this.format})}return e.prototype.set=function(e){"FORMAT"in e&&(this.format=y({},this.format,e.FORMAT),e.FORMAT=this.format),v.config(e)},e.DEFAULT_FORMAT={prefix:"",decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0,suffix:""},e}();e.BigNumber=function(){function e(t){"object"==typeof t&&e.isBigNumber(t)?this.bn=t.bn.plus(0):this.bn=e.toBigNumberJs(t)}return e.prototype.clone=function(){return new e(this)},e.prototype.add=function(t){return new e(this.bn.plus(e.toBigNumberJs(t)))},e.prototype.sub=function(t){return new e(this.bn.minus(e.toBigNumberJs(t)))},e.prototype.mul=function(t){return new e(this.bn.times(e.toBigNumberJs(t)))},e.prototype.div=function(t){return new e(this.bn.div(e.toBigNumberJs(t)))},e.prototype.pow=function(t){return new e(this.bn.pow(e.toBigNumberJs(t)))},e.prototype.abs=function(){return new e(this.bn.abs())},e.prototype.mod=function(t){return new e(this.bn.mod(e.toBigNumberJs(t)))},e.prototype.roundTo=function(t,n){return void 0===t&&(t=0),void 0===n&&(n=4),new e(this.bn.dp(t||0,n))},e.prototype.eq=function(t){return this.bn.eq(e.toBigNumberJs(t))},e.prototype.lt=function(t){return this.bn.lt(e.toBigNumberJs(t))},e.prototype.gt=function(t){return this.bn.gt(e.toBigNumberJs(t))},e.prototype.lte=function(t){return this.bn.lte(e.toBigNumberJs(t))},e.prototype.gte=function(t){return this.bn.gte(e.toBigNumberJs(t))},e.prototype.isNaN=function(){return this.bn.isNaN()},e.prototype.isFinite=function(){return this.bn.isFinite()},e.prototype.isZero=function(){return this.eq(0)},e.prototype.isPositive=function(){return this.gt(0)},e.prototype.isNegative=function(){return this.lt(0)},e.prototype.isInt=function(){return this.bn.isInteger()},e.prototype.getDecimalsCount=function(){return this.bn.dp()},e.prototype.isEven=function(){return this.mod(2).eq(0)},e.prototype.isOdd=function(){return!this.isEven()},e.prototype.toBytes=function(){if(!this.isInt())throw new Error("Cant create bytes from number with decimals!");var t=this.isNegative(),n=t?"1":"0",r=e._toLength(64,this.bn.plus(n).abs().toString(2).replace("-","")).split(""),i=[];do{i.push(parseInt(r.splice(0,8).join(""),2))}while(r.length);return t?Uint8Array.from(i.map((function(e){return 255-e}))):Uint8Array.from(i)},e.prototype.toFormat=function(e,t,n){return this.bn.toFormat(e,t,n)},e.prototype.toFixed=function(e,t){return null==e?this.bn.toFixed():this.bn.toFixed(e,t)},e.prototype.toString=function(){return this.toFixed()},e.prototype.toNumber=function(){return this.bn.toNumber()},e.prototype.toJSON=function(){return this.bn.toFixed()},e.prototype.valueOf=function(){return this.bn.valueOf()},e.fromBytes=function(t){if(8!==t.length)throw new Error("Wrong bytes length! Need 8 bytes!");var n=t[0]>127,r=Array.from(t).map((function(e){return n?255-e:e})).map((function(t){return e._toLength(8,t.toString(2))})).join(""),i=new e(new v(r,2));return n?i.mul(-1).sub(1):i},e.max=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.toBigNumber(t).reduce((function(e,t){return e.gte(t)?e:t}))},e.min=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.toBigNumber(t).reduce((function(e,t){return e.lte(t)?e:t}))},e.sum=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.toBigNumber(t).reduce((function(e,t){return e.add(t)}))},e.isBigNumber=function(t){return t&&"object"==typeof t&&(t instanceof e||Object.entries(e.prototype).filter((function(e){return"_"!==e[0].charAt(0)})).every((function(e){var n=e[0],r=e[1];return n in t&&typeof r==typeof t[n]})))},e.toBigNumber=function(t){return Array.isArray(t)?t.map((function(t){return new e(t)})):new e(t)},e.toBigNumberJs=function(t){return v.isBigNumber(t)?t:t instanceof e?t.bn:new v(t)},e._toLength=function(e,t){return new Array(e).fill("0",0,e).concat(t.split("")).slice(-e).join("")},e.MAX_VALUE=new e("9223372036854775807"),e.MIN_VALUE=new e("-9223372036854775808"),e.MAX_UNSIGNED_VALUE=new e("18446744073709551615"),e.config=new O,e}(),function(e){!function(e){e[e.ROUND_UP=0]="ROUND_UP",e[e.ROUND_DOWN=1]="ROUND_DOWN",e[e.ROUND_CEIL=2]="ROUND_CEIL",e[e.ROUND_FLOOR=3]="ROUND_FLOOR",e[e.ROUND_HALF_UP=4]="ROUND_HALF_UP",e[e.ROUND_HALF_DOWN=5]="ROUND_HALF_DOWN",e[e.ROUND_HALF_EVEN=6]="ROUND_HALF_EVEN",e[e.ROUND_HALF_CEIL=7]="ROUND_HALF_CEIL",e[e.ROUND_HALF_FLOOR=8]="ROUND_HALF_FLOOR"}(e.ROUND_MODE||(e.ROUND_MODE={}))}(e.BigNumber||(e.BigNumber={}));var N=e.BigNumber;e.default=N,Object.defineProperty(e,"__esModule",{value:!0})}(t)},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(12));t.default=function(e){return i.default(e).then((function(e){return String.fromCharCode(e)}))}},function(e,t,n){"use strict";var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],u=0,s=o.length;u<s;u++,i++)r[i]=o[u];return r};Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o=n(0),u=n(24),s=function(){function e(e,t,n,r){var i,o;this._emitter=new u.EventEmitter,this._timer=null,this.address=t,this._interval=r||1e3,this._base=e,this._lastBlock={lastId:(null===(i=n)||void 0===i?void 0:i.id)||"",height:(null===(o=n)||void 0===o?void 0:o.height)||0,transactions:n?[n]:[]},this._addTimeout()}return e.prototype.on=function(e,t){this._emitter.on(e,t)},e.prototype.once=function(e,t){this._emitter.once(e,t)},e.prototype.off=function(e,t){this._emitter.off(e,t)},e.prototype._run=function(){var t=this;this._timer&&clearTimeout(this._timer);var n=function(){return t._addTimeout()};i.transactions(this._base,this.address,1).then((function(i){var u=i[0];if(!u)return t._addTimeout(),null;t.getTransactionsInHeight(u,310).then((function(n){var i,u=e._groupByHeight(n),s=o.keys(u).map(Number).sort((function(e,t){return t-e})),a=s[0],c=s[1];if(t._lastBlock.height){var f=o.indexBy(o.prop("id"),t._lastBlock.transactions),l=e._getTransactionsToDispatch(r(u[a],u[c]||[]),f,t._lastBlock.lastId);t._lastBlock.height!==a?t._lastBlock={height:a,lastId:u[c]&&u[c].length?u[c][0].id:"",transactions:u[a]}:(i=t._lastBlock.transactions).push.apply(i,l),l.length&&t._emitter.trigger("change-state",l)}else t._lastBlock={height:a,lastId:u[c]&&u[c].length?u[c][0].id:"",transactions:u[a]},t._emitter.trigger("change-state",n);t._addTimeout()}),n)})).catch(n)},e.prototype.getTransactionsInHeight=function(t,n){var u=this,s=t.height,a=function(t){return t.length>=n?Promise.resolve(t):i.transactions(u._base,u.address,t.length+100).then((function(n){if(t.length===n.length)return t;var i=e._groupByHeight(n),u=o.keys(i).map(Number).sort((function(e,t){return t-e})),c=u[0],f=u[1];return c===s&&f?r(i[c],[i[f][0]]):a(n)}))};return a([t])},e.prototype._addTimeout=function(){var e=this;this._timer=setTimeout((function(){e._run()}),this._interval)},e._groupByHeight=function(e){return e.reduce((function(e,t){return e[t.height]?e[t.height].push(t):e[t.height]=[t],e}),Object.create(null))},e._getTransactionsToDispatch=function(e,t,n){for(var r=[],i=0;i<e.length;i++){var o=e[i];if(o.id===n)break;t[o.id]||r.push(o)}return r},e}();t.Watch=s,t.default=function(e,t,n){return i.transactions(e,t,1).then((function(r){var i=r[0];return new s(e,t,i,n)}))}},function(e,t,n){"use strict";t.__esModule=!0,function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(25))},function(e,t,n){"use strict";t.__esModule=!0;var r=function(){function e(){this._events=Object.create(null)}return e.prototype.hasListeners=function(e){return!(!this._events[e]||!this._events[e].length)},e.prototype.getActiveEvents=function(){var e=this;return Object.keys(this._events).filter((function(t){return e.hasListeners(t)}))},e.prototype.trigger=function(e,t){this._events[e]&&(this._events[e]=this._events[e].filter((function(e){try{e.handler.call(e.context,t)}catch(e){}return!e.once})),this._events[e].length||delete this._events[e])},e.prototype.on=function(e,t,n){this._on(e,t,n,!1)},e.prototype.once=function(e,t,n){this._on(e,t,n,!0)},e.prototype.off=function(e,t){var n=this,r="string"==typeof e?e:null,i="function"==typeof t?t:"function"==typeof e?e:null;r?i?r in this._events&&(this._events[r]=this._events[r].filter((function(e){return e.handler!==i}))):delete this._events[r]:Object.keys(this._events).forEach((function(e){n.off(e,i)}))},e.prototype._on=function(e,t,n,r){this._events[e]||(this._events[e]=[]),this._events[e].push({handler:t,context:n,once:r})},e}();t.EventEmitter=r}])})); |
@@ -1,12 +0,15 @@ | ||
import { BigNumber } from '@waves/bignumber'; | ||
import { assetsBalance } from '../../api-node/assets'; | ||
import { filter, map, pipe, prop } from '../utils'; | ||
export default function (base, address, wavesFee) { | ||
return assetsBalance(base, address).then(pipe(prop('balances'), filter(canBeSponsor(wavesFee)), map(currentFee(wavesFee)))); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bignumber_1 = require("@waves/bignumber"); | ||
var assets_1 = require("../../api-node/assets"); | ||
var utils_1 = require("../utils"); | ||
function default_1(base, address, wavesFee) { | ||
return assets_1.assetsBalance(base, address).then(utils_1.pipe(utils_1.prop('balances'), utils_1.filter(canBeSponsor(wavesFee)), utils_1.map(currentFee(wavesFee)))); | ||
} | ||
exports.default = default_1; | ||
function canBeSponsor(wavesFee) { | ||
return function (balance) { return (balance.minSponsoredAssetFee | ||
&& BigNumber.toBigNumber(balance.sponsorBalance || 0) | ||
&& bignumber_1.BigNumber.toBigNumber(balance.sponsorBalance || 0) | ||
.gte(wavesFee) | ||
&& BigNumber.toBigNumber(wavesFee) | ||
&& bignumber_1.BigNumber.toBigNumber(wavesFee) | ||
.div(0.001 * Math.pow(10, 8)) | ||
@@ -17,3 +20,3 @@ .mul(balance.minSponsoredAssetFee) | ||
function currentFee(wavesFee) { | ||
var count = BigNumber.toBigNumber(wavesFee) | ||
var count = bignumber_1.BigNumber.toBigNumber(wavesFee) | ||
.div(0.001 * Math.pow(10, 8)); | ||
@@ -23,3 +26,3 @@ return function (balance) { return ({ | ||
wavesFee: wavesFee, | ||
assetFee: BigNumber.toBigNumber(balance.minSponsoredAssetFee) | ||
assetFee: bignumber_1.BigNumber.toBigNumber(balance.minSponsoredAssetFee) | ||
.mul(count) | ||
@@ -26,0 +29,0 @@ .toFixed() |
@@ -0,18 +1,21 @@ | ||
"use strict"; | ||
var _a; | ||
import { filter, pipe, prop, switchTransactionByType, toArray, uniq } from '../utils'; | ||
import { NAME_MAP } from '../../constants'; | ||
var getAssetIdList = switchTransactionByType((_a = {}, | ||
_a[NAME_MAP.transfer] = function (tx) { return [tx.assetId, tx.feeAssetId]; }, | ||
_a[NAME_MAP.burn] = function (tx) { return [tx.assetId]; }, | ||
_a[NAME_MAP.reissue] = function (tx) { return [tx.assetId]; }, | ||
_a[NAME_MAP.exchange] = function (tx) { return [tx.buyOrder.assetPair.amountAsset, tx.buyOrder.assetPair.priceAsset, tx.buyOrder.matcherFeeAssetId, tx.sellOrder.matcherFeeAssetId]; }, | ||
_a[NAME_MAP.massTransfer] = function (tx) { return [tx.assetId]; }, | ||
_a[NAME_MAP.setAssetScript] = function (tx) { return [tx.assetId]; }, | ||
_a[NAME_MAP.sponsorship] = function (tx) { return [tx.assetId]; }, | ||
_a[NAME_MAP.invoke] = function (tx) { return (tx.payment || []).map(prop('assetId')); }, | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("../utils"); | ||
var constants_1 = require("../../constants"); | ||
var getAssetIdList = utils_1.switchTransactionByType((_a = {}, | ||
_a[constants_1.NAME_MAP.transfer] = function (tx) { return [tx.assetId, tx.feeAssetId]; }, | ||
_a[constants_1.NAME_MAP.burn] = function (tx) { return [tx.assetId]; }, | ||
_a[constants_1.NAME_MAP.reissue] = function (tx) { return [tx.assetId]; }, | ||
_a[constants_1.NAME_MAP.exchange] = function (tx) { return [tx.buyOrder.assetPair.amountAsset, tx.buyOrder.assetPair.priceAsset, tx.buyOrder.matcherFeeAssetId, tx.sellOrder.matcherFeeAssetId]; }, | ||
_a[constants_1.NAME_MAP.massTransfer] = function (tx) { return [tx.assetId]; }, | ||
_a[constants_1.NAME_MAP.setAssetScript] = function (tx) { return [tx.assetId]; }, | ||
_a[constants_1.NAME_MAP.sponsorship] = function (tx) { return [tx.assetId]; }, | ||
_a[constants_1.NAME_MAP.invoke] = function (tx) { return (tx.payment || []).map(utils_1.prop('assetId')); }, | ||
_a)); | ||
export default function (tx) { | ||
var idList = toArray(tx).reduce(function (acc, tx) { return acc.concat(getAssetIdList(tx) || []); }, []); | ||
return pipe(filter(Boolean), uniq)(idList); | ||
function default_1(tx) { | ||
var idList = utils_1.toArray(tx).reduce(function (acc, tx) { return acc.concat(getAssetIdList(tx) || []); }, []); | ||
return utils_1.pipe(utils_1.filter(Boolean), utils_1.uniq)(idList); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=getAssetIdListByTx.js.map |
@@ -1,8 +0,14 @@ | ||
import { details } from '../../api-node/assets'; | ||
import getAssetIdListByTx from './getAssetIdListByTx'; | ||
import { indexBy, prop } from '../utils'; | ||
export default function (base, tx) { | ||
return details(base, getAssetIdListByTx(tx)) | ||
.then(function (list) { return indexBy(prop('assetId'), list); }); | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var assets_1 = require("../../api-node/assets"); | ||
var getAssetIdListByTx_1 = __importDefault(require("./getAssetIdListByTx")); | ||
var utils_1 = require("../utils"); | ||
function default_1(base, tx) { | ||
return assets_1.details(base, getAssetIdListByTx_1.default(tx)) | ||
.then(function (list) { return utils_1.indexBy(utils_1.prop('assetId'), list); }); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=getAssetsByTransaction.js.map |
@@ -1,7 +0,13 @@ | ||
import { transactions } from '../../api-node/transactions'; | ||
import getAssetsByTransaction from './getAssetsByTransaction'; | ||
export default function (base, address, limit, after) { | ||
return transactions(base, address, limit, after) | ||
.then(function (transactions) { return getAssetsByTransaction(base, transactions).then(function (assets) { return ({ transactions: transactions, assets: assets }); }); }); | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var transactions_1 = require("../../api-node/transactions"); | ||
var getAssetsByTransaction_1 = __importDefault(require("./getAssetsByTransaction")); | ||
function default_1(base, address, limit, after) { | ||
return transactions_1.transactions(base, address, limit, after) | ||
.then(function (transactions) { return getAssetsByTransaction_1.default(base, transactions).then(function (assets) { return ({ transactions: transactions, assets: assets }); }); }); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=getTransactionsWithAssets.js.map |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
@@ -8,9 +9,10 @@ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
}; | ||
import { transactions } from '../../api-node/transactions'; | ||
import { indexBy, keys, prop } from '../utils'; | ||
import { EventEmitter } from 'typed-ts-events'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var transactions_1 = require("../../api-node/transactions"); | ||
var utils_1 = require("../utils"); | ||
var typed_ts_events_1 = require("typed-ts-events"); | ||
var Watch = /** @class */ (function () { | ||
function Watch(base, address, tx, interval) { | ||
var _a, _b; | ||
this._emitter = new EventEmitter(); | ||
this._emitter = new typed_ts_events_1.EventEmitter(); | ||
this._timer = null; | ||
@@ -42,3 +44,3 @@ this.address = address; | ||
var onError = function () { return _this._addTimeout(); }; | ||
transactions(this._base, this.address, 1) | ||
transactions_1.transactions(this._base, this.address, 1) | ||
.then(function (_a) { | ||
@@ -54,3 +56,3 @@ var tx = _a[0]; | ||
var hash = Watch._groupByHeight(list); | ||
var heightList = keys(hash) | ||
var heightList = utils_1.keys(hash) | ||
.map(Number) | ||
@@ -68,3 +70,3 @@ .sort(function (a, b) { return b - a; }); | ||
else { | ||
var wasDispatchHash = indexBy(prop('id'), _this._lastBlock.transactions); | ||
var wasDispatchHash = utils_1.indexBy(utils_1.prop('id'), _this._lastBlock.transactions); | ||
var toDispatch = Watch._getTransactionsToDispatch(__spreadArrays(hash[last], (hash[prev] || [])), wasDispatchHash, _this._lastBlock.lastId); | ||
@@ -97,3 +99,3 @@ if (_this._lastBlock.height !== last) { | ||
} | ||
return transactions(_this._base, _this.address, downloaded.length + 100).then(function (list) { | ||
return transactions_1.transactions(_this._base, _this.address, downloaded.length + 100).then(function (list) { | ||
if (downloaded.length === list.length) { | ||
@@ -103,3 +105,3 @@ return downloaded; | ||
var hash = Watch._groupByHeight(list); | ||
var heightList = keys(hash) | ||
var heightList = utils_1.keys(hash) | ||
.map(Number) | ||
@@ -150,5 +152,5 @@ .sort(function (a, b) { return b - a; }); | ||
}()); | ||
export { Watch }; | ||
export default function (base, address, interval) { | ||
return transactions(base, address, 1) | ||
exports.Watch = Watch; | ||
function default_1(base, address, interval) { | ||
return transactions_1.transactions(base, address, 1) | ||
.then(function (_a) { | ||
@@ -159,2 +161,3 @@ var tx = _a[0]; | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=watch.js.map |
@@ -1,9 +0,12 @@ | ||
import { headersAt, headersLast } from '../../api-node/blocks'; | ||
export default function (base) { | ||
return headersLast(base).then(function (header) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var blocks_1 = require("../../api-node/blocks"); | ||
function default_1(base) { | ||
return blocks_1.headersLast(base).then(function (header) { | ||
var firstHeight = Math.max(2, header.height - 1000); | ||
return headersAt(base, firstHeight) | ||
return blocks_1.headersAt(base, firstHeight) | ||
.then(function (oldHeader) { return Math.floor((header.timestamp - oldHeader.timestamp) / (header.height - firstHeight)); }); | ||
}); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=detectInterval.js.map |
@@ -1,5 +0,8 @@ | ||
import { headersLast } from '../../api-node/blocks'; | ||
export default function (base) { | ||
return headersLast(base).then(function (header) { return base58Decode(header.generator)[1]; }); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var blocks_1 = require("../../api-node/blocks"); | ||
function default_1(base) { | ||
return blocks_1.headersLast(base).then(function (header) { return base58Decode(header.generator)[1]; }); | ||
} | ||
exports.default = default_1; | ||
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; | ||
@@ -6,0 +9,0 @@ var ALPHABET_MAP = {}; |
@@ -1,5 +0,11 @@ | ||
import getNetworkByte from './getNetworkByte'; | ||
export default function (base) { | ||
return getNetworkByte(base).then(function (byte) { return String.fromCharCode(byte); }); | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var getNetworkByte_1 = __importDefault(require("./getNetworkByte")); | ||
function default_1(base) { | ||
return getNetworkByte_1.default(base).then(function (byte) { return String.fromCharCode(byte); }); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=getNetworkCode.js.map |
@@ -1,9 +0,14 @@ | ||
import { headersLast, height } from '../../api-node/blocks'; | ||
import { wait } from '../utils'; | ||
import detectInterval from './detectInterval'; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var blocks_1 = require("../../api-node/blocks"); | ||
var utils_1 = require("../utils"); | ||
var detectInterval_1 = __importDefault(require("./detectInterval")); | ||
var storage = Object.create(null); | ||
export default function (base, current) { | ||
function default_1(base, current) { | ||
return Promise.all([ | ||
getInterval(base), | ||
current == undefined ? height(base).then(function (_a) { | ||
current == undefined ? blocks_1.height(base).then(function (_a) { | ||
var height = _a.height; | ||
@@ -17,3 +22,3 @@ return height + 1; | ||
function loop(interval, current) { | ||
return headersLast(base).then(function (_a) { | ||
return blocks_1.headersLast(base).then(function (_a) { | ||
var height = _a.height, timestamp = _a.timestamp; | ||
@@ -26,6 +31,7 @@ if (height >= current) { | ||
var timeout = (((blocksToWait - 1) * interval) + ((interval - Math.abs(now - timestamp)))) * 0.8; | ||
return wait(inRange(timeout, 200, (interval * blocksToWait) * 0.8)).then(function () { return loop(interval, current); }); | ||
return utils_1.wait(inRange(timeout, 200, (interval * blocksToWait) * 0.8)).then(function () { return loop(interval, current); }); | ||
}); | ||
} | ||
} | ||
exports.default = default_1; | ||
function inRange(current, min, max) { | ||
@@ -39,3 +45,3 @@ return Math.round(Math.min(Math.max(current, min), max)); | ||
else { | ||
return detectInterval(base).then(function (interval) { | ||
return detectInterval_1.default(base).then(function (interval) { | ||
storage[base] = interval; | ||
@@ -42,0 +48,0 @@ return interval; |
@@ -0,5 +1,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var reg = new RegExp('((?!\\\\)"\\w+"):\\s*(-?[\\d|\\.]{14,})', 'g'); | ||
export default function (json) { | ||
function default_1(json) { | ||
return JSON.parse(json.replace(reg, "$1:\"$2\"")); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=parse.js.map |
@@ -1,2 +0,4 @@ | ||
export default function (params, evolver) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function default_1(params, evolver) { | ||
if (evolver === void 0) { evolver = Object.create(null); } | ||
@@ -20,3 +22,4 @@ var query = Object.keys(params) | ||
} | ||
exports.default = default_1; | ||
; | ||
//# sourceMappingURL=query.js.map |
@@ -1,10 +0,16 @@ | ||
import resolve from './resolve'; | ||
import parse from './parse'; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var resolve_1 = __importDefault(require("./resolve")); | ||
var parse_1 = __importDefault(require("./parse")); | ||
var request = typeof fetch === 'function' ? fetch : require('node-fetch'); | ||
export default function (params) { | ||
return request(resolve(params.url, params.base), updateHeaders(params.options)) | ||
function default_1(params) { | ||
return request(resolve_1.default(params.url, params.base), updateHeaders(params.options)) | ||
.then(parseResponse); | ||
} | ||
exports.default = default_1; | ||
function parseResponse(r) { | ||
return r.text().then(function (message) { return r.ok ? parse(message) : Promise.reject(tryParse(message)); }); | ||
return r.text().then(function (message) { return r.ok ? parse_1.default(message) : Promise.reject(tryParse(message)); }); | ||
} | ||
@@ -11,0 +17,0 @@ function tryParse(message) { |
@@ -1,4 +0,7 @@ | ||
export default function (path, base) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function default_1(path, base) { | ||
return new URL(path, base).toString(); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=resolve.js.map |
@@ -0,6 +1,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var FIELDS = ['value', 'amount', 'matcherFee', 'price', 'fee', 'minSponsoredAssetFee', 'quantity', 'sellMatcherFee', 'buyMatcherFee']; | ||
var reg = new RegExp("(?!\\\\)\"(" + FIELDS.join('|') + ")\":\\s*\"(-?\\d+)\"", 'g'); | ||
export default function (data) { | ||
function default_1(data) { | ||
return JSON.stringify(data).replace(reg, '"$1":$2'); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=stringify.js.map |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
@@ -12,5 +13,9 @@ __assign = Object.assign || function(t) { | ||
}; | ||
import { broadcast } from '../../api-node/transactions'; | ||
import { head, toArray } from '../utils'; | ||
import wait from './wait'; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var transactions_1 = require("../../api-node/transactions"); | ||
var utils_1 = require("../utils"); | ||
var wait_1 = __importDefault(require("./wait")); | ||
var DEFAULT_BROADCAST_OPTIONS = { | ||
@@ -22,3 +27,3 @@ chain: false, | ||
}; | ||
export default function (base, list, options) { | ||
function default_1(base, list, options) { | ||
var opt = __assign(__assign({}, DEFAULT_BROADCAST_OPTIONS), (options || {})); | ||
@@ -28,9 +33,10 @@ var isOnce = !Array.isArray(list); | ||
return (opt.chain | ||
? chainBroadcast(base, toArray(list), __assign(__assign({}, opt), { confirmations: confirmations })) | ||
: simpleBroadcast(base, toArray(list))) | ||
.then(function (list) { return opt.confirmations <= 0 ? list : wait(base, list, opt); }) | ||
.then(function (list) { return isOnce ? head(list) : list; }); | ||
? chainBroadcast(base, utils_1.toArray(list), __assign(__assign({}, opt), { confirmations: confirmations })) | ||
: simpleBroadcast(base, utils_1.toArray(list))) | ||
.then(function (list) { return opt.confirmations <= 0 ? list : wait_1.default(base, list, opt); }) | ||
.then(function (list) { return isOnce ? utils_1.head(list) : list; }); | ||
} | ||
exports.default = default_1; | ||
function simpleBroadcast(base, list) { | ||
return Promise.all(list.map(function (tx) { return broadcast(base, tx); })); | ||
return Promise.all(list.map(function (tx) { return transactions_1.broadcast(base, tx); })); | ||
} | ||
@@ -47,4 +53,4 @@ function chainBroadcast(base, list, options) { | ||
var tx = toBroadcast.pop(); | ||
broadcast(base, tx) | ||
.then(function (tx) { return wait(base, tx, options); }) | ||
transactions_1.broadcast(base, tx) | ||
.then(function (tx) { return wait_1.default(base, tx, options); }) | ||
.then(function (tx) { | ||
@@ -51,0 +57,0 @@ result.push(tx); |
@@ -1,5 +0,7 @@ | ||
import { head, indexBy, prop, toArray, wait } from '../utils'; | ||
import { status } from '../../api-node/transactions'; | ||
import { TRANSACTION_STATUSES } from '../../constants'; | ||
export default function (base, tx, options) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("../utils"); | ||
var transactions_1 = require("../../api-node/transactions"); | ||
var constants_1 = require("../../constants"); | ||
function default_1(base, tx, options) { | ||
var isOnce = !Array.isArray(tx); | ||
@@ -12,6 +14,6 @@ var start = Date.now(); | ||
var waitTx = function (list) { | ||
return status(base, list.map(prop('id'))) | ||
return transactions_1.status(base, list.map(utils_1.prop('id'))) | ||
.then(function (status) { | ||
var hash = indexBy(prop('id'), status.statuses); | ||
var hasError = list.some(function (tx) { return hash[tx.id].status === TRANSACTION_STATUSES.NOT_FOUND; }); | ||
var hash = utils_1.indexBy(utils_1.prop('id'), status.statuses); | ||
var hasError = list.some(function (tx) { return hash[tx.id].status === constants_1.TRANSACTION_STATUSES.NOT_FOUND; }); | ||
if (hasError) { | ||
@@ -35,7 +37,8 @@ throw new Error('One transaction is not in blockchain!'); | ||
} | ||
return wait(requestInterval).then(function () { return waitTx(toRequest); }); | ||
return utils_1.wait(requestInterval).then(function () { return waitTx(toRequest); }); | ||
}); | ||
}; | ||
return waitTx(toArray(tx)).then(function () { return isOnce ? head(confirmed) : confirmed; }); | ||
return waitTx(utils_1.toArray(tx)).then(function () { return isOnce ? utils_1.head(confirmed) : confirmed; }); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=wait.js.map |
@@ -1,8 +0,12 @@ | ||
export function toArray(data) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function toArray(data) { | ||
return Array.isArray(data) ? data : [data]; | ||
} | ||
export function head(data) { | ||
exports.toArray = toArray; | ||
function head(data) { | ||
return data[0]; | ||
} | ||
export function wait(time) { | ||
exports.head = head; | ||
function wait(time) { | ||
return new Promise(function (resolve) { | ||
@@ -12,16 +16,18 @@ setTimeout(resolve, time); | ||
} | ||
export function prop(key) { | ||
exports.wait = wait; | ||
function prop(key) { | ||
return function (data) { return data[key]; }; | ||
} | ||
export var keys = function (obj) { | ||
exports.prop = prop; | ||
exports.keys = function (obj) { | ||
return Object.keys(obj); | ||
}; | ||
export var entries = function (obj) { | ||
return keys(obj).map(function (name) { return [name, obj[name]]; }); | ||
exports.entries = function (obj) { | ||
return exports.keys(obj).map(function (name) { return [name, obj[name]]; }); | ||
}; | ||
export var values = function (obj) { | ||
return keys(obj).map(function (key) { return obj[key]; }); | ||
exports.values = function (obj) { | ||
return exports.keys(obj).map(function (key) { return obj[key]; }); | ||
}; | ||
export var assign = function (target, merge) { | ||
return entries(merge).reduce(function (acc, _a) { | ||
exports.assign = function (target, merge) { | ||
return exports.entries(merge).reduce(function (acc, _a) { | ||
var key = _a[0], value = _a[1]; | ||
@@ -32,9 +38,11 @@ target[key] = value; | ||
}; | ||
export function map(process) { | ||
function map(process) { | ||
return function (list) { return list.map(process); }; | ||
} | ||
export function filter(process) { | ||
exports.map = map; | ||
function filter(process) { | ||
return function (list) { return list.filter(process); }; | ||
} | ||
export function indexBy(process, data) { | ||
exports.filter = filter; | ||
function indexBy(process, data) { | ||
return data.reduce(function (acc, item) { | ||
@@ -45,4 +53,5 @@ acc[process(item)] = item; | ||
} | ||
export var uniq = function (list) { | ||
return keys(list.reduce(function (acc, item) { | ||
exports.indexBy = indexBy; | ||
exports.uniq = function (list) { | ||
return exports.keys(list.reduce(function (acc, item) { | ||
acc[item] = item; | ||
@@ -52,6 +61,7 @@ return acc; | ||
}; | ||
export function switchTransactionByType(choices) { | ||
function switchTransactionByType(choices) { | ||
return function (tx) { return choices[tx.type] && typeof choices[tx.type] === 'function' ? choices[tx.type](tx) : undefined; }; | ||
} | ||
export var pipe = function () { | ||
exports.switchTransactionByType = switchTransactionByType; | ||
exports.pipe = function () { | ||
var args = []; | ||
@@ -58,0 +68,0 @@ for (var _i = 0; _i < arguments.length; _i++) { |
{ | ||
"name": "@waves/blockchain-api", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
354371
3160