UNPKG

@hashgraphonline/standards-sdk

Version:

The Hashgraph Online Standards SDK provides a complete implementation of the Hashgraph Consensus Standards (HCS), giving developers all the tools needed to build applications on Hedera.

134 lines 5.77 kB
import { Logger } from '../utils/logger'; import { HederaMirrorNode } from '../services/mirror-node'; import { HCS2ClientConfig, HCS2Message, HCS2RegisterMessage, HCS2UpdateMessage, HCS2DeleteMessage, HCS2MigrateMessage, HCS2RegistryType, TopicRegistrationResponse, RegistryOperationResponse, TopicRegistry, CreateRegistryOptions, RegisterEntryOptions, UpdateEntryOptions, DeleteEntryOptions, MigrateTopicOptions, QueryRegistryOptions } from './types'; import { TransactionReceipt } from '@hashgraph/sdk'; import { NetworkType } from '../utils/types'; /** * Base client for HCS-2 operations * This abstract class provides shared functionality for both SDK and browser implementations */ export declare abstract class HCS2BaseClient { protected logger: Logger; protected mirrorNode: HederaMirrorNode; protected network: NetworkType; /** * Create a new HCS-2 base client * @param config Client configuration */ constructor(config: HCS2ClientConfig); /** * Create a new registry topic * @param options Registry creation options * @returns Promise resolving to the transaction result */ abstract createRegistry(options: CreateRegistryOptions): Promise<TopicRegistrationResponse>; /** * Register a new entry in the registry * @param registryTopicId The topic ID of the registry * @param options Registration options * @returns Promise resolving to the operation result */ abstract registerEntry(registryTopicId: string, options: RegisterEntryOptions): Promise<RegistryOperationResponse>; /** * Update an existing entry in the registry (indexed registries only) * @param registryTopicId The topic ID of the registry * @param options Update options * @returns Promise resolving to the operation result */ abstract updateEntry(registryTopicId: string, options: UpdateEntryOptions): Promise<RegistryOperationResponse>; /** * Delete an entry from the registry (indexed registries only) * @param registryTopicId The topic ID of the registry * @param options Delete options * @returns Promise resolving to the operation result */ abstract deleteEntry(registryTopicId: string, options: DeleteEntryOptions): Promise<RegistryOperationResponse>; /** * Migrate a registry to a new topic * @param registryTopicId The topic ID of the registry * @param options Migration options * @returns Promise resolving to the operation result */ abstract migrateRegistry(registryTopicId: string, options: MigrateTopicOptions): Promise<RegistryOperationResponse>; /** * Get all entries from a registry * @param topicId The topic ID of the registry * @param options Query options * @returns Promise resolving to the registry information */ abstract getRegistry(topicId: string, options?: QueryRegistryOptions): Promise<TopicRegistry>; /** * Submit a message to a topic * @param topicId The topic ID to submit to * @param payload The message payload * @returns Promise resolving to the transaction receipt */ abstract submitMessage(topicId: string, payload: HCS2Message): Promise<TransactionReceipt>; /** * Determine the registry type from a topic memo * @param memo The topic memo * @returns The registry type or undefined if not found */ protected parseRegistryTypeFromMemo(memo: string): { registryType: HCS2RegistryType; ttl: number; } | undefined; /** * Generate a memo string for a registry topic * @param registryType The registry type * @param ttl The time-to-live in seconds * @returns The memo string */ protected generateRegistryMemo(registryType: HCS2RegistryType, ttl: number): string; /** * Validate a HCS-2 message * @param message The message to validate * @returns Validation result */ protected validateMessage(message: any): { valid: boolean; errors: string[]; }; /** * Create a register message * @param targetTopicId The target topic ID * @param metadata Optional metadata URI * @param memo Optional memo * @returns The register message */ protected createRegisterMessage(targetTopicId: string, metadata?: string, memo?: string): HCS2RegisterMessage; /** * Create an update message * @param targetTopicId The target topic ID * @param uid The unique ID to update * @param metadata Optional metadata URI * @param memo Optional memo * @returns The update message */ protected createUpdateMessage(targetTopicId: string, uid: string, metadata?: string, memo?: string): HCS2UpdateMessage; /** * Create a delete message * @param uid The unique ID to delete * @param memo Optional memo * @returns The delete message */ protected createDeleteMessage(uid: string, memo?: string): HCS2DeleteMessage; /** * Create a migrate message * @param targetTopicId The target topic ID to migrate to * @param metadata Optional metadata URI * @param memo Optional memo * @returns The migrate message */ protected createMigrateMessage(targetTopicId: string, metadata?: string, memo?: string): HCS2MigrateMessage; /** * Parse registry entries from topic messages * @param topicId The topic ID * @param messages The messages to parse * @param registryType The registry type * @param ttl The time-to-live in seconds * @returns The parsed registry */ protected parseRegistryEntries(topicId: string, messages: any[], registryType: HCS2RegistryType, ttl: number): TopicRegistry; } //# sourceMappingURL=base-client.d.ts.map