Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Org profile improvements
Alexis Sellier committed 5 years ago
commit 068205a8a150ebb39e83913c59fd43e1ce5069ab
parent c2dc2c597b7ea8c4bd325a3fcca87119c2d516bf
2 files changed +36 -26
modified src/base/orgs/Org.ts
@@ -1,6 +1,7 @@
import * as ethers from 'ethers';
import type { TransactionReceipt, TransactionResponse } from '@ethersproject/providers';
import type { ContractReceipt } from '@ethersproject/contracts';
+
import { assert } from '@app/error';

import type { Config } from '@app/config';

@@ -16,6 +17,8 @@ export class Org {
  safe: string

  constructor(address: string, safe: string) {
+
    assert(ethers.utils.isAddress(address), "address must be valid");
+

    this.address = address;
    this.safe = safe;
  }
@@ -24,10 +27,6 @@ export class Org {
    return await config.provider.lookupAddress(this.address);
  }

-
  async resolveName(config: Config): Promise<string> {
-
    return await config.provider.resolveName(this.address);
-
  }
-

  static fromReceipt(receipt: ContractReceipt): Org | null {
    let event = receipt.events?.find(e => e.event === 'OrgCreated');

@@ -49,10 +48,11 @@ export class Org {
      orgAbi,
      config.provider
    );
+
    const resolved = await org.resolvedAddress;

    try {
      let safe = await org.owner();
-
      return new Org(address, safe);
+
      return new Org(resolved, safe);
    } catch (e) {
      console.error(e);
      return null;
modified src/base/orgs/Profile.svelte
@@ -18,37 +18,47 @@
  };
</script>

+
<style>
+
  .fields {
+
    display: grid;
+
    grid-template-columns: auto auto;
+
    grid-gap: 1rem;
+
  }
+
  .fields > div {
+
    justify-self: start;
+
    align-self: center;
+
  }
+
</style>
+

{#await Org.get(address, config)}
-
  <Loading/>
+
  <Loading />
{:then org}
  {#if org}
    <div>
      <h1>
-
        {org.address}
+
        {address}
      </h1>
-
      <table>
-
        <tr><td class="label">Address</td><td>{org.address}</td></tr>
-
        <tr><td class="label">Safe</td><td>{org.safe}</td></tr>
-
        <tr>
-
          <td class="label">Name</td>
-
          <td>
-
            {#await org.lookupAddress(config)}
-
              <Loading small />
-
            {:then name}
-
              {#if name}
-
                {name}
-
              {:else}
-
                <span class="subtle">Not registered</span>
-
              {/if}
-
            {/await}
-
          </td>
-
        </tr>
-
      </table>
+
      <div class="fields">
+
        <div class="label">Address</div><div>{org.address}</div>
+
        <div class="label">Safe</div><div>{org.safe}</div>
+
        <div class="label">Name</div>
+
        <div>
+
          {#await org.lookupAddress(config)}
+
            <Loading small />
+
          {:then name}
+
            {#if name}
+
              {name}
+
            {:else}
+
              <span class="subtle">Not registered</span>
+
            {/if}
+
          {/await}
+
        </div>
+
      </div>
    </div>
  {:else}
    <Modal subtle>
      <span slot="title">🏜️</span>
-
      <span slot="body">Sorry, <span class="highlight">{address}</span> is not an Org address.</span>
+
      <span slot="body">Sorry, <span class="highlight">{address}</span> does not resolve to an Org address.</span>
      <span slot="actions">
        <button on:click={back}>
          Back