UNPKG

@bsv/sdk

Version:

BSV Blockchain Software Development Kit

121 lines 5.81 kB
import { WalletInterface, WalletProtocol, OriginatorDomainNameStringUnder250Bytes } from '../wallet/index.js'; import { BroadcastResponse, BroadcastFailure } from '../transaction/index.js'; import { LookupResolver } from '../overlay-tools/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. * - Remove existing registry entries by spending their UTXOs. * - Update existing registry entries. * * 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 readonly originator?; private network; private readonly resolver; private cachedIdentityKey; private readonly acceptDelayedBroadcast; constructor(wallet?: WalletInterface, options?: { acceptDelayedBroadcast?: boolean; resolver?: LookupResolver; }, originator?: OriginatorDomainNameStringUnder250Bytes); /** * Gets the wallet's identity key, caching it after the first call. * @returns The public identity key as a hex string. */ private getIdentityKey; /** * Gets the network, initializing and caching it on first call. * @returns The network type ('mainnet' or 'testnet'). */ private getNetwork; /** * 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[]>; /** * Removes a registry definition by spending its associated UTXO. * * @param registryRecord - The registry record to remove (must have valid txid, outputIndex, and lockingScript). * @returns Broadcast success/failure. */ removeDefinition(registryRecord: RegistryRecord): Promise<BroadcastResponse | BroadcastFailure>; /** * Updates an existing registry record by spending its UTXO and creating a new one with updated data. * * @param registryRecord - The existing registry record to update (must have valid txid, outputIndex, and lockingScript). * @param updatedData - The new definition data to replace the old record. * @returns Broadcast success/failure. */ updateDefinition(registryRecord: RegistryRecord, updatedData: DefinitionData): 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