mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-03 02:30:29 +08:00
26 lines
715 B
TypeScript
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);
|
|
}
|
|
}
|