mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-02 02:00:31 +08:00
Add return types to more functions
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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,4 +1,4 @@
|
||||
import { derived, writable } from "svelte/store";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
export enum State {
|
||||
Error = -1,
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user