mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Improve vesting discovery and error messages
When loading a ETH address as vesting contract we show a cryptic error message, which non tech-savy end users don't understand, this commit changes it to something more human readable. We allow users to enter and load a contract that probably isn't a vesting contract. The `getInfo` function in the `vesting` folder is very prone to possible errors, and benefits from some parallelization between all the method calls. We allow hereby to enter a contract address in search and once on the contract profile page we provide a link to the detailed vesting information if available. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
+16
-4
@@ -16,10 +16,12 @@ import { base } from "@app/lib/router";
|
||||
import { config } from "@app/lib/config";
|
||||
import { getAddress, getResolver } from "@app/lib/registrar";
|
||||
import { getAvatar, getSeed, getRegistration } from "@app/lib/registrar";
|
||||
import { getInfo } from "@app/lib/vesting";
|
||||
|
||||
export enum AddressType {
|
||||
Contract,
|
||||
Org,
|
||||
Vesting,
|
||||
EOA,
|
||||
}
|
||||
|
||||
@@ -127,6 +129,11 @@ export function formatAddress(input: string): string {
|
||||
);
|
||||
}
|
||||
|
||||
// Returns a shortened Ethereum transaction hash
|
||||
export function formatTx(input: string): string {
|
||||
return input.substring(0, 20) + "…";
|
||||
}
|
||||
|
||||
export function formatCommit(oid: string): string {
|
||||
return oid.substring(0, 7);
|
||||
}
|
||||
@@ -288,12 +295,13 @@ export function isFulfilled<T>(
|
||||
return input.status === "fulfilled";
|
||||
}
|
||||
|
||||
// Get the explorer link of an address, eg. Etherscan.
|
||||
export function explorerLink(addr: string, wallet: Wallet): string {
|
||||
// Get the explorer link of an address or tx, eg. Etherscan.
|
||||
export function explorerLink(addrOrTx: string, wallet: Wallet): string {
|
||||
const type = isAddress(addrOrTx) ? "address" : "tx";
|
||||
if (wallet.network.name === "goerli") {
|
||||
return `https://goerli.etherscan.io/address/${addr}`;
|
||||
return `https://goerli.etherscan.io/${type}/${addrOrTx}`;
|
||||
}
|
||||
return `https://etherscan.io/address/${addr}`;
|
||||
return `https://etherscan.io/${type}/${addrOrTx}`;
|
||||
}
|
||||
|
||||
// Format a name.
|
||||
@@ -349,6 +357,10 @@ export async function identifyAddress(
|
||||
const bytes = ethers.utils.arrayify(code);
|
||||
|
||||
if (bytes.length > 0) {
|
||||
const info = await getInfo(address, wallet);
|
||||
if (info) {
|
||||
return AddressType.Vesting;
|
||||
}
|
||||
return AddressType.Contract;
|
||||
}
|
||||
return AddressType.EOA;
|
||||
|
||||
Reference in New Issue
Block a user