@liquality/bitcoin-esplora-api-provider
Advanced tools
Comparing version 0.8.7 to 0.8.8
@@ -1,2 +0,2 @@ | ||
module.exports=function(t){var e={};function n(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},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 s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(s,r,function(e){return t[e]}.bind(null,r));return s},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=7)}([function(t,e){t.exports=require("@liquality/utils")},function(t,e){t.exports=require("lodash")},function(t,e){t.exports=require("@liquality/bitcoin-utils")},function(t,e){t.exports=require("@liquality/errors")},function(t,e){t.exports=require("bignumber.js")},function(t,e){t.exports=require("@liquality/node-provider")},function(t){t.exports=JSON.parse('{"a":"0.8.7"}')},function(t,e,n){"use strict";n.r(e);var s=n(5),r=n.n(s),a=n(2),o=n(0),i=n(3),c=n(1),u=n(4),d=n.n(u),l=n(6);class h extends r.a{constructor(t,e,n=1,s=3){super({baseURL:t,responseType:"text",transformResponse:void 0}),this._network=e,this._numberOfBlockConfirmation=n,this._defaultFeePerByte=s}async getFeePerByte(t=this._numberOfBlockConfirmation){try{const e=await this.nodeGet("/fee-estimates"),n=Object.keys(e).reduce((e,n)=>Math.abs(e-t)<Math.abs(n-t)?e:n);return Math.round(e[n])}catch(t){return this._defaultFeePerByte}}async getMinRelayFee(){return 1}async isAddressUsed(t){return await this.getReceivedByAddress(t)>0}async getBalance(t){Object(c.isArray)(t)||(t=[t]);const e=await this.getUnspentTransactions(t);return Object(c.flatten)(e).reduce((t,e)=>t.plus(e.satoshis),new d.a(0))}async _getUnspentTransactions(t){return(await this.nodeGet(`/address/${Object(o.addressToString)(t)}/utxo`)).map(e=>({...e,address:Object(o.addressToString)(t),satoshis:e.value,amount:d()(e.value).dividedBy(1e8).toNumber(),blockHeight:e.status.block_height}))}async getUnspentTransactions(t){const e=await Promise.all(t.map(t=>this._getUnspentTransactions(t)));return Object(c.flatten)(e)}async _getAddressTransactionCount(t){const e=await this.nodeGet(`/address/${Object(o.addressToString)(t)}`);return e.chain_stats.tx_count+e.mempool_stats.tx_count}async getAddressTransactionCounts(t){const e=await Promise.all(t.map(async t=>{return{[t]:await this._getAddressTransactionCount(t)}}));return Object.assign({},...e)}async getTransactionHex(t){return this.nodeGet(`/tx/${t}/hex`)}async getTransaction(t){let e;try{e=await this.nodeGet(`/tx/${t}`)}catch(e){if("NodeError"===e.name&&e.message.includes("Transaction not found")){const{name:n,message:s,...r}=e;throw new i.TxNotFoundError(`Transaction not found: ${t}`,r)}throw e}const n=await this.getBlockHeight();return this.formatTransaction(e,n)}async formatTransaction(t,e){const n=await this.getTransactionHex(t.txid),s=t.status.confirmed?e-t.status.block_height+1:0,r=Object(a.decodeRawTransaction)(n,this._network);return r.confirmations=s,Object(a.normalizeTransactionObject)(r,t.fee,{hash:t.status.block_hash,number:t.status.block_height})}async getBlockByHash(t){let e;try{e=await this.nodeGet(`/block/${t}`)}catch(e){if("NodeError"===e.name&&e.message.includes("Block not found")){const{name:n,message:s,...r}=e;throw new i.BlockNotFoundError(`Block not found: ${t}`,r)}throw e}const{id:n,height:s,timestamp:r,mediantime:a,size:o,previousblockhash:c,nonce:u}=e;return{hash:n,number:s,timestamp:a||r,size:o,parentHash:c,nonce:u}}async getBlockHash(t){return this.nodeGet(`/block-height/${t}`)}async getBlockByNumber(t){return this.getBlockByHash(await this.getBlockHash(t))}async getBlockHeight(){const t=await this.nodeGet("/blocks/tip/height");return parseInt(t)}async getTransactionByHash(t){return this.getRawTransactionByHash(t,!0)}async getRawTransactionByHash(t,e=!1){return e?this.getTransaction(t):this.getTransactionHex(t)}async sendRawTransaction(t){return this.nodePost("/tx",t)}}h.version=l.a;e.default=h}]).default; | ||
module.exports=function(t){var e={};function n(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},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 s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(s,r,function(e){return t[e]}.bind(null,r));return s},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=7)}([function(t,e){t.exports=require("@liquality/utils")},function(t,e){t.exports=require("lodash")},function(t,e){t.exports=require("@liquality/bitcoin-utils")},function(t,e){t.exports=require("@liquality/errors")},function(t,e){t.exports=require("bignumber.js")},function(t,e){t.exports=require("@liquality/node-provider")},function(t){t.exports=JSON.parse('{"a":"0.8.8"}')},function(t,e,n){"use strict";n.r(e);var s=n(5),r=n.n(s),a=n(2),o=n(0),i=n(3),c=n(1),u=n(4),d=n.n(u),l=n(6);class h extends r.a{constructor(t,e,n=1,s=3){super({baseURL:t,responseType:"text",transformResponse:void 0}),this._network=e,this._numberOfBlockConfirmation=n,this._defaultFeePerByte=s}async getFeePerByte(t=this._numberOfBlockConfirmation){try{const e=await this.nodeGet("/fee-estimates"),n=Object.keys(e).reduce((e,n)=>Math.abs(e-t)<Math.abs(n-t)?e:n);return Math.round(e[n])}catch(t){return this._defaultFeePerByte}}async getMinRelayFee(){return 1}async isAddressUsed(t){return await this.getReceivedByAddress(t)>0}async getBalance(t){Object(c.isArray)(t)||(t=[t]);const e=await this.getUnspentTransactions(t);return Object(c.flatten)(e).reduce((t,e)=>t.plus(e.satoshis),new d.a(0))}async _getUnspentTransactions(t){return(await this.nodeGet(`/address/${Object(o.addressToString)(t)}/utxo`)).map(e=>({...e,address:Object(o.addressToString)(t),satoshis:e.value,amount:d()(e.value).dividedBy(1e8).toNumber(),blockHeight:e.status.block_height}))}async getUnspentTransactions(t){const e=await Promise.all(t.map(t=>this._getUnspentTransactions(t)));return Object(c.flatten)(e)}async _getAddressTransactionCount(t){const e=await this.nodeGet(`/address/${Object(o.addressToString)(t)}`);return e.chain_stats.tx_count+e.mempool_stats.tx_count}async getAddressTransactionCounts(t){const e=await Promise.all(t.map(async t=>{return{[t]:await this._getAddressTransactionCount(t)}}));return Object.assign({},...e)}async getTransactionHex(t){return this.nodeGet(`/tx/${t}/hex`)}async getTransaction(t){let e;try{e=await this.nodeGet(`/tx/${t}`)}catch(e){if("NodeError"===e.name&&e.message.includes("Transaction not found")){const{name:n,message:s,...r}=e;throw new i.TxNotFoundError(`Transaction not found: ${t}`,r)}throw e}const n=await this.getBlockHeight();return this.formatTransaction(e,n)}async formatTransaction(t,e){const n=await this.getTransactionHex(t.txid),s=t.status.confirmed?e-t.status.block_height+1:0,r=Object(a.decodeRawTransaction)(n,this._network);return r.confirmations=s,Object(a.normalizeTransactionObject)(r,t.fee,{hash:t.status.block_hash,number:t.status.block_height})}async getBlockByHash(t){let e;try{e=await this.nodeGet(`/block/${t}`)}catch(e){if("NodeError"===e.name&&e.message.includes("Block not found")){const{name:n,message:s,...r}=e;throw new i.BlockNotFoundError(`Block not found: ${t}`,r)}throw e}const{id:n,height:s,timestamp:r,mediantime:a,size:o,previousblockhash:c,nonce:u}=e;return{hash:n,number:s,timestamp:a||r,size:o,parentHash:c,nonce:u}}async getBlockHash(t){return this.nodeGet(`/block-height/${t}`)}async getBlockByNumber(t){return this.getBlockByHash(await this.getBlockHash(t))}async getBlockHeight(){const t=await this.nodeGet("/blocks/tip/height");return parseInt(t)}async getTransactionByHash(t){return this.getRawTransactionByHash(t,!0)}async getRawTransactionByHash(t,e=!1){return e?this.getTransaction(t):this.getTransactionHex(t)}async sendRawTransaction(t){return this.nodePost("/tx",t)}}h.version=l.a;e.default=h}]).default; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -5,3 +5,3 @@ { | ||
"umdExport": "default", | ||
"version": "0.8.7", | ||
"version": "0.8.8", | ||
"description": "", | ||
@@ -23,6 +23,6 @@ "module": "lib/index.js", | ||
"@babel/runtime": "^7.12.1", | ||
"@liquality/bitcoin-utils": "^0.8.7", | ||
"@liquality/errors": "^0.8.7", | ||
"@liquality/node-provider": "^0.8.7", | ||
"@liquality/utils": "^0.8.7", | ||
"@liquality/bitcoin-utils": "^0.8.8", | ||
"@liquality/errors": "^0.8.8", | ||
"@liquality/node-provider": "^0.8.8", | ||
"@liquality/utils": "^0.8.8", | ||
"bignumber.js": "^9.0.0", | ||
@@ -48,3 +48,3 @@ "lodash": "^4.17.20" | ||
}, | ||
"gitHead": "4a0c4367571f9bd81645305451326bdbe3394797" | ||
"gitHead": "816e8f797958d8456dad7d70e365138c9a35f62c" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Updated@liquality/errors@^0.8.8
Updated@liquality/utils@^0.8.8