@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. https://hol.org
99 lines (98 loc) • 3.04 kB
JavaScript
import { BaseHederaTransactionTool, BaseHederaQueryTool } from "hedera-agent-kit";
class BaseInscriberTransactionTool extends BaseHederaTransactionTool {
constructor(params) {
super(params);
this.namespace = "inscriber";
this.inscriberBuilder = params.inscriberBuilder;
this.contentResolver = params.contentResolver || null;
}
/**
* Override to return the InscriberBuilder
*/
getServiceBuilder() {
return this.inscriberBuilder;
}
/**
* Get content resolver with fallback to registry
*/
getContentResolver() {
return this.contentResolver;
}
/**
* Set entity creation handler for automatic entity storage
*/
setEntityCreationHandler(handler) {
this.onEntityCreated = handler;
}
/**
* Generate a quote for an inscription without executing it
* @param input - The inscription input data
* @param options - Inscription options
* @returns Promise containing the quote result
*/
async generateInscriptionQuote(input, options) {
const network = this.inscriberBuilder["hederaKit"].client.network;
const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
const quoteOptions = {
...options,
quoteOnly: true,
network: networkType
};
const result = await this.inscriberBuilder.inscribe(input, quoteOptions);
if (!result.quote || result.confirmed) {
throw new Error("Failed to generate quote - unexpected response type");
}
return result.result;
}
}
class BaseInscriberQueryTool extends BaseHederaQueryTool {
constructor(params) {
super(params);
this.namespace = "inscriber";
this.inscriberBuilder = params.inscriberBuilder;
this.contentResolver = params.contentResolver || null;
}
/**
* Override to return the InscriberBuilder
*/
getServiceBuilder() {
return this.inscriberBuilder;
}
/**
* Get content resolver with fallback to registry
*/
getContentResolver() {
return this.contentResolver;
}
/**
* Set entity creation handler for automatic entity storage
*/
setEntityCreationHandler(handler) {
this.onEntityCreated = handler;
}
/**
* Generate a quote for an inscription without executing it
* @param input - The inscription input data
* @param options - Inscription options
* @returns Promise containing the quote result
*/
async generateInscriptionQuote(input, options) {
const network = this.inscriberBuilder["hederaKit"].client.network;
const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
const quoteOptions = {
...options,
quoteOnly: true,
network: networkType
};
const result = await this.inscriberBuilder.inscribe(input, quoteOptions);
if (!result.quote || result.confirmed) {
throw new Error("Failed to generate quote - unexpected response type");
}
return result.result;
}
}
export {
BaseInscriberQueryTool,
BaseInscriberTransactionTool
};
//# sourceMappingURL=standards-agent-kit.es35.js.map