@waves/blockchain-api
Advanced tools
Comparing version 0.0.1 to 0.0.2
import { TLong, TRANSACTION_NAME_MAP } from '../../interface'; | ||
import { TTransactionFromAPIMap } from '@waves/ts-types'; | ||
/** | ||
* TODO | ||
* GET /assets/details/{assetId} | ||
* Information about an asset | ||
*/ | ||
export declare function details(base: string, assetId: string): Promise<TAssetDetails>; | ||
export declare function details(base: string, assetId: Array<string>): Promise<Array<TAssetDetails>>; | ||
/** | ||
@@ -42,1 +43,14 @@ * TODO | ||
}; | ||
export declare type TAssetDetails<LONG = TLong> = { | ||
assetId: string; | ||
issueHeight: number; | ||
issueTimestamp: number; | ||
issuer: string; | ||
name: string; | ||
description: string; | ||
decimals: number; | ||
reissuable: boolean; | ||
quantity: LONG; | ||
scripted: boolean; | ||
minSponsoredAssetFee: LONG | null; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = require("../../tools/request"); | ||
var utils_1 = require("../../tools/utils"); | ||
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 }); })) | ||
.then(function (list) { return isOnce ? list[0] : list; }); | ||
} | ||
exports.details = details; | ||
/** | ||
* TODO | ||
* GET /assets/details/{assetId} | ||
* Information about an asset | ||
*/ | ||
/** | ||
* TODO | ||
* GET /assets/{assetId}/distribution/{height}/limit/{limit} | ||
@@ -12,0 +14,0 @@ * Asset balance distribution at height |
@@ -0,5 +1,7 @@ | ||
import { ILeaseTransaction, IWithApiMixin } from '@waves/ts-types'; | ||
import { TLong } from '../../interface'; | ||
/** | ||
* TODO | ||
* GET /leasing/active/{address} | ||
* Get all active leases for an address | ||
*/ | ||
export declare function active(base: string, address: string): Promise<Array<ILeaseTransaction<TLong> & IWithApiMixin>>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = require("../../tools/request"); | ||
/** | ||
* TODO | ||
* GET /leasing/active/{address} | ||
* Get all active leases for an address | ||
*/ | ||
function active(base, address) { | ||
return request_1.default({ base: base, url: "/leasing/active/" + address }); | ||
} | ||
exports.active = active; | ||
//# sourceMappingURL=index.js.map |
@@ -0,10 +1,21 @@ | ||
import { TLong } from '../../interface'; | ||
/** | ||
* TODO | ||
* GET /blockchain/rewards/{height} | ||
* Reward status | ||
*/ | ||
/** | ||
* TODO | ||
* GET /blockchain/rewards | ||
* Current reward status | ||
*/ | ||
export declare function rewards(base: string, height?: number): Promise<TRewards<TLong>>; | ||
export declare type TRewards<LONG> = { | ||
height: number; | ||
totalWavesAmount: LONG; | ||
currentReward: LONG; | ||
minIncrement: LONG; | ||
term: number; | ||
nextCheck: number; | ||
votingIntervalStart: number; | ||
votingInterval: number; | ||
votingThreshold: number; | ||
votes: { | ||
increase: number; | ||
decrease: number; | ||
}; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var request_1 = require("../../tools/request"); | ||
/** | ||
* TODO | ||
* GET /blockchain/rewards/{height} | ||
* Reward status | ||
*/ | ||
/** | ||
* TODO | ||
* GET /blockchain/rewards | ||
* Current reward status | ||
*/ | ||
function rewards(base, height) { | ||
return request_1.default({ base: base, url: height ? "/blockchain/rewards/" + height : '/blockchain/rewards' }); | ||
} | ||
exports.rewards = rewards; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,4 @@ | ||
import { IWithProofs, TTransaction, TTransactionFromAPI } from '@waves/ts-types'; | ||
import { IWithProofs, TTransaction, TTransactionFromAPI, TTransactionMap } from '@waves/ts-types'; | ||
import { TTransactionStatuses } from '../../constants'; | ||
import { TLong } from '../../interface'; | ||
import { TTransactionStatuses } from '../../constants'; | ||
/** | ||
@@ -10,3 +10,2 @@ * TODO | ||
/** | ||
* TODO | ||
* POST /transactions/calculateFee | ||
@@ -20,2 +19,9 @@ * Calculate transaction fee | ||
*/ | ||
export declare function calculateFee<T extends keyof TTransactionMap<TLong>>(base: string, tx: Partial<TTransactionMap<TLong>[T]> & { | ||
type: T; | ||
}): Promise<TFeeInfo>; | ||
export declare type TFeeInfo<LONG = TLong> = { | ||
feeAssetId: string | null; | ||
feeAmount: LONG; | ||
}; | ||
/** | ||
@@ -22,0 +28,0 @@ * TODO |
@@ -14,6 +14,7 @@ "use strict"; | ||
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 blocks_1 = require("../blocks"); | ||
var constants_1 = require("../../constants"); | ||
var stringify_1 = require("../../tools/stringify"); | ||
/** | ||
@@ -25,3 +26,2 @@ * TODO | ||
/** | ||
* TODO | ||
* POST /transactions/calculateFee | ||
@@ -35,2 +35,13 @@ * Calculate transaction fee | ||
*/ | ||
function calculateFee(base, tx) { | ||
return request_1.default({ | ||
base: base, | ||
url: '/transactions/calculateFee', | ||
options: { | ||
method: 'POST', | ||
body: stringify_1.default(tx) | ||
} | ||
}); | ||
} | ||
exports.calculateFee = calculateFee; | ||
/** | ||
@@ -111,3 +122,3 @@ * TODO | ||
method: 'POST', | ||
body: JSON.stringify(tx), | ||
body: stringify_1.default(tx), | ||
headers: { | ||
@@ -114,0 +125,0 @@ 'Content-Type': 'application/json' |
export declare const TYPE_MAP: { | ||
3: string; | ||
4: string; | ||
5: string; | ||
6: string; | ||
7: string; | ||
8: string; | ||
9: string; | ||
10: string; | ||
11: string; | ||
12: string; | ||
13: string; | ||
14: string; | ||
15: string; | ||
16: string; | ||
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"; | ||
}; | ||
export declare const NAME_MAP: { | ||
'issue': number; | ||
'transfer': number; | ||
'reissue': number; | ||
'burn': number; | ||
'exchange': number; | ||
'lease': number; | ||
'cancelLease': number; | ||
'alias': number; | ||
'massTransfer': number; | ||
'data': number; | ||
'setScript': number; | ||
'sponsorship': number; | ||
'setAssetScript': number; | ||
'invoke': number; | ||
'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; | ||
}; | ||
@@ -33,0 +33,0 @@ export declare const TRANSACTION_STATUSES: { |
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'; | ||
@@ -8,2 +9,3 @@ import resolve from './tools/resolve'; | ||
import { IOptions, TMap, TMapTuple } from './tools/transactions/broadcast'; | ||
import getAssetIdListByTx from './tools/adresses/getAssetIdListByTx'; | ||
import parse from './tools/parse'; | ||
@@ -22,2 +24,3 @@ import { TTransactionFromAPIMap, TTransactionWithProofs } from '@waves/ts-types'; | ||
transactions: TWrapRecord<typeof transactionsModule>; | ||
leasing: TWrapRecord<typeof leasingModule>; | ||
tools: { | ||
@@ -34,2 +37,8 @@ transactions: { | ||
createWatch: (address: string, interval?: number | undefined) => Promise<import("./tools/adresses/watch").Watch>; | ||
getAssetsByTransaction: (tx: import("@waves/ts-types").IIssueTransaction<TLong> | import("@waves/ts-types").ITransferTransaction<TLong> | import("@waves/ts-types").IReissueTransaction<TLong> | import("@waves/ts-types").IBurnTransaction<TLong> | import("@waves/ts-types").ILeaseTransaction<TLong> | import("@waves/ts-types").ICancelLeaseTransaction<TLong> | import("@waves/ts-types").IAliasTransaction<TLong> | import("@waves/ts-types").IMassTransferTransaction<TLong> | import("@waves/ts-types").IDataTransaction<TLong> | import("@waves/ts-types").ISetScriptTransaction<TLong> | import("@waves/ts-types").ISponsorshipTransaction<TLong> | import("@waves/ts-types").IExchangeTransaction<TLong> | import("@waves/ts-types").ISetAssetScriptTransaction<TLong> | import("@waves/ts-types").IInvokeScriptTransaction<TLong> | import("@waves/ts-types").TTransaction<TLong>[]) => Promise<Record<string, import("./api-node/assets").TAssetDetails<TLong>>>; | ||
getAssetIdListByTx: typeof getAssetIdListByTx; | ||
getTransactionsWithAssets: (address: string, limit: number, after?: string | undefined) => Promise<{ | ||
transactions: import("@waves/ts-types").TTransactionFromAPI<TLong>[]; | ||
assets: Record<string, import("./api-node/assets").TAssetDetails<TLong>>; | ||
}>; | ||
}; | ||
@@ -36,0 +45,0 @@ query: typeof query; |
@@ -6,2 +6,3 @@ "use strict"; | ||
var transactionsModule = require("./api-node/transactions"); | ||
var leasingModule = require("./api-node/leasing"); | ||
var query_1 = require("./tools/query"); | ||
@@ -11,2 +12,5 @@ var resolve_1 = require("./tools/resolve"); | ||
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"); | ||
@@ -21,2 +25,3 @@ var parse_1 = require("./tools/parse"); | ||
var transactions = wrapRecord(base, transactionsModule); | ||
var leasing = wrapRecord(base, leasingModule); | ||
var tools = { | ||
@@ -32,3 +37,6 @@ transactions: { | ||
addresses: { | ||
createWatch: wrapRequest(base, watch_1.default) | ||
createWatch: wrapRequest(base, watch_1.default), | ||
getAssetsByTransaction: wrapRequest(base, getAssetsByTransaction_1.default), | ||
getAssetIdListByTx: getAssetIdListByTx_1.default, | ||
getTransactionsWithAssets: wrapRequest(base, getTransactionsWithAssets_1.default), | ||
}, | ||
@@ -44,2 +52,3 @@ query: query_1.default, | ||
transactions: transactions, | ||
leasing: leasing, | ||
tools: tools | ||
@@ -46,0 +55,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.nodeApi=e():t.nodeApi=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(5),i=n(6),u="function"==typeof fetch?fetch:n(12);function o(t){return t.text().then((function(e){return t.ok?i.default(e):Promise.reject(function(t){try{return JSON.parse(t)}catch(e){return t}}(e))}))}e.default=function(t){return u(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";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 i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),u=n(2),o=n(3),s=n(7);function a(t,e){return i.default({base:t,url:"/transactions/unconfirmed/info/"+e})}function c(t,e){return i.default({base:t,url:"/transactions/info/"+e})}e.transactions=function(t,e,n,r,o){return i.default({base:t,url:"/transactions/address/"+e+"/limit/"+n+u.default({after:r})}).then((function(t){return t[0]}))},e.unconfirmedInfo=a,e.info=c,e.status=function(t,e){var n={id:"",confirmations:-1,height:-1,inUTX:!1,status:s.TRANSACTION_STATUSES.NOT_FOUND},i=e.map((function(e){return a(t,e).then((function(){return r(r({},n),{id:e,status:s.TRANSACTION_STATUSES.UNCONFIRMED,inUTX:!0})})).catch((function(){return c(t,e).then((function(t){return r(r({},n),{id:e,status:s.TRANSACTION_STATUSES.IN_BLOCKCHAIN,height:t.height})}))})).catch((function(){return r(r({},n),{id:e})}))}));return Promise.all([o.height(t),Promise.all(i)]).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===s.TRANSACTION_STATUSES.IN_BLOCKCHAIN?e-t.height:t.confirmations})}))}}))},e.broadcast=function(t,e){return i.default({base:t,url:"/transactions/broadcast",options:{method:"POST",body:JSON.stringify(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.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],i=n[1];return t[r]=i,t}),t)},e.map=function(t){return function(e){return e.map(t)}},e.indexBy=function(t,e){return e.reduce((function(e,n){return e[t(n)]=n,e}),{})}},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}),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});var r=n(4),i=n(1),u=n(7);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 i.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===u.TRANSACTION_STATUSES.NOT_FOUND})))throw new Error("One transaction is not in blockchain!");var i=e.filter((function(t){return!(n[t.id].confirmations>=c)||(a.push(t),!1)}));if(i.length)return f&&Date.now()-s>f?Promise.reject("Timeout error!"):r.wait(l).then((function(){return d(i)}))}))};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(3);e.default=function(t){return r.headersLast(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 u))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]+=u[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]}))};for(var i="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",u={},o=0;o<i.length;o++)u[i.charAt(o)]=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(11),i=n(3),u=n(1),o=n(2),s=n(5),a=n(0),c=n(13),f=n(8),l=n(6),d=n(9),h=n(14),p=n(15);function v(t){return{addresses:_(t,r),blocks:_(t,i),transactions:_(t,u),tools:{transactions:{broadcast:b(t,c.default),wait:b(t,f.default)},blocks:{getNetworkByte:b(t,d.default),getNetworkCode:b(t,h.default)},addresses:{createWatch:b(t,p.default)},query:o.default,resolve:s.default,request:a.default,parse:l.default}}}function _(t,e){return Object.keys(e).reduce((function(n,r){return n[r]=b(t,e[r]),n}),{})}function b(t,e){return e.bind(null,t)}e.create=v,e.default=v},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),i=n(2);e.dataKey=function(t,e,n,i){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,i){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,u){return void 0===n&&(n=Object.create(null)),r.default({base:t,url:"/addresses/data/"+e+i.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";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 i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),u=n(4),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,u){var s=e.slice().reverse(),a=[],c=function(){if(!s.length)return r(a),null;var e=s.pop();i.broadcast(t,e).then((function(e){return o.default(t,e,n)})).then((function(t){a.push(t),c()}),u)};c()}))}(t,u.toArray(e),r(r({},a),{confirmations:f})):function(t,e){return Promise.all(e.map((function(e){return i.broadcast(t,e)})))}(t,u.toArray(e))).then((function(e){return a.confirmations<=0?e:o.default(t,e,a)})).then((function(t){return c?u.head(t):t}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(9);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),i=0;for(e=0;e<n;e++)for(var u=arguments[e],o=0,s=u.length;o<s;o++,i++)r[i]=u[o];return r};Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),u=n(4),o=n(16),s=function(){function t(t,e,n,r){var i,u;this._emitter=new o.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===(u=n)||void 0===u?void 0:u.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()};i.transactions(this._base,this.address,1).then((function(i){var o=i[0];if(!o)return e._addTimeout(),null;e.getTransactionsInHeight(o,310).then((function(n){var i,o=t._groupByHeight(n),s=u.keys(o).map(Number).sort((function(t,e){return e-t})),a=s[0],c=s[1];if(e._lastBlock.height){var f=u.indexBy(u.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]}:(i=e._lastBlock.transactions).push.apply(i,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):i.transactions(o._base,o.address,e.length+100).then((function(n){if(e.length===n.length)return e;var i=t._groupByHeight(n),o=u.keys(i).map(Number).sort((function(t,e){return e-t})),c=o[0],f=o[1];return c===s&&f?r(i[c],[i[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=[],i=0;i<t.length;i++){var u=t[i];if(u.id===n)break;e[u.id]||r.push(u)}return r},t}();e.Watch=s,e.default=function(t,e,n){return i.transactions(t,e,1).then((function(r){var i=r[0];return new s(t,e,i,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(17))},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){"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}])})); |
@@ -0,1 +1,3 @@ | ||
import { TTransaction, TTransactionMap } from '@waves/ts-types'; | ||
import { TLong } from '../interface'; | ||
export declare function toArray<T>(data: T | Array<T>): Array<T>; | ||
@@ -5,7 +7,21 @@ export declare function head<T>(data: Array<T>): T | undefined; | ||
export declare function prop<T extends Record<string, any>, P extends keyof T>(key: P): (data: T) => T[P]; | ||
export declare const keys: <T extends Record<import("../interface").TLong, any>>(obj: T) => (keyof T)[]; | ||
export declare const entries: <T extends Record<import("../interface").TLong, any>>(obj: T) => [keyof T, T[keyof T]][]; | ||
export declare const values: <T extends Record<import("../interface").TLong, any>>(obj: T) => T[keyof T][]; | ||
export declare const assign: <T extends Record<import("../interface").TLong, any>, R extends Record<import("../interface").TLong, any>>(target: T, merge: R) => T & R; | ||
export declare const keys: <T extends Record<TLong, any>>(obj: T) => (keyof T)[]; | ||
export declare const entries: <T extends Record<TLong, any>>(obj: T) => [keyof T, T[keyof T]][]; | ||
export declare const values: <T extends Record<TLong, any>>(obj: T) => T[keyof T][]; | ||
export declare const assign: <T extends Record<TLong, any>, R extends Record<TLong, any>>(target: T, merge: R) => T & R; | ||
export declare function map<T, U>(process: (data: T, index: number) => U): (list: Array<T>) => Array<U>; | ||
export declare function filter<T, S extends T>(process: (data: T, index: number) => data is S): (list: Array<T>) => Array<S>; | ||
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>; | ||
export declare const uniq: (list: string[]) => string[]; | ||
declare type TChoices = { | ||
[Key in keyof TTransactionMap<TLong>]?: (data: TTransactionMap<TLong>[Key]) => any; | ||
}; | ||
export interface ISwitchTransactionResult<R extends TChoices> { | ||
<T extends TTransaction<TLong>>(tx: T): R[T['type']] extends (data: TTransactionMap<TLong>[T['type']]) => infer A ? A : undefined; | ||
} | ||
export declare function switchTransactionByType<R extends TChoices>(choices: R): ISwitchTransactionResult<R>; | ||
export declare const pipe: IPipe; | ||
export interface IPipe { | ||
<A, B, R>(a: (data: A) => B, b: (data: B) => R): (a: A) => R; | ||
} | ||
export {}; |
@@ -41,2 +41,6 @@ "use strict"; | ||
exports.map = map; | ||
function filter(process) { | ||
return function (list) { return list.filter(process); }; | ||
} | ||
exports.filter = filter; | ||
function indexBy(process, data) { | ||
@@ -49,2 +53,19 @@ return data.reduce(function (acc, item) { | ||
exports.indexBy = indexBy; | ||
exports.uniq = function (list) { | ||
return exports.keys(list.reduce(function (acc, item) { | ||
acc[item] = item; | ||
return acc; | ||
}, Object.create(null))); | ||
}; | ||
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 () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return function (data) { return args.reduce(function (acc, item) { return acc(item); }, data); }; | ||
}; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@waves/blockchain-api", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "dist/index.js", | ||
@@ -15,3 +15,5 @@ "types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@waves/ts-types": "^0.3.1" | ||
"@types/node-fetch": "^2.5.4", | ||
"@waves/ts-types": "^0.3.1", | ||
"node-fetch": "^2.6.0" | ||
}, | ||
@@ -43,3 +45,2 @@ "files": [ | ||
"@types/jest": "^24.0.23", | ||
"@types/node-fetch": "^2.5.3", | ||
"@waves/node-state": "0.0.7", | ||
@@ -49,3 +50,2 @@ "@waves/seed-provider": "0.0.2", | ||
"jest": "^24.9.0", | ||
"node-fetch": "^2.6.0", | ||
"ts-jest": "^24.1.0", | ||
@@ -52,0 +52,0 @@ "ts-loader": "^6.2.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 too big to display
Sorry, the diff of this file is not supported yet
251895
10
100
2883
3
+ Added@types/node-fetch@^2.5.4
+ Addednode-fetch@^2.6.0
+ Added@types/node@22.9.1(transitive)
+ Added@types/node-fetch@2.6.12(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)