Files
radicle-explorer/src/base/users/User.ts
T
2022-08-31 17:47:07 +02:00

26 lines
715 B
TypeScript

import * as ethers from "ethers";
import type { Config } from "@app/config";
import { assert } from "@app/error";
import type { TransactionResponse } from "@ethersproject/providers";
export class User {
address: string;
constructor(address: string) {
assert(ethers.utils.isAddress(address), "address must be valid");
this.address = address.toLowerCase(); // Don't store address checksum.
}
async setName(name: string, config: Config): Promise<TransactionResponse> {
assert(config.signer);
const reverseRegistrar = new ethers.Contract(
config.reverseRegistrar.address,
config.abi.reverseRegistrar,
config.signer,
);
return reverseRegistrar.setName(name);
}
}