Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Rework 'Error'
Alexis Sellier committed 5 years ago
commit 6dc56c6afff4bf74d45e6df87629a5536fd7af41
parent 6587ddc0719f014fc0d202708ce7adf5a6a0e007
3 files changed +8 -8
modified src/Header.svelte
@@ -5,8 +5,8 @@
  import { ethers } from "ethers";
  import { link } from "svelte-routing";
  import { formatBalance } from "@app/utils";
-
  import { session, disconnectWallet, shortAddress } from "./session";
-
  import { error, ERROR } from './error';
+
  import { error, Failure } from '@app/error';
+
  import { session, disconnectWallet, shortAddress } from "@app/session";
  import Logo from './Logo.svelte';
  import Connect from './Connect.svelte';

@@ -62,7 +62,7 @@
</style>

{#if $error}
-
  {#if $error.type === ERROR.TRANSACTION_FAILED}
+
  {#if $error.type === Failure.TransactionFailed}
    <div class="error">
      <strong>Error:</strong> Transaction <a href="https://etherscan.io/tx/{$error.hash}">{$error.hash}</a> failed.
    </div>
modified src/base/register/registrar.ts
@@ -3,7 +3,7 @@
import { ethers } from "ethers";
import { State, state } from './state';
import { approveSpender, updateBalance } from '@app/session';
-
import { ERROR } from '@app/error';
+
import { Failure } from '@app/error';

const registrarAbi = [
  {"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"commitment","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"CommitmentMade","type":"event"},
@@ -98,7 +98,7 @@ async function register(name, owner, salt, config) {
    window.localStorage.clear();
    state.set(State.Registered);
  } catch (e) {
-
    throw { type: ERROR.TRANSACTION_FAILED, hash: tx.hash };
+
    throw { type: Failure.TransactionFailed, hash: tx.hash };
  }
}

modified src/error.ts
@@ -1,7 +1,7 @@
import { writable } from "svelte/store";

-
export const ERROR = {
-
  TRANSACTION_FAILED: 1,
-
};
+
export enum Failure {
+
  TransactionFailed = 1,
+
}

export const error = writable(null);