@tronweb3/tronwallet-adapter-bybit
Version:
Wallet adapter for Bybit Wallet extension and Bybit Wallet app.
2 lines (1 loc) • 41.7 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self)["@tronweb3/tronwallet-adapter-bybit"]=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n={},o={},r={},i={},s={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function o(){}function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function i(t,e,o,i,s){if("function"!=typeof o)throw new TypeError("The listener must be a function");var a=new r(o,i||t,s),c=n?n+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new o:delete t._events[e]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,o,r=[];if(0===this._eventsCount)return r;for(o in t=this._events)e.call(t,o)&&r.push(n?o.slice(1):o);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.prototype.listeners=function(t){var e=n?n+t:t,o=this._events[e];if(!o)return[];if(o.fn)return[o.fn];for(var r=0,i=o.length,s=new Array(i);r<i;r++)s[r]=o[r].fn;return s},a.prototype.listenerCount=function(t){var e=n?n+t:t,o=this._events[e];return o?o.fn?1:o.length:0},a.prototype.emit=function(t,e,o,r,i,s){var a=n?n+t:t;if(!this._events[a])return!1;var c,l,d=this._events[a],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(t,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,e),!0;case 3:return d.fn.call(d.context,e,o),!0;case 4:return d.fn.call(d.context,e,o,r),!0;case 5:return d.fn.call(d.context,e,o,r,i),!0;case 6:return d.fn.call(d.context,e,o,r,i,s),!0}for(l=1,c=new Array(h-1);l<h;l++)c[l-1]=arguments[l];d.fn.apply(d.context,c)}else{var u,w=d.length;for(l=0;l<w;l++)switch(d[l].once&&this.removeListener(t,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,e);break;case 3:d[l].fn.call(d[l].context,e,o);break;case 4:d[l].fn.call(d[l].context,e,o,r);break;default:if(!c)for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];d[l].fn.apply(d[l].context,c)}}return!0},a.prototype.on=function(t,e,n){return i(this,t,e,n,!1)},a.prototype.once=function(t,e,n){return i(this,t,e,n,!0)},a.prototype.removeListener=function(t,e,o,r){var i=n?n+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||r&&!a.once||o&&a.context!==o||s(this,i);else{for(var c=0,l=[],d=a.length;c<d;c++)(a[c].fn!==e||r&&!a[c].once||o&&a[c].context!==o)&&l.push(a[c]);l.length?this._events[i]=1===l.length?l[0]:l:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&s(this,e)):(this._events=new o,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a}(s);var a=s.exports,c=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(i,"__esModule",{value:!0}),i.Adapter=i.AdapterState=i.WalletReadyState=i.EventEmitter=void 0;const l=c(a);var d,h;i.EventEmitter=l.default,function(t){t.Loading="Loading",t.NotFound="NotFound",t.Found="Found"}(d||(i.WalletReadyState=d={})),function(t){t.Loading="Loading",t.NotFound="NotFound",t.Disconnect="Disconnected",t.Connected="Connected"}(h||(i.AdapterState=h={}));class u extends l.default{get connected(){return this.state===h.Connected}disconnect(){return console.info("The current adapter doesn't support disconnect by DApp."),Promise.resolve()}multiSign(...t){return Promise.reject("The current wallet doesn't support multiSign.")}switchChain(t){return Promise.reject("The current wallet doesn't support switch chain.")}}i.Adapter=u;var w={};Object.defineProperty(w,"__esModule",{value:!0}),w.WalletGetNetworkError=w.WalletSwitchChainError=w.WalletWindowClosedError=w.WalletWalletLoadError=w.WalletSignTransactionError=w.WalletSignMessageError=w.WalletDisconnectionError=w.WalletConnectionError=w.WalletDisconnectedError=w.WalletNotSelectedError=w.WalletNotFoundError=w.WalletError=void 0;class p extends Error{constructor(t,e){super(t),this.error=e}}w.WalletError=p;w.WalletNotFoundError=class extends p{constructor(){super(...arguments),this.name="WalletNotFoundError",this.message="The wallet is not found."}};w.WalletNotSelectedError=class extends p{constructor(){super(...arguments),this.name="WalletNotSelectedError",this.message="No wallet is selected. Please select a wallet."}};w.WalletDisconnectedError=class extends p{constructor(){super(...arguments),this.name="WalletDisconnectedError",this.message="The wallet is disconnected. Please connect first."}};w.WalletConnectionError=class extends p{constructor(){super(...arguments),this.name="WalletConnectionError"}};w.WalletDisconnectionError=class extends p{constructor(){super(...arguments),this.name="WalletDisconnectionError"}};w.WalletSignMessageError=class extends p{constructor(){super(...arguments),this.name="WalletSignMessageError"}};w.WalletSignTransactionError=class extends p{constructor(){super(...arguments),this.name="WalletSignTransactionError"}};w.WalletWalletLoadError=class extends p{constructor(){super(...arguments),this.name="WalletWalletLoadError"}};w.WalletWindowClosedError=class extends p{constructor(){super(...arguments),this.name="WalletWindowClosedError",this.message="The QR window is closed."}};w.WalletSwitchChainError=class extends p{constructor(){super(...arguments),this.name="WalletSwitchChainError"}};w.WalletGetNetworkError=class extends p{constructor(){super(...arguments),this.name="WalletGetNetworkError"}};var A,g,f={};Object.defineProperty(f,"__esModule",{value:!0}),f.ChainNetwork=f.NetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Shasta="Shasta",t.Nile="Nile",t.Unknown="Unknown"}(A||(f.NetworkType=A={})),function(t){t.Mainnet="Mainnet",t.Shasta="Shasta",t.Nile="Nile"}(g||(f.ChainNetwork=g={}));var y={};function v(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"undefined"!=typeof navigator}Object.defineProperty(y,"__esModule",{value:!0}),y.isInBrowser=v,y.checkAdapterState=function(t){if(!v())return;const e=[];function n(){for(const t of e)t()}function o(){t()&&n()}const r=setInterval(o,500);e.push((()=>clearInterval(r))),"loading"===document.readyState&&(document.addEventListener("DOMContentLoaded",o,{once:!0}),e.push((()=>document.removeEventListener("DOMContentLoaded",o))));"complete"!==document.readyState&&(window.addEventListener("load",o,{once:!0}),e.push((()=>window.removeEventListener("load",o))));o(),setTimeout(n,6e4)},y.isInMobileBrowser=function(){return"undefined"!=typeof navigator&&navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i)},function(e){var n=t&&t.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,r)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),o=t&&t.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||n(e,t,o)};Object.defineProperty(e,"__esModule",{value:!0}),o(i,e),o(w,e),o(f,e),o(y,e)}(r);var N={},M={},I={},b=t&&t.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{c(o.next(t))}catch(t){i(t)}}function a(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(I,"__esModule",{value:!0}),I.supportTron=j,I.supportTronLink=m,I.isInTronLinkApp=T,I.openTronLink=function({dappIcon:t,dappName:e}={dappIcon:"",dappName:""}){if(!m()&&(0,W.isInMobileBrowser)()&&!T()){let n="",o="";try{n=document.title;const t=document.querySelector('link[rel*="icon"]');t&&(o=new URL(t.getAttribute("href")||"",location.href).toString())}catch(t){}const{origin:r,pathname:i,search:s,hash:a}=window.location,c=r+i+s+(a.includes("?")?a:`${a}?_=1`),l={action:"open",actionId:Date.now()+"",callbackUrl:"http://someurl.com",dappIcon:t||o,dappName:e||n,url:c,protocol:"TronLink",version:"1.0",chainId:"0x2b6653dc"};return window.location.href=`tronlinkoutside://pull.activity?param=${encodeURIComponent(JSON.stringify(l))}`,!0}return!1},I.waitTronwebReady=function(t){return b(this,void 0,void 0,(function*(){return new Promise(((e,n)=>{const o=setInterval((()=>{t.tronWeb&&(clearInterval(o),clearTimeout(r),e())}),50),r=setTimeout((()=>{clearInterval(o),n("`window.tron.tronweb` is not ready.")}),2e3)}))}))};const W=r;function j(){return!(!window.tron||!window.tron.isTronLink)}function m(){return!!(j()||window.tronLink||window.tronWeb)}function T(){return(0,W.isInBrowser)()&&void 0!==window.iTron}!function(e){var n=t&&t.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{c(o.next(t))}catch(t){i(t)}}function a(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.TronLinkAdapter=e.TronLinkAdapterName=e.chainIdNetworkMap=void 0,e.getNetworkInfoByTronWeb=s;const o=r,i=I;function s(t){return n(this,void 0,void 0,(function*(){var n,r,i;const{blockID:s=""}=yield t.trx.getBlockByNumber(0),a=`0x${s.slice(-8)}`;return{networkType:e.chainIdNetworkMap[a]||o.NetworkType.Unknown,chainId:a,fullNode:(null===(n=t.fullNode)||void 0===n?void 0:n.host)||"",solidityNode:(null===(r=t.solidityNode)||void 0===r?void 0:r.host)||"",eventServer:(null===(i=t.eventServer)||void 0===i?void 0:i.host)||""}}))}e.chainIdNetworkMap={"0x2b6653dc":o.NetworkType.Mainnet,"0x94a9059e":o.NetworkType.Shasta,"0xcd8690dc":o.NetworkType.Nile},e.TronLinkAdapterName="TronLink";class a extends o.Adapter{constructor(t={}){super(),this.name=e.TronLinkAdapterName,this.url="https://www.tronlink.org/",this.icon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF0AAABdCAYAAADHcWrDAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAUGVYSWZNTQAqAAAACAACARIAAwAAAAEAAQAAh2kABAAAAAEAAAAmAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAABdoAMABAAAAAEAAABdAAAAAMkTBfIAAAFZaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Chle4QcAABZhSURBVHgB7V0JlBTVuf6runtWllkA2QeYQQRBZHNFxZjw4jFqMEFxCWIS1yOaTeJ76nk5Lyc5CUZNfCoa0BgUxRh3QD2CJs8lELaIgOCw78sszN4z0131vu/W1NDTfbtneqa7Zx5v/nN6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loading,this._supportNewTronProtocol=!1,this._tronLinkMessageHandler=t=>{var e,n,r,i,s;const a=null===(e=t.data)||void 0===e?void 0:e.message;if(a)if("accountsChanged"===a.action)setTimeout((()=>{var t;const e=this.address||"";if(null===(t=this._wallet)||void 0===t?void 0:t.ready){const t=a.data.address;this.setAddress(t),this.setState(o.AdapterState.Connected)}else this.setAddress(null),this.setState(o.AdapterState.Disconnect);this.emit("accountsChanged",this.address||"",e),!e&&this.address?this.emit("connect",this.address):e&&!this.address&&this.emit("disconnect")}),200);else if("setNode"===a.action)this.emit("chainChanged",{chainId:(null===(r=null===(n=a.data)||void 0===n?void 0:n.node)||void 0===r?void 0:r.chainId)||""});else if("connect"===a.action){const t=(null===(s=null===(i=this._wallet.tronWeb)||void 0===i?void 0:i.defaultAddress)||void 0===s?void 0:s.base58)||"";this.setAddress(t),this.setState(o.AdapterState.Connected),this.emit("connect",t)}else"disconnect"===a.action&&(this.setAddress(null),this.setState(o.AdapterState.Disconnect),this.emit("disconnect"))},this._onChainChanged=t=>{this.emit("chainChanged",t)},this._onAccountsChanged=()=>{var t,e,n;const r=this.address||"",i=(null===(t=this._wallet)||void 0===t?void 0:t.tronWeb)&&(null===(n=null===(e=this._wallet)||void 0===e?void 0:e.tronWeb.defaultAddress)||void 0===n?void 0:n.base58)||"";if(i){const t=i;this.setAddress(t),this.setState(o.AdapterState.Connected)}else this.setAddress(null),this.setState(o.AdapterState.Disconnect);this.emit("accountsChanged",this.address||"",r),!r&&this.address?this.emit("connect",this.address):r&&!this.address&&this.emit("disconnect")},this._checkPromise=null,this._updateWallet=()=>{var t,e,n,r,i,s,a,c;let l=this.state,d=this.address;(0,o.isInMobileBrowser)()?(window.tronLink?this._wallet=window.tronLink:this._wallet={ready:!!(null===(t=window.tronWeb)||void 0===t?void 0:t.defaultAddress),tronWeb:window.tronWeb,request:()=>Promise.resolve(!0)},d=(null===(n=null===(e=this._wallet.tronWeb)||void 0===e?void 0:e.defaultAddress)||void 0===n?void 0:n.base58)||null,l=d?o.AdapterState.Connected:o.AdapterState.Disconnect):window.tron&&window.tron.isTronLink?(this._supportNewTronProtocol=!0,this._wallet=window.tron,this._listenTronEvent(),d=this._wallet.tronWeb&&(null===(i=null===(r=this._wallet.tronWeb)||void 0===r?void 0:r.defaultAddress)||void 0===i?void 0:i.base58)||null,l=d?o.AdapterState.Connected:o.AdapterState.Disconnect):window.tronLink?(this._wallet=window.tronLink,this._listenTronLinkEvent(),d=(null===(a=null===(s=this._wallet.tronWeb)||void 0===s?void 0:s.defaultAddress)||void 0===a?void 0:a.base58)||null,l=this._wallet.ready?o.AdapterState.Connected:o.AdapterState.Disconnect):window.tronWeb?(this._wallet={ready:window.tronWeb.ready,tronWeb:window.tronWeb,request:()=>Promise.resolve(!0)},d=(null===(c=this._wallet.tronWeb.defaultAddress)||void 0===c?void 0:c.base58)||null,l=this._wallet.ready?o.AdapterState.Connected:o.AdapterState.Disconnect):(this._wallet=null,d=null,l=o.AdapterState.NotFound),(0,o.isInMobileBrowser)()&&l===o.AdapterState.Disconnect&&this.checkForWalletReadyForApp(),this.setAddress(d),this.setState(l)},this.checkReadyInterval=null;const{checkTimeout:n=3e4,dappIcon:r="",dappName:s="",openUrlWhenWalletNotFound:a=!0,openTronLinkAppOnMobile:c=!0}=t;if("number"!=typeof n)throw new Error("[TronLinkAdapter] config.checkTimeout should be a number");if(this.config={checkTimeout:n,openTronLinkAppOnMobile:c,openUrlWhenWalletNotFound:a,dappIcon:r,dappName:s},this._connecting=!1,this._wallet=null,this._address=null,!(0,o.isInBrowser)())return this._readyState=o.WalletReadyState.NotFound,void this.setState(o.AdapterState.NotFound);(0,i.supportTron)()||(0,o.isInMobileBrowser)()&&(window.tronLink||window.tronWeb)?(this._readyState=o.WalletReadyState.Found,this._updateWallet()):this._checkWallet().then((()=>{this.connected&&this.emit("connect",this.address||"")}))}get address(){return this._address}get state(){return this._state}get readyState(){return this._readyState}get connecting(){return this._connecting}network(){return n(this,void 0,void 0,(function*(){var t;try{if(yield this._checkWallet(),this.state!==o.AdapterState.Connected)throw new o.WalletDisconnectedError;const e=(null===(t=this._wallet)||void 0===t?void 0:t.tronWeb)||window.tronWeb;if(!e)throw new o.WalletDisconnectedError;try{return yield s(e)}catch(t){throw new o.WalletGetNetworkError(null==t?void 0:t.message,t)}}catch(t){throw this.emit("error",t),t}}))}connect(){return n(this,void 0,void 0,(function*(){var t,e;try{if(this.checkIfOpenTronLink(),this.connected||this.connecting)return;if(yield this._checkWallet(),this.state===o.AdapterState.NotFound)throw!1!==this.config.openUrlWhenWalletNotFound&&(0,o.isInBrowser)()&&window.open(this.url,"_blank"),new o.WalletNotFoundError;if(!this._wallet)return;if(this._connecting=!0,this._supportNewTronProtocol){const t=this._wallet;try{const e=(yield t.request({method:"eth_requestAccounts"}))[0];this.setAddress(e),this.setState(o.AdapterState.Connected),this._listenTronEvent(),this._wallet.tronWeb||(yield(0,i.waitTronwebReady)(this._wallet))}catch(t){let e=(null==t?void 0:t.message)||t||"Connect TronLink wallet failed.";throw-32002===t.code&&(e="The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed."),4001===t.code&&(e="The user rejected connection."),new o.WalletConnectionError(e,t)}}else if(window.tronLink){const e=this._wallet;try{const t=yield e.request({method:"tron_requestAccounts"});if(!t)throw new o.WalletConnectionError("TronLink wallet is locked or no wallet account is avaliable.");if(4e3===t.code)throw new o.WalletConnectionError("The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.");if(4001===t.code)throw new o.WalletConnectionError("The user rejected connection.")}catch(t){throw new o.WalletConnectionError(null==t?void 0:t.message,t)}const n=(null===(t=e.tronWeb.defaultAddress)||void 0===t?void 0:t.base58)||"";this.setAddress(n),this.setState(o.AdapterState.Connected),this._listenTronLinkEvent()}else{if(!window.tronWeb)throw new o.WalletConnectionError("Cannot connect wallet.");{const t=(null===(e=this._wallet.tronWeb.defaultAddress)||void 0===e?void 0:e.base58)||"";this.setAddress(t),this.setState(o.AdapterState.Connected)}}this.connected&&this.emit("connect",this.address||"")}catch(t){throw this.emit("error",t),t}finally{this._connecting=!1}}))}disconnect(){return n(this,void 0,void 0,(function*(){this._supportNewTronProtocol?this._stopListenTronEvent():this._stopListenTronLinkEvent(),this.state===o.AdapterState.Connected&&(this.setAddress(null),this.setState(o.AdapterState.Disconnect),this.emit("disconnect"))}))}signTransaction(t,e){return n(this,void 0,void 0,(function*(){try{const n=yield this.checkAndGetWallet();try{return yield n.tronWeb.trx.sign(t,e)}catch(t){throw t instanceof Error?new o.WalletSignTransactionError(t.message,t):new o.WalletSignTransactionError(t,new Error(t))}}catch(t){throw this.emit("error",t),t}}))}multiSign(t,e,r){return n(this,void 0,void 0,(function*(){try{const n=yield this.checkAndGetWallet();try{return yield n.tronWeb.trx.multiSign(t,e,r)}catch(t){throw t instanceof Error?new o.WalletSignTransactionError(t.message,t):new o.WalletSignTransactionError(t,new Error(t))}}catch(t){throw this.emit("error",t),t}}))}signMessage(t,e){return n(this,void 0,void 0,(function*(){try{const n=yield this.checkAndGetWallet();try{return yield n.tronWeb.trx.signMessageV2(t,e)}catch(t){throw t instanceof Error?new o.WalletSignMessageError(t.message,t):new o.WalletSignMessageError(t,new Error(t))}}catch(t){throw this.emit("error",t),t}}))}switchChain(t){return n(this,void 0,void 0,(function*(){try{if(yield this._checkWallet(),this.state===o.AdapterState.NotFound)throw!1!==this.config.openUrlWhenWalletNotFound&&(0,o.isInBrowser)()&&window.open(this.url,"_blank"),new o.WalletNotFoundError;if(!this._supportNewTronProtocol)throw new o.WalletSwitchChainError("Current version of TronLink doesn't support switch chain operation.");const e=this._wallet;try{yield e.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(t){throw new o.WalletSwitchChainError((null==t?void 0:t.message)||t,t instanceof Error?t:new Error(t))}}catch(t){throw this.emit("error",t),t}}))}checkAndGetWallet(){return n(this,void 0,void 0,(function*(){if(this.checkIfOpenTronLink(),yield this._checkWallet(),this.state!==o.AdapterState.Connected)throw new o.WalletDisconnectedError;const t=this._wallet;if(!t||!t.tronWeb)throw new o.WalletDisconnectedError;return t}))}_listenTronLinkEvent(){this._stopListenTronLinkEvent(),window.addEventListener("message",this._tronLinkMessageHandler)}_stopListenTronLinkEvent(){window.removeEventListener("message",this._tronLinkMessageHandler)}checkIfOpenTronLink(){const{dappName:t="",dappIcon:e=""}=this.config;if(!1!==this.config.openTronLinkAppOnMobile&&(0,i.openTronLink)({dappIcon:e,dappName:t}))throw new o.WalletNotFoundError}_listenTronEvent(){this._stopListenTronEvent(),this._stopListenTronLinkEvent();const t=this._wallet;t.on("chainChanged",this._onChainChanged),t.on("accountsChanged",this._onAccountsChanged)}_stopListenTronEvent(){const t=this._wallet;t.removeListener("chainChanged",this._onChainChanged),t.removeListener("accountsChanged",this._onAccountsChanged)}_checkWallet(){if(this.readyState===o.WalletReadyState.Found)return Promise.resolve(!0);if(this._checkPromise)return this._checkPromise;const t=Math.floor(20),e=Math.floor(this.config.checkTimeout/100);let n,r=0;return this._checkPromise=new Promise((s=>{const a=()=>{r++;const a=r<t&&!(0,o.isInMobileBrowser)()?(0,i.supportTron)():(0,i.supportTronLink)();(a||r>e)&&(n&&clearInterval(n),this._readyState=a?o.WalletReadyState.Found:o.WalletReadyState.NotFound,this._updateWallet(),this.emit("readyStateChanged",this.readyState),s(a))};n=setInterval(a,100),a()})),this._checkPromise}checkForWalletReadyForApp(){if(this.checkReadyInterval)return;let t=0;const e=Math.floor(this.config.checkTimeout/200);this.checkReadyInterval=setInterval((()=>{var n,o;(window.tronLink?null===(n=window.tronLink.tronWeb)||void 0===n?void 0:n.defaultAddress:null===(o=window.tronWeb)||void 0===o?void 0:o.defaultAddress)?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null,this._updateWallet(),this.emit("connect",this.address||"")):t>e?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null):t++}),200)}setAddress(t){this._address=t}setState(t){t!==this.state&&(this._state=t,this.emit("stateChanged",t))}}e.TronLinkAdapter=a}(M);var D={};Object.defineProperty(D,"__esModule",{value:!0}),function(e){var n=t&&t.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,r)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),o=t&&t.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||n(e,t,o)};Object.defineProperty(e,"__esModule",{value:!0}),o(M,e),o(D,e),o(I,e)}(N);var k={};Object.defineProperty(k,"__esModule",{value:!0}),k.isBybitApp=void 0,k.supportBybitWallet=function(){return!(!window.bybitWallet||!window.bybitWallet.tronLink)},k.isInBybitApp=S,k.openBybitWallet=function(){if(!S()&&(0,E.isInMobileBrowser)())return window.location.href=`https://app.bybit.com/inapp?by_dp=${encodeURIComponent("bybitapp://open/route?targetUrl=by%3A%2F%2Fweb3%2Ftab%2Findex%3Findex%3D0")}&by_web_link=${encodeURIComponent(window.location.href)}`,!0;return!1};const E=r;function S(){return"undefined"!=typeof window&&void 0!==window.navigator&&/bybit_app/i.test(window.navigator.userAgent)}return k.isBybitApp="undefined"!=typeof navigator&&/bybit_app/i.test(navigator.userAgent),function(e){var n=t&&t.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{c(o.next(t))}catch(t){i(t)}}function a(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.BybitWalletAdapter=e.BybitWalletAdapterName=void 0;const o=r,i=N,s=k;e.BybitWalletAdapterName="Bybit Wallet";class a extends o.Adapter{constructor(t={}){super(),this.name=e.BybitWalletAdapterName,this.url="https://bybit.com/web3",this.icon="data:image/svg+xml;base64,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MzMwOCIgeTE9IjI1LjU5NCIgeDI9Ijg0LjYzODEiIHkyPSIyMS43MjE2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiNGRkQ3NDgiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRjdBNjAwIi8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+Cg==",this._readyState=(0,o.isInBrowser)()?o.WalletReadyState.Loading:o.WalletReadyState.NotFound,this._state=o.AdapterState.Loading,this.messageHandler=t=>{var e,n,r;const i=null===(e=t.data)||void 0===e?void 0:e.message;if(i)if("accountsChanged"===i.action)setTimeout((()=>{var t;const e=this.address||"";if(null===(t=this._wallet)||void 0===t?void 0:t.ready){const t=i.data.address;this.setAddress(t),this.setState(o.AdapterState.Connected)}else this.setAddress(null),this.setState(o.AdapterState.Disconnect);(this.address||"")!==e&&this.emit("accountsChanged",this.address||"",e),!e&&this.address?this.emit("connect",this.address):e&&!this.address&&this.emit("disconnect")}),200);else if("connect"===i.action){const t=this.connected,e=this.address||"",i=(null===(r=null===(n=this._wallet.tronWeb)||void 0===n?void 0:n.defaultAddress)||void 0===r?void 0:r.base58)||"";this.setAddress(i),this.setState(o.AdapterState.Connected),t?i!==e&&this.emit("accountsChanged",this.address||"",e):this.emit("connect",i)}else"disconnect"===i.action&&(this.setAddress(null),this.setState(o.AdapterState.Disconnect),this.emit("disconnect"))},this._checkPromise=null,this._updateWallet=()=>{var t,e;let n=this.state,r=this.address;(0,s.supportBybitWallet)()?(this._wallet=window.bybitWallet.tronLink,this._listenEvent(),r=(null===(e=null===(t=this._wallet.tronWeb)||void 0===t?void 0:t.defaultAddress)||void 0===e?void 0:e.base58)||null,n=this._wallet.ready?o.AdapterState.Connected:o.AdapterState.Disconnect):(this._wallet=null,r=null,n=o.AdapterState.NotFound),this.setAddress(r),this.setState(n)};const{checkTimeout:n=2e3,openUrlWhenWalletNotFound:r=!0,openAppWithDeeplink:i=!0}=t;if("number"!=typeof n)throw new Error("[BybitWalletAdapter] config.checkTimeout should be a number");if(this.config={checkTimeout:n,openAppWithDeeplink:i,openUrlWhenWalletNotFound:r},this._connecting=!1,this._wallet=null,this._address=null,!(0,o.isInBrowser)())return this._readyState=o.WalletReadyState.NotFound,void this.setState(o.AdapterState.NotFound);(0,s.supportBybitWallet)()?(this._readyState=o.WalletReadyState.Found,this._updateWallet()):this._checkWallet().then((()=>{this.connected&&this.emit("connect",this.address||"")}))}get address(){return this._address}get state(){return this._state}get readyState(){return this._readyState}get connecting(){return this._connecting}network(){return n(this,void 0,void 0,(function*(){try{if(yield this._checkWallet(),this.state!==o.AdapterState.Connected)throw new o.WalletDisconnectedError;const t=this._wallet;if(!t||!t.tronWeb)throw new o.WalletDisconnectedError;try{return yield(0,i.getNetworkInfoByTronWeb)(t.tronWeb)}catch(t){throw new o.WalletGetNetworkError(null==t?void 0:t.message,t)}}catch(t){throw this.emit("error",t),t}}))}connect(){return n(this,void 0,void 0,(function*(){var t;try{if(this.checkIfOpenBybitWallet(),this.connected||this.connecting)return;if(yield this._checkWallet(),this.state===o.AdapterState.NotFound)throw!1!==this.config.openUrlWhenWalletNotFound&&(0,o.isInBrowser)()&&window.open(this.url,"_blank"),new o.WalletNotFoundError;if(!this._wallet)return;this._connecting=!0;const e=this._wallet;try{const t=yield e.request({method:"tron_requestAccounts"});if(!t)throw new o.WalletConnectionError("Request connect error.");if(4e3===t.code)throw new o.WalletConnectionError("The same DApp has already initiated a request to connect to BybitWallet, and the pop-up window has not been closed.");if(4001===t.code)throw new o.WalletConnectionError("The user rejected connection.")}catch(t){throw new o.WalletConnectionError(null==t?void 0:t.message,t)}const n=(null===(t=e.tronWeb.defaultAddress)||void 0===t?void 0:t.base58)||"";this.setAddress(n),this.setState(o.AdapterState.Connected),this._listenEvent(),this.connected&&this.emit("connect",this.address||"")}catch(t){throw this.emit("error",t),t}finally{this._connecting=!1}}))}disconnect(){return n(this,void 0,void 0,(function*(){this._stopListenEvent(),this.state===o.AdapterState.Connected&&(this.setAddress(null),this.setState(o.AdapterState.Disconnect),this.emit("disconnect"))}))}signTransaction(t,e){return n(this,void 0,void 0,(function*(){try{const n=yield this.checkAndGetWallet();try{return yield n.tronWeb.trx.sign(t,e)}catch(t){throw t instanceof Error?new o.WalletSignTransactionError(t.message,t):new o.WalletSignTransactionError(t,new Error(t))}}catch(t){throw this.emit("error",t),t}}))}multiSign(t,e,r){return n(this,void 0,void 0,(function*(){try{const n=yield this.checkAndGetWallet();try{return yield n.tronWeb.trx.multiSign(t,e,r)}catch(t){throw t instanceof Error?new o.WalletSignTransactionError(t.message,t):new o.WalletSignTransactionError(t,new Error(t))}}catch(t){throw this.emit("error",t),t}}))}signMessage(t,e){return n(this,void 0,void 0,(function*(){try{const n=yield this.checkAndGetWallet();try{return yield n.tronWeb.trx.signMessageV2(t,e)}catch(t){throw t instanceof Error?new o.WalletSignMessageError(t.message,t):new o.WalletSignMessageError(t,new Error(t))}}catch(t){throw this.emit("error",t),t}}))}checkAndGetWallet(){return n(this,void 0,void 0,(function*(){if(this.checkIfOpenBybitWallet(),yield this._checkWallet(),this.state!==o.AdapterState.Connected)throw new o.WalletDisconnectedError;const t=this._wallet;if(!t||!t.tronWeb)throw new o.WalletDisconnectedError;return t}))}_listenEvent(){this._stopListenEvent(),window.addEventListener("message",this.messageHandler)}_stopListenEvent(){window.removeEventListener("message",this.messageHandler)}checkIfOpenBybitWallet(){if(!1!==this.config.openAppWithDeeplink&&(0,s.openBybitWallet)())throw new o.WalletNotFoundError}_checkWallet(){if(this.readyState===o.WalletReadyState.Found)return Promise.resolve(!0);if(this._checkPromise)return this._checkPromise;const t=Math.floor(this.config.checkTimeout/100);let e,n=0;return this._checkPromise=new Promise((r=>{const i=()=>{n++;const i=(0,s.supportBybitWallet)();(i||n>t)&&(e&&clearInterval(e),this._readyState=i?o.WalletReadyState.Found:o.WalletReadyState.NotFound,this._updateWallet(),this.emit("readyStateChanged",this.readyState),r(i))};e=setInterval(i,100),i()})),this._checkPromise}setAddress(t){this._address=t}setState(t){t!==this.state&&(this._state=t,this.emit("stateChanged",t))}}e.BybitWalletAdapter=a}(o),function(e){var n=t&&t.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,r)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),r=t&&t.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||n(e,t,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(o,e),r(k,e)}(n),e(n)}));