mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 11:20:36 +08:00
Improve walletconnect error message
This commit is contained in:
+1
-2
@@ -51,7 +51,6 @@
|
||||
{#if $walletConnectState.state === "open"}
|
||||
<ConnectWallet {config} uri={$walletConnectState.uri} on:close={onModalClose} />
|
||||
{:else if error}
|
||||
<Error floating title="Wallet connection failed" {error}
|
||||
on:close={() => error = null} />
|
||||
<Error floating emoji="👛" title="Connection failed" {error} on:close={() => error = null} />
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
export let error: Err | null = null;
|
||||
export let title = "Error";
|
||||
export let emoji = "";
|
||||
export let subtitle = "";
|
||||
export let message = "";
|
||||
export let floating = false;
|
||||
@@ -18,6 +19,9 @@
|
||||
|
||||
<Modal on:close error {floating} {subtle}>
|
||||
<span slot="title">
|
||||
{#if emoji}
|
||||
<div>{emoji}</div>
|
||||
{/if}
|
||||
{title}
|
||||
</span>
|
||||
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ import type { BigNumber } from 'ethers';
|
||||
import type { TransactionReceipt, TransactionResponse } from '@ethersproject/providers';
|
||||
import { Config, getConfig } from "@app/config";
|
||||
import { Unreachable, assert, assertEq } from "@app/error";
|
||||
import { formatNetwork } from "@app/utils";
|
||||
import * as ethers from "ethers";
|
||||
|
||||
export enum Connection {
|
||||
@@ -99,7 +100,7 @@ export const loadState = (initial: State): Store => {
|
||||
if (network.chainId !== config.network.chainId) {
|
||||
config.walletConnect.client.killSession();
|
||||
throw new Error(
|
||||
`Network mismatch. Please switch to ${config.network.name}.`
|
||||
`Network mismatch. Please switch your wallet to ${formatNetwork(config.network)}.`
|
||||
);
|
||||
}
|
||||
store.set({ connection: Connection.Connected, session });
|
||||
|
||||
@@ -71,6 +71,15 @@ export function formatSeedApi(input: string): string {
|
||||
return input;
|
||||
}
|
||||
|
||||
export function formatNetwork(input: { name: string }): string {
|
||||
let name = input.name;
|
||||
|
||||
if (name === "homestead") {
|
||||
name = "mainnet";
|
||||
}
|
||||
return capitalize(name);
|
||||
}
|
||||
|
||||
export function capitalize(s: string): string {
|
||||
if (s === "") return s;
|
||||
return s[0].toUpperCase() + s.substr(1);
|
||||
|
||||
Reference in New Issue
Block a user