Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Run linter on more files
Alexis Sellier committed 4 years ago
commit eb664f3beac071651e7b3d1101ed46a37214b4c0
parent 0b6d60c69ac36f6d05142a8ef8f02e1a45aded88
5 files changed +35 -35
modified src/base/orgs/Org.ts
@@ -77,9 +77,9 @@ export class Org {

  async getProjects(config: Config): Promise<Array<Project>> {
    const result = await utils.querySubgraph(GetProjects, { org: this.address }, config);
-
    let projects: Project[] = [];
+
    const projects: Project[] = [];

-
    for (let p of result.projects) {
+
    for (const p of result.projects) {
      try {
        p.id = utils.formatRadicleId(ethers.utils.arrayify(p.id));
        p.anchor.stateHash = utils.formatProjectHash(
@@ -96,9 +96,9 @@ export class Org {

  static async getAll(config: Config): Promise<Array<Org>> {
    const result = await utils.querySubgraph(GetOrgs, {}, config);
-
    let orgs: Org[] = [];
+
    const orgs: Org[] = [];

-
    for (let o of result.orgs) {
+
    for (const o of result.orgs) {
      try {
        orgs.push(new Org(o.id, o.owner));
      } catch (e) {
@@ -109,11 +109,11 @@ export class Org {
  }

  static fromReceipt(receipt: ContractReceipt): Org | null {
-
    let event = receipt.events?.find(e => e.event === 'OrgCreated');
+
    const event = receipt.events?.find(e => e.event === 'OrgCreated');

    if (event && event.args) {
-
      let address = event.args[0];
-
      let owner = event.args[1];
+
      const address = event.args[0];
+
      const owner = event.args[1];

      return new Org(address, owner);
    }
modified src/base/registrations/registrar.ts
@@ -11,14 +11,14 @@ import { unixTime } from '@app/utils';
import { assert } from '@app/error';

export interface Registration {
-
  name: string
-
  owner: string
-
  address: string | null
-
  url: string | null
-
  avatar: string | null
-
  twitter: string | null
-
  github: string | null
-
  resolver: EnsResolver
+
  name: string;
+
  owner: string;
+
  address: string | null;
+
  url: string | null;
+
  avatar: string | null;
+
  twitter: string | null;
+
  github: string | null;
+
  resolver: EnsResolver;
}

export enum State {
@@ -80,8 +80,8 @@ export async function registerName(name: string, owner: string, config: Config)

  if (! name) return;

-
  let commitmentJson = window.localStorage.getItem('commitment');
-
  let commitment = commitmentJson && JSON.parse(commitmentJson);
+
  const commitmentJson = window.localStorage.getItem('commitment');
+
  const commitment = commitmentJson && JSON.parse(commitmentJson);

  try {
    // Try to recover an existing commitment.
@@ -96,9 +96,9 @@ export async function registerName(name: string, owner: string, config: Config)
}

async function commitAndRegister(name: string, owner: string, config: Config) {
-
  let salt = ethers.utils.randomBytes(32);
-
  let minAge = (await registrar(config).minCommitmentAge()).toNumber();
-
  let fee = await registrationFee(config);
+
  const salt = ethers.utils.randomBytes(32);
+
  const minAge = (await registrar(config).minCommitmentAge()).toNumber();
+
  const fee = await registrationFee(config);
  // Avoids gas spent by the owner, trying to commit to a name and not having
  // enough RAD balance
  if ((await radToken(config).balanceOf(owner)).lt(fee)) {
@@ -202,7 +202,7 @@ async function register(name: string, owner: string, salt: Uint8Array, config: C
}

function makeCommitment(name: string, owner: string, salt: Uint8Array): string {
-
  let bytes = ethers.utils.concat([
+
  const bytes = ethers.utils.concat([
    ethers.utils.toUtf8Bytes(name),
    ethers.utils.getAddress(owner),
    ethers.BigNumber.from(salt).toHexString(),
@@ -211,13 +211,13 @@ function makeCommitment(name: string, owner: string, salt: Uint8Array): string {
}

async function getOwner(name: string, config: Config): Promise<string> {
-
  let ensAddr = config.provider.network.ensAddress;
+
  const ensAddr = config.provider.network.ensAddress;
  if (! ensAddr) {
    throw new Error("ENS address is not defined");
  }

-
  let registry = new ethers.Contract(ensAddr, config.abi.ens, config.provider);
-
  let owner = await registry.owner(ethers.utils.namehash(name));
+
  const registry = new ethers.Contract(ensAddr, config.abi.ens, config.provider);
+
  const owner = await registry.owner(ethers.utils.namehash(name));

  return owner;
}
modified src/base/registrations/resolver.ts
@@ -4,7 +4,7 @@ import { ethers } from 'ethers';
import type { Config } from '@app/config';
import { assert } from '@app/error';

-
export type EnsRecord = { name: string, value: string };
+
export type EnsRecord = { name: string; value: string };

export async function setRecords(name: string, records: EnsRecord[], resolver: EnsResolver, config: Config): Promise<TransactionResponse> {
  assert(config.signer);
@@ -12,10 +12,10 @@ export async function setRecords(name: string, records: EnsRecord[], resolver: E
  const resolverContract = new ethers.Contract(resolver.address, config.abi.resolver, config.signer);
  const node = ethers.utils.namehash(`${name}.${config.registrar.domain}`);

-
  let calls = [];
+
  const calls = [];
  const iface = new ethers.utils.Interface(config.abi.resolver);

-
  for (let r of records) {
+
  for (const r of records) {
    switch (r.name) {
      case "address":
        calls.push(
modified src/base/vesting/state.ts
@@ -9,7 +9,7 @@ export enum State {
  WithdrawingSign = 4,
  Withdrawing = 5,
  Withdrawn = 6,
-
};
+
}

export const state = writable(State.Idle);

modified src/base/vesting/vesting.ts
@@ -6,12 +6,12 @@ import type { Config } from "@app/config";


export interface VestingInfo {
-
  token: string,
-
  symbol: string,
-
  beneficiary: string,
-
  totalVesting: string,
-
  withdrawableBalance: string,
-
  withdrawn: string
+
  token: string;
+
  symbol: string;
+
  beneficiary: string;
+
  totalVesting: string;
+
  withdrawableBalance: string;
+
  withdrawn: string;
}

export async function withdrawVested(address: string, config: Config) {
@@ -20,7 +20,7 @@ export async function withdrawVested(address: string, config: Config) {

  state.set(State.WithdrawingSign);

-
  let tx = await contract.connect(signer).withdrawVested();
+
  const tx = await contract.connect(signer).withdrawVested();

  state.set(State.Withdrawing);
  await tx.wait();