Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Remove registration fee
Alexis Sellier committed 4 years ago
commit 101d6d329fcf9040bcd0f7617e7b8e72ae672139
parent 896372cd09d9ed63494b5218db10d611dce9d0c9
3 files changed +32 -28
modified src/base/registrations/New.svelte
@@ -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.
modified src/base/registrations/registrar.ts
@@ -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 });
-

-
  const tx = await registrar(config)
-
    .connect(config.signer)
-
    .commitWithPermit(
-
      commitment,
-
      owner,
-
      fee,
-
      deadline,
-
      signature.v,
-
      signature.r,
-
      signature.s,
-
      { gasLimit: 180000 });
+

+
  let tx = null;
+

+
  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 });

modified src/config.json
@@ -103,6 +103,7 @@
      "function radNode() view returns (bytes32)",
      "function minCommitmentAge() view returns (uint256)",
      "function registrationFeeRad() view returns (uint256)",
+
      "function commit(bytes32)",
      "function commitWithPermit(bytes32, address, uint256, uint256, uint8, bytes32, bytes32)",
      "function register(string, address, uint256)",
      "function valid(string) pure returns (bool)",