Allow orgs to be looked up by name

This commit is contained in:
Alexis Sellier
2021-05-05 12:09:15 +02:00
parent 9189c24e09
commit 1f139c12d9
4 changed files with 17 additions and 8 deletions
+8 -6
View File
@@ -14,17 +14,18 @@ const orgAbi = ["function owner() view returns (address)"];
export class Org {
address: string
safe: string
name: string | null
constructor(address: string, safe: string) {
this.address = address;
this.safe = safe;
this.name = null;
}
async resolveAddress(config: Config): Promise<string> {
this.name = await config.provider.lookupAddress(this.address);
return this.name;
async lookupAddress(config: Config): Promise<string> {
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 {
@@ -52,7 +53,8 @@ export class Org {
try {
let safe = await org.owner();
return new Org(address, safe);
} catch (_) {
} catch (e) {
console.error(e);
return null;
}
}
+6 -1
View File
@@ -1,4 +1,5 @@
<script lang="typescript">
import { ethers } from 'ethers';
import { navigate } from 'svelte-routing';
import type { Config } from '@app/config';
import { Org } from './Org';
@@ -8,6 +9,10 @@
export let address: string;
export let config: Config;
if (! ethers.utils.isAddress(address)) {
address = `${address}.${config.registrar.domain}`;
}
const back = () => {
navigate("/orgs");
};
@@ -27,7 +32,7 @@
<tr>
<td class="label">Name</td>
<td>
{#await org.resolveAddress(config)}
{#await org.lookupAddress(config)}
<Loading small />
{:then name}
{#if name}
+2
View File
@@ -1,6 +1,7 @@
{
"homestead": {
"registrar": {
"domain": "radicle.eth",
"address": "0x37723287Ae6F34866d82EE623401f92Ec9013154"
},
"radToken": {
@@ -12,6 +13,7 @@
},
"ropsten": {
"registrar": {
"domain": "rad.eth",
"address": "0xb31441c140E92Ca20A0141D68b13b10ca051e40a"
},
"radToken": {
+1 -1
View File
@@ -9,7 +9,7 @@ declare global {
export type Config = {
network: { name: string, chainId: number },
registrar: { address: string },
registrar: { address: string, domain: string },
radToken: { address: string },
orgFactory: { address: string },
gasLimits: { createOrg: number },