Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Make sure we have a signer in some cases
Alexis Sellier committed 5 years ago
commit 34298a1081be8848aa42ce5e19610ac2d0ee28f4
parent 58ce44f5f586a896008975139a88bfb5c339aaca
4 files changed +16 -3
modified src/Header.svelte
@@ -107,7 +107,7 @@
    <div class="nav">
      <a use:link href="/registrations">Register</a>
      <a use:link href="/vesting/">Vesting</a>
-
      {#if config && config.network.name === 'ropsten'}
+
      {#if config && config.signer && config.network.name === 'ropsten'}
        <a use:link href="/orgs/">Orgs</a>
      {/if}
    </div>
modified src/base/orgs/Org.ts
@@ -32,6 +32,8 @@ export class Org {
  }

  async setName(name: string, config: Config): Promise<TransactionResponse> {
+
    assert(config.signer);
+

    const org = new ethers.Contract(
      this.address,
      orgAbi,
@@ -78,6 +80,8 @@ export class Org {
    threshold: number,
    config: Config,
  ): Promise<TransactionResponse> {
+
    assert(config.signer);
+

    const orgFactory = new ethers.Contract(
      config.orgFactory.address,
      orgFactoryAbi,
@@ -93,6 +97,8 @@ export class Org {
    owner: string,
    config: Config,
  ): Promise<TransactionResponse> {
+
    assert(config.signer);
+

    const orgFactory = new ethers.Contract(
      config.orgFactory.address,
      orgFactoryAbi,
modified src/base/registrations/registrar.ts
@@ -84,6 +84,8 @@ export async function registrationFee(config: Config) {
}

export async function registerName(name: string, owner: string, config: Config) {
+
  assert(config.signer);
+

  if (! name) return;

  let commitmentJson = window.localStorage.getItem('commitment');
@@ -119,6 +121,8 @@ async function commitAndRegister(name: string, owner: string, config: Config) {
}

async function commit(commitment: string, fee: BigNumber, minAge: number, config: Config) {
+
  assert(config.signer);
+

  state.set(State.Committing);

  const owner = config.signer;
@@ -188,10 +192,10 @@ async function permitSignature(
}

async function register(name: string, owner: string, salt: Uint8Array, config: Config) {
+
  assert(config.signer);
  state.set(State.Registering);

-
  const signer = config.provider.getSigner();
-
  const tx = await registrar(config).connect(signer).register(
+
  const tx = await registrar(config).connect(config.signer).register(
    name, owner, ethers.BigNumber.from(salt), { gasLimit: 150000 }
  );
  console.log("Sent", tx);
modified src/base/registrations/resolver.ts
@@ -2,6 +2,7 @@ import type { TransactionResponse } from '@ethersproject/providers';
import type { EnsResolver } from '@ethersproject/providers';
import { ethers } from 'ethers';
import type { Config } from '@app/config';
+
import { assert } from '@app/error';

const resolverAbi = [
  "function multicall(bytes[] calldata data) returns(bytes[] memory results)",
@@ -12,6 +13,8 @@ const resolverAbi = [
export type EnsRecord = { name: string, value: string };

export async function setRecords(name: string, records: EnsRecord[], resolver: EnsResolver, config: Config): Promise<TransactionResponse> {
+
  assert(config.signer);
+

  const resolverContract = new ethers.Contract(resolver.address, resolverAbi, config.signer);
  const node = ethers.utils.namehash(`${name}.${config.registrar.domain}`);