diff --git a/patches/@walletconnect+core+1.8.0.patch b/patches/@walletconnect+core+1.8.0.patch index eded2f6..3820b42 100644 --- a/patches/@walletconnect+core+1.8.0.patch +++ b/patches/@walletconnect+core+1.8.0.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/@walletconnect/core/dist/esm/index.js b/node_modules/@walletconnect/core/dist/esm/index.js -index a66eece..16c8f7f 100644 +index a66eece..4668f0f 100644 --- a/node_modules/@walletconnect/core/dist/esm/index.js +++ b/node_modules/@walletconnect/core/dist/esm/index.js @@ -22,11 +22,16 @@ class Connector { @@ -41,6 +41,30 @@ index a66eece..16c8f7f 100644 } approveSession(sessionStatus) { if (this._connected) { +@@ -372,6 +382,7 @@ class Connector { + this._removeStorageSession(); + } + updateSession(sessionStatus) { ++ console.log('updateSession') + if (!this._connected) { + throw new Error(ERROR_SESSION_DISCONNECTED); + } +@@ -810,6 +821,15 @@ class Connector { + event: "transport_error", + params: ["Websocket connection failed"], + })); ++ let self = this; ++ let sendOpenMsg = () => { ++ self._eventManager.trigger({ ++ event: "socket_open", ++ params: [], ++ }); ++ self._transport.remove("open", sendOpenMsg) ++ } ++ this._transport.on("open", sendOpenMsg); + this._transport.open(); + } + _formatUri() { diff --git a/node_modules/@walletconnect/core/dist/esm/url.js b/node_modules/@walletconnect/core/dist/esm/url.js index d6da2b8..19202d5 100644 --- a/node_modules/@walletconnect/core/dist/esm/url.js diff --git a/src/comp/ZWalletConnect.ts b/src/comp/ZWalletConnect.ts index 0b3bc08..dc2eb30 100644 --- a/src/comp/ZWalletConnect.ts +++ b/src/comp/ZWalletConnect.ts @@ -6,6 +6,7 @@ import { toHexChainId } from '../util/chain.util' export class ZWalletConnect { provider: WalletConnectProvider accounts: string[] = [] + socketConnected = false constructor(rpc: any) { console.log('ZWalletConnect constructor'); @@ -13,9 +14,13 @@ export class ZWalletConnect { rpc, qrcodeModal: { open(uri: string, cb: any, opts?: any): void { - console.log('walletconnect open qrcode modal') + console.log('walletconnect prepare jump to wallet: ' + uri) + setTimeout(()=>{ + // @ts-ignore + jumpToWallet(uri) + }, 1500) //@ts-ignore - jumpToWallet(uri); + // jumpToWallet(uri); }, close(): void { @@ -91,7 +96,7 @@ export class ZWalletConnect { if (!from) { throw new Error('no account'); } - console.log('clicked, sending personal sign req', 'from', from, msgParams) + console.log('sending personal sign req from', from, msgParams) const params = [from, msgParams] const result: any = await this.sendCmd({ method: 'eth_signTypedData_v4', diff --git a/src/lib/WalletConnectProvider.ts b/src/lib/WalletConnectProvider.ts index 8cd99a6..95dedc7 100644 --- a/src/lib/WalletConnectProvider.ts +++ b/src/lib/WalletConnectProvider.ts @@ -267,8 +267,16 @@ class WalletConnectProvider extends ProviderEngine { if (!this.connected) { this.connected = true; this.updateState(wc.session); + wc.on('socket_open', (error, payload) => { + if (error) { + return reject(error); + } + console.log('socket open'); + resolve(wc); + }) + } else { + resolve(wc); } - resolve(wc); } }); }