Remove registration fee

Since the DAO passed a proposal to remove the registration fee,
we handle that in the UI.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-04-06 11:23:32 +02:00
parent 896372cd09
commit 101d6d329f
3 changed files with 30 additions and 26 deletions
+5 -13
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import { navigate } from 'svelte-routing';
import { formatAddress, formatBalance } from '@app/utils';
import { formatAddress } from '@app/utils';
import { session } from '@app/session';
import type { Config } from '@app/config';
@@ -10,7 +10,7 @@
import Loading from '@app/Loading.svelte';
import Message from '@app/Message.svelte';
import { registrar, registrationFee } from './registrar';
import { registrar } from './registrar';
enum State {
CheckingAvailability,
@@ -26,7 +26,6 @@
// We only support lower-case names.
name = name.toLowerCase();
let fee: string;
let state = State.CheckingAvailability;
let error: string | null = null;
$: registrationOwner = owner || ($session && $session.address);
@@ -39,12 +38,7 @@
onMount(async () => {
try {
const [_fee, isAvailable] = await Promise.all([
registrationFee(config),
registrar(config).available(name),
]);
fee = formatBalance(_fee);
const isAvailable = await registrar(config).available(name);
if (isAvailable) {
state = State.NameAvailable;
@@ -76,11 +70,9 @@
{#if state === State.NameAvailable}
{#if registrationOwner}
The name <strong>{name}</strong> is available for registration
under account <strong>{formatAddress(registrationOwner)}</strong>
for <strong>{fee} RAD</strong>.
under account <strong>{formatAddress(registrationOwner)}</strong>.
{:else}
The name <strong>{name}</strong> is available
for <strong>{fee} RAD</strong>.
The name <strong>{name}</strong> is available.
{/if}
{:else if state === State.NameUnavailable}
This name is <strong>not available</strong> for registration.
+24 -13
View File
@@ -220,21 +220,32 @@ async function commit(
const spender = config.registrar.address;
const deadline = ethers.BigNumber.from(unixTime()).add(3600); // Expire one hour from now.
const token = config.token;
const signature = await permitSignature(config.signer, token, spender, fee, deadline);
state.set({ connection: State.SigningCommit });
let tx = null;
const tx = await registrar(config)
.connect(config.signer)
.commitWithPermit(
commitment,
owner,
fee,
deadline,
signature.v,
signature.r,
signature.s,
{ gasLimit: 180000 });
if (fee.isZero()) {
state.set({ connection: State.SigningCommit });
tx = await registrar(config)
.connect(config.signer)
.commit(commitment, { gasLimit: 180000 });
} else {
const signature = await permitSignature(config.signer, token, spender, fee, deadline);
state.set({ connection: State.SigningCommit });
tx = await registrar(config)
.connect(config.signer)
.commitWithPermit(
commitment,
owner,
fee,
deadline,
signature.v,
signature.r,
signature.s,
{ gasLimit: 180000 });
}
state.set({ connection: State.Committing });