itaquelaboriosam
Version:
3 lines (2 loc) • 13.5 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@web3-react/abstract-connector");function e(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function n(t){return function(){var n=this,r=arguments;return new Promise((function(o,i){var a=t.apply(n,r);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,c,u,"throw",t)}c(void 0)}))}}function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function o(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,a(t,e)}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e,n){return(u=c()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&a(o,n.prototype),o}).apply(null,arguments)}function h(t){var e="function"==typeof Map?new Map:void 0;return(h=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,i(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,t)})(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}require("tiny-warning");var f,l=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function u(t,e,n,r){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new C(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=b(a,n);if(c){if(c===s)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===s)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,i),o}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var s={};function f(){}function l(){}function d(){}var p={};c(p,o,(function(){return this}));var w=Object.getPrototypeOf,v=w&&w(w(_([])));v&&v!==e&&n.call(v,o)&&(p=v);var y=d.prototype=f.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){var r;this._invoke=function(o,i){function a(){return new e((function(r,a){!function r(o,i,a,c){var u=h(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function b(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var r=h(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,s;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function _(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=d,c(y,"constructor",d),c(d,"constructor",l),l.displayName=c(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,c(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new m(u(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),c(y,a,"Generator"),c(y,o,(function(){return this})),c(y,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=_,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),s},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),k(n),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;k(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:_(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(f={exports:{}}),f.exports);function d(t){return t.hasOwnProperty("result")?t.result:t}var p=function(t){function e(){var e;return(e=t.call(this)||this).name=e.constructor.name,e.message="No Ethereum provider was found on window.ethereum.",e}return o(e,t),e}(h(Error)),w=function(t){function e(){var e;return(e=t.call(this)||this).name=e.constructor.name,e.message="The user rejected the request.",e}return o(e,t),e}(h(Error));exports.CoinWalletConnector=function(t){function e(e){var n;return(n=t.call(this,e)||this).handleNetworkChanged=n.handleNetworkChanged.bind(s(n)),n.handleChainChanged=n.handleChainChanged.bind(s(n)),n.handleAccountsChanged=n.handleAccountsChanged.bind(s(n)),n.handleClose=n.handleClose.bind(s(n)),n}o(e,t);var i=e.prototype;return i.handleChainChanged=function(t){this.emitUpdate({chainId:t,provider:window.eth})},i.handleAccountsChanged=function(t){0===t.length?this.emitDeactivate():this.emitUpdate({account:t[0]})},i.handleClose=function(t,e){this.emitDeactivate()},i.handleNetworkChanged=function(t){this.emitUpdate({chainId:t,provider:window.eth})},i.activate=function(){var t=n(l.mark((function t(){var e;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(window.eth){t.next=2;break}throw new p;case 2:return window.eth.on&&(window.eth.on("chainChanged",this.handleChainChanged),window.eth.on("accountsChanged",this.handleAccountsChanged),window.eth.on("close",this.handleClose),window.eth.on("networkChanged",this.handleNetworkChanged)),window.eth.isMetaMask&&(window.eth.autoRefreshOnNetworkChange=!1),t.prev=4,t.next=7,window.eth.send("eth_requestAccounts").then((function(t){return d(t)[0]}));case 7:e=t.sent,t.next=15;break;case 10:if(t.prev=10,t.t0=t.catch(4),4001!==t.t0.code){t.next=14;break}throw new w;case 14:case 15:if(e){t.next=19;break}return t.next=18,window.eth.enable().then((function(t){return t&&d(t)[0]}));case 18:e=t.sent;case 19:return t.abrupt("return",r({provider:window.eth},e?{account:e}:{}));case 20:case"end":return t.stop()}}),t,this,[[4,10]])})));return function(){return t.apply(this,arguments)}}(),i.getProvider=function(){var t=n(l.mark((function t(){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",window.eth);case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),i.getChainId=function(){var t=n(l.mark((function t(){var e;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(window.eth){t.next=2;break}throw new p;case 2:return t.prev=2,t.next=5,window.eth.send("eth_chainId").then(d);case 5:e=t.sent,t.next=11;break;case 8:t.prev=8,t.t0=t.catch(2);case 11:if(e){t.next=21;break}return t.prev=12,t.next=15,window.eth.send("net_version").then(d);case 15:e=t.sent,t.next=21;break;case 18:t.prev=18,t.t1=t.catch(12);case 21:if(!e)try{e=d(window.eth.send({method:"net_version"}))}catch(t){}return e||(e=window.eth.isDapper?d(window.eth.cachedResults.net_version):window.eth.chainId||window.eth.netVersion||window.eth.networkVersion||window.eth._chainId),t.abrupt("return",e);case 24:case"end":return t.stop()}}),t,null,[[2,8],[12,18]])})));return function(){return t.apply(this,arguments)}}(),i.getAccount=function(){var t=n(l.mark((function t(){var e;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(window.eth){t.next=2;break}throw new p;case 2:return t.prev=2,t.next=5,window.eth.send("eth_accounts").then((function(t){return d(t)[0]}));case 5:e=t.sent,t.next=11;break;case 8:t.prev=8,t.t0=t.catch(2);case 11:if(e){t.next=21;break}return t.prev=12,t.next=15,window.eth.enable().then((function(t){return d(t)[0]}));case 15:e=t.sent,t.next=21;break;case 18:t.prev=18,t.t1=t.catch(12);case 21:return e||(e=d(window.eth.send({method:"eth_accounts"}))[0]),t.abrupt("return",e);case 23:case"end":return t.stop()}}),t,null,[[2,8],[12,18]])})));return function(){return t.apply(this,arguments)}}(),i.deactivate=function(){window.eth&&window.eth.removeListener&&(window.eth.removeListener("chainChanged",this.handleChainChanged),window.eth.removeListener("accountsChanged",this.handleAccountsChanged),window.eth.removeListener("close",this.handleClose),window.eth.removeListener("networkChanged",this.handleNetworkChanged))},i.isAuthorized=function(){var t=n(l.mark((function t(){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(window.eth){t.next=2;break}return t.abrupt("return",!1);case 2:return t.prev=2,t.next=5,window.eth.send("eth_accounts").then((function(t){return d(t).length>0}));case 5:return t.abrupt("return",t.sent);case 8:return t.prev=8,t.t0=t.catch(2),t.abrupt("return",!1);case 11:case"end":return t.stop()}}),t,null,[[2,8]])})));return function(){return t.apply(this,arguments)}}(),e}(t.AbstractConnector),exports.NoEthereumProviderError=p,exports.UserRejectedRequestError=w;
//# sourceMappingURL=coinwallet-connector.cjs.production.min.js.map