Org profile improvements

This commit is contained in:
Alexis Sellier
2021-05-08 20:59:25 +02:00
parent c2dc2c597b
commit 068205a8a1
2 changed files with 36 additions and 26 deletions
+5 -5
View File
@@ -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;
+31 -21
View File
@@ -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