mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
Allow orgs to be looked up by name
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user