mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 22:30:41 +08:00
Fix walletconnect rejection from mobile
This commit is contained in:
+8
-2
@@ -1,4 +1,4 @@
|
||||
import { writable } from "svelte/store";
|
||||
import { get, writable } from "svelte/store";
|
||||
import type { Writable } from "svelte/store";
|
||||
import { ethers } from "ethers";
|
||||
import type { TypedDataSigner } from '@ethersproject/abstract-signer';
|
||||
@@ -150,7 +150,7 @@ export class Config {
|
||||
state.set({ state: "open", uri, onClose });
|
||||
},
|
||||
close: () => {
|
||||
state.set({ state: "close" });
|
||||
// We handle the "close" event through the "disconnect" handler.
|
||||
}
|
||||
},
|
||||
clientMeta: {
|
||||
@@ -165,6 +165,12 @@ export class Config {
|
||||
walletConnect.on("modal_closed", () => {
|
||||
state.set({ state: "close" });
|
||||
});
|
||||
walletConnect.on("disconnect", () => {
|
||||
const wcs = get(state);
|
||||
if (wcs.state === "open") {
|
||||
wcs.onClose();
|
||||
}
|
||||
});
|
||||
|
||||
const walletConnectSigner = new WalletConnectSigner(walletConnect, provider);
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ export const loadState = (initial: State): Store => {
|
||||
|
||||
try {
|
||||
await config.walletConnect.client.connect();
|
||||
console.log("WalletConnect: connected.");
|
||||
|
||||
const address = await signer.getAddress();
|
||||
const tokenBalance: BigNumber = await config.token.balanceOf(address);
|
||||
@@ -103,6 +104,7 @@ export const loadState = (initial: State): Store => {
|
||||
}
|
||||
store.set({ connection: Connection.Connected, session });
|
||||
} catch (e) {
|
||||
console.log("WalletConnect: connection failed.");
|
||||
store.set({ connection: Connection.Disconnected });
|
||||
|
||||
// There seems to be no way to detect this "error" caused by the user
|
||||
|
||||
Reference in New Issue
Block a user