Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Improve walletconnect error message
Alexis Sellier committed 4 years ago
commit d346f164b303a06ca2c34ed3b515dba85290ee79
parent 061a4f75fb3aa110748276f16d8f2862156756da
4 files changed +16 -3
modified src/Connect.svelte
@@ -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}

modified src/Error.svelte
@@ -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>

modified src/session.ts
@@ -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 });
modified src/utils.ts
@@ -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);