Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Detect org addresses
Alexis Sellier committed 4 years ago
commit 7e30182478263032e0eb0dd97751575e26541690
parent b49699dfe0254f74578c71a01c671ee39438ee8b
4 files changed +34 -3
modified public/index.css
@@ -36,6 +36,7 @@
	--color-negative-6: #ffd4d4;
	--color-foreground: #ffffff;
	--color-foreground-faded: #777788;
+
	--color-foreground-background: #77778811;
	--color-foreground-1: #242e38;
	--color-foreground-2: #29343d;
	--color-foreground-3: #333e47;
@@ -248,6 +249,18 @@ input.wide {
.bold {
	font-weight: bold !important;
}
+
.badge {
+
	color: var(--color-foreground-faded);
+
	background: var(--color-foreground-background);
+
	border-radius: var(--border-radius);
+
	padding: 0.125rem 0.5rem;
+
	margin: 0 0.5rem;
+
	font-size: 0.75rem;
+
}
+
.badge.tertiary {
+
	color: var(--color-tertiary);
+
	background: var(--color-tertiary-background);
+
}

span.small {
	font-size: 0.75rem;
modified src/Address.svelte
@@ -1,4 +1,5 @@
<script lang="typescript">
+
  import { onMount } from 'svelte';
  import { ethers } from 'ethers';
  import { explorerLink } from '@app/utils';
  import Blockies from '@app/Blockies.svelte';
@@ -8,6 +9,16 @@
  export let config: Config;

  let checksumAddress = ethers.utils.getAddress(address);
+
  let isContract = false;
+
  let isOrg = false;
+

+
  onMount(async () => {
+
    let code = await config.provider.getCode(address);
+
    let bytes = ethers.utils.arrayify(code);
+

+
    isContract = bytes.length > 0;
+
    isOrg = ethers.utils.keccak256(bytes) === config.orgs.contractHash;
+
  });
</script>

<style>
@@ -31,4 +42,9 @@
<div class="address">
  <span class="icon"><Blockies address={address} /></span>
  <a href={explorerLink(address, config)} target="_blank">{checksumAddress}</a>
+
  {#if isOrg}
+
    <span class="badge">org</span>
+
  {:else if isContract}
+
    <span class="badge">contract</span>
+
  {/if}
</div>
modified src/config.json
@@ -23,7 +23,8 @@
      "address": "0xe1814B14430CF14f0950A29FF26217115B815676"
    },
    "orgs": {
-
      "subgraph": "https://api.thegraph.com/subgraphs/name/radicle-dev/radicle-orgs-ropsten"
+
      "subgraph": "https://api.thegraph.com/subgraphs/name/radicle-dev/radicle-orgs-ropsten",
+
      "contractHash": "0xc5bd5bc3cbcb709540df530c5ad2a9d91463ebb891a789286872938d963c12e9"
    }
  },
  "rinkeby": {
@@ -38,7 +39,8 @@
      "address": "0xe30aA5594FFB52B6bF5bbB21eB7e71Ac525bB028"
    },
    "orgs": {
-
      "subgraph": "https://api.thegraph.com/subgraphs/name/radicle-dev/radicle-orgs-rinkeby"
+
      "subgraph": "https://api.thegraph.com/subgraphs/name/radicle-dev/radicle-orgs-rinkeby",
+
      "contractHash": "0xc5bd5bc3cbcb709540df530c5ad2a9d91463ebb891a789286872938d963c12e9"
    }
  },
  "seed": {
modified src/config.ts
@@ -20,7 +20,7 @@ export class Config {
  registrar: { address: string, domain: string };
  radToken: { address: string };
  orgFactory: { address: string };
-
  orgs: { subgraph: string };
+
  orgs: { subgraph: string, contractHash: string };
  gasLimits: { createOrg: number };
  provider: ethers.providers.JsonRpcProvider;
  signer: ethers.Signer & TypedDataSigner | null;