Use org seed for projects in org view

This commit is contained in:
Alexis Sellier
2021-07-19 15:14:36 +02:00
parent 931b18f18c
commit 19b9009918
4 changed files with 18 additions and 2 deletions
+1 -1
View File
@@ -220,7 +220,7 @@
{:then projects}
{#each projects as project}
<div class="project">
<Project {project} org={org.address} {config} />
<Project {project} org={org.address} {config} seed={profile.seed} />
</div>
{/each}
{:catch err}
+3 -1
View File
@@ -16,13 +16,15 @@
export let project: proj.Project;
export let config: Config;
export let org: string | undefined;
export let seed: string | undefined;
let state: State = { status: Status.Loading };
let info: proj.Info | null = null;
onMount(async () => {
try {
const result = await proj.getInfo(project.id, config);
const cfg = seed ? config.withSeed(seed) : config;
const result = await proj.getInfo(project.id, cfg);
state = { status: Status.Loaded };
info = result;
} catch (err) {
+9
View File
@@ -72,6 +72,15 @@ export class Config {
this.provider,
);
}
// Return the config with an overwritten seed URL.
withSeed(seed: string): Config {
const cfg = {} as Config;
Object.assign(cfg, this);
cfg.seed.api = seed;
return cfg;
}
}
/// Gas limits for various transactions.
+5
View File
@@ -54,6 +54,11 @@ export class Profile {
else return undefined;
}
// Using undefined as return type if nothing to be returned since it works better with <a href> links
get seed(): string | undefined {
return this.profile?.ens?.seed ?? undefined;
}
// Keeping this function private since the desired entrypoint is .get()
private static async lookupAddress(address: string, config: Config): Promise<[IProfile, string]> {
const profile: IProfile = { ens: null, idx: null };