@waves/blockchain-api
Advanced tools
Comparing version 0.0.2 to 0.0.4
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = require("../../tools/request"); | ||
var query_1 = require("../../tools/query"); | ||
function dataKey(base, address, key, options) { | ||
return request_1.default({ | ||
import request from '../../tools/request'; | ||
import query from '../../tools/query'; | ||
export function dataKey(base, address, key, options) { | ||
return request({ | ||
base: base, | ||
@@ -11,5 +9,4 @@ url: "/addresses/data/" + address + "/" + encodeURIComponent(key) | ||
} | ||
exports.dataKey = dataKey; | ||
function scriptInfoMeta(base, address, options) { | ||
return request_1.default({ | ||
export function scriptInfoMeta(base, address, options) { | ||
return request({ | ||
base: base, | ||
@@ -19,5 +16,4 @@ url: "/addresses/scriptInfo/" + address + "/meta" | ||
} | ||
exports.scriptInfoMeta = scriptInfoMeta; | ||
function balanceDetails(base, address, options) { | ||
return request_1.default({ | ||
export function balanceDetails(base, address, options) { | ||
return request({ | ||
base: base, | ||
@@ -27,5 +23,4 @@ url: "/addresses/balance/details/" + address | ||
} | ||
exports.balanceDetails = balanceDetails; | ||
function balanceConfirmations(base, address, confirmations, options) { | ||
return request_1.default({ | ||
export function balanceConfirmations(base, address, confirmations, options) { | ||
return request({ | ||
base: base, | ||
@@ -35,6 +30,5 @@ url: "/addresses/balance/" + address + "/" + confirmations | ||
} | ||
exports.balanceConfirmations = balanceConfirmations; | ||
// TODO effectiveBalanceConfirmations | ||
function scriptInfo(base, address, options) { | ||
return request_1.default({ | ||
export function scriptInfo(base, address, options) { | ||
return request({ | ||
base: base, | ||
@@ -44,23 +38,18 @@ url: "/addresses/scriptInfo/" + address | ||
} | ||
exports.scriptInfo = scriptInfo; | ||
function data(base, address, params, options) { | ||
export function data(base, address, params, options) { | ||
if (params === void 0) { params = Object.create(null); } | ||
return request_1.default({ | ||
return request({ | ||
base: base, | ||
url: "/addresses/data/" + address + query_1.default(params) | ||
url: "/addresses/data/" + address + query(params) | ||
}); | ||
} | ||
exports.data = data; | ||
function validate(base, address, options) { | ||
return request_1.default({ base: base, url: "/addresses/validate/" + address }); | ||
export function validate(base, address, options) { | ||
return request({ base: base, url: "/addresses/validate/" + address }); | ||
} | ||
exports.validate = validate; | ||
function balance(base, address, options) { | ||
return request_1.default({ base: base, url: "/addresses/balance/" + address }); | ||
export function balance(base, address, options) { | ||
return request({ base: base, url: "/addresses/balance/" + address }); | ||
} | ||
exports.balance = balance; | ||
function buildAddress(base, publicKey, options) { | ||
return request_1.default({ base: base, url: "/addresses/publicKey/" + publicKey }); | ||
export function buildAddress(base, publicKey, options) { | ||
return request({ base: base, url: "/addresses/publicKey/" + publicKey }); | ||
} | ||
exports.buildAddress = buildAddress; | ||
//# sourceMappingURL=index.js.map |
@@ -1,11 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = require("../../tools/request"); | ||
var utils_1 = require("../../tools/utils"); | ||
function details(base, assetId) { | ||
import request from '../../tools/request'; | ||
import { toArray } from '../../tools/utils'; | ||
export function details(base, assetId) { | ||
var isOnce = !Array.isArray(assetId); | ||
return Promise.all(utils_1.toArray(assetId).map(function (id) { return request_1.default({ base: base, url: "/assets/details/" + id }); })) | ||
return Promise.all(toArray(assetId).map(function (id) { return request({ base: base, url: "/assets/details/" + id }); })) | ||
.then(function (list) { return isOnce ? list[0] : list; }); | ||
} | ||
exports.details = details; | ||
/** | ||
@@ -26,6 +23,5 @@ * TODO | ||
*/ | ||
function assetsBalance(base, address) { | ||
return request_1.default({ base: base, url: "/assets/balance/" + address }); | ||
export function assetsBalance(base, address) { | ||
return request({ base: base, url: "/assets/balance/" + address }); | ||
} | ||
exports.assetsBalance = assetsBalance; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = require("../../tools/request"); | ||
import request from '../../tools/request'; | ||
//GET /blocks/headers/seq/{from}/{to} TODO | ||
@@ -10,6 +8,5 @@ //Block header range | ||
*/ | ||
function headersLast(base, options) { | ||
return request_1.default({ base: base, url: '/blocks/headers/last' }); | ||
export function headersLast(base, options) { | ||
return request({ base: base, url: '/blocks/headers/last' }); | ||
} | ||
exports.headersLast = headersLast; | ||
//GET /blocks/height/{signature} TODO | ||
@@ -22,6 +19,5 @@ //Block height | ||
*/ | ||
function headersAt(base, height, options) { | ||
return request_1.default({ base: base, url: "/blocks/headers/at/" + height }); | ||
export function headersAt(base, height, options) { | ||
return request({ base: base, url: "/blocks/headers/at/" + height }); | ||
} | ||
exports.headersAt = headersAt; | ||
/** | ||
@@ -32,6 +28,5 @@ * GET /blocks/at/{height} | ||
*/ | ||
function blockAt(base, height) { | ||
return request_1.default({ base: base, url: "/blocks/at/" + height }); | ||
export function blockAt(base, height) { | ||
return request({ base: base, url: "/blocks/at/" + height }); | ||
} | ||
exports.blockAt = blockAt; | ||
//GET /blocks/seq/{from}/{to} TODO | ||
@@ -53,6 +48,5 @@ //Block range | ||
*/ | ||
function height(base) { | ||
return request_1.default({ base: base, url: '/blocks/height' }); | ||
export function height(base) { | ||
return request({ base: base, url: '/blocks/height' }); | ||
} | ||
exports.height = height; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = require("../../tools/request"); | ||
import request from '../../tools/request'; | ||
/** | ||
@@ -8,6 +6,5 @@ * GET /leasing/active/{address} | ||
*/ | ||
function active(base, address) { | ||
return request_1.default({ base: base, url: "/leasing/active/" + address }); | ||
export function active(base, address) { | ||
return request({ base: base, url: "/leasing/active/" + address }); | ||
} | ||
exports.active = active; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = require("../../tools/request"); | ||
import request from '../../tools/request'; | ||
/** | ||
@@ -8,6 +6,5 @@ * GET /blockchain/rewards | ||
*/ | ||
function rewards(base, height) { | ||
return request_1.default({ base: base, url: height ? "/blockchain/rewards/" + height : '/blockchain/rewards' }); | ||
export function rewards(base, height) { | ||
return request({ base: base, url: height ? "/blockchain/rewards/" + height : '/blockchain/rewards' }); | ||
} | ||
exports.rewards = rewards; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
@@ -13,8 +12,7 @@ __assign = Object.assign || function(t) { | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var constants_1 = require("../../constants"); | ||
var blocks_1 = require("../blocks"); | ||
var request_1 = require("../../tools/request"); | ||
var query_1 = require("../../tools/query"); | ||
var stringify_1 = require("../../tools/stringify"); | ||
import { TRANSACTION_STATUSES } from '../../constants'; | ||
import { height } from '../blocks'; | ||
import request from '../../tools/request'; | ||
import query from '../../tools/query'; | ||
import stringify from '../../tools/stringify'; | ||
/** | ||
@@ -34,4 +32,4 @@ * TODO | ||
*/ | ||
function calculateFee(base, tx) { | ||
return request_1.default({ | ||
export function calculateFee(base, tx) { | ||
return request({ | ||
base: base, | ||
@@ -41,7 +39,6 @@ url: '/transactions/calculateFee', | ||
method: 'POST', | ||
body: stringify_1.default(tx) | ||
body: stringify(tx) | ||
} | ||
}); | ||
} | ||
exports.calculateFee = calculateFee; | ||
/** | ||
@@ -59,6 +56,6 @@ * TODO | ||
*/ | ||
function transactions(base, address, limit, after, retry) { | ||
return request_1.default({ | ||
export function transactions(base, address, limit, after, retry) { | ||
return request({ | ||
base: base, | ||
url: "/transactions/address/" + address + "/limit/" + limit + query_1.default({ after: after }) | ||
url: "/transactions/address/" + address + "/limit/" + limit + query({ after: after }) | ||
}).then(function (_a) { | ||
@@ -69,3 +66,2 @@ var list = _a[0]; | ||
} | ||
exports.transactions = transactions; | ||
/** | ||
@@ -75,6 +71,5 @@ * GET /transactions/unconfirmed/info/{id} | ||
*/ | ||
function unconfirmedInfo(base, id) { | ||
return request_1.default({ base: base, url: "/transactions/unconfirmed/info/" + id }); | ||
export function unconfirmedInfo(base, id) { | ||
return request({ base: base, url: "/transactions/unconfirmed/info/" + id }); | ||
} | ||
exports.unconfirmedInfo = unconfirmedInfo; | ||
/** | ||
@@ -89,7 +84,6 @@ * TODO | ||
*/ | ||
function info(base, id) { | ||
return request_1.default({ base: base, url: "/transactions/info/" + id }); | ||
export function info(base, id) { | ||
return request({ base: base, url: "/transactions/info/" + id }); | ||
} | ||
exports.info = info; | ||
function status(base, list) { | ||
export function status(base, list) { | ||
var DEFAULT_STATUS = { | ||
@@ -100,13 +94,13 @@ id: '', | ||
inUTX: false, | ||
status: constants_1.TRANSACTION_STATUSES.NOT_FOUND | ||
status: TRANSACTION_STATUSES.NOT_FOUND | ||
}; | ||
var loadAllTxInfo = list.map(function (id) { | ||
return unconfirmedInfo(base, id) | ||
.then(function () { return (__assign(__assign({}, DEFAULT_STATUS), { id: id, status: constants_1.TRANSACTION_STATUSES.UNCONFIRMED, inUTX: true })); }) | ||
.then(function () { return (__assign(__assign({}, DEFAULT_STATUS), { id: id, status: TRANSACTION_STATUSES.UNCONFIRMED, inUTX: true })); }) | ||
.catch(function () { return info(base, id) | ||
.then(function (tx) { return (__assign(__assign({}, DEFAULT_STATUS), { id: id, status: constants_1.TRANSACTION_STATUSES.IN_BLOCKCHAIN, height: tx.height })); }); }) | ||
.then(function (tx) { return (__assign(__assign({}, DEFAULT_STATUS), { id: id, status: TRANSACTION_STATUSES.IN_BLOCKCHAIN, height: tx.height })); }); }) | ||
.catch(function () { return (__assign(__assign({}, DEFAULT_STATUS), { id: id })); }); | ||
}); | ||
return Promise.all([ | ||
blocks_1.height(base), | ||
height(base), | ||
Promise.all(loadAllTxInfo) | ||
@@ -117,13 +111,12 @@ ]).then(function (_a) { | ||
height: height, | ||
statuses: statuses.map(function (item) { return (__assign(__assign({}, item), { confirmations: item.status === constants_1.TRANSACTION_STATUSES.IN_BLOCKCHAIN ? height - item.height : item.confirmations })); }) | ||
statuses: statuses.map(function (item) { return (__assign(__assign({}, item), { confirmations: item.status === TRANSACTION_STATUSES.IN_BLOCKCHAIN ? height - item.height : item.confirmations })); }) | ||
}); | ||
}); | ||
} | ||
exports.status = status; | ||
function broadcast(base, tx) { | ||
return request_1.default({ | ||
export function broadcast(base, tx) { | ||
return request({ | ||
base: base, url: '/transactions/broadcast', | ||
options: { | ||
method: 'POST', | ||
body: stringify_1.default(tx), | ||
body: stringify(tx), | ||
headers: { | ||
@@ -135,3 +128,2 @@ 'Content-Type': 'application/json' | ||
} | ||
exports.broadcast = broadcast; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TYPE_MAP = { | ||
export var TYPE_MAP = { | ||
3: 'issue', | ||
@@ -19,3 +17,3 @@ 4: 'transfer', | ||
}; | ||
exports.NAME_MAP = { | ||
export var NAME_MAP = { | ||
'issue': 3, | ||
@@ -36,3 +34,3 @@ 'transfer': 4, | ||
}; | ||
exports.TRANSACTION_STATUSES = { | ||
export var TRANSACTION_STATUSES = { | ||
IN_BLOCKCHAIN: 'in_blockchain', | ||
@@ -39,0 +37,0 @@ UNCONFIRMED: 'unconfirmed', |
@@ -41,2 +41,3 @@ import * as addressesModule from './api-node/addresses'; | ||
}>; | ||
availableSponsoredBalances: (address: string, wavesFee: TLong) => Promise<import("./tools/adresses/availableSponsoredBalances").TAssetFeeInfo[]>; | ||
}; | ||
@@ -43,0 +44,0 @@ query: typeof query; |
@@ -1,20 +0,19 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var addressesModule = require("./api-node/addresses"); | ||
var blocksModule = require("./api-node/blocks"); | ||
var transactionsModule = require("./api-node/transactions"); | ||
var leasingModule = require("./api-node/leasing"); | ||
var query_1 = require("./tools/query"); | ||
var resolve_1 = require("./tools/resolve"); | ||
var request_1 = require("./tools/request"); | ||
var broadcast_1 = require("./tools/transactions/broadcast"); | ||
var getAssetsByTransaction_1 = require("./tools/adresses/getAssetsByTransaction"); | ||
var getAssetIdListByTx_1 = require("./tools/adresses/getAssetIdListByTx"); | ||
var getTransactionsWithAssets_1 = require("./tools/adresses/getTransactionsWithAssets"); | ||
var wait_1 = require("./tools/transactions/wait"); | ||
var parse_1 = require("./tools/parse"); | ||
var getNetworkByte_1 = require("./tools/blocks/getNetworkByte"); | ||
var getNetworkCode_1 = require("./tools/blocks/getNetworkCode"); | ||
var watch_1 = require("./tools/adresses/watch"); | ||
function create(base) { | ||
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'; | ||
export function create(base) { | ||
var addresses = wrapRecord(base, addressesModule); | ||
@@ -26,19 +25,20 @@ var blocks = wrapRecord(base, blocksModule); | ||
transactions: { | ||
broadcast: wrapRequest(base, broadcast_1.default), | ||
wait: wrapRequest(base, wait_1.default) | ||
broadcast: wrapRequest(base, broadcast), | ||
wait: wrapRequest(base, wait) | ||
}, | ||
blocks: { | ||
getNetworkByte: wrapRequest(base, getNetworkByte_1.default), | ||
getNetworkCode: wrapRequest(base, getNetworkCode_1.default) | ||
getNetworkByte: wrapRequest(base, getNetworkByte), | ||
getNetworkCode: wrapRequest(base, getNetworkCode) | ||
}, | ||
addresses: { | ||
createWatch: wrapRequest(base, watch_1.default), | ||
getAssetsByTransaction: wrapRequest(base, getAssetsByTransaction_1.default), | ||
getAssetIdListByTx: getAssetIdListByTx_1.default, | ||
getTransactionsWithAssets: wrapRequest(base, getTransactionsWithAssets_1.default), | ||
createWatch: wrapRequest(base, createWatch), | ||
getAssetsByTransaction: wrapRequest(base, getAssetsByTransaction), | ||
getAssetIdListByTx: getAssetIdListByTx, | ||
getTransactionsWithAssets: wrapRequest(base, getTransactionsWithAssets), | ||
availableSponsoredBalances: wrapRequest(base, availableSponsoredBalances) | ||
}, | ||
query: query_1.default, | ||
resolve: resolve_1.default, | ||
request: request_1.default, | ||
parse: parse_1.default | ||
query: query, | ||
resolve: resolve, | ||
request: request, | ||
parse: parse | ||
}; | ||
@@ -53,4 +53,3 @@ return { | ||
} | ||
exports.create = create; | ||
exports.default = create; | ||
export default create; | ||
function wrapRecord(base, hash) { | ||
@@ -57,0 +56,0 @@ return Object.keys(hash).reduce(function (acc, methodName) { |
@@ -1,3 +0,1 @@ | ||
"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 u=e[r]={i:r,l:!1,exports:{}};return t[r].call(u.exports,u,u.exports,n),u.l=!0,u.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 u in t)n.d(r,u,function(e){return t[e]}.bind(null,u));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=12)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(6),u=n(7),i="function"==typeof fetch?fetch:n(14);function o(t){return t.text().then((function(e){return t.ok?u.default(e):Promise.reject(function(t){try{return JSON.parse(t)}catch(e){return t}}(e))}))}e.default=function(t){return i(r.default(t.url,t.base),function(t){void 0===t&&(t=Object.create(null));return t.credentials="include",t}(t.options)).then(o)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toArray=function(t){return Array.isArray(t)?t:[t]},e.head=function(t){return t[0]},e.wait=function(t){return new Promise((function(e){setTimeout(e,t)}))},e.prop=function(t){return function(e){return e[t]}},e.keys=function(t){return Object.keys(t)},e.entries=function(t){return e.keys(t).map((function(e){return[e,t[e]]}))},e.values=function(t){return e.keys(t).map((function(e){return t[e]}))},e.assign=function(t,n){return e.entries(n).reduce((function(e,n){var r=n[0],u=n[1];return t[r]=u,t}),t)},e.map=function(t){return function(e){return e.map(t)}},e.filter=function(t){return function(e){return e.filter(t)}},e.indexBy=function(t,e){return e.reduce((function(e,n){return e[t(n)]=n,e}),{})},e.uniq=function(t){return e.keys(t.reduce((function(t,e){return t[e]=e,t}),Object.create(null)))},e.switchTransactionByType=function(t){return function(e){return t[e.type]&&"function"==typeof t[e.type]?t[e.type](e):void 0}},e.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return t.reduce((function(t,e){return t(e)}),e)}}},function(t,e,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var u in e=arguments[n])Object.prototype.hasOwnProperty.call(e,u)&&(t[u]=e[u]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var u=n(5),i=n(4),o=n(0),s=n(3),a=n(15);function c(t,e){return o.default({base:t,url:"/transactions/unconfirmed/info/"+e})}function f(t,e){return o.default({base:t,url:"/transactions/info/"+e})}e.calculateFee=function(t,e){return o.default({base:t,url:"/transactions/calculateFee",options:{method:"POST",body:a.default(e)}})},e.transactions=function(t,e,n,r,u){return o.default({base:t,url:"/transactions/address/"+e+"/limit/"+n+s.default({after:r})}).then((function(t){return t[0]}))},e.unconfirmedInfo=c,e.info=f,e.status=function(t,e){var n={id:"",confirmations:-1,height:-1,inUTX:!1,status:u.TRANSACTION_STATUSES.NOT_FOUND},o=e.map((function(e){return c(t,e).then((function(){return r(r({},n),{id:e,status:u.TRANSACTION_STATUSES.UNCONFIRMED,inUTX:!0})})).catch((function(){return f(t,e).then((function(t){return r(r({},n),{id:e,status:u.TRANSACTION_STATUSES.IN_BLOCKCHAIN,height:t.height})}))})).catch((function(){return r(r({},n),{id:e})}))}));return Promise.all([i.height(t),Promise.all(o)]).then((function(t){var e=t[0].height,n=t[1];return{height:e,statuses:n.map((function(t){return r(r({},t),{confirmations:t.status===u.TRANSACTION_STATUSES.IN_BLOCKCHAIN?e-t.height:t.confirmations})}))}}))},e.broadcast=function(t,e){return o.default({base:t,url:"/transactions/broadcast",options:{method:"POST",body:a.default(e),headers:{"Content-Type":"application/json"}}})}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=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(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0);e.headersLast=function(t,e){return r.default({base:t,url:"/blocks/headers/last"})},e.headersAt=function(t,e,n){return r.default({base:t,url:"/blocks/headers/at/"+e})},e.blockAt=function(t,e){return r.default({base:t,url:"/blocks/at/"+e})},e.height=function(t){return r.default({base:t,url:"/blocks/height"})}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.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"},e.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},e.TRANSACTION_STATUSES={IN_BLOCKCHAIN:"in_blockchain",UNCONFIRMED:"unconfirmed",NOT_FOUND:"not_found"}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){return new URL(t,e).toString()}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=new RegExp('((?!\\\\)"\\w+"):\\s*(-?[\\d|\\.]{14,})',"g");e.default=function(t){return JSON.parse(t.replace(r,'$1:"$2"'))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),u=n(2),i=n(5);e.default=function(t,e,n){var o=!Array.isArray(e),s=Date.now(),a=[],c=n&&n.confirmations||0,f=n&&n.maxWaitTime||0,l=n&&n.requestInterval||250,d=function(e){return u.status(t,e.map(r.prop("id"))).then((function(t){var n=r.indexBy(r.prop("id"),t.statuses);if(e.some((function(t){return n[t.id].status===i.TRANSACTION_STATUSES.NOT_FOUND})))throw new Error("One transaction is not in blockchain!");var u=e.filter((function(t){return!(n[t.id].confirmations>=c)||(a.push(t),!1)}));if(u.length)return f&&Date.now()-s>f?Promise.reject("Timeout error!"):r.wait(l).then((function(){return d(u)}))}))};return d(r.toArray(e)).then((function(){return o?r.head(a):a}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(18),u=n(10),i=n(1);e.default=function(t,e){return r.details(t,u.default(e)).then((function(t){return i.indexBy(i.prop("assetId"),t)}))}},function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0});var u=n(1),i=n(5),o=u.switchTransactionByType(((r={})[i.NAME_MAP.transfer]=function(t){return[t.assetId,t.feeAssetId]},r[i.NAME_MAP.burn]=function(t){return[t.assetId]},r[i.NAME_MAP.reissue]=function(t){return[t.assetId]},r[i.NAME_MAP.exchange]=function(t){return[t.buyOrder.assetPair.amountAsset,t.buyOrder.assetPair.priceAsset,t.buyOrder.matcherFeeAssetId,t.sellOrder.matcherFeeAssetId]},r[i.NAME_MAP.massTransfer]=function(t){return[t.assetId]},r[i.NAME_MAP.setAssetScript]=function(t){return[t.assetId]},r[i.NAME_MAP.sponsorship]=function(t){return[t.assetId]},r[i.NAME_MAP.invoke]=function(t){return(t.payment||[]).map(u.prop("assetId"))},r));e.default=function(t){var e=u.toArray(t).reduce((function(t,e){return t.concat(o(e)||[])}),[]);return u.pipe(u.filter(Boolean),u.uniq)(e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(4);e.default=function(t){return r.headersLast(t).then((function(t){return function(t){var e,n,r,u,o;if(0===t.length)return new Uint8Array(0);o=void 0,u=void 0,e=[0],o=0;for(;o<t.length;){if(!((n=t[o])in i))throw"Base58.decode received unacceptable input. Character '"+n+"' is not in the Base58 alphabet.";for(u=0;u<e.length;)e[u]*=58,u++;for(e[0]+=i[n],r=0,u=0;u<e.length;)e[u]+=r,r=e[u]>>8,e[u]&=255,++u;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]}))};for(var u="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",i={},o=0;o<u.length;o++)i[u.charAt(o)]=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(13),u=n(4),i=n(2),o=n(16),s=n(3),a=n(6),c=n(0),f=n(17),l=n(9),d=n(10),h=n(19),p=n(8),v=n(7),_=n(11),y=n(20),b=n(21);function g(t){return{addresses:m(t,r),blocks:m(t,u),transactions:m(t,i),leasing:m(t,o),tools:{transactions:{broadcast:A(t,f.default),wait:A(t,p.default)},blocks:{getNetworkByte:A(t,_.default),getNetworkCode:A(t,y.default)},addresses:{createWatch:A(t,b.default),getAssetsByTransaction:A(t,l.default),getAssetIdListByTx:d.default,getTransactionsWithAssets:A(t,h.default)},query:s.default,resolve:a.default,request:c.default,parse:v.default}}}function m(t,e){return Object.keys(e).reduce((function(n,r){return n[r]=A(t,e[r]),n}),{})}function A(t,e){return e.bind(null,t)}e.create=g,e.default=g},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),u=n(3);e.dataKey=function(t,e,n,u){return r.default({base:t,url:"/addresses/data/"+e+"/"+encodeURIComponent(n)})},e.scriptInfoMeta=function(t,e,n){return r.default({base:t,url:"/addresses/scriptInfo/"+e+"/meta"})},e.balanceDetails=function(t,e,n){return r.default({base:t,url:"/addresses/balance/details/"+e})},e.balanceConfirmations=function(t,e,n,u){return r.default({base:t,url:"/addresses/balance/"+e+"/"+n})},e.scriptInfo=function(t,e,n){return r.default({base:t,url:"/addresses/scriptInfo/"+e})},e.data=function(t,e,n,i){return void 0===n&&(n=Object.create(null)),r.default({base:t,url:"/addresses/data/"+e+u.default(n)})},e.validate=function(t,e,n){return r.default({base:t,url:"/addresses/validate/"+e})},e.balance=function(t,e,n){return r.default({base:t,url:"/addresses/balance/"+e})},e.buildAddress=function(t,e,n){return r.default({base:t,url:"/addresses/publicKey/"+e})}},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";Object.defineProperty(e,"__esModule",{value:!0});var r=new RegExp('(?!\\\\)"('+["value","amount","matcherFee","price","fee","minSponsoredAssetFee","quantity","sellMatcherFee","buyMatcherFee"].join("|")+')":\\s*"(-?\\d+)"',"g");e.default=function(t){return JSON.stringify(t).replace(r,"$1:$2")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0);e.active=function(t,e){return r.default({base:t,url:"/leasing/active/"+e})}},function(t,e,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var u in e=arguments[n])Object.prototype.hasOwnProperty.call(e,u)&&(t[u]=e[u]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var u=n(2),i=n(1),o=n(8),s={chain:!1,confirmations:-1,maxWaitTime:0,requestInterval:0};e.default=function(t,e,n){var a=r(r({},s),n||{}),c=!Array.isArray(e),f=a.confirmations>0?1:0;return(a.chain?function(t,e,n){return new Promise((function(r,i){var s=e.slice().reverse(),a=[],c=function(){if(!s.length)return r(a),null;var e=s.pop();u.broadcast(t,e).then((function(e){return o.default(t,e,n)})).then((function(t){a.push(t),c()}),i)};c()}))}(t,i.toArray(e),r(r({},a),{confirmations:f})):function(t,e){return Promise.all(e.map((function(e){return u.broadcast(t,e)})))}(t,i.toArray(e))).then((function(e){return a.confirmations<=0?e:o.default(t,e,a)})).then((function(t){return c?i.head(t):t}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),u=n(1);e.details=function(t,e){var n=!Array.isArray(e);return Promise.all(u.toArray(e).map((function(e){return r.default({base:t,url:"/assets/details/"+e})}))).then((function(t){return n?t[0]:t}))},e.assetsBalance=function(t,e){return r.default({base:t,url:"/assets/balance/"+e})}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),u=n(9);e.default=function(t,e,n,i){return r.transactions(t,e,n,i).then((function(e){return u.default(t,e).then((function(t){return{transactions:e,assets:t}}))}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(11);e.default=function(t){return r.default(t).then((function(t){return String.fromCharCode(t)}))}},function(t,e,n){"use strict";var r=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),u=0;for(e=0;e<n;e++)for(var i=arguments[e],o=0,s=i.length;o<s;o++,u++)r[u]=i[o];return r};Object.defineProperty(e,"__esModule",{value:!0});var u=n(2),i=n(1),o=n(22),s=function(){function t(t,e,n,r){var u,i;this._emitter=new o.EventEmitter,this._timer=null,this.address=e,this._interval=r||1e3,this._base=t,this._lastBlock={lastId:(null===(u=n)||void 0===u?void 0:u.id)||"",height:(null===(i=n)||void 0===i?void 0:i.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()};u.transactions(this._base,this.address,1).then((function(u){var o=u[0];if(!o)return e._addTimeout(),null;e.getTransactionsInHeight(o,310).then((function(n){var u,o=t._groupByHeight(n),s=i.keys(o).map(Number).sort((function(t,e){return e-t})),a=s[0],c=s[1];if(e._lastBlock.height){var f=i.indexBy(i.prop("id"),e._lastBlock.transactions),l=t._getTransactionsToDispatch(r(o[a],o[c]||[]),f,e._lastBlock.lastId);e._lastBlock.height!==a?e._lastBlock={height:a,lastId:o[c]&&o[c].length?o[c][0].id:"",transactions:o[a]}:(u=e._lastBlock.transactions).push.apply(u,l),l.length&&e._emitter.trigger("change-state",l)}else e._lastBlock={height:a,lastId:o[c]&&o[c].length?o[c][0].id:"",transactions:o[a]},e._emitter.trigger("change-state",n);e._addTimeout()}),n)})).catch(n)},t.prototype.getTransactionsInHeight=function(e,n){var o=this,s=e.height,a=function(e){return e.length>=n?Promise.resolve(e):u.transactions(o._base,o.address,e.length+100).then((function(n){if(e.length===n.length)return e;var u=t._groupByHeight(n),o=i.keys(u).map(Number).sort((function(t,e){return e-t})),c=o[0],f=o[1];return c===s&&f?r(u[c],[u[f][0]]):a(n)}))};return a([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=[],u=0;u<t.length;u++){var i=t[u];if(i.id===n)break;e[i.id]||r.push(i)}return r},t}();e.Watch=s,e.default=function(t,e,n){return u.transactions(t,e,1).then((function(r){var u=r[0];return new s(t,e,u,n)}))}},function(t,e,n){"use strict";e.__esModule=!0,function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(23))},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,u="function"==typeof e?e:"function"==typeof t?t:null;r?u?r in this._events&&(this._events[r]=this._events[r].filter((function(t){return t.handler!==u}))):delete this._events[r]:Object.keys(this._events).forEach((function(t){n.off(t,u)}))},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){"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,E,B,I,R,U=q.prototype={constructor:q,toString:null,valueOf:null},D=new q(1),F=20,T=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),F+m.e+1,T);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=T: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),F=n),t.hasOwnProperty(e="ROUNDING_MODE")&&(g(n=t[e],0,8,e),T=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:F,ROUNDING_MODE:T,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=F: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=F,b=T;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,E,B,I,R,U=i.s==o.s?1:-1,D=i.c,F=o.c;if(!(D&&D[0]&&F&&F[0]))return new q(i.s&&o.s&&(D?!F||D[0]!=F[0]:F)?D&&0==D[0]||!F?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;F[d]==(D[d]||0);d++);if(F[d]>(D[d]||0)&&p--,U<0)w.push(1),g=!0;else{for(E=D.length,I=F.length,d=0,U+=2,(m=r(a/(F[0]+1)))>1&&(F=t(F,m,a),D=t(D,m,a),I=F.length,E=D.length),A=I,N=(O=D.slice(0,I)).length;N<I;O[N++]=0);R=F.slice(),R=[0].concat(R),B=F[0],F[1]>=a/2&&B++;do{if(m=0,(l=e(F,O,I,N))<0){if(_=O[0],I!=N&&(_=_*a+(O[1]||0)),(m=r(_/B))>1)for(m>=a&&(m=a-1),v=(b=t(F,m,a)).length,N=O.length;1==e(b,O,v,N);)m--,n(b,I<v?R:F,v,a),v=b.length,l=1;else 0==m&&(l=m=1),v=(b=F.slice()).length;if(v<N&&(b=[0].concat(b)),n(O,b,N,a),N=O.length,-1==l)for(;e(F,O,I,N)<1;)m++,n(O,I<N?R:F,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++<E||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,E=/^([^.]+)\.$/,B=/^\.([^.]+)$/,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(E,"$1").replace(B,"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=T: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),F,T)},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,T,void 0):p)},U.integerValue=function(t){var e=new q(this);return null==t?t=T: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==T?-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==T?-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=T: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=F+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+F+2,1),t=!n.times(n).eq(o));break}if(!r&&($(i,i.e+F+2,0),i.times(i).eq(o))){n=i;break}f+=4,s+=4,r=1}return $(n,n.e+F+1,T,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,T).minus(b).abs().comparedTo(w(l,n,u,T).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),F+i+1,T)).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 d})),n.d(r,"scriptInfoMeta",(function(){return g})),n.d(r,"balanceDetails",(function(){return m})),n.d(r,"balanceConfirmations",(function(){return b})),n.d(r,"scriptInfo",(function(){return v})),n.d(r,"data",(function(){return y})),n.d(r,"validate",(function(){return w})),n.d(r,"balance",(function(){return O})),n.d(r,"buildAddress",(function(){return N}));var i={};n.r(i),n.d(i,"headersLast",(function(){return _})),n.d(i,"headersAt",(function(){return A})),n.d(i,"blockAt",(function(){return E})),n.d(i,"height",(function(){return B}));var o={};n.r(o),n.d(o,"calculateFee",(function(){return C})),n.d(o,"transactions",(function(){return k})),n.d(o,"unconfirmedInfo",(function(){return H})),n.d(o,"info",(function(){return q})),n.d(o,"status",(function(){return G})),n.d(o,"broadcast",(function(){return J}));var u={};n.r(u),n.d(u,"active",(function(){return W}));var s=function(t,e){return new URL(t,e).toString()},c=new RegExp('((?!\\\\)"\\w+"):\\s*(-?[\\d|\\.]{14,})',"g"),f=function(t){return JSON.parse(t.replace(c,'$1:"$2"'))},a="function"==typeof fetch?fetch:n(2),l=function(t){return a(s(t.url,t.base),function(t){void 0===t&&(t=Object.create(null));return t.credentials="include",t}(t.options)).then(h)};function h(t){return t.text().then((function(e){return t.ok?f(e):Promise.reject(function(t){try{return JSON.parse(t)}catch(e){return t}}(e))}))}var p=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 d(t,e,n,r){return l({base:t,url:"/addresses/data/"+e+"/"+encodeURIComponent(n)})}function g(t,e,n){return l({base:t,url:"/addresses/scriptInfo/"+e+"/meta"})}function m(t,e,n){return l({base:t,url:"/addresses/balance/details/"+e})}function b(t,e,n,r){return l({base:t,url:"/addresses/balance/"+e+"/"+n})}function v(t,e,n){return l({base:t,url:"/addresses/scriptInfo/"+e})}function y(t,e,n,r){return void 0===n&&(n=Object.create(null)),l({base:t,url:"/addresses/data/"+e+p(n)})}function w(t,e,n){return l({base:t,url:"/addresses/validate/"+e})}function O(t,e,n){return l({base:t,url:"/addresses/balance/"+e})}function N(t,e,n){return l({base:t,url:"/addresses/publicKey/"+e})}function _(t,e){return l({base:t,url:"/blocks/headers/last"})}function A(t,e,n){return l({base:t,url:"/blocks/headers/at/"+e})}function E(t,e){return l({base:t,url:"/blocks/at/"+e})}function B(t){return l({base:t,url:"/blocks/height"})}var I=4,R=5,U=6,D=7,F=11,T=14,L=15,S=16,P={IN_BLOCKCHAIN:"in_blockchain",UNCONFIRMED:"unconfirmed",NOT_FOUND:"not_found"},j=new RegExp('(?!\\\\)"('+["value","amount","matcherFee","price","fee","minSponsoredAssetFee","quantity","sellMatcherFee","buyMatcherFee"].join("|")+')":\\s*"(-?\\d+)"',"g"),x=function(t){return JSON.stringify(t).replace(j,"$1:$2")},M=function(){return(M=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 C(t,e){return l({base:t,url:"/transactions/calculateFee",options:{method:"POST",body:x(e)}})}function k(t,e,n,r,i){return l({base:t,url:"/transactions/address/"+e+"/limit/"+n+p({after:r})}).then((function(t){return t[0]}))}function H(t,e){return l({base:t,url:"/transactions/unconfirmed/info/"+e})}function q(t,e){return l({base:t,url:"/transactions/info/"+e})}function G(t,e){var n={id:"",confirmations:-1,height:-1,inUTX:!1,status:P.NOT_FOUND},r=e.map((function(e){return H(t,e).then((function(){return M(M({},n),{id:e,status:P.UNCONFIRMED,inUTX:!0})})).catch((function(){return q(t,e).then((function(t){return M(M({},n),{id:e,status:P.IN_BLOCKCHAIN,height:t.height})}))})).catch((function(){return M(M({},n),{id:e})}))}));return Promise.all([B(t),Promise.all(r)]).then((function(t){var e=t[0].height,n=t[1];return{height:e,statuses:n.map((function(t){return M(M({},t),{confirmations:t.status===P.IN_BLOCKCHAIN?e-t.height:t.confirmations})}))}}))}function J(t,e){return l({base:t,url:"/transactions/broadcast",options:{method:"POST",body:x(e),headers:{"Content-Type":"application/json"}}})}function W(t,e){return l({base:t,url:"/leasing/active/"+e})}function $(t){return Array.isArray(t)?t:[t]}function V(t){return t[0]}function z(t){return function(e){return e[t]}}var X=function(t){return Object.keys(t)};function K(t){return function(e){return e.filter(t)}}function Y(t,e){return e.reduce((function(e,n){return e[t(n)]=n,e}),{})}var Z=function(t){return X(t.reduce((function(t,e){return t[e]=e,t}),Object.create(null)))};var Q,tt=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return t.reduce((function(t,e){return t(e)}),e)}},et=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 G(t,e.map(z("id"))).then((function(t){var n=Y(z("id"),t.statuses);if(e.some((function(t){return n[t.id].status===P.NOT_FOUND})))throw new Error("One transaction is not in blockchain!");var r,a=e.filter((function(t){return!(n[t.id].confirmations>=u)||(o.push(t),!1)}));if(a.length)return s&&Date.now()-i>s?Promise.reject("Timeout error!"):(r=c,new Promise((function(t){setTimeout(t,r)}))).then((function(){return f(a)}))}))};return f($(e)).then((function(){return r?V(o):o}))},nt=function(){return(nt=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)},rt={chain:!1,confirmations:-1,maxWaitTime:0,requestInterval:0},it=function(t,e,n){var r=nt(nt({},rt),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();J(t,e).then((function(e){return et(t,e,n)})).then((function(t){u.push(t),s()}),i)};s()}))}(t,$(e),nt(nt({},r),{confirmations:o})):function(t,e){return Promise.all(e.map((function(e){return J(t,e)})))}(t,$(e))).then((function(e){return r.confirmations<=0?e:et(t,e,r)})).then((function(t){return i?V(t):t}))};var ot,ut=((Q={})[I]=function(t){return[t.assetId,t.feeAssetId]},Q[U]=function(t){return[t.assetId]},Q[R]=function(t){return[t.assetId]},Q[D]=function(t){return[t.buyOrder.assetPair.amountAsset,t.buyOrder.assetPair.priceAsset,t.buyOrder.matcherFeeAssetId,t.sellOrder.matcherFeeAssetId]},Q[F]=function(t){return[t.assetId]},Q[L]=function(t){return[t.assetId]},Q[T]=function(t){return[t.assetId]},Q[S]=function(t){return(t.payment||[]).map(z("assetId"))},ot=Q,function(t){return ot[t.type]&&"function"==typeof ot[t.type]?ot[t.type](t):void 0}),st=function(t){var e=$(t).reduce((function(t,e){return t.concat(ut(e)||[])}),[]);return tt(K(Boolean),Z)(e)},ct=function(t,e){return function(t,e){var n=!Array.isArray(e);return Promise.all($(e).map((function(e){return l({base:t,url:"/assets/details/"+e})}))).then((function(t){return n?t[0]:t}))}(t,st(e)).then((function(t){return Y(z("assetId"),t)}))},ft=function(t,e,n,r){return k(t,e,n,r).then((function(e){return ct(t,e).then((function(t){return{transactions:e,assets:t}}))}))},at=n(0),lt=function(t,e,n){return function(t,e){return l({base:t,url:"/assets/balance/"+e})}(t,e).then(tt(z("balances"),K(function(t){return function(e){return e.minSponsoredAssetFee&&at.BigNumber.toBigNumber(e.sponsorBalance||0).gte(t)&&at.BigNumber.toBigNumber(t).div(.001*Math.pow(10,8)).mul(e.minSponsoredAssetFee).gte(e.balance)||!1}}(n)),(r=function(t){var e=at.BigNumber.toBigNumber(t).div(.001*Math.pow(10,8));return function(n){return{assetId:n.assetId,wavesFee:t,assetFee:at.BigNumber.toBigNumber(n.minSponsoredAssetFee).mul(e).toFixed()}}}(n),function(t){return t.map(r)})));var r};for(var ht=function(t){return _(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 dt))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]+=dt[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]}))},pt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",dt={},gt=0;gt<pt.length;gt++)dt[pt.charAt(gt)]=gt;var mt=function(t){return ht(t).then((function(t){return String.fromCharCode(t)}))},bt=n(1),vt=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},yt=function(){function t(t,e,n,r){var i,o;this._emitter=new bt.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()};k(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=X(i).map(Number).sort((function(t,e){return e-t})),u=o[0],s=o[1];if(e._lastBlock.height){var c=Y(z("id"),e._lastBlock.transactions),f=t._getTransactionsToDispatch(vt(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):k(r._base,r.address,e.length+100).then((function(n){if(e.length===n.length)return e;var r=t._groupByHeight(n),u=X(r).map(Number).sort((function(t,e){return e-t})),s=u[0],c=u[1];return s===i&&c?vt(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}(),wt=function(t,e,n){return k(t,e,1).then((function(r){var i=r[0];return new yt(t,e,i,n)}))};function Ot(t){return{addresses:Nt(t,r),blocks:Nt(t,i),transactions:Nt(t,o),leasing:Nt(t,u),tools:{transactions:{broadcast:_t(t,it),wait:_t(t,et)},blocks:{getNetworkByte:_t(t,ht),getNetworkCode:_t(t,mt)},addresses:{createWatch:_t(t,wt),getAssetsByTransaction:_t(t,ct),getAssetIdListByTx:st,getTransactionsWithAssets:_t(t,ft),availableSponsoredBalances:_t(t,lt)},query:p,resolve:s,request:l,parse:f}}}n.d(e,"create",(function(){return Ot}));e.default=Ot;function Nt(t,e){return Object.keys(e).reduce((function(n,r){return n[r]=_t(t,e[r]),n}),{})}function _t(t,e){return e.bind(null,t)}}])})); |
@@ -1,21 +0,18 @@ | ||
"use strict"; | ||
var _a; | ||
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')); }, | ||
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')); }, | ||
_a)); | ||
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); | ||
export default function (tx) { | ||
var idList = toArray(tx).reduce(function (acc, tx) { return acc.concat(getAssetIdList(tx) || []); }, []); | ||
return pipe(filter(Boolean), uniq)(idList); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=getAssetIdListByTx.js.map |
@@ -1,11 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var assets_1 = require("../../api-node/assets"); | ||
var getAssetIdListByTx_1 = 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); }); | ||
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); }); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=getAssetsByTransaction.js.map |
@@ -1,10 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var transactions_1 = require("../../api-node/transactions"); | ||
var getAssetsByTransaction_1 = 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 }); }); }); | ||
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 }); }); }); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=getTransactionsWithAssets.js.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
@@ -9,10 +8,9 @@ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
}; | ||
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"); | ||
import { transactions } from '../../api-node/transactions'; | ||
import { indexBy, keys, prop } from '../utils'; | ||
import { EventEmitter } from 'typed-ts-events'; | ||
var Watch = /** @class */ (function () { | ||
function Watch(base, address, tx, interval) { | ||
var _a, _b; | ||
this._emitter = new typed_ts_events_1.EventEmitter(); | ||
this._emitter = new EventEmitter(); | ||
this._timer = null; | ||
@@ -44,3 +42,3 @@ this.address = address; | ||
var onError = function () { return _this._addTimeout(); }; | ||
transactions_1.transactions(this._base, this.address, 1) | ||
transactions(this._base, this.address, 1) | ||
.then(function (_a) { | ||
@@ -56,3 +54,3 @@ var tx = _a[0]; | ||
var hash = Watch._groupByHeight(list); | ||
var heightList = utils_1.keys(hash) | ||
var heightList = keys(hash) | ||
.map(Number) | ||
@@ -70,3 +68,3 @@ .sort(function (a, b) { return b - a; }); | ||
else { | ||
var wasDispatchHash = utils_1.indexBy(utils_1.prop('id'), _this._lastBlock.transactions); | ||
var wasDispatchHash = indexBy(prop('id'), _this._lastBlock.transactions); | ||
var toDispatch = Watch._getTransactionsToDispatch(__spreadArrays(hash[last], (hash[prev] || [])), wasDispatchHash, _this._lastBlock.lastId); | ||
@@ -99,3 +97,3 @@ if (_this._lastBlock.height !== last) { | ||
} | ||
return transactions_1.transactions(_this._base, _this.address, downloaded.length + 100).then(function (list) { | ||
return transactions(_this._base, _this.address, downloaded.length + 100).then(function (list) { | ||
if (downloaded.length === list.length) { | ||
@@ -105,3 +103,3 @@ return downloaded; | ||
var hash = Watch._groupByHeight(list); | ||
var heightList = utils_1.keys(hash) | ||
var heightList = keys(hash) | ||
.map(Number) | ||
@@ -152,5 +150,5 @@ .sort(function (a, b) { return b - a; }); | ||
}()); | ||
exports.Watch = Watch; | ||
function default_1(base, address, interval) { | ||
return transactions_1.transactions(base, address, 1) | ||
export { Watch }; | ||
export default function (base, address, interval) { | ||
return transactions(base, address, 1) | ||
.then(function (_a) { | ||
@@ -161,3 +159,2 @@ var tx = _a[0]; | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=watch.js.map |
@@ -1,12 +0,9 @@ | ||
"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) { | ||
import { headersAt, headersLast } from '../../api-node/blocks'; | ||
export default function (base) { | ||
return headersLast(base).then(function (header) { | ||
var firstHeight = Math.max(2, header.height - 1000); | ||
return blocks_1.headersAt(base, firstHeight) | ||
return 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,8 +0,5 @@ | ||
"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]; }); | ||
import { headersLast } from '../../api-node/blocks'; | ||
export default function (base) { | ||
return headersLast(base).then(function (header) { return base58Decode(header.generator)[1]; }); | ||
} | ||
exports.default = default_1; | ||
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; | ||
@@ -9,0 +6,0 @@ var ALPHABET_MAP = {}; |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var getNetworkByte_1 = require("./getNetworkByte"); | ||
function default_1(base) { | ||
return getNetworkByte_1.default(base).then(function (byte) { return String.fromCharCode(byte); }); | ||
import getNetworkByte from './getNetworkByte'; | ||
export default function (base) { | ||
return getNetworkByte(base).then(function (byte) { return String.fromCharCode(byte); }); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=getNetworkCode.js.map |
@@ -1,11 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var blocks_1 = require("../../api-node/blocks"); | ||
var utils_1 = require("../utils"); | ||
var detectInterval_1 = require("./detectInterval"); | ||
import { headersLast, height } from '../../api-node/blocks'; | ||
import { wait } from '../utils'; | ||
import detectInterval from './detectInterval'; | ||
var storage = Object.create(null); | ||
function default_1(base, current) { | ||
export default function (base, current) { | ||
return Promise.all([ | ||
getInterval(base), | ||
current == undefined ? blocks_1.height(base).then(function (_a) { | ||
current == undefined ? height(base).then(function (_a) { | ||
var height = _a.height; | ||
@@ -19,3 +17,3 @@ return height + 1; | ||
function loop(interval, current) { | ||
return blocks_1.headersLast(base).then(function (_a) { | ||
return headersLast(base).then(function (_a) { | ||
var height = _a.height, timestamp = _a.timestamp; | ||
@@ -28,7 +26,6 @@ if (height >= current) { | ||
var timeout = (((blocksToWait - 1) * interval) + ((interval - Math.abs(now - timestamp)))) * 0.8; | ||
return utils_1.wait(inRange(timeout, 200, (interval * blocksToWait) * 0.8)).then(function () { return loop(interval, current); }); | ||
return wait(inRange(timeout, 200, (interval * blocksToWait) * 0.8)).then(function () { return loop(interval, current); }); | ||
}); | ||
} | ||
} | ||
exports.default = default_1; | ||
function inRange(current, min, max) { | ||
@@ -42,3 +39,3 @@ return Math.round(Math.min(Math.max(current, min), max)); | ||
else { | ||
return detectInterval_1.default(base).then(function (interval) { | ||
return detectInterval(base).then(function (interval) { | ||
storage[base] = interval; | ||
@@ -45,0 +42,0 @@ return interval; |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var reg = new RegExp('((?!\\\\)"\\w+"):\\s*(-?[\\d|\\.]{14,})', 'g'); | ||
function default_1(json) { | ||
export default function (json) { | ||
return JSON.parse(json.replace(reg, "$1:\"$2\"")); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=parse.js.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function default_1(params, evolver) { | ||
export default function (params, evolver) { | ||
if (evolver === void 0) { evolver = Object.create(null); } | ||
@@ -22,4 +20,3 @@ var query = Object.keys(params) | ||
} | ||
exports.default = default_1; | ||
; | ||
//# sourceMappingURL=query.js.map |
@@ -1,13 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var resolve_1 = require("./resolve"); | ||
var parse_1 = require("./parse"); | ||
import resolve from './resolve'; | ||
import parse from './parse'; | ||
var request = typeof fetch === 'function' ? fetch : require('node-fetch'); | ||
function default_1(params) { | ||
return request(resolve_1.default(params.url, params.base), updateHeaders(params.options)) | ||
export default function (params) { | ||
return request(resolve(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_1.default(message) : Promise.reject(tryParse(message)); }); | ||
return r.text().then(function (message) { return r.ok ? parse(message) : Promise.reject(tryParse(message)); }); | ||
} | ||
@@ -14,0 +11,0 @@ function tryParse(message) { |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function default_1(path, base) { | ||
export default function (path, base) { | ||
return new URL(path, base).toString(); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=resolve.js.map |
@@ -1,9 +0,6 @@ | ||
"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'); | ||
function default_1(data) { | ||
export default function (data) { | ||
return JSON.stringify(data).replace(reg, '$1:$2'); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=stringify.js.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
@@ -13,6 +12,5 @@ __assign = Object.assign || function(t) { | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var transactions_1 = require("../../api-node/transactions"); | ||
var utils_1 = require("../utils"); | ||
var wait_1 = require("./wait"); | ||
import { broadcast } from '../../api-node/transactions'; | ||
import { head, toArray } from '../utils'; | ||
import wait from './wait'; | ||
var DEFAULT_BROADCAST_OPTIONS = { | ||
@@ -24,3 +22,3 @@ chain: false, | ||
}; | ||
function default_1(base, list, options) { | ||
export default function (base, list, options) { | ||
var opt = __assign(__assign({}, DEFAULT_BROADCAST_OPTIONS), (options || {})); | ||
@@ -30,10 +28,9 @@ var isOnce = !Array.isArray(list); | ||
return (opt.chain | ||
? 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; }); | ||
? 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; }); | ||
} | ||
exports.default = default_1; | ||
function simpleBroadcast(base, list) { | ||
return Promise.all(list.map(function (tx) { return transactions_1.broadcast(base, tx); })); | ||
return Promise.all(list.map(function (tx) { return broadcast(base, tx); })); | ||
} | ||
@@ -50,4 +47,4 @@ function chainBroadcast(base, list, options) { | ||
var tx = toBroadcast.pop(); | ||
transactions_1.broadcast(base, tx) | ||
.then(function (tx) { return wait_1.default(base, tx, options); }) | ||
broadcast(base, tx) | ||
.then(function (tx) { return wait(base, tx, options); }) | ||
.then(function (tx) { | ||
@@ -54,0 +51,0 @@ result.push(tx); |
@@ -1,7 +0,5 @@ | ||
"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) { | ||
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) { | ||
var isOnce = !Array.isArray(tx); | ||
@@ -14,6 +12,6 @@ var start = Date.now(); | ||
var waitTx = function (list) { | ||
return transactions_1.status(base, list.map(utils_1.prop('id'))) | ||
return status(base, list.map(prop('id'))) | ||
.then(function (status) { | ||
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; }); | ||
var hash = indexBy(prop('id'), status.statuses); | ||
var hasError = list.some(function (tx) { return hash[tx.id].status === TRANSACTION_STATUSES.NOT_FOUND; }); | ||
if (hasError) { | ||
@@ -37,8 +35,7 @@ throw new Error('One transaction is not in blockchain!'); | ||
} | ||
return utils_1.wait(requestInterval).then(function () { return waitTx(toRequest); }); | ||
return wait(requestInterval).then(function () { return waitTx(toRequest); }); | ||
}); | ||
}; | ||
return waitTx(utils_1.toArray(tx)).then(function () { return isOnce ? utils_1.head(confirmed) : confirmed; }); | ||
return waitTx(toArray(tx)).then(function () { return isOnce ? head(confirmed) : confirmed; }); | ||
} | ||
exports.default = default_1; | ||
//# sourceMappingURL=wait.js.map |
@@ -12,2 +12,3 @@ import { TTransaction, TTransactionMap } from '@waves/ts-types'; | ||
export declare function map<T, U>(process: (data: T, index: number) => U): (list: Array<T>) => Array<U>; | ||
export declare function filter<T>(process: (data: T, index: number) => boolean): (list: Array<T>) => Array<T>; | ||
export declare function filter<T, S extends T>(process: (data: T, index: number) => data is S): (list: Array<T>) => Array<S>; | ||
@@ -26,3 +27,5 @@ export declare function indexBy<T extends Record<string, any>, P extends (data: T) => string | number>(process: (data: T) => T[keyof T], data: Array<T>): Record<ReturnType<P>, T>; | ||
<A, B, R>(a: (data: A) => B, b: (data: B) => R): (a: A) => R; | ||
<A, B, C, R>(a: (data: A) => B, b: (data: B) => C, c: (data: C) => R): (a: A) => R; | ||
<A, B, C, D, R>(a: (data: A) => B, b: (data: B) => C, c: (data: C) => D, d: (data: D) => R): (a: A) => R; | ||
} | ||
export {}; |
@@ -1,12 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function toArray(data) { | ||
export function toArray(data) { | ||
return Array.isArray(data) ? data : [data]; | ||
} | ||
exports.toArray = toArray; | ||
function head(data) { | ||
export function head(data) { | ||
return data[0]; | ||
} | ||
exports.head = head; | ||
function wait(time) { | ||
export function wait(time) { | ||
return new Promise(function (resolve) { | ||
@@ -16,18 +12,16 @@ setTimeout(resolve, time); | ||
} | ||
exports.wait = wait; | ||
function prop(key) { | ||
export function prop(key) { | ||
return function (data) { return data[key]; }; | ||
} | ||
exports.prop = prop; | ||
exports.keys = function (obj) { | ||
export var keys = function (obj) { | ||
return Object.keys(obj); | ||
}; | ||
exports.entries = function (obj) { | ||
return exports.keys(obj).map(function (name) { return [name, obj[name]]; }); | ||
export var entries = function (obj) { | ||
return keys(obj).map(function (name) { return [name, obj[name]]; }); | ||
}; | ||
exports.values = function (obj) { | ||
return exports.keys(obj).map(function (key) { return obj[key]; }); | ||
export var values = function (obj) { | ||
return keys(obj).map(function (key) { return obj[key]; }); | ||
}; | ||
exports.assign = function (target, merge) { | ||
return exports.entries(merge).reduce(function (acc, _a) { | ||
export var assign = function (target, merge) { | ||
return entries(merge).reduce(function (acc, _a) { | ||
var key = _a[0], value = _a[1]; | ||
@@ -38,11 +32,9 @@ target[key] = value; | ||
}; | ||
function map(process) { | ||
export function map(process) { | ||
return function (list) { return list.map(process); }; | ||
} | ||
exports.map = map; | ||
function filter(process) { | ||
export function filter(process) { | ||
return function (list) { return list.filter(process); }; | ||
} | ||
exports.filter = filter; | ||
function indexBy(process, data) { | ||
export function indexBy(process, data) { | ||
return data.reduce(function (acc, item) { | ||
@@ -53,5 +45,4 @@ acc[process(item)] = item; | ||
} | ||
exports.indexBy = indexBy; | ||
exports.uniq = function (list) { | ||
return exports.keys(list.reduce(function (acc, item) { | ||
export var uniq = function (list) { | ||
return keys(list.reduce(function (acc, item) { | ||
acc[item] = item; | ||
@@ -61,7 +52,6 @@ return acc; | ||
}; | ||
function switchTransactionByType(choices) { | ||
export function switchTransactionByType(choices) { | ||
return function (tx) { return choices[tx.type] && typeof choices[tx.type] === 'function' ? choices[tx.type](tx) : undefined; }; | ||
} | ||
exports.switchTransactionByType = switchTransactionByType; | ||
exports.pipe = function () { | ||
export var pipe = function () { | ||
var args = []; | ||
@@ -68,0 +58,0 @@ for (var _i = 0; _i < arguments.length; _i++) { |
{ | ||
"name": "@waves/blockchain-api", | ||
"version": "0.0.2", | ||
"version": "0.0.4", | ||
"main": "dist/index.js", | ||
@@ -16,2 +16,3 @@ "types": "dist/index.d.ts", | ||
"@types/node-fetch": "^2.5.4", | ||
"@waves/bignumber": "0.0.1", | ||
"@waves/ts-types": "^0.3.1", | ||
@@ -18,0 +19,0 @@ "node-fetch": "^2.6.0" |
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
351975
103
2943
4
+ Added@waves/bignumber@0.0.1
+ Added@types/bignumber.js@5.0.4(transitive)
+ Added@waves/bignumber@0.0.1(transitive)
+ Addedbignumber.js@8.1.1(transitive)