@bsv/sdk
Version:
BSV Blockchain Software Development Kit
94 lines • 4.5 kB
TypeScript
import { WalletInterface, WalletProtocol } from '../wallet/index.js';
import { BroadcastResponse, BroadcastFailure } from '../transaction/index.js';
import { DefinitionData, DefinitionType, RegistryQueryMapping, RegistryRecord } from './types/index.js';
/**
* RegistryClient manages on-chain registry definitions for three types:
* - basket (basket-based items)
* - protocol (protocol-based items)
* - certificate (certificate-based items)
*
* It provides methods to:
* - Register new definitions using pushdrop-based UTXOs.
* - Resolve existing definitions using a lookup service.
* - List registry entries associated with the operator's wallet.
* - Revoke an existing registry entry by spending its UTXO.
*
* Registry operators use this client to establish and manage
* canonical references for baskets, protocols, and certificate types.
*/
export declare class RegistryClient {
private readonly wallet;
private network;
constructor(wallet?: WalletInterface);
/**
* Publishes a new on-chain definition for baskets, protocols, or certificates.
* The definition data is encoded in a pushdrop-based UTXO.
*
* Registry operators (i.e., identity key owners) can create these definitions
* to establish canonical references for basket IDs, protocol specs, or certificate schemas.
*
* @param data - Structured information about a 'basket', 'protocol', or 'certificate'.
* @returns A promise with the broadcast result or failure.
*/
registerDefinition(data: DefinitionData): Promise<BroadcastResponse | BroadcastFailure>;
/**
* Resolves registrant tokens of a particular type using a lookup service.
*
* The query object shape depends on the registry type:
* - For "basket", the query is of type BasketMapQuery:
* { basketID?: string; name?: string; registryOperators?: string[]; }
* - For "protocol", the query is of type ProtoMapQuery:
* { name?: string; registryOperators?: string[]; protocolID?: WalletProtocol; }
* - For "certificate", the query is of type CertMapQuery:
* { type?: string; name?: string; registryOperators?: string[]; }
*
* @param definitionType - The registry type, which can be 'basket', 'protocol', or 'certificate'.
* @param query - The query object used to filter registry records, whose shape is determined by the registry type.
* @returns A promise that resolves to an array of matching registry records.
*/
resolve<T extends DefinitionType>(definitionType: T, query: RegistryQueryMapping[T]): Promise<DefinitionData[]>;
/**
* Lists the registry operator's published definitions for the given type.
*
* Returns parsed registry records including transaction details such as txid, outputIndex, satoshis, and the locking script.
*
* @param definitionType - The type of registry definition to list ('basket', 'protocol', or 'certificate').
* @returns A promise that resolves to an array of RegistryRecord objects.
*/
listOwnRegistryEntries(definitionType: DefinitionType): Promise<RegistryRecord[]>;
/**
* Revokes a registry record by spending its associated UTXO.
*
* @param registryRecord - Must have valid txid, outputIndex, and lockingScript.
* @returns Broadcast success/failure.
*/
revokeOwnRegistryEntry(registryRecord: RegistryRecord): Promise<BroadcastResponse | BroadcastFailure>;
/**
* Convert definition data into an array of pushdrop fields (strings).
* Each definition type has a slightly different shape.
*/
private buildPushDropFields;
/**
* Decodes a pushdrop locking script for a given definition type,
* returning a typed record with the appropriate fields.
*/
private parseLockingScript;
/**
* Convert our definitionType to the wallet protocol format ([protocolID, keyID]).
*/
private mapDefinitionTypeToWalletProtocol;
/**
* Convert 'basket'|'protocol'|'certificate' to the basket name used by the wallet.
*/
private mapDefinitionTypeToBasketName;
/**
* Convert 'basket'|'protocol'|'certificate' to the broadcast topic name.
*/
private mapDefinitionTypeToTopic;
/**
* Convert 'basket'|'protocol'|'certificate' to the lookup service name.
*/
private mapDefinitionTypeToServiceName;
}
export declare function deserializeWalletProtocol(str: string): WalletProtocol;
//# sourceMappingURL=RegistryClient.d.ts.map