@dodoex/wallet-web3 0.0.3-3 → 0.0.3-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/controllers/ConnectController.d.ts +6 -5
- package/dist/cjs/core/index.d.ts +0 -1
- package/dist/cjs/{index-1613ac94.cjs → index-0eeb697b.cjs} +2 -2
- package/dist/cjs/{index-613571b4.cjs → index-3a14a931.cjs} +1 -1
- package/dist/cjs/index-a26b6945.cjs +1 -0
- package/dist/cjs/index-a9081fe4.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/portis-8c790653.cjs +1 -0
- package/dist/cjs/provider-95f3425c.cjs +1 -0
- package/dist/cjs/state.d.ts +12 -3
- package/dist/cjs/uAuth-692ecdf6.cjs +1 -0
- package/dist/cjs/walletConnect-14d9d490.cjs +1 -0
- package/dist/cjs/walletLink-b99948b8.cjs +1 -0
- package/dist/controllers/ConnectController.d.ts +6 -5
- package/dist/core/index.d.ts +0 -1
- package/dist/{index-201c01d8.js → index-3a9d1d45.js} +2 -2
- package/dist/{index-cecc22f4.js → index-9af08480.js} +1 -1
- package/dist/index-a2c8f38f.js +1 -0
- package/dist/index-afc4ce88.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/portis-f89a1cba.js +1 -0
- package/dist/provider-1ecbc0fa.js +1 -0
- package/dist/state.d.ts +12 -3
- package/dist/uAuth-1f7b3a0a.js +1 -0
- package/dist/walletConnect-ac756ff6.js +1 -0
- package/dist/walletLink-c286f908.js +1 -0
- package/package.json +2 -2
- package/dist/cjs/controllers/StateController.d.ts +0 -27
- package/dist/cjs/index-0494ffbc.cjs +0 -1
- package/dist/cjs/index-b63f2913.cjs +0 -19
- package/dist/cjs/portis-09fea9b2.cjs +0 -1
- package/dist/cjs/provider-653a6c4b.cjs +0 -1
- package/dist/cjs/uAuth-e46c0332.cjs +0 -1
- package/dist/cjs/walletConnect-a74c7523.cjs +0 -1
- package/dist/cjs/walletLink-5a993e87.cjs +0 -1
- package/dist/controllers/StateController.d.ts +0 -27
- package/dist/index-b6a46a6d.js +0 -1
- package/dist/index-b869aac9.js +0 -19
- package/dist/portis-3b5726bc.js +0 -1
- package/dist/provider-847fb9d1.js +0 -1
- package/dist/uAuth-458fbce7.js +0 -1
- package/dist/walletConnect-643e147f.js +0 -1
- package/dist/walletLink-fd84e70b.js +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-a26b6945.cjs");require("@ethersproject/providers"),require("@ethersproject/constants"),require("@ethersproject/contracts"),require("@ethersproject/address"),require("zustand"),exports.HD_PATH_LIST=e.HD_PATH_LIST,exports.OpenBlockIframeWallet=e.OpenBlockIframeWallet,Object.defineProperty(exports,"WalletType",{enumerable:!0,get:function(){return e.WalletType}}),Object.defineProperty(exports,"WatchResult",{enumerable:!0,get:function(){return e.WatchResult}}),exports.allWalletList=e.allWalletList,exports.approve=e.approve,exports.default=e.Core,exports.getContract=e.getContract,exports.getEstimateGas=e.getEstimateGas,exports.getGasPrice=e.getGasPrice,exports.getGnosisPackage=e.getGnosisPackage,exports.getIsOpenBlockIframe=e.getIsOpenBlockIframe,exports.getIsolatedEnvironmentWallet=e.getIsolatedEnvironmentWallet,exports.getLedgerUSBPackage=e.getLedgerUSBPackage,exports.getOpenBlockIframeConnector=e.connectOpenBlockIframe,exports.getPortisConnector=e.getPortisConnector,exports.getProviderByChain=e.getProviderByChain,exports.getUAuthPackage=e.getUAuthPackage,exports.getWalletConnectConnector=e.getWalletConnectConnector,exports.getWalletDisabledStateFunction=e.getWalletDisabledStateFunction,exports.getWalletLinkConnector=e.getWalletLinkConnector,exports.getWalletList=e.getWalletList,exports.injectedConnect=e.injectedConnect,exports.injectedList=e.injectedList,exports.injectedListObject=e.injectedListObject,exports.registerNetworkWithMetamask=e.registerNetworkWithMetamask,exports.sendTransaction=e.sendTransaction,exports.standaloneList=e.standaloneList,exports.standaloneListObject=e.standaloneListObject,exports.useWalletStore=e.useWalletStore,exports.watchTx=e.watchTx;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./index-a26b6945.cjs");function t(e,t){var i="string"==typeof e?Object.assign({},n[e]):e;if("object"!=typeof i)throw new Error("[Portis] illegal 'network' parameter. Read more about it here: https://docs.portis.io/#/configuration?id=network");if(!i.nodeUrl)throw new Error("[Portis] 'nodeUrl' is required. Read more about it here: https://docs.portis.io/#/configuration?id=network");if(t&&!i.gasRelayHubAddress)throw new Error("[Portis] can't find default gas relay hub for "+e);return"string"!=typeof e||t||delete i.gasRelayHubAddress,i}require("@ethersproject/providers"),require("@ethersproject/constants"),require("@ethersproject/contracts"),require("@ethersproject/address"),require("zustand");var n={mainnet:{nodeUrl:"https://mainnet.infura.io/v3/faa4639b090f46499f29d894da0551a0",chainId:"1",gasRelayHubAddress:"0xD216153c06E857cD7f72665E0aF1d7D82172F494"},ropsten:{nodeUrl:"https://ropsten.infura.io/v3/faa4639b090f46499f29d894da0551a0",chainId:"3",gasRelayHubAddress:"0xD216153c06E857cD7f72665E0aF1d7D82172F494"},rinkeby:{nodeUrl:"https://rinkeby.infura.io/v3/faa4639b090f46499f29d894da0551a0",chainId:"4",gasRelayHubAddress:"0xD216153c06E857cD7f72665E0aF1d7D82172F494"},goerli:{nodeUrl:"https://goerli.infura.io/v3/faa4639b090f46499f29d894da0551a0",chainId:"5"},ubiq:{nodeUrl:"https://rpc1.ubiqscan.io",chainId:"8"},thundercoreTestnet:{nodeUrl:"https://testnet-rpc.thundercore.com:8544",chainId:"18"},orchid:{nodeUrl:"https://public-node.rsk.co",chainId:"30"},orchidTestnet:{nodeUrl:"https://public-node.testnet.rsk.co",chainId:"31"},kovan:{nodeUrl:"https://kovan.infura.io/v3/faa4639b090f46499f29d894da0551a0",chainId:"42",gasRelayHubAddress:"0xD216153c06E857cD7f72665E0aF1d7D82172F494"},classic:{nodeUrl:"https://ethereumclassic.network",chainId:"61"},sokol:{nodeUrl:"https://sokol.poa.network",chainId:"77"},core:{nodeUrl:"https://core.poa.network",chainId:"99"},xdai:{nodeUrl:"https://dai.poa.network",chainId:"100",gasRelayHubAddress:"0xD216153c06E857cD7f72665E0aF1d7D82172F494"},thundercore:{nodeUrl:"https://mainnet-rpc.thundercore.com",chainId:"108"},fuse:{nodeUrl:"https://rpc.fusenet.io",chainId:"122"},lightstreams:{nodeUrl:"https://node.mainnet.lightstreams.io",chainId:"163"},matic:{nodeUrl:"https://polygon-rpc.com",chainId:"137"},maticMumbai:{nodeUrl:"https://rpc-mumbai.matic.today",chainId:"80001"},maticAlpha:{nodeUrl:"https://alpha.ethereum.matic.network",chainId:"4626"},maticTestnet:{nodeUrl:"https://testnet2.matic.network",chainId:"8995"}},i=function(){return!("undefined"==typeof window||!window.document)},r=!1;function o(){return new Promise((function(e,t){i()?r?e():["loaded","interactive","complete"].indexOf(document.readyState)>-1?(r=!0,e()):window.addEventListener("load",(function(){r=!0,e()}),!1):t()}))}function a(){var e="localhost"===location.hostname||"127.0.0.1"===location.hostname,t="https:"===location.protocol;if(!(e||t))throw"[Portis] Access to the WebCrypto API is restricted to secure origins.\nIf this is a development environment please use http://localhost:"+location.port+" instead.\nOtherwise, please use an SSL certificate."}var s={};Object.defineProperty(s,"__esModule",{value:!0});var c=s.default=s.ERR_NOT_IN_IFRAME=s.ERR_CONNECTION_TIMEOUT=s.ERR_CONNECTION_DESTROYED=void 0,u="handshake",d="handshake-reply",l="call",h="reply",f="fulfilled",g="rejected",p="message",v="ConnectionDestroyed";s.ERR_CONNECTION_DESTROYED=v;var m="ConnectionTimeout";s.ERR_CONNECTION_TIMEOUT=m;var w="NotInIframe";s.ERR_NOT_IN_IFRAME=w;var b,y={"http:":"80","https:":"443"},_=/^(https?:)?\/\/([^/:]+)(:(\d+))?/,E={ERR_CONNECTION_DESTROYED:v,ERR_CONNECTION_TIMEOUT:m,ERR_NOT_IN_IFRAME:w,Promise:function(){try{return window?window.Promise:null}catch(e){return null}}(),debug:!1},C=(b=0,function(){return++b}),P=function(){if(E.debug){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,["[Penpal]"].concat(n))}},k=function(e){var t=[];return e((function(){t.forEach((function(e){e()}))})),{then:function(e){t.push(e)}}},I=function(e){return{name:e.name,message:e.message,stack:e.stack}},W=function(e,t,n,i){var r=t.localName,o=t.local,a=t.remote,s=t.remoteOrigin,c=!1;P("".concat(r,": Connecting call sender"));var u=function(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];if(P("".concat(r,": Sending ").concat(e,"() call")),c){var u=new Error("Unable to send ".concat(e,"() call due ")+"to destroyed connection");throw u.code=v,u}return new E.Promise((function(t,i){var c=C();o.addEventListener(p,(function n(u){if(u.source===a&&u.origin===s&&u.data.penpal===h&&u.data.id===c){P("".concat(r,": Received ").concat(e,"() reply")),o.removeEventListener(p,n);var d=u.data.returnValue;u.data.returnValueIsError&&(l=d,g=new Error,Object.keys(l).forEach((function(e){return g[e]=l[e]})),d=g),(u.data.resolution===f?t:i)(d)}var l,g})),a.postMessage({penpal:l,id:c,methodName:e,args:n},s)}))}};i.then((function(){c=!0})),n.reduce((function(e,t){return e[t]=u(t),e}),e)},x=function(e,t,n){var i=e.localName,r=e.local,o=e.remote,a=e.remoteOrigin,s=!1;P("".concat(i,": Connecting call receiver"));var c=function(e){if(e.source===o&&e.origin===a&&e.data.penpal===l){var n=e.data,r=n.methodName,c=n.args,u=n.id;if(P("".concat(i,": Received ").concat(r,"() call")),r in t){var d=function(e){return function(t){if(P("".concat(i,": Sending ").concat(r,"() reply")),s)P("".concat(i,": Unable to send ").concat(r,"() reply due to destroyed connection"));else{var n={penpal:h,id:u,resolution:e,returnValue:t};e===g&&t instanceof Error&&(n.returnValue=I(t),n.returnValueIsError=!0);try{o.postMessage(n,a)}catch(e){throw"DataCloneError"===e.name&&o.postMessage({penpal:h,id:u,resolution:g,returnValue:I(e),returnValueIsError:!0},a),e}}}};new E.Promise((function(e){return e(t[r].apply(t,c))})).then(d(f),d(g))}}};r.addEventListener(p,c),n.then((function(){s=!0,r.removeEventListener(p,c)}))};E.connectToChild=function(e){var t,n=e.url,i=e.appendTo,r=e.methods,o=void 0===r?{}:r,a=e.timeout,s=new k((function(e){t=e})),c=window,l=document.createElement("iframe");(i||document.body).appendChild(l),s.then((function(){l.parentNode&&l.parentNode.removeChild(l)}));var h=l.contentWindow||l.contentDocument.parentWindow,f=function(e){var t,n,i,r=document.location,o=_.exec(e);o?(t=o[1]?o[1]:r.protocol,n=o[2],i=o[4]):(t=r.protocol,n=r.hostname,i=r.port);var a=i&&i!==y[t]?":".concat(i):"";return"".concat(t,"//").concat(n).concat(a)}(n);return{promise:new E.Promise((function(e,i){var r;void 0!==a&&(r=setTimeout((function(){var e=new Error("Connection to child timed out after ".concat(a,"ms"));e.code=m,i(e),t()}),a));var g,w,b={},y=function(t){if(t.source===h&&t.origin===f&&t.data.penpal===u){P("Parent: Received handshake, sending reply"),t.source.postMessage({penpal:d,methodNames:Object.keys(o)},t.origin);var n={localName:"Parent",local:c,remote:h,remoteOrigin:t.origin};w&&w();var i=new k((function(e){s.then(e),w=e}));x(n,o,i),g&&g.forEach((function(e){delete b[e]})),g=t.data.methodNames,W(b,n,g,s),clearTimeout(r),e(b)}};c.addEventListener(p,y),s.then((function(){c.removeEventListener(p,y);var e=new Error("Connection destroyed");e.code=v,i(e)})),P("Parent: Loading iframe"),l.src=n})),iframe:l,destroy:t}},E.connectToParent=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.parentOrigin,i=void 0===n?"*":n,r=t.methods,o=void 0===r?{}:r,a=t.timeout;if(window===window.top){var s=new Error("connectToParent() must be called within an iframe");throw s.code=w,s}var c=new k((function(t){e=t})),l=window,h=l.parent,f=new E.Promise((function(t,n){var r;void 0!==a&&(r=setTimeout((function(){var t=new Error("Connection to parent timed out after ".concat(a,"ms"));t.code=m,n(t),e()}),a));var s=function e(n){if(("*"===i||i===n.origin)&&n.source===h&&n.data.penpal===d){P("Child: Received handshake reply"),l.removeEventListener(p,e);var a={localName:"Child",local:l,remote:h,remoteOrigin:n.origin},s={};x(a,o,c),W(s,a,n.data.methodNames,c),clearTimeout(r),t(s)}};l.addEventListener(p,s),c.then((function(){l.removeEventListener(p,s);var e=new Error("Connection destroyed");e.code=v,n(e)})),P("Child: Sending handshake"),h.postMessage({penpal:u,methodNames:Object.keys(o)},i)}));return{promise:f,destroy:e}};var T=E;c=s.default=T;var A=function(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(a,s)}c((i=i.apply(e,t||[])).next())}))},O=function(e,t){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},M=process.env.PORTIS_WIDGET_URL||"https://widget.portis.io",N="por_portis-widget-frame",L="por_portis-container";var R=function(){function e(t,n){this._widgetConfig=t,this._clearProviderSession=n,this._widgetUrl=M,this._onLoginCallback=function(){},this._onLogoutCallback=function(){},this._onErrorCallback=function(){},a(),t.staging?(console.warn("Please note: you are using the Portis STAGING environment."),this._widgetUrl="https://widget-staging.portis.io"):t.feature&&(console.warn("Please note: you are using the Portis FEATURE environment."),this._widgetUrl="https://widget-feature.portis.io"),e._checkIfWidgetAlreadyInitialized()}return e.prototype.getWidget=function(){return A(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return this.widgetInstance?[3,2]:(this.widgetPromise||(this.widgetPromise=this._initWidget()),e=this,[4,this.widgetPromise]);case 1:e.widgetInstance=t.sent(),t.label=2;case 2:return[2,this.widgetInstance]}}))}))},e.prototype.setDefaultEmail=function(e){this._widgetConfig.defaultEmail=e},e.prototype.setOnLoginCallback=function(e){this._onLoginCallback=e},e.prototype.setOnLogoutCallback=function(e){this._onLogoutCallback=e},e.prototype.setOnActiveWalletChangedCallback=function(e){this._onActiveWalletChangedCallback=e},e.prototype.setOnErrorCallback=function(e){this._onErrorCallback=e},e.prototype.showPortis=function(){return A(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.getWidget()];case 1:return[2,e.sent().communication.showPortis(this._widgetConfig)]}}))}))},e.prototype.getCampaignInfo=function(e){return A(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.getWidget()];case 1:return[2,t.sent().communication.getCampaignInfo(e)]}}))}))},e.prototype.claimVoucher=function(e){return A(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.getWidget()];case 1:return[2,t.sent().communication.claimVoucher(e,this._widgetConfig)]}}))}))},e.prototype.logout=function(){return A(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.getWidget()];case 1:return[2,e.sent().communication.logout()]}}))}))},e.prototype.getExtendedPublicKey=function(e,t){return void 0===e&&(e="m/44'/60'/0'/0/0"),void 0===t&&(t="Ethereum"),A(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return[4,this.getWidget()];case 1:return[2,n.sent().communication.getExtendedPublicKey(e,t,this._widgetConfig)]}}))}))},e.prototype.importWallet=function(e){return A(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.getWidget()];case 1:return[2,t.sent().communication.importWallet(e,this._widgetConfig)]}}))}))},e.prototype.isLoggedIn=function(){return A(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.getWidget()];case 1:return[2,e.sent().communication.isLoggedIn()]}}))}))},e.prototype.signBitcoinTransaction=function(e){return A(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.getWidget()];case 1:return[2,t.sent().communication.signBitcoinTransaction(e,this._widgetConfig)]}}))}))},e.prototype.showBitcoinWallet=function(e){return void 0===e&&(e="m/49'/0'/0'/0/0"),A(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.getWidget()];case 1:return[2,t.sent().communication.showBitcoinWallet(e,this._widgetConfig)]}}))}))},e.prototype.purchaseERC20=function(e){return A(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.getWidget()];case 1:return[2,t.sent().communication.purchaseERC20(e,this._widgetConfig)]}}))}))},e._checkIfWidgetAlreadyInitialized=function(){document.getElementsByClassName(L).length&&console.warn("An instance of Portis was already initialized. This is probably a mistake. Make sure that you use the same Portis instance throughout your app.")},e.prototype._initWidget=function(){return A(this,void 0,void 0,(function(){var t,n,i,r,a;return O(this,(function(s){switch(s.label){case 0:return[4,o()];case 1:return s.sent(),(t=document.createElement("style")).innerHTML="\n.por_portis-container {\n position: fixed;\n width: 0px;\n height: 0px;\n top: 0px;\n right: 0px;\n z-index: 2147483647;\n}\n\n@media (max-width: 576px) {\n .por_portis-container {\n bottom: 0;\n top: auto;\n }\n}\n\n.por_portis-widget-frame {\n position: fixed;\n width: 375px;\n height: 0;\n top: 20px;\n right: 20px;\n box-shadow: 0 5px 40px rgba(0,0,0,.16);\n border-radius: 8px;\n overflow: hidden;\n z-index: 2147483000;\n}\n\n@media (max-width: 576px) {\n .por_portis-widget-frame {\n bottom: 0;\n top: auto;\n width: 100%;\n right: 0;\n left: 0;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n }\n}\n",(n=document.createElement("div")).className=L,(i=document.createElement("div")).id="portis-container-"+Date.now(),i.className=N,n.appendChild(i),document.body.appendChild(n),document.head.appendChild(t),[4,(r=c.connectToChild({url:this._widgetUrl,appendTo:document.getElementById(i.id),methods:{setHeight:this._setHeight.bind(this),getWindowSize:e._getWindowSize.bind(this),onLogin:this._onLogin.bind(this),onLogout:this._onLogout.bind(this),onActiveWalletChanged:this._onActiveWalletChanged.bind(this),hasOnActiveWalletChanged:this.hasOnActiveWalletChanged.bind(this),onError:this._onError.bind(this)}})).promise];case 2:return(a=s.sent()).setSdkConfig(this._widgetConfig),r.iframe.style.position="absolute",r.iframe.style.height="100%",r.iframe.style.width="100%",r.iframe.style.border="0 transparent",[2,{communication:a,widgetFrame:i}]}}))}))},e.prototype._setHeight=function(e){return A(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.getWidget()];case 1:return t.sent().widgetFrame.style.height=e+"px",[2]}}))}))},e._getWindowSize=function(){var e=document.getElementsByTagName("body")[0];return{width:window.innerWidth||document.documentElement.clientWidth||e.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||e.clientHeight}},e.prototype._onLogin=function(e,t,n){this._onLoginCallback&&this._onLoginCallback(e,t,n)},e.prototype._onLogout=function(){this._clearProviderSession(),this._onLogoutCallback&&this._onLogoutCallback()},e.prototype._onActiveWalletChanged=function(e){this._onActiveWalletChangedCallback&&this._onActiveWalletChangedCallback(e)},e.prototype.hasOnActiveWalletChanged=function(){return!!this._onActiveWalletChangedCallback},e.prototype._onError=function(e){this._onErrorCallback&&this._onErrorCallback(e)},e}(),S=function(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(a,s)}c((i=i.apply(e,t||[])).next())}))},D=function(e,t){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},U=require("ethereumjs-util"),j=U.addHexPrefix,B=U.stripHexPrefix,q=U.BN,F="0x5208";function G(e,t){return S(this,void 0,void 0,(function(){var n,i,r,o,a;return D(this,(function(s){switch(s.label){case 0:return[4,e.getBlockByNumber("latest",!1)];case 1:return n=s.sent(),[4,V(e,t,n.gasLimit)];case 2:if(i=s.sent(),r=i.safeGas,o=i.simpleSend,a=i.gasLimitSpecified,o||a)return[2,r];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,H(e,t,n.gasLimit,r)];case 4:return[2,s.sent()];case 5:return s.sent(),[2,r];case 6:return[2]}}))}))}function V(e,t,n){return S(this,void 0,void 0,(function(){var i,r,o;return D(this,(function(a){switch(a.label){case 0:return Boolean(t.gas)?[2,{safeGas:t.gas,simpleSend:!1,gasLimitSpecified:!0}]:(i=t.to,Boolean(i)?[4,e.getCode(i)]:[3,2]);case 1:if(r=a.sent(),!r||"0x"===r||"0x0"===r){if(t.data)throw new Error("Trying to call a function on a non-contract address");return[2,{safeGas:F,simpleSend:!0,gasLimitSpecified:!1}]}a.label=2;case 2:return o=K(n),s=o,c=20,u=new q(19),d=new q(c),[2,{safeGas:Y(s.mul(u).div(d)),simpleSend:!1,gasLimitSpecified:!1}]}var s,c,u,d}))}))}function H(e,t,n,i){return S(this,void 0,void 0,(function(){var r;return D(this,(function(o){switch(o.label){case 0:return t.gas=i,r=j,[4,e.estimateGas(t)];case 1:return[2,z(r.apply(void 0,[o.sent()]),n)]}}))}))}function z(e,t){var n=K(e),i=K(t).muln(.9),r=n.muln(1.5);return n.gt(i)?Y(n):r.lt(i)?Y(r):Y(i)}function K(e){return new q(B(e),16)}function Y(e){return j(e.toString(16))}var J=function(){function e(e){this.provider=e}return e.prototype.getBlockByNumber=function(e,t){return this.sendAsync("eth_getBlockByNumber",e,t)},e.prototype.getCode=function(e,t){return void 0===t&&(t="latest"),this.sendAsync("eth_getCode",e,t)},e.prototype.estimateGas=function(e){return this.sendAsync("eth_estimateGas",e)},e.prototype.sendAsync=function(e){for(var t=this,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new Promise((function(i,r){t.provider.sendAsync({id:42,jsonrpc:"2.0",method:e,params:n},(function(e,t){e?r(e):i(t.result)}))}))},e}(),Q=function(){return Q=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Q.apply(this,arguments)},X=function(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(a,s)}c((i=i.apply(e,t||[])).next())}))},Z=function(e,t){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},$=require("web3-provider-engine"),ee=require("web3-provider-engine/dist/es5/subproviders/cache.js"),te=require("web3-provider-engine/dist/es5/subproviders/fixture.js"),ne=require("web3-provider-engine/dist/es5/subproviders/filters.js"),ie=require("web3-provider-engine/dist/es5/subproviders/hooked-wallet.js"),re=require("web3-provider-engine/dist/es5/subproviders/nonce-tracker.js"),oe=require("web3-provider-engine/dist/es5/subproviders/subscriptions.js"),ae=function(){function e(e,t){this.config=e,this._getWidgetCommunication=t,this.provider=this._initProvider()}return e.prototype.setSelectedAddress=function(e){this._selectedAddress=e},e.prototype.changeNetwork=function(e,n){var i=t(e,n);this.clearSubprovider(re),this.clearSubprovider(ee),this.config.network=i},e.prototype._initProvider=function(){var e=this;if(this.engine)return this.engine;this.engine=new $;var t=new J(this.engine);return this.engine.send=function(t,n){if("string"==typeof t)return new Promise((function(i,r){e.engine.sendAsync({jsonrpc:"2.0",id:42,method:t,params:n||[]},(function(e,t){e?r(e):i(t.result)}))}));if(!n){var i=null;switch(t.method){case"eth_accounts":case"eth_coinbase":i=e._selectedAddress?[e._selectedAddress]:[];break;case"net_version":i=e._network;break;case"eth_uninstallFilter":e.engine.sendAsync(t,(function(e){return e})),i=!0;break;default:var r="The Portis Web3 object does not support synchronous methods like "+t.method+" without a callback parameter.";throw new Error(r)}return{id:t.id,jsonrpc:t.jsonrpc,result:i}}e.engine.sendAsync(t,n)},this.engine.addProvider(new te({web3_clientVersion:"Portis/v"+this.config.version+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1,eth_syncing:!0})),this.engine.addProvider(new ee),this.engine.addProvider(new oe),this.engine.addProvider(new ne),this.engine.addProvider(new re),this.engine.addProvider({setEngine:function(e){return e},handleRequest:function(t,n){return X(e,void 0,void 0,(function(){return Z(this,(function(e){return t.id||(t.id=42),n(),[2]}))}))}}),this.engine.addProvider(new ie({getAccounts:function(t){return X(e,void 0,void 0,(function(){var e,n,i;return Z(this,(function(r){switch(r.label){case 0:return[4,this._getWidgetCommunication()];case 1:return[4,r.sent().getAccounts(this.config)];case 2:return e=r.sent(),n=e.error,i=e.result,!n&&i&&(this._selectedAddress=i[0]),t(n,i),[2]}}))}))},signTransaction:function(t,n){return X(e,void 0,void 0,(function(){var e,i,r;return Z(this,(function(o){switch(o.label){case 0:return[4,this._getWidgetCommunication()];case 1:return[4,o.sent().signTransaction(t,this.config)];case 2:return e=o.sent(),i=e.error,r=e.result,n(i,r),[2]}}))}))},signMessage:function(t,n){return X(e,void 0,void 0,(function(){var e,i,r,o,a;return Z(this,(function(s){switch(s.label){case 0:return[4,this._getWidgetCommunication()];case 1:return e=s.sent(),i=Q({},t,{messageStandard:"signMessage"}),[4,e.signMessage(i,this.config)];case 2:return r=s.sent(),o=r.error,a=r.result,n(o,a),[2]}}))}))},signPersonalMessage:function(t,n){return X(e,void 0,void 0,(function(){var e,i,r,o,a;return Z(this,(function(s){switch(s.label){case 0:return[4,this._getWidgetCommunication()];case 1:return e=s.sent(),i=Q({},t,{messageStandard:"signPersonalMessage"}),[4,e.signMessage(i,this.config)];case 2:return r=s.sent(),o=r.error,a=r.result,n(o,a),[2]}}))}))},signTypedMessage:function(t,n){return X(e,void 0,void 0,(function(){var e,i,r,o,a;return Z(this,(function(s){switch(s.label){case 0:return[4,this._getWidgetCommunication()];case 1:return e=s.sent(),i=Q({},t,{messageStandard:"signTypedMessage"}),[4,e.signMessage(i,this.config)];case 2:return r=s.sent(),o=r.error,a=r.result,n(o,a),[2]}}))}))},signTypedMessageV3:function(t,n){return X(e,void 0,void 0,(function(){var e,i,r,o,a;return Z(this,(function(s){switch(s.label){case 0:return[4,this._getWidgetCommunication()];case 1:return e=s.sent(),i=Q({},t,{messageStandard:"signTypedMessageV3"}),[4,e.signMessage(i,this.config)];case 2:return r=s.sent(),o=r.error,a=r.result,n(o,a),[2]}}))}))},estimateGas:function(n,i){return X(e,void 0,void 0,(function(){var e;return Z(this,(function(r){switch(r.label){case 0:return[4,G(t,n)];case 1:return e=r.sent(),i(null,e),[2]}}))}))},getGasPrice:function(t){return X(e,void 0,void 0,(function(){return Z(this,(function(e){return t(null,""),[2]}))}))}})),this.engine.addProvider({setEngine:function(e){return e},handleRequest:function(t,n,i){return X(e,void 0,void 0,(function(){var e,n,r;return Z(this,(function(o){switch(o.label){case 0:return[4,this._getWidgetCommunication()];case 1:return[4,o.sent().relay(t,this.config)];case 2:return e=o.sent(),n=e.error,r=e.result,"net_version"===t.method&&(this._network=r,this.engine.networkVersion=this._network),i(n,r),[2]}}))}))}}),this.engine.enable=function(){return new Promise((function(t,n){e.engine.sendAsync({method:"eth_accounts"},(function(e,i){e?n(e):t(i.result)}))}))},this.engine.isConnected=function(){return!0},this.engine.isPortis=!0,this.engine.on("error",(function(e){e&&e.message&&e.message.includes("PollingBlockTracker")?console.warn("If you see this warning constantly, there might be an error with your RPC node."):console.error(e)})),this.engine.start(),this.engine},e.prototype.clearSubprovider=function(e){var t=this.provider._providers.find((function(t){return t instanceof e}));this.provider.removeProvider(t),this.provider.addProvider(new e)},e}(),se=function(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(a,s)}c((i=i.apply(e,t||[])).next())}))},ce=function(e,t){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},ue=["email","reputation"];o().then((function(){document.getElementsByClassName(N).length&&console.warn("Portis script was already loaded. This might cause unexpected behavior. If loading with a <script> tag, please make sure that you only load it once.")})).catch((function(){}));var de=function(){function e(e,n,r){if(void 0===r&&(r={}),!i())return new Proxy(this,{get:function(e,t){return e[t]instanceof Function?function(){}:void 0}});a(),this._validateParams(e,n,r),this._config={dappId:e,network:t(n,r.gasRelay),version:"4.0.7",scope:r.scope,registerPageByDefault:r.registerPageByDefault,staging:r.staging,feature:r.feature},this._getWidgetCommunication=this._getWidgetCommunication.bind(this),this._widgetManagerInstance=new R(this.config,this._clearProviderSession),this._web3ManagerInstance=new ae(this.config,this._getWidgetCommunication),this.setDefaultEmail=this.setDefaultEmail.bind(this),this.changeNetwork=this.changeNetwork.bind(this),this.getWidget=this.getWidget.bind(this),this.onLogin=this.onLogin.bind(this),this.onLogout=this.onLogout.bind(this),this.onActiveWalletChanged=this.onActiveWalletChanged.bind(this),this.onError=this.onError.bind(this),this.showPortis=this.showPortis.bind(this),this.getCampaignInfo=this.getCampaignInfo.bind(this),this.claimVoucher=this.claimVoucher.bind(this),this.getExtendedPublicKey=this.getExtendedPublicKey.bind(this),this.importWallet=this.importWallet.bind(this),this.isLoggedIn=this.isLoggedIn.bind(this),this.signBitcoinTransaction=this.signBitcoinTransaction.bind(this),this.showBitcoinWallet=this.showBitcoinWallet.bind(this)}return Object.defineProperty(e.prototype,"_widgetManager",{get:function(){return this._widgetManagerInstance},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_web3Manager",{get:function(){return this._web3ManagerInstance},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),e.prototype._clearProviderSession=function(){this._web3Manager.setSelectedAddress("")},e.prototype._getWidgetCommunication=function(){return se(this,void 0,void 0,(function(){return ce(this,(function(e){switch(e.label){case 0:return[4,this._widgetManager.getWidget()];case 1:return[2,e.sent().communication]}}))}))},Object.defineProperty(e.prototype,"web3Provider",{get:function(){return this._web3Manager.provider},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"provider",{get:function(){return this.web3Provider},enumerable:!0,configurable:!0}),e.prototype.changeNetwork=function(e,t){this._web3Manager.changeNetwork(e,t)},e.prototype.setDefaultEmail=function(e){this._widgetManager.setDefaultEmail(e)},e.prototype.getWidget=function(){return se(this,void 0,void 0,(function(){return ce(this,(function(e){return[2,this._widgetManager.getWidget()]}))}))},e.prototype.onLogin=function(e){this._widgetManager.setOnLoginCallback(e)},e.prototype.onLogout=function(e){this._widgetManager.setOnLogoutCallback(e)},e.prototype.onActiveWalletChanged=function(e){this._widgetManager.setOnActiveWalletChangedCallback(e)},e.prototype.onError=function(e){this._widgetManager.setOnErrorCallback(e)},e.prototype.showPortis=function(){return se(this,void 0,void 0,(function(){return ce(this,(function(e){return[2,this._widgetManager.showPortis()]}))}))},e.prototype.getCampaignInfo=function(e){return se(this,void 0,void 0,(function(){return ce(this,(function(t){return[2,this._widgetManager.getCampaignInfo(e)]}))}))},e.prototype.claimVoucher=function(e){return se(this,void 0,void 0,(function(){return ce(this,(function(t){return[2,this._widgetManager.claimVoucher(e)]}))}))},e.prototype.logout=function(){return se(this,void 0,void 0,(function(){return ce(this,(function(e){return[2,this._widgetManager.logout()]}))}))},e.prototype.getExtendedPublicKey=function(e,t){return void 0===e&&(e="m/44'/60'/0'/0/0"),void 0===t&&(t="Ethereum"),se(this,void 0,void 0,(function(){return ce(this,(function(n){return[2,this._widgetManager.getExtendedPublicKey(e,t)]}))}))},e.prototype.importWallet=function(e){return se(this,void 0,void 0,(function(){return ce(this,(function(t){return[2,this._widgetManager.importWallet(e)]}))}))},e.prototype.isLoggedIn=function(){return se(this,void 0,void 0,(function(){return ce(this,(function(e){return[2,this._widgetManager.isLoggedIn()]}))}))},e.prototype.signBitcoinTransaction=function(e){return se(this,void 0,void 0,(function(){return ce(this,(function(t){return[2,this._widgetManager.signBitcoinTransaction(e)]}))}))},e.prototype.showBitcoinWallet=function(e){return void 0===e&&(e="m/49'/0'/0'/0/0"),se(this,void 0,void 0,(function(){return ce(this,(function(t){return[2,this._widgetManager.showBitcoinWallet(e)]}))}))},e.prototype._validateParams=function(e,t,n){if(!e)throw new Error("[Portis] 'dappId' is required. Get your dappId here: https://dashboard.portis.io");if(!t)throw new Error("[Portis] 'network' is required. Read more about it here: https://docs.portis.io/#/configuration?id=network");if(n.scope){if(!Array.isArray(n.scope))throw new Error("[Portis] 'scope' must be an array. Read more about it here: https://docs.portis.io/#/configuration?id=scope");if(n.scope.filter((function(e){return ue.indexOf(e)<0})).length>0)throw new Error("[Portis] invalid 'scope' parameter. Read more about it here: https://docs.portis.io/#/configuration?id=scope")}if(void 0!==n.registerPageByDefault&&"boolean"!=typeof n.registerPageByDefault)throw new Error("[Portis] invalid 'registerPageByDefault' parameter, must be a boolean. Read more about it here: https://docs.portis.io/#/configuration?id=registerPageByDefault")},e}(),le=de;exports.default=function(t,n){var i=t.chainId,r=t.portisParams;return e.__awaiter(this,void 0,void 0,(function(){var t,o;return e.__generator(this,(function(a){switch(a.label){case 0:if(!(null==r?void 0:r.id))throw new Error("uAuthParams is not valid.");switch(t="",i){case 1:default:t="mainnet";break;case 5:t="goerli"}return[4,(o=new le(r.id,t,r.config)).provider.enable()];case 1:return a.sent(),o.provider._portis=o,o.provider.on("connect",n.connect),o.provider.on("disconnect",n.disconnect),o.provider.on("accountsChanged",n.accountsChanged),o.provider.on("chainChanged",n.chainChanged),o.provider.on("message",n.message),[2,e.convertWeb3Provider(o.provider)]}}))}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./index-a26b6945.cjs");require("@ethersproject/providers"),require("@ethersproject/constants"),require("@ethersproject/contracts"),require("@ethersproject/address"),require("zustand");var t="dapp-inpage-integration",n="openblock-content-integration",i=["https://cocoswap.com","https://app.openocean.finance"],r=["https://oec.cocoswap.com"],o=function(){function o(){console.log("start initialize openblockinpage provider"),this.callBackList={},this.eventListener={},this.isMetaMask=!0,this.isOpenBlock=!0,this.chainId=null,this.networkVersion=null,this.selectedAddress=null,this.request=this.request.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this.on=this.on.bind(this),this.isConnected=this.isConnected.bind(this),this.enable=this.enable.bind(this),this._metamask=this._getExperimentalApi(),this._initInpageListener(),this.getProviderData()}return o.prototype.getProviderData=function(){var t;return e.__awaiter(this,void 0,void 0,(function(){var n;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,this.request("metamask_getProviderState")];case 1:return n=e.sent(),this.chainId=null==n?void 0:n.chainId,this.networkVersion=null==n?void 0:n.networkVersion,this.selectedAddress=null===(t=null==n?void 0:n.accounts)||void 0===t?void 0:t[0],[2]}}))}))},o.prototype.request=function(t){return e.__awaiter(this,void 0,void 0,(function(){var n;return e.__generator(this,(function(e){switch(e.label){case 0:return"eth_requestAccounts"!==t.method?[3,2]:[4,this._hookRequest("eth_accounts")];case 1:if((n=e.sent()).length)return[2,new Promise((function(e){return e(n)}))];e.label=2;case 2:return[2,this._hookRequest(t)]}}))}))},o.prototype.send=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){return"function"==typeof t[1]?(this.sendAsync(t[0],t[1]),[2]):"string"==typeof t[0]?[2,this.request({method:t[0],params:t[1]})]:1===t.length?[2,this.request(t)]:[2]}))}))},o.prototype.sendAsync=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.__awaiter(this,void 0,void 0,(function(){var n,i;return e.__generator(this,(function(e){return n={method:t[0].method,params:t[0].params},i=t[0].id,this.request(n).then((function(e){t[1](null,{id:i,jsonrpc:"2.0",result:e})})).catch((function(e){t[1](null,{id:i,jsonrpc:"2.0",error:e})})),[2]}))}))},o.prototype.isConnected=function(){return!0},o.prototype.enable=function(){return e.__awaiter(this,void 0,void 0,(function(){var t;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,this._hookRequest("eth_accounts")];case 1:return(t=e.sent()).length?[2,new Promise((function(e){return e(t)}))]:[2,this.request({method:"eth_requestAccounts"})]}}))}))},o.prototype.on=function(t,n){var i;"string"==typeof t&&"function"==typeof n&&(this.eventListener[t]&&this.eventListener[t].length>5||(this.eventListener[t]?(this.eventListener[t].push(n),this.eventListener[t]=Array.from(new Set(this.eventListener[t]))):this.eventListener[t]||(this.eventListener=e.__assign(e.__assign({},this.eventListener),((i={})[t]=[n],i))),this._registerEvent(t)))},o.prototype.removeListener=function(){},o.prototype._initInpageListener=function(){var e=this;window.addEventListener("message",(function(n){var i,r,o;if(n.data.target===t){var s=null===(o=null===(r=null===(i=n.data)||void 0===i?void 0:i.value)||void 0===r?void 0:r.data)||void 0===o?void 0:o.mark;s&&("call_method"===s.type?e._handleNormalMethod(s,n):"register_event"===s.type&&e._handleEventMethod(s,n))}}),!1)},o.prototype._handleNormalMethod=function(e,t){var n,i,r,o,s;(null===(n=t.data.value.data)||void 0===n?void 0:n.error)?null===(i=this.callBackList[e.id])||void 0===i||i.reject(null===(r=t.data.value.data)||void 0===r?void 0:r.error):null===(o=this.callBackList[e.id])||void 0===o||o.resolve(null===(s=t.data.value.data)||void 0===s?void 0:s.result),delete this.callBackList[e.id]},o.prototype._handleEventMethod=function(e,t){var n,o,s,a,d,u,c,h=this,l=null===(a=null===(s=null===(o=null===(n=t.data)||void 0===n?void 0:n.value)||void 0===o?void 0:o.data)||void 0===s?void 0:s.mark)||void 0===a?void 0:a.eventName,v=null===(c=null===(u=null===(d=t.data)||void 0===d?void 0:d.value)||void 0===u?void 0:u.data)||void 0===c?void 0:c.params;if(l){var p=this.eventListener[l];if(!p)return void("https://app.openocean.finance"===window.location.origin&&window.location.reload());p.forEach((function(e){"chainChanged"===l&&(h.chainId=v,h.networkVersion=Number(v)),r.includes(window.location.origin)&&"chainChanged"===l||(i.includes(window.location.origin)?window.location.reload():e(v))}))}},o.prototype._hookRequest=function(i){var r=this;return new Promise((function(o,s){var a=function(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return e()+e()+e()+e()+e()+e()+e()+e()}();"string"==typeof i&&(i={method:i}),i=e.__assign(e.__assign({},i),{mark:{id:a,method:i.method,type:"call_method"}}),window.parent.postMessage({from:t,target:n,data:i},"*"),r.callBackList[a]={resolve:o,reject:s}}))},o.prototype._registerEvent=function(e){var i={mark:{eventName:e,type:"register_event"},eventName:e};window.parent.postMessage({from:t,target:n,data:i},"*")},o.prototype._getExperimentalApi=function(){return new Proxy({isUnlocked:function(){return new Promise((function(e){return e(!0)}))}},{get:function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];return Reflect.get.apply(Reflect,e.__spreadArray([t,n],e.__read(i),!1))}})},o}();exports.default=function(){var t;if(null===(t=window.obethereum)||void 0===t?void 0:t.isOpenBlock)return window.obethereum;var n=new o;n=new Proxy(n,{deleteProperty:function(){return!0}});try{Object.defineProperty(window,"obethereum",{set:function(e){console.log("set ethereum",e)},get:function(){return n}})}catch(e){console.log("initializeProvider error",e),window.obethereum=n}return window.web3=e.__assign({},window.web3),window.web3.currentProvider=n,window.dispatchEvent(new Event("ethereum#initialized")),n};
|
package/dist/cjs/state.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface Connected {
|
|
|
5
5
|
isSafe: boolean;
|
|
6
6
|
wallet: Wallet;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface WalletState {
|
|
9
9
|
chainId: number;
|
|
10
10
|
account: string | undefined;
|
|
11
11
|
accounts: string[] | undefined;
|
|
@@ -13,5 +13,14 @@ declare const walletState: {
|
|
|
13
13
|
walletType: WalletType | undefined;
|
|
14
14
|
connectLoading: boolean;
|
|
15
15
|
connected: Connected | undefined;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
startConnecting: () => void;
|
|
17
|
+
connectSuccess: (provider: JsonRpcProvider, wallet: Wallet, isAutoConnect: boolean) => void;
|
|
18
|
+
connectFailed: () => void;
|
|
19
|
+
connectionBreak: () => void;
|
|
20
|
+
accountsChanged: (accounts: string[]) => void;
|
|
21
|
+
chainIdChanged: (chainId: number) => void;
|
|
22
|
+
setRpcUrlProvider: (url: string) => void;
|
|
23
|
+
disconnect: (rpcUrl?: string) => void;
|
|
24
|
+
}
|
|
25
|
+
declare const useWalletStore: import("zustand").UseBoundStore<import("zustand").StoreApi<WalletState>>;
|
|
26
|
+
export default useWalletStore;
|