@dodoex/wallet-web3 0.0.11-7 → 0.0.11-8

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.
@@ -1 +1 @@
1
- import{_ as r,a as e}from"./index-33777282.js";import t from"@portis/web3";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";function o({chainId:o,portisParams:i},n){return r(this,void 0,void 0,(function*(){if(!(null==i?void 0:i.id))throw new Error("uAuthParams is not valid.");let r="";switch(o){case 1:default:r="mainnet";break;case 5:r="goerli"}const s=new t(i.id,r,i.config);return yield s.provider.enable(),s.provider._portis=s,s.provider.on("connect",n.connect),s.provider.on("disconnect",n.disconnect),s.provider.on("accountsChanged",n.accountsChanged),s.provider.on("chainChanged",n.chainChanged),s.provider.on("message",n.message),e(s.provider)}))}export{o as default};
1
+ import{_ as r,a as e}from"./index-119f4df7.js";import t from"@portis/web3";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";function o({chainId:o,portisParams:i},n){return r(this,void 0,void 0,(function*(){if(!(null==i?void 0:i.id))throw new Error("uAuthParams is not valid.");let r="";switch(o){case 1:default:r="mainnet";break;case 5:r="goerli"}const s=new t(i.id,r,i.config);return yield s.provider.enable(),s.provider._portis=s,s.provider.on("connect",n.connect),s.provider.on("disconnect",n.disconnect),s.provider.on("accountsChanged",n.accountsChanged),s.provider.on("chainChanged",n.chainChanged),s.provider.on("message",n.message),e(s.provider)}))}export{o as default};
@@ -1 +1 @@
1
- import{_ as e}from"./index-33777282.js";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";const t="dapp-inpage-integration",i="openblock-content-integration",n=["https://cocoswap.com","https://app.openocean.finance"],o=["https://oec.cocoswap.com"];class s{constructor(){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()}getProviderData(){var t;return e(this,void 0,void 0,(function*(){const e=yield this.request("metamask_getProviderState");this.chainId=null==e?void 0:e.chainId,this.networkVersion=null==e?void 0:e.networkVersion,this.selectedAddress=null===(t=null==e?void 0:e.accounts)||void 0===t?void 0:t[0]}))}request(t){return e(this,void 0,void 0,(function*(){if("eth_requestAccounts"===t.method){const e=yield this._hookRequest("eth_accounts");if(e.length)return new Promise((t=>t(e)))}return this._hookRequest(t)}))}send(...t){return e(this,void 0,void 0,(function*(){if("function"!=typeof t[1])return"string"==typeof t[0]?this.request({method:t[0],params:t[1]}):1===t.length?this.request(t):void 0;this.sendAsync(t[0],t[1])}))}sendAsync(...t){return e(this,void 0,void 0,(function*(){const e={method:t[0].method,params:t[0].params},i=t[0].id;this.request(e).then((e=>{t[1](null,{id:i,jsonrpc:"2.0",result:e})})).catch((e=>{t[1](null,{id:i,jsonrpc:"2.0",error:e})}))}))}isConnected(){return!0}enable(){return e(this,void 0,void 0,(function*(){const e=yield this._hookRequest("eth_accounts");return e.length?new Promise((t=>t(e))):this.request({method:"eth_requestAccounts"})}))}on(e,t){"string"==typeof e&&"function"==typeof t&&(this.eventListener[e]&&this.eventListener[e].length>5||(this.eventListener[e]?(this.eventListener[e].push(t),this.eventListener[e]=Array.from(new Set(this.eventListener[e]))):this.eventListener[e]||(this.eventListener=Object.assign(Object.assign({},this.eventListener),{[e]:[t]})),this._registerEvent(e)))}removeListener(){}_initInpageListener(){window.addEventListener("message",(e=>{var i,n,o;if(e.data.target!==t)return;const s=null===(o=null===(n=null===(i=e.data)||void 0===i?void 0:i.value)||void 0===n?void 0:n.data)||void 0===o?void 0:o.mark;s&&("call_method"===s.type?this._handleNormalMethod(s,e):"register_event"===s.type&&this._handleEventMethod(s,e))}),!1)}_handleNormalMethod(e,t){var i,n,o,s,r;(null===(i=t.data.value.data)||void 0===i?void 0:i.error)?null===(n=this.callBackList[e.id])||void 0===n||n.reject(null===(o=t.data.value.data)||void 0===o?void 0:o.error):null===(s=this.callBackList[e.id])||void 0===s||s.resolve(null===(r=t.data.value.data)||void 0===r?void 0:r.result),delete this.callBackList[e.id]}_handleEventMethod(e,t){var i,s,r,d,a,h,l;const c=null===(d=null===(r=null===(s=null===(i=t.data)||void 0===i?void 0:i.value)||void 0===s?void 0:s.data)||void 0===r?void 0:r.mark)||void 0===d?void 0:d.eventName,u=null===(l=null===(h=null===(a=t.data)||void 0===a?void 0:a.value)||void 0===h?void 0:h.data)||void 0===l?void 0:l.params;if(c){const e=this.eventListener[c];if(!e)return void("https://app.openocean.finance"===window.location.origin&&window.location.reload());e.forEach((e=>{"chainChanged"===c&&(this.chainId=u,this.networkVersion=Number(u)),o.includes(window.location.origin)&&"chainChanged"===c||(n.includes(window.location.origin)?window.location.reload():e(u))}))}}_hookRequest(e){return new Promise(((n,o)=>{const s=(()=>{function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return e()+e()+e()+e()+e()+e()+e()+e()})();"string"==typeof e&&(e={method:e}),e=Object.assign(Object.assign({},e),{mark:{id:s,method:e.method,type:"call_method"}}),window.parent.postMessage({from:t,target:i,data:e},"*"),this.callBackList[s]={resolve:n,reject:o}}))}_registerEvent(e){const n={mark:{eventName:e,type:"register_event"},eventName:e};window.parent.postMessage({from:t,target:i,data:n},"*")}_getExperimentalApi(){return new Proxy({isUnlocked:()=>new Promise((e=>e(!0)))},{get:(e,t,...i)=>Reflect.get(e,t,...i)})}}function r(){var e;if(null===(e=window.obethereum)||void 0===e?void 0:e.isOpenBlock)return window.obethereum;let t=new s;t=new Proxy(t,{deleteProperty:()=>!0});try{Object.defineProperty(window,"obethereum",{set(e){console.log("set ethereum",e)},get:()=>t})}catch(e){console.log("initializeProvider error",e),window.obethereum=t}return window.web3=Object.assign({},window.web3),window.web3.currentProvider=t,window.dispatchEvent(new Event("ethereum#initialized")),t}export{r as default};
1
+ import{_ as e}from"./index-119f4df7.js";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";const t="dapp-inpage-integration",i="openblock-content-integration",n=["https://cocoswap.com","https://app.openocean.finance"],o=["https://oec.cocoswap.com"];class s{constructor(){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()}getProviderData(){var t;return e(this,void 0,void 0,(function*(){const e=yield this.request("metamask_getProviderState");this.chainId=null==e?void 0:e.chainId,this.networkVersion=null==e?void 0:e.networkVersion,this.selectedAddress=null===(t=null==e?void 0:e.accounts)||void 0===t?void 0:t[0]}))}request(t){return e(this,void 0,void 0,(function*(){if("eth_requestAccounts"===t.method){const e=yield this._hookRequest("eth_accounts");if(e.length)return new Promise((t=>t(e)))}return this._hookRequest(t)}))}send(...t){return e(this,void 0,void 0,(function*(){if("function"!=typeof t[1])return"string"==typeof t[0]?this.request({method:t[0],params:t[1]}):1===t.length?this.request(t):void 0;this.sendAsync(t[0],t[1])}))}sendAsync(...t){return e(this,void 0,void 0,(function*(){const e={method:t[0].method,params:t[0].params},i=t[0].id;this.request(e).then((e=>{t[1](null,{id:i,jsonrpc:"2.0",result:e})})).catch((e=>{t[1](null,{id:i,jsonrpc:"2.0",error:e})}))}))}isConnected(){return!0}enable(){return e(this,void 0,void 0,(function*(){const e=yield this._hookRequest("eth_accounts");return e.length?new Promise((t=>t(e))):this.request({method:"eth_requestAccounts"})}))}on(e,t){"string"==typeof e&&"function"==typeof t&&(this.eventListener[e]&&this.eventListener[e].length>5||(this.eventListener[e]?(this.eventListener[e].push(t),this.eventListener[e]=Array.from(new Set(this.eventListener[e]))):this.eventListener[e]||(this.eventListener=Object.assign(Object.assign({},this.eventListener),{[e]:[t]})),this._registerEvent(e)))}removeListener(){}_initInpageListener(){window.addEventListener("message",(e=>{var i,n,o;if(e.data.target!==t)return;const s=null===(o=null===(n=null===(i=e.data)||void 0===i?void 0:i.value)||void 0===n?void 0:n.data)||void 0===o?void 0:o.mark;s&&("call_method"===s.type?this._handleNormalMethod(s,e):"register_event"===s.type&&this._handleEventMethod(s,e))}),!1)}_handleNormalMethod(e,t){var i,n,o,s,r;(null===(i=t.data.value.data)||void 0===i?void 0:i.error)?null===(n=this.callBackList[e.id])||void 0===n||n.reject(null===(o=t.data.value.data)||void 0===o?void 0:o.error):null===(s=this.callBackList[e.id])||void 0===s||s.resolve(null===(r=t.data.value.data)||void 0===r?void 0:r.result),delete this.callBackList[e.id]}_handleEventMethod(e,t){var i,s,r,d,a,h,l;const c=null===(d=null===(r=null===(s=null===(i=t.data)||void 0===i?void 0:i.value)||void 0===s?void 0:s.data)||void 0===r?void 0:r.mark)||void 0===d?void 0:d.eventName,u=null===(l=null===(h=null===(a=t.data)||void 0===a?void 0:a.value)||void 0===h?void 0:h.data)||void 0===l?void 0:l.params;if(c){const e=this.eventListener[c];if(!e)return void("https://app.openocean.finance"===window.location.origin&&window.location.reload());e.forEach((e=>{"chainChanged"===c&&(this.chainId=u,this.networkVersion=Number(u)),o.includes(window.location.origin)&&"chainChanged"===c||(n.includes(window.location.origin)?window.location.reload():e(u))}))}}_hookRequest(e){return new Promise(((n,o)=>{const s=(()=>{function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return e()+e()+e()+e()+e()+e()+e()+e()})();"string"==typeof e&&(e={method:e}),e=Object.assign(Object.assign({},e),{mark:{id:s,method:e.method,type:"call_method"}}),window.parent.postMessage({from:t,target:i,data:e},"*"),this.callBackList[s]={resolve:n,reject:o}}))}_registerEvent(e){const n={mark:{eventName:e,type:"register_event"},eventName:e};window.parent.postMessage({from:t,target:i,data:n},"*")}_getExperimentalApi(){return new Proxy({isUnlocked:()=>new Promise((e=>e(!0)))},{get:(e,t,...i)=>Reflect.get(e,t,...i)})}}function r(){var e;if(null===(e=window.obethereum)||void 0===e?void 0:e.isOpenBlock)return window.obethereum;let t=new s;t=new Proxy(t,{deleteProperty:()=>!0});try{Object.defineProperty(window,"obethereum",{set(e){console.log("set ethereum",e)},get:()=>t})}catch(e){console.log("initializeProvider error",e),window.obethereum=t}return window.web3=Object.assign({},window.web3),window.web3.currentProvider=t,window.dispatchEvent(new Event("ethereum#initialized")),t}export{r as default};
@@ -1 +1 @@
1
- import{_ as t,i as e}from"./index-33777282.js";import r from"@uauth/js";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";let o,i=!1;function n(n,s){return t(this,void 0,void 0,(function*(){if(i)return;const{uAuthParams:t}=n;if(!(null==t?void 0:t.clientID))throw new Error("uAuthParams is not valid.");i=!0;try{const n=Object.assign(Object.assign({},t),{redirectUri:t.redirectUri||window.location.origin});let l,c;o=new r(n);try{l=yield o.user()}catch(t){if(!o.fallbackLoginOptions.scope.includes("wallet"))throw new Error('Must request the "wallet" scope for connector to work.');if(n.shouldLoginWithRedirect)throw yield o.login(),yield new Promise((()=>{})),new Error("Should never get here.");yield o.loginWithPopup(),l=yield o.user()}if(null==l.wallet_type_hint)throw new Error("no wallet type present");if(["web3","injected"].includes(l.wallet_type_hint))c=e(void 0,s);else{if("walletconnect"!==l.wallet_type_hint||!n.walletConnect)throw new Error("Connector not supported");c=n.walletConnect()}return i=!1,c}catch(t){i=!1}}))}function s(){return null==o?void 0:o.logout()}export{n as default,s as disconnectWallet};
1
+ import{_ as t,i as e}from"./index-119f4df7.js";import r from"@uauth/js";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";let o,i=!1;function n(n,s){return t(this,void 0,void 0,(function*(){if(i)return;const{uAuthParams:t}=n;if(!(null==t?void 0:t.clientID))throw new Error("uAuthParams is not valid.");i=!0;try{const n=Object.assign(Object.assign({},t),{redirectUri:t.redirectUri||window.location.origin});let l,c;o=new r(n);try{l=yield o.user()}catch(t){if(!o.fallbackLoginOptions.scope.includes("wallet"))throw new Error('Must request the "wallet" scope for connector to work.');if(n.shouldLoginWithRedirect)throw yield o.login(),yield new Promise((()=>{})),new Error("Should never get here.");yield o.loginWithPopup(),l=yield o.user()}if(null==l.wallet_type_hint)throw new Error("no wallet type present");if(["web3","injected"].includes(l.wallet_type_hint))c=e(void 0,s);else{if("walletconnect"!==l.wallet_type_hint||!n.walletConnect)throw new Error("Connector not supported");c=n.walletConnect()}return i=!1,c}catch(t){i=!1}}))}function s(){return null==o?void 0:o.logout()}export{n as default,s as disconnectWallet};
@@ -1 +1 @@
1
- import{_ as e,a as t}from"./index-33777282.js";import{EthereumProvider as o}from"@walletconnect/ethereum-provider";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";function r({chainId:r,rpcUrl:n,rpc:c,walletConnectParams:a,darkMode:s},i){return e(this,void 0,void 0,(function*(){let e,d,p="wss://relay.walletconnect.com",l=!0;a&&(p=a.bridge||p,l=void 0!==a.qrcode?a.qrcode:l,a.infuraId,d=a.qrModalOptions||void 0),c?e=c:r&&n&&(e={[r]:n});const h=yield o.init({projectId:"59e050d1f27ed617e65bb9637c9498d6",chains:r?[r]:[],showQrModal:!0,rpcMap:e,qrModalOptions:Object.assign({themeMode:s?"dark":"light"},d)});return h.on("display_uri",(e=>{(null==d?void 0:d.openCallback)&&d.openCallback(e)})),yield h.enable(),h.on("connect",i.connect),h.on("disconnect",(e=>{i.disconnect(e),i.accountsChanged([])})),h.on("accountsChanged",i.accountsChanged),h.on("chainChanged",i.chainChanged),h.on("message",(({type:e,data:t})=>i.message(e,t))),t(h)}))}export{r as default};
1
+ import{_ as e,a as t}from"./index-119f4df7.js";import{EthereumProvider as o}from"@walletconnect/ethereum-provider";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";function r({chainId:r,rpcUrl:n,rpc:c,walletConnectParams:a,darkMode:s},i){return e(this,void 0,void 0,(function*(){let e,d,p="wss://relay.walletconnect.com",l=!0;a&&(p=a.bridge||p,l=void 0!==a.qrcode?a.qrcode:l,a.infuraId,d=a.qrModalOptions||void 0),c?e=c:r&&n&&(e={[r]:n});const h=yield o.init({projectId:"59e050d1f27ed617e65bb9637c9498d6",chains:r?[r]:[],showQrModal:!0,rpcMap:e,qrModalOptions:Object.assign({themeMode:s?"dark":"light"},d)});return h.on("display_uri",(e=>{(null==d?void 0:d.openCallback)&&d.openCallback(e)})),yield h.enable(),h.on("connect",i.connect),h.on("disconnect",(e=>{i.disconnect(e),i.accountsChanged([])})),h.on("accountsChanged",i.accountsChanged),h.on("chainChanged",i.chainChanged),h.on("message",(({type:e,data:t})=>i.message(e,t))),t(h)}))}export{r as default};
@@ -1 +1 @@
1
- import{_ as e,i as r,a as t}from"./index-33777282.js";import o from"@coinbase/wallet-sdk";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";function n({chainId:n,rpcUrl:i,appName:s,appLogoUrl:a,darkMode:p},c){return e(this,void 0,void 0,(function*(){if(window.ethereum&&(window.ethereum.isWalletLink||window.ethereum.isToshi))return r(window.ethereum,c);if(!s)throw new Error("walletLink need appName");const e=new o({appName:s,appLogoUrl:a,darkMode:p}).makeWeb3Provider(i,n);return yield e.enable(),e.on("connect",c.connect),e.on("disconnect",c.disconnect),e.on("accountsChanged",c.accountsChanged),e.on("chainChanged",c.chainChanged),e.on("message",c.message),t(e)}))}export{n as default};
1
+ import{_ as e,i as r,a as t}from"./index-119f4df7.js";import o from"@coinbase/wallet-sdk";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/keccak256";function n({chainId:n,rpcUrl:i,appName:s,appLogoUrl:a,darkMode:p},c){return e(this,void 0,void 0,(function*(){if(window.ethereum&&(window.ethereum.isWalletLink||window.ethereum.isToshi))return r(window.ethereum,c);if(!s)throw new Error("walletLink need appName");const e=new o({appName:s,appLogoUrl:a,darkMode:p}).makeWeb3Provider(i,n);return yield e.enable(),e.on("connect",c.connect),e.on("disconnect",c.disconnect),e.on("accountsChanged",c.accountsChanged),e.on("chainChanged",c.chainChanged),e.on("message",c.message),t(e)}))}export{n as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dodoex/wallet-web3",
3
- "version": "0.0.11-7",
3
+ "version": "0.0.11-8",
4
4
  "description": "",
5
5
  "source": "src/index.ts",
6
6
  "types": "dist/index.d.ts",