deleteNameRegistry static method
Future<TransactionInstruction>
deleteNameRegistry({
- required SolanaRPC rpc,
- required String name,
- required SolAddress refundTargetKey,
- SolAddress? nameClass,
- SolAddress? nameParent,
Delete the name account and transfer the rent to the target.
Implementation
static Future<TransactionInstruction> deleteNameRegistry({
/// The solana connection object to the RPC node
required SolanaRPC rpc,
/// The name of the name account
required String name,
/// The refund destination address
required SolAddress refundTargetKey,
/// The class of this name, if it exsists
SolAddress? nameClass,
/// The parent name of this name, if it exists
SolAddress? nameParent,
}) async {
final hashedName = NameServiceProgramUtils.getHashedName(name);
final nameAccountKey = NameServiceProgramUtils.getNameAccountProgram(
hashedName: hashedName,
nameClass: nameClass,
nameParent: nameParent,
);
SolAddress? nameOwner = nameClass;
if (nameOwner == null) {
final account = await rpc
.request(SolanaRPCNameRegistryAccount(account: nameAccountKey));
if (account == null) {
throw const MessageException("Account not found.");
}
nameOwner = account.owner;
}
return NameServiceProgram.delete(
nameAccountKey: nameAccountKey,
refundTargetKey: refundTargetKey,
nameOwnerKey: nameOwner,
);
}