优化第三方钱包启动逻辑

This commit is contained in:
cebgcontract 2022-09-16 11:43:46 +08:00
parent 598a99b12b
commit 61b3b23034
3 changed files with 42 additions and 5 deletions

View File

@ -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

View File

@ -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',

View File

@ -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);
}
});
}