Add return types to more functions

This commit is contained in:
Alexis Sellier
2021-06-10 11:05:03 +02:00
parent eb664f3bea
commit 76e7b8dc4d
4 changed files with 9 additions and 11 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import * as ethers from 'ethers';
import type { TransactionReceipt, TransactionResponse } from '@ethersproject/providers';
import type { TransactionResponse } from '@ethersproject/providers';
import type { ContractReceipt } from '@ethersproject/contracts';
import { assert } from '@app/error';
import * as utils from '@app/utils';
+6 -6
View File
@@ -63,19 +63,19 @@ export async function getRegistration(name: string, config: Config): Promise<Reg
};
}
export function registrar(config: Config) {
export function registrar(config: Config): ethers.Contract {
return new ethers.Contract(config.registrar.address, config.abi.registrar, config.provider);
}
export function radToken(config: Config) {
export function radToken(config: Config): ethers.Contract {
return new ethers.Contract(config.radToken.address, config.abi.token, config.provider);
}
export async function registrationFee(config: Config) {
export async function registrationFee(config: Config): Promise<BigNumber> {
return await registrar(config).registrationFeeRad();
}
export async function registerName(name: string, owner: string, config: Config) {
export async function registerName(name: string, owner: string, config: Config): Promise<void> {
assert(config.signer);
if (! name) return;
@@ -95,7 +95,7 @@ export async function registerName(name: string, owner: string, config: Config)
}
}
async function commitAndRegister(name: string, owner: string, config: Config) {
async function commitAndRegister(name: string, owner: string, config: Config): Promise<void> {
const salt = ethers.utils.randomBytes(32);
const minAge = (await registrar(config).minCommitmentAge()).toNumber();
const fee = await registrationFee(config);
@@ -117,7 +117,7 @@ async function commitAndRegister(name: string, owner: string, config: Config) {
await register(name, owner, salt, config);
}
async function commit(commitment: string, fee: BigNumber, minAge: number, config: Config) {
async function commit(commitment: string, fee: BigNumber, minAge: number, config: Config): Promise<void> {
assert(config.signer);
state.set(State.Committing);
+1 -1
View File
@@ -1,4 +1,4 @@
import { derived, writable } from "svelte/store";
import { writable } from "svelte/store";
export enum State {
Error = -1,
+1 -3
View File
@@ -14,7 +14,7 @@ export interface VestingInfo {
withdrawn: string;
}
export async function withdrawVested(address: string, config: Config) {
export async function withdrawVested(address: string, config: Config): Promise<void> {
const contract = new ethers.Contract(address, config.abi.vesting, config.provider);
const signer = config.provider.getSigner();
@@ -30,8 +30,6 @@ export async function withdrawVested(address: string, config: Config) {
export async function getInfo(address: string, config: Config): Promise<VestingInfo> {
const contract = new ethers.Contract(address, config.abi.vesting, config.provider);
const signer = config.provider.getSigner();
const token = await contract.token();
const beneficiary = await contract.beneficiary();
const withdrawable = await contract.withdrawableBalance();