mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
Since we are now more open to other ENS domains, in the registration view form we should refer to domain instead of sudomain, and in the creation process we should refer to name instead of subdomain Signed-off-by: Sebastian Martinez <sebastinez@me.com>
75 lines
2.2 KiB
Svelte
75 lines
2.2 KiB
Svelte
<script lang="ts">
|
|
import { onMount, createEventDispatcher } from 'svelte';
|
|
import { setRecords } from './resolver';
|
|
import type { EnsRecord } from './resolver';
|
|
import type { Registration } from './registrar';
|
|
import type { Config } from '@app/config';
|
|
import Loading from '@app/Loading.svelte';
|
|
import Modal from '@app/Modal.svelte';
|
|
import { Status, State } from "@app/utils";
|
|
|
|
export let domain: string;
|
|
export let config: Config;
|
|
export let records: EnsRecord[];
|
|
export let registration: Registration;
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
let state: State = { status: Status.Failed, error: "Error registering, something happened." };
|
|
|
|
onMount(async () => {
|
|
try {
|
|
state.status = Status.Signing;
|
|
const tx = await setRecords(domain, records, registration.resolver, config);
|
|
state.status = Status.Pending;
|
|
await tx.wait();
|
|
state.status = Status.Success;
|
|
} catch (e: any) {
|
|
console.error(e);
|
|
state = { status: Status.Failed, error: e.message };
|
|
}
|
|
});
|
|
|
|
const onDone = () => {
|
|
// Reload page to load updates to the registration.
|
|
location.reload();
|
|
};
|
|
|
|
const onClose = () => {
|
|
dispatch('close');
|
|
};
|
|
</script>
|
|
|
|
<Modal floating error={state.status === Status.Failed}>
|
|
<span slot="title">
|
|
<div>🧾</div>
|
|
<div>Update registration</div>
|
|
</span>
|
|
<span slot="subtitle">
|
|
{#if state.status === Status.Signing}
|
|
<p>Please confirm the transaction in your wallet</p>
|
|
{:else if state.status === Status.Pending}
|
|
<p>Waiting for transaction to be processed...</p>
|
|
{:else if state.status === Status.Success}
|
|
<p>Your registration was successfully updated.</p>
|
|
{:else if state.status === Status.Failed}
|
|
<p class="error">
|
|
<strong>Error:</strong> {state.error}
|
|
</p>
|
|
{/if}
|
|
</span>
|
|
<span slot="actions">
|
|
{#if [Status.Signing, Status.Pending].includes(state.status)}
|
|
<Loading center small />
|
|
{:else if state.status === Status.Success}
|
|
<button on:click={onDone}>
|
|
Done
|
|
</button>
|
|
{:else if state.status === Status.Failed}
|
|
<button on:click={onClose}>
|
|
Close
|
|
</button>
|
|
{/if}
|
|
</span>
|
|
</Modal>
|