mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-30 15:11:22 +00:00
fixes and renames
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { getPrimaryDomain as _getPrimaryDomain } from "@bonfida/spl-name-service";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { SolanaAgentKit } from "../index";
|
||||
import { SolanaAgent } from "../index";
|
||||
|
||||
/**
|
||||
* Retrieves the primary .sol domain associated with a given Solana public key.
|
||||
@@ -9,29 +9,29 @@ import { SolanaAgentKit } from "../index";
|
||||
* a specified Solana public key. If the primary domain is stale or an error occurs during
|
||||
* the resolution, it throws an error.
|
||||
*
|
||||
* @param agent SolanaAgentKit instance
|
||||
* @param agent SolanaAgent instance
|
||||
* @param account The Solana public key for which to retrieve the primary domain
|
||||
* @returns A promise that resolves to the primary .sol domain as a string
|
||||
* @throws Error if the domain is stale or if the domain resolution fails
|
||||
*/
|
||||
export async function getPrimaryDomain(
|
||||
agent: SolanaAgentKit,
|
||||
account: PublicKey
|
||||
agent: SolanaAgent,
|
||||
account: PublicKey,
|
||||
): Promise<string> {
|
||||
try {
|
||||
const { reverse, stale } = await _getPrimaryDomain(
|
||||
agent.connection,
|
||||
account
|
||||
account,
|
||||
);
|
||||
if (stale) {
|
||||
throw new Error(
|
||||
`Primary domain is stale for account: ${account.toBase58()}`
|
||||
`Primary domain is stale for account: ${account.toBase58()}`,
|
||||
);
|
||||
}
|
||||
return reverse;
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Failed to get primary domain for account: ${account.toBase58()}`
|
||||
`Failed to get primary domain for account: ${account.toBase58()}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user