From 8f9efa51be07ababb5649b1bbb166f0bba09d74f Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 3 Jun 2021 16:03:35 +0200 Subject: [PATCH] Link to safes --- src/Address.svelte | 7 ++++--- src/config.json | 9 ++++++--- src/config.ts | 2 +- src/utils.ts | 8 ++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Address.svelte b/src/Address.svelte index f1a4c2410..a9847b30e 100644 --- a/src/Address.svelte +++ b/src/Address.svelte @@ -2,7 +2,7 @@ import { onMount } from 'svelte'; import { link } from 'svelte-routing'; import { ethers } from 'ethers'; - import { explorerLink } from '@app/utils'; + import { explorerLink, safeLink } from '@app/utils'; import Blockies from '@app/Blockies.svelte'; import Loading from '@app/Loading.svelte'; import type { Config } from '@app/config'; @@ -53,12 +53,13 @@ {#if addressType === AddressType.Org} {addressLabel} org + {:else if addressType === AddressType.Safe} + {addressLabel} + safe {:else} {addressLabel} {#if addressType === AddressType.Contract} contract - {:else if addressType === AddressType.Safe} - safe {:else if addressType === AddressType.EOA} {:else} diff --git a/src/config.json b/src/config.json index 1f2b46d28..9bf0e4076 100644 --- a/src/config.json +++ b/src/config.json @@ -11,7 +11,8 @@ "address": "0x0000000000000000000000000000000000000000" }, "safe": { - "api": "https://safe-transaction.gnosis.io/api/v1" + "api": "https://safe-transaction.gnosis.io/api/v1", + "viewer": "https://gnosis-safe.io/app/#/safes" } }, "ropsten": { @@ -30,7 +31,8 @@ "contractHash": "0xc5bd5bc3cbcb709540df530c5ad2a9d91463ebb891a789286872938d963c12e9" }, "safe": { - "api": null + "api": null, + "viewer": null } }, "rinkeby": { @@ -49,7 +51,8 @@ "contractHash": "0xc5bd5bc3cbcb709540df530c5ad2a9d91463ebb891a789286872938d963c12e9" }, "safe": { - "api": "https://safe-transaction.rinkeby.gnosis.io/api/v1" + "api": "https://safe-transaction.rinkeby.gnosis.io/api/v1", + "viewer": "https://rinkeby.gnosis-safe.io/app/#/safes" } }, "seed": { diff --git a/src/config.ts b/src/config.ts index 6ea40a291..7d0d4362f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -25,7 +25,7 @@ export class Config { provider: ethers.providers.JsonRpcProvider; signer: ethers.Signer & TypedDataSigner | null; seed: { url: string }; - safe: { api: string | null }; + safe: { api: string | null, viewer: string | null }; constructor( network: { name: string, chainId: number }, diff --git a/src/utils.ts b/src/utils.ts index c0a917887..eef3ad7a1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -81,6 +81,14 @@ export function explorerLink(addr: string, config: Config): string { return `https://etherscan.io/address/${addr}`; } +// Get the Gnosis Safe link of an address, eg. Etherscan. +export function safeLink(addr: string, config: Config): string { + if (config.safe.viewer) { + return `${config.safe.viewer}/${addr}`; + } + return explorerLink(addr, config); +} + // Query a subgraph. export async function querySubgraph( query: string,