From eb664f3beac071651e7b3d1101ed46a37214b4c0 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 10 Jun 2021 11:01:22 +0200 Subject: [PATCH] Run linter on more files --- src/base/orgs/Org.ts | 14 ++++++------ src/base/registrations/registrar.ts | 34 ++++++++++++++--------------- src/base/registrations/resolver.ts | 6 ++--- src/base/vesting/state.ts | 2 +- src/base/vesting/vesting.ts | 14 ++++++------ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/base/orgs/Org.ts b/src/base/orgs/Org.ts index daff189a6..76b8a23ba 100644 --- a/src/base/orgs/Org.ts +++ b/src/base/orgs/Org.ts @@ -77,9 +77,9 @@ export class Org { async getProjects(config: Config): Promise> { 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> { 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); } diff --git a/src/base/registrations/registrar.ts b/src/base/registrations/registrar.ts index 4e56e2ce7..786458319 100644 --- a/src/base/registrations/registrar.ts +++ b/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 { - 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; } diff --git a/src/base/registrations/resolver.ts b/src/base/registrations/resolver.ts index 99add0e83..b376edd44 100644 --- a/src/base/registrations/resolver.ts +++ b/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 { 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( diff --git a/src/base/vesting/state.ts b/src/base/vesting/state.ts index 1dde8db3f..33c4d23d3 100644 --- a/src/base/vesting/state.ts +++ b/src/base/vesting/state.ts @@ -9,7 +9,7 @@ export enum State { WithdrawingSign = 4, Withdrawing = 5, Withdrawn = 6, -}; +} export const state = writable(State.Idle); diff --git a/src/base/vesting/vesting.ts b/src/base/vesting/vesting.ts index 10ac1ddcd..9c5171777 100644 --- a/src/base/vesting/vesting.ts +++ b/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();