UNPKG

@hashgraphonline/standards-agent-kit

Version:

A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.

90 lines (89 loc) 2.72 kB
import { BaseServiceBuilder } from "hedera-agent-kit"; import { HCS6Client } from "@hashgraphonline/standards-sdk"; class HCS6Builder extends BaseServiceBuilder { constructor(hederaKit) { super(hederaKit); } /** * Get or create HCS-6 client */ async getHCS6Client() { if (!this.hcs6Client) { const operatorId = this.hederaKit.signer.getAccountId().toString(); const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey() ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw() : ""; const network = this.hederaKit.client.network; const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet"; const config = { network: networkType, operatorId, operatorKey: operatorPrivateKey }; this.hcs6Client = new HCS6Client(config); } return this.hcs6Client; } /** * Create a new HCS-6 dynamic registry * Note: This executes the transaction directly via HCS6Client */ async createRegistry(options = {}) { const client = await this.getHCS6Client(); return await client.createRegistry(options); } /** * Register a new dynamic hashinal entry in an HCS-6 registry */ async registerEntry(registryTopicId, options) { const client = await this.getHCS6Client(); return await client.registerEntry(registryTopicId, options); } /** * Query entries from an HCS-6 registry */ async getRegistry(topicId, options = {}) { const client = await this.getHCS6Client(); return await client.getRegistry(topicId, options); } /** * Create a complete dynamic hashinal with inscription and registry */ async createHashinal(options) { const client = await this.getHCS6Client(); return await client.createHashinal(options); } /** * Register a dynamic hashinal with combined inscription and registry creation * This is the main method for creating and updating dynamic hashinals */ async register(options) { const client = await this.getHCS6Client(); return await client.register(options); } /** * Submit a raw message to an HCS-6 topic */ async submitMessage(topicId, payload) { const client = await this.getHCS6Client(); return await client.submitMessage(topicId, payload); } /** * Get topic info from mirror node */ async getTopicInfo(topicId) { const client = await this.getHCS6Client(); return await client.getTopicInfo(topicId); } /** * Close the HCS-6 client */ async close() { if (this.hcs6Client) { this.hcs6Client.close(); this.hcs6Client = void 0; } } } export { HCS6Builder }; //# sourceMappingURL=standards-agent-kit.es4.js.map