@xdefi/bitcoin-provider
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -92,8 +92,8 @@ import { EventEmitter } from 'events'; | ||
} | ||
const _initBinanceDexProvider = (msgStream, callBacksMap) => { | ||
const _initBitcoinProvider = (msgStream, callBacksMap) => { | ||
return new XDEFIBitcoinProvider(msgStream, callBacksMap); | ||
}; | ||
const initBinanceDexProvider = _initBinanceDexProvider; | ||
const initBitcoinProvider = _initBitcoinProvider; | ||
export { XDEFIBitcoinProvider, initBinanceDexProvider, XDEFIBitcoinPayloadMethods, MessageNamespace }; | ||
export { XDEFIBitcoinProvider, initBitcoinProvider, XDEFIBitcoinPayloadMethods, MessageNamespace }; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import{EventEmitter}from"events";const genPayloadId=()=>{return 1e3*(new Date).getTime()+Math.floor(1e3*Math.random())};var XDEFIBitcoinPayloadMethods,MessageNamespace;!function(e){e[e.REQUEST_ACCOUNTS=0]="REQUEST_ACCOUNTS",e[e.SIGN_TRANSACTION=1]="SIGN_TRANSACTION",e[e.GET_UNSPENT_UTXOS=2]="GET_UNSPENT_UTXOS",e[e.TRANSFER=3]="TRANSFER"}(XDEFIBitcoinPayloadMethods||(XDEFIBitcoinPayloadMethods={})),function(e){e[e.BINANCEDEX=0]="BINANCEDEX",e[e.BINANCESMARTCHAIN=1]="BINANCESMARTCHAIN",e[e.BITCOIN=2]="BITCOIN",e[e.ETHEREUM=3]="ETHEREUM"}(MessageNamespace||(MessageNamespace={}));class XDEFIBitcoinProvider extends EventEmitter{constructor(e,t){super(),this.msgStream=e,this.callBacksMap=t,this.chainId="mainnet",this.network="mainnet"}emitAccountsChanged(){this.emit("accountsChanged",{})}changeNetwork(e,t){if(e!==t)throw Error(`changeNetwork failed, incorrect chainId-network ${e} ${t}`);if(!["mainnet","testnet"].includes(e))throw Error(`changeNetwork failed, incorrect chainId-network ${e} ${t}`);this.chainId=e,this.network=t,this.emit("chainChanged",{chainId:e,network:t})}request(e,t){const a=genPayloadId();let i;switch(e.method){case XDEFIBitcoinPayloadMethods.REQUEST_ACCOUNTS:case XDEFIBitcoinPayloadMethods.SIGN_TRANSACTION:case XDEFIBitcoinPayloadMethods.GET_UNSPENT_UTXOS:case XDEFIBitcoinPayloadMethods.TRANSFER:i={name:"provider",data:{xdefiId:a,origin:null,namespace:MessageNamespace.BITCOIN,raw:{id:a,method:e.method,params:e.params},time:Date.now()}},t&&this.callBacksMap&&this.callBacksMap.set(i.data.raw.id,t),this.msgStream&&this.msgStream.write(i);break;default:throw Error(`XDEFI Bitcoin Provider: this method ${e.method} is not supported`)}}}const _initBinanceDexProvider=(e,t)=>new XDEFIBitcoinProvider(e,t),initBinanceDexProvider=_initBinanceDexProvider;export{XDEFIBitcoinProvider,initBinanceDexProvider,XDEFIBitcoinPayloadMethods,MessageNamespace}; | ||
import{EventEmitter}from"events";const genPayloadId=()=>{return 1e3*(new Date).getTime()+Math.floor(1e3*Math.random())};var XDEFIBitcoinPayloadMethods,MessageNamespace;!function(e){e[e.REQUEST_ACCOUNTS=0]="REQUEST_ACCOUNTS",e[e.SIGN_TRANSACTION=1]="SIGN_TRANSACTION",e[e.GET_UNSPENT_UTXOS=2]="GET_UNSPENT_UTXOS",e[e.TRANSFER=3]="TRANSFER"}(XDEFIBitcoinPayloadMethods||(XDEFIBitcoinPayloadMethods={})),function(e){e[e.BINANCEDEX=0]="BINANCEDEX",e[e.BINANCESMARTCHAIN=1]="BINANCESMARTCHAIN",e[e.BITCOIN=2]="BITCOIN",e[e.ETHEREUM=3]="ETHEREUM"}(MessageNamespace||(MessageNamespace={}));class XDEFIBitcoinProvider extends EventEmitter{constructor(e,t){super(),this.msgStream=e,this.callBacksMap=t,this.chainId="mainnet",this.network="mainnet"}emitAccountsChanged(){this.emit("accountsChanged",{})}changeNetwork(e,t){if(e!==t)throw Error(`changeNetwork failed, incorrect chainId-network ${e} ${t}`);if(!["mainnet","testnet"].includes(e))throw Error(`changeNetwork failed, incorrect chainId-network ${e} ${t}`);this.chainId=e,this.network=t,this.emit("chainChanged",{chainId:e,network:t})}request(e,t){const i=genPayloadId();let a;switch(e.method){case XDEFIBitcoinPayloadMethods.REQUEST_ACCOUNTS:case XDEFIBitcoinPayloadMethods.SIGN_TRANSACTION:case XDEFIBitcoinPayloadMethods.GET_UNSPENT_UTXOS:case XDEFIBitcoinPayloadMethods.TRANSFER:a={name:"provider",data:{xdefiId:i,origin:null,namespace:MessageNamespace.BITCOIN,raw:{id:i,method:e.method,params:e.params},time:Date.now()}},t&&this.callBacksMap&&this.callBacksMap.set(a.data.raw.id,t),this.msgStream&&this.msgStream.write(a);break;default:throw Error(`XDEFI Bitcoin Provider: this method ${e.method} is not supported`)}}}const _initBitcoinProvider=(e,t)=>new XDEFIBitcoinProvider(e,t),initBitcoinProvider=_initBitcoinProvider;export{XDEFIBitcoinProvider,initBitcoinProvider,XDEFIBitcoinPayloadMethods,MessageNamespace}; | ||
//# sourceMappingURL=index.esm.min.js.map |
@@ -97,9 +97,9 @@ (function (global, factory) { | ||
}(events.EventEmitter)); | ||
var _initBinanceDexProvider = function (msgStream, callBacksMap) { | ||
var _initBitcoinProvider = function (msgStream, callBacksMap) { | ||
return new XDEFIBitcoinProvider(msgStream, callBacksMap); | ||
}; | ||
var initBinanceDexProvider = _initBinanceDexProvider; | ||
var initBitcoinProvider = _initBitcoinProvider; | ||
exports.XDEFIBitcoinProvider = XDEFIBitcoinProvider; | ||
exports.initBinanceDexProvider = initBinanceDexProvider; | ||
exports.initBitcoinProvider = initBitcoinProvider; | ||
@@ -106,0 +106,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("events")):"function"==typeof define&&define.amd?define(["exports","tslib","events"],t):t((e=e||self).BitcoinProvider={},e.tslib_1,e.events)}(this,function(n,t,e){"use strict";var i,a;(i=n.XDEFIBitcoinPayloadMethods||(n.XDEFIBitcoinPayloadMethods={}))[i.REQUEST_ACCOUNTS=0]="REQUEST_ACCOUNTS",i[i.SIGN_TRANSACTION=1]="SIGN_TRANSACTION",i[i.GET_UNSPENT_UTXOS=2]="GET_UNSPENT_UTXOS",i[i.TRANSFER=3]="TRANSFER",(a=n.MessageNamespace||(n.MessageNamespace={}))[a.BINANCEDEX=0]="BINANCEDEX",a[a.BINANCESMARTCHAIN=1]="BINANCESMARTCHAIN",a[a.BITCOIN=2]="BITCOIN",a[a.ETHEREUM=3]="ETHEREUM";var o=function(a){function e(e,t){var i=a.call(this)||this;return i.msgStream=e,i.callBacksMap=t,i.chainId="mainnet",i.network="mainnet",i}return t.__extends(e,a),e.prototype.emitAccountsChanged=function(){this.emit("accountsChanged",{})},e.prototype.changeNetwork=function(e,t){if(e!==t)throw Error("changeNetwork failed, incorrect chainId-network "+e+" "+t);if(!["mainnet","testnet"].includes(e))throw Error("changeNetwork failed, incorrect chainId-network "+e+" "+t);this.chainId=e,this.network=t,this.emit("chainChanged",{chainId:e,network:t})},e.prototype.request=function(e,t){var i,a=1e3*(new Date).getTime()+Math.floor(1e3*Math.random());switch(e.method){case n.XDEFIBitcoinPayloadMethods.REQUEST_ACCOUNTS:case n.XDEFIBitcoinPayloadMethods.SIGN_TRANSACTION:case n.XDEFIBitcoinPayloadMethods.GET_UNSPENT_UTXOS:case n.XDEFIBitcoinPayloadMethods.TRANSFER:i={name:"provider",data:{xdefiId:a,origin:null,namespace:n.MessageNamespace.BITCOIN,raw:{id:a,method:e.method,params:e.params},time:Date.now()}},t&&this.callBacksMap&&this.callBacksMap.set(i.data.raw.id,t),this.msgStream&&this.msgStream.write(i);break;default:throw Error("XDEFI Bitcoin Provider: this method "+e.method+" is not supported")}},e}(e.EventEmitter),r=function(e,t){return new o(e,t)};n.XDEFIBitcoinProvider=o,n.initBinanceDexProvider=r,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("events")):"function"==typeof define&&define.amd?define(["exports","tslib","events"],t):t((e=e||self).BitcoinProvider={},e.tslib_1,e.events)}(this,function(o,t,e){"use strict";var i,a;(i=o.XDEFIBitcoinPayloadMethods||(o.XDEFIBitcoinPayloadMethods={}))[i.REQUEST_ACCOUNTS=0]="REQUEST_ACCOUNTS",i[i.SIGN_TRANSACTION=1]="SIGN_TRANSACTION",i[i.GET_UNSPENT_UTXOS=2]="GET_UNSPENT_UTXOS",i[i.TRANSFER=3]="TRANSFER",(a=o.MessageNamespace||(o.MessageNamespace={}))[a.BINANCEDEX=0]="BINANCEDEX",a[a.BINANCESMARTCHAIN=1]="BINANCESMARTCHAIN",a[a.BITCOIN=2]="BITCOIN",a[a.ETHEREUM=3]="ETHEREUM";var n=function(a){function e(e,t){var i=a.call(this)||this;return i.msgStream=e,i.callBacksMap=t,i.chainId="mainnet",i.network="mainnet",i}return t.__extends(e,a),e.prototype.emitAccountsChanged=function(){this.emit("accountsChanged",{})},e.prototype.changeNetwork=function(e,t){if(e!==t)throw Error("changeNetwork failed, incorrect chainId-network "+e+" "+t);if(!["mainnet","testnet"].includes(e))throw Error("changeNetwork failed, incorrect chainId-network "+e+" "+t);this.chainId=e,this.network=t,this.emit("chainChanged",{chainId:e,network:t})},e.prototype.request=function(e,t){var i,a=1e3*(new Date).getTime()+Math.floor(1e3*Math.random());switch(e.method){case o.XDEFIBitcoinPayloadMethods.REQUEST_ACCOUNTS:case o.XDEFIBitcoinPayloadMethods.SIGN_TRANSACTION:case o.XDEFIBitcoinPayloadMethods.GET_UNSPENT_UTXOS:case o.XDEFIBitcoinPayloadMethods.TRANSFER:i={name:"provider",data:{xdefiId:a,origin:null,namespace:o.MessageNamespace.BITCOIN,raw:{id:a,method:e.method,params:e.params},time:Date.now()}},t&&this.callBacksMap&&this.callBacksMap.set(i.data.raw.id,t),this.msgStream&&this.msgStream.write(i);break;default:throw Error("XDEFI Bitcoin Provider: this method "+e.method+" is not supported")}},e}(e.EventEmitter),r=function(e,t){return new n(e,t)};o.XDEFIBitcoinProvider=n,o.initBitcoinProvider=r,Object.defineProperty(o,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=index.umd.min.js.map |
@@ -71,6 +71,6 @@ import { EventEmitter } from 'events'; | ||
export default XDEFIBitcoinProvider; | ||
const _initBinanceDexProvider = (msgStream, callBacksMap) => { | ||
const _initBitcoinProvider = (msgStream, callBacksMap) => { | ||
return new XDEFIBitcoinProvider(msgStream, callBacksMap); | ||
}; | ||
export const initBinanceDexProvider = _initBinanceDexProvider; | ||
export const initBitcoinProvider = _initBitcoinProvider; | ||
//# sourceMappingURL=xdefi-bitcoin-provider.js.map |
@@ -76,6 +76,6 @@ import * as tslib_1 from "tslib"; | ||
export default XDEFIBitcoinProvider; | ||
var _initBinanceDexProvider = function (msgStream, callBacksMap) { | ||
var _initBitcoinProvider = function (msgStream, callBacksMap) { | ||
return new XDEFIBitcoinProvider(msgStream, callBacksMap); | ||
}; | ||
export var initBinanceDexProvider = _initBinanceDexProvider; | ||
export var initBitcoinProvider = _initBitcoinProvider; | ||
//# sourceMappingURL=xdefi-bitcoin-provider.js.map |
{ | ||
"name": "@xdefi/bitcoin-provider", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "xdefi bitcoin provider", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -15,3 +15,3 @@ /// <reference types="node" /> | ||
export default XDEFIBitcoinProvider; | ||
export declare const initBinanceDexProvider: (msgStream: any, callBacksMap: Map<number, any>) => XDEFIBitcoinProvider; | ||
export declare const initBitcoinProvider: (msgStream: any, callBacksMap: Map<number, any>) => XDEFIBitcoinProvider; | ||
//# sourceMappingURL=xdefi-bitcoin-provider.d.ts.map |
{ | ||
"name": "@xdefi/bitcoin-provider", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "xdefi bitcoin provider", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
65862