@dodoex/wallet-web3 0.0.10-0 → 0.0.10-2

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 e,a as r}from"./index-a49ead3c.js";import o from"@portis/web3";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";function t({chainId:t,portisParams:i},n){return e(this,void 0,void 0,(function*(){if(!(null==i?void 0:i.id))throw new Error("uAuthParams is not valid.");let e="";switch(t){case 1:default:e="mainnet";break;case 5:e="goerli"}const s=new o(i.id,e,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),r(s.provider)}))}export{t as default};
1
+ import{_ as e,a as r}from"./index-cb880e02.js";import o from"@portis/web3";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";function t({chainId:t,portisParams:i},n){return e(this,void 0,void 0,(function*(){if(!(null==i?void 0:i.id))throw new Error("uAuthParams is not valid.");let e="";switch(t){case 1:default:e="mainnet";break;case 5:e="goerli"}const s=new o(i.id,e,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),r(s.provider)}))}export{t as default};
@@ -1 +1 @@
1
- import{_ as e}from"./index-a49ead3c.js";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";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-cb880e02.js";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";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-a49ead3c.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";let o,i=!1;function n(n,l){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 s,c;o=new r(n);try{s=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(),s=yield o.user()}if(null==s.wallet_type_hint)throw new Error("no wallet type present");if(["web3","injected"].includes(s.wallet_type_hint))c=e(void 0,l);else{if("walletconnect"!==s.wallet_type_hint||!n.walletConnect)throw new Error("Connector not supported");c=n.walletConnect()}return i=!1,c}catch(t){i=!1}}))}function l(){return null==o?void 0:o.logout()}export{n as default,l as disconnectWallet};
1
+ import{_ as t,i as e}from"./index-cb880e02.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";let o,i=!1;function n(n,l){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 s,c;o=new r(n);try{s=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(),s=yield o.user()}if(null==s.wallet_type_hint)throw new Error("no wallet type present");if(["web3","injected"].includes(s.wallet_type_hint))c=e(void 0,l);else{if("walletconnect"!==s.wallet_type_hint||!n.walletConnect)throw new Error("Connector not supported");c=n.walletConnect()}return i=!1,c}catch(t){i=!1}}))}function l(){return null==o?void 0:o.logout()}export{n as default,l as disconnectWallet};
@@ -1 +1 @@
1
- import{_ as e,a as o}from"./index-a49ead3c.js";import{EthereumProvider as t}from"@walletconnect/ethereum-provider";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";function n({chainId:n,rpcUrl:r,rpc:a,walletConnectParams:c,darkMode:s},d){return e(this,void 0,void 0,(function*(){let e,i,p="wss://relay.walletconnect.com",l=!0;c&&(p=c.bridge||p,l=void 0!==c.qrcode?c.qrcode:l,c.infuraId,i=c.qrModalOptions||void 0),a?e=a:n&&r&&(e={[n]:r});const h=yield t.init({projectId:"59e050d1f27ed617e65bb9637c9498d6",chains:n?[n]:[],showQrModal:!0,rpcMap:e,qrModalOptions:Object.assign({themeMode:s?"dark":"light"},i)});return h.on("display_uri",(e=>{(null==i?void 0:i.openCallback)&&i.openCallback(e)})),yield h.enable(),h.on("connect",d.connect),h.on("disconnect",(e=>{d.disconnect(e),d.accountsChanged([])})),h.on("accountsChanged",d.accountsChanged),h.on("chainChanged",d.chainChanged),h.on("message",(({type:e,data:o})=>d.message(e,o))),o(h)}))}export{n as default};
1
+ import{_ as e,a as o}from"./index-cb880e02.js";import{EthereumProvider as t}from"@walletconnect/ethereum-provider";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";function n({chainId:n,rpcUrl:r,rpc:c,walletConnectParams:a,darkMode:s},d){return e(this,void 0,void 0,(function*(){let e,i,p="wss://relay.walletconnect.com",l=!0;a&&(p=a.bridge||p,l=void 0!==a.qrcode?a.qrcode:l,a.infuraId,i=a.qrModalOptions||void 0),c?e=c:n&&r&&(e={[n]:r});const h=yield t.init({projectId:"59e050d1f27ed617e65bb9637c9498d6",chains:n?[n]:[],showQrModal:!0,rpcMap:e,qrModalOptions:Object.assign({themeMode:s?"dark":"light"},i)});return h.on("display_uri",(e=>{(null==i?void 0:i.openCallback)&&i.openCallback(e)})),yield h.enable(),h.on("connect",d.connect),h.on("disconnect",(e=>{d.disconnect(e),d.accountsChanged([])})),h.on("accountsChanged",d.accountsChanged),h.on("chainChanged",d.chainChanged),h.on("message",(({type:e,data:o})=>d.message(e,o))),o(h)}))}export{n as default};
@@ -1 +1 @@
1
- import{_ as e,i as o,a as r}from"./index-a49ead3c.js";import t from"@coinbase/wallet-sdk";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";function n({chainId:n,rpcUrl:a,appName:i,appLogoUrl:s,darkMode:c},d){return e(this,void 0,void 0,(function*(){if(window.ethereum&&(window.ethereum.isWalletLink||window.ethereum.isToshi))return o(window.ethereum,d);if(!i)throw new Error("walletLink need appName");const e=new t({appName:i,appLogoUrl:s,darkMode:c}).makeWeb3Provider(a,n);return yield e.enable(),e.on("connect",d.connect),e.on("disconnect",d.disconnect),e.on("accountsChanged",d.accountsChanged),e.on("chainChanged",d.chainChanged),e.on("message",d.message),r(e)}))}export{n as default};
1
+ import{_ as e,i as o,a as r}from"./index-cb880e02.js";import t from"@coinbase/wallet-sdk";import"@ethersproject/providers";import"zustand";import"@ethersproject/strings";import"@ethersproject/bytes";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/address";function n({chainId:n,rpcUrl:a,appName:i,appLogoUrl:s,darkMode:c},p){return e(this,void 0,void 0,(function*(){if(window.ethereum&&(window.ethereum.isWalletLink||window.ethereum.isToshi))return o(window.ethereum,p);if(!i)throw new Error("walletLink need appName");const e=new t({appName:i,appLogoUrl:s,darkMode:c}).makeWeb3Provider(a,n);return yield e.enable(),e.on("connect",p.connect),e.on("disconnect",p.disconnect),e.on("accountsChanged",p.accountsChanged),e.on("chainChanged",p.chainChanged),e.on("message",p.message),r(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.10-0",
3
+ "version": "0.0.10-2",
4
4
  "description": "",
5
5
  "source": "src/index.ts",
6
6
  "types": "dist/index.d.ts",
@@ -62,7 +62,7 @@
62
62
  "@rollup/plugin-node-resolve": "^14.1.0",
63
63
  "@svgr/rollup": "^6.2.1",
64
64
  "eslint-plugin-valtio": "^0.6.2",
65
- "np": "^7.6.1",
65
+ "np": "^8.0.4",
66
66
  "rollup": "^2.75.5",
67
67
  "rollup-plugin-terser": "^7.0.2",
68
68
  "rollup-plugin-typescript2": "^0.32.0",
@@ -70,4 +70,4 @@
70
70
  "tslib": "^2.4.0",
71
71
  "typescript": "^4.7.3"
72
72
  }
73
- }
73
+ }