@hashgraphonline/standards-sdk 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/hcs-10/agent-builder.d.ts +21 -3
- package/dist/es/hcs-10/base-client.d.ts +2 -3
- package/dist/es/hcs-10/fee-config-builder.d.ts +66 -0
- package/dist/es/hcs-10/index.d.ts +1 -0
- package/dist/es/hcs-10/sdk.d.ts +10 -3
- package/dist/es/index.d.ts +1 -0
- package/dist/es/services/index.d.ts +1 -0
- package/dist/es/{utils/mirror-node-utils.d.ts → services/mirror-node.d.ts} +10 -7
- package/dist/es/standards-sdk.es.js +804 -81
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/utils/index.d.ts +0 -1
- package/dist/umd/hcs-10/agent-builder.d.ts +21 -3
- package/dist/umd/hcs-10/base-client.d.ts +2 -3
- package/dist/umd/hcs-10/fee-config-builder.d.ts +66 -0
- package/dist/umd/hcs-10/index.d.ts +1 -0
- package/dist/umd/hcs-10/sdk.d.ts +10 -3
- package/dist/umd/index.d.ts +1 -0
- package/dist/umd/services/index.d.ts +1 -0
- package/dist/umd/{utils/mirror-node-utils.d.ts → services/mirror-node.d.ts} +10 -7
- package/dist/umd/standards-sdk.umd.js +13 -13
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/dist/umd/utils/index.d.ts +0 -1
- package/package.json +2 -1
- package/dist/es/hcs-10/types.d.ts +0 -11
- package/dist/umd/hcs-10/types.d.ts +0 -11
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { InboundTopicType, NetworkType,
|
|
1
|
+
import { InboundTopicType, NetworkType, FeeConfigBuilderInterface, AgentConfiguration } from './types.d';
|
|
2
2
|
import { AIAgentCapability } from '../hcs-11';
|
|
3
3
|
import { AgentMetadata } from './sdk';
|
|
4
4
|
type SocialPlatform = 'twitter' | 'discord' | 'github' | 'website' | 'x' | 'linkedin' | 'youtube' | 'telegram';
|
|
5
|
+
/**
|
|
6
|
+
* AgentBuilder is a builder class for creating agent configurations.
|
|
7
|
+
* It provides a fluent interface for setting various properties of the agent.
|
|
8
|
+
*
|
|
9
|
+
* Example usage:
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const agentBuilder = new AgentBuilder();
|
|
12
|
+
* agentBuilder.setName('My Agent');
|
|
13
|
+
* agentBuilder.setDescription('This is my agent');
|
|
14
|
+
* agentBuilder.setCapabilities([AIAgentCapability.CREATE_CONTENT]);
|
|
15
|
+
* agentBuilder.setModel('gpt-4o');
|
|
16
|
+
* agentBuilder.setCreator('John Doe');
|
|
17
|
+
* agentBuilder.addSocial('twitter', 'JohnDoe');
|
|
18
|
+
* agentBuilder.addProperty('key', 'value');
|
|
19
|
+
* const agentConfig = agentBuilder.build();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
5
23
|
export declare class AgentBuilder {
|
|
6
24
|
private config;
|
|
7
25
|
setName(name: string): AgentBuilder;
|
|
@@ -16,8 +34,8 @@ export declare class AgentBuilder {
|
|
|
16
34
|
setProfilePicture(pfpBuffer: Buffer, pfpFileName: string): AgentBuilder;
|
|
17
35
|
setNetwork(network: NetworkType): AgentBuilder;
|
|
18
36
|
setInboundTopicType(inboundTopicType: InboundTopicType): AgentBuilder;
|
|
19
|
-
setFeeConfig(
|
|
20
|
-
setConnectionFeeConfig(
|
|
37
|
+
setFeeConfig(feeConfigBuilder: FeeConfigBuilderInterface): AgentBuilder;
|
|
38
|
+
setConnectionFeeConfig(feeConfigBuilder: FeeConfigBuilderInterface): AgentBuilder;
|
|
21
39
|
setExistingAccount(accountId: string, privateKey: string): AgentBuilder;
|
|
22
40
|
build(): AgentConfiguration;
|
|
23
41
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger, LogLevel } from '../utils/logger';
|
|
2
2
|
import { Registration } from './registrations';
|
|
3
|
-
import { HederaMirrorNode, TopicInfo, AccountResponse } from '../
|
|
3
|
+
import { HederaMirrorNode, TopicInfo, AccountResponse } from '../services/mirror-node';
|
|
4
4
|
export interface HCS10Config {
|
|
5
5
|
network: 'mainnet' | 'testnet';
|
|
6
6
|
logLevel?: LogLevel;
|
|
@@ -42,8 +42,7 @@ export declare abstract class HCS10BaseClient extends Registration {
|
|
|
42
42
|
getAccountMemo(accountId: string): Promise<string | null>;
|
|
43
43
|
protected getTopicInfoFromMemo(memo: string): Promise<TopicInfo | null>;
|
|
44
44
|
getTopicInfo(accountId: string): Promise<TopicInfo | null>;
|
|
45
|
-
retrieveOutboundConnectTopic(accountId: string): Promise<
|
|
46
|
-
retrieveOutboundConnectTopicFromNetwork(accountId: string): Promise<TopicInfo>;
|
|
45
|
+
retrieveOutboundConnectTopic(accountId: string): Promise<TopicInfo>;
|
|
47
46
|
retrieveOutboundMessages(agentAccountId: string): Promise<HCSMessage[]>;
|
|
48
47
|
hasConnectionCreated(agentAccountId: string, connectionId: number): Promise<boolean>;
|
|
49
48
|
clearCache(): void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { FeeConfigBuilderInterface, TopicFeeConfig } from './types.d';
|
|
2
|
+
/**
|
|
3
|
+
* FeeConfigBuilder provides a fluent interface for creating fee configurations
|
|
4
|
+
* for HCS-10 topics. This makes it easy to configure fees without dealing with
|
|
5
|
+
* the complexity of the underlying fee structure.
|
|
6
|
+
*
|
|
7
|
+
* Example usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const feeConfig = new FeeConfigBuilder()
|
|
10
|
+
* .setHbarAmount(1) // 1 HBAR
|
|
11
|
+
* .setFeeCollector('0.0.12345')
|
|
12
|
+
* .addExemptAccount('0.0.67890')
|
|
13
|
+
* .build();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class FeeConfigBuilder implements FeeConfigBuilderInterface {
|
|
17
|
+
private feeAmount;
|
|
18
|
+
private decimals;
|
|
19
|
+
private feeCollectorAccountId;
|
|
20
|
+
private exemptAccountIds;
|
|
21
|
+
/**
|
|
22
|
+
* Static factory method to create a fee config with HBAR amount in one line
|
|
23
|
+
* @param hbarAmount Amount in HBAR
|
|
24
|
+
* @param collectorAccountId Account that will receive the fees
|
|
25
|
+
* @param exemptAccounts Optional array of exempt account IDs
|
|
26
|
+
* @returns A configured FeeConfigBuilder
|
|
27
|
+
*/
|
|
28
|
+
static forHbar(hbarAmount: number, collectorAccountId: string, exemptAccounts?: string[]): FeeConfigBuilder;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the fee amount in HBAR (convenient method)
|
|
31
|
+
* @param hbarAmount The amount in HBAR (e.g., 5 for 5 HBAR)
|
|
32
|
+
* @returns This builder instance for method chaining
|
|
33
|
+
*/
|
|
34
|
+
setHbarAmount(hbarAmount: number): FeeConfigBuilder;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the amount of the fee to be collected for topic submissions
|
|
37
|
+
* @param amount The fee amount (in tinybars or token units)
|
|
38
|
+
* @param decimals Decimal places for fixed point representation (default: 0)
|
|
39
|
+
* @returns This builder instance for method chaining
|
|
40
|
+
*/
|
|
41
|
+
setFeeAmount(amount: number, decimals?: number): FeeConfigBuilder;
|
|
42
|
+
/**
|
|
43
|
+
* Sets the Hedera account ID that will collect the fees
|
|
44
|
+
* @param accountId The fee collector's account ID (e.g., '0.0.12345')
|
|
45
|
+
* @returns This builder instance for method chaining
|
|
46
|
+
*/
|
|
47
|
+
setFeeCollector(accountId: string): FeeConfigBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Adds an account ID to the list of accounts exempt from paying fees
|
|
50
|
+
* @param accountId The account ID to exempt from fees
|
|
51
|
+
* @returns This builder instance for method chaining
|
|
52
|
+
*/
|
|
53
|
+
addExemptAccount(accountId: string): FeeConfigBuilder;
|
|
54
|
+
/**
|
|
55
|
+
* Adds multiple account IDs to the list of accounts exempt from paying fees
|
|
56
|
+
* @param accountIds Array of account IDs to exempt from fees
|
|
57
|
+
* @returns This builder instance for method chaining
|
|
58
|
+
*/
|
|
59
|
+
addExemptAccounts(accountIds: string[]): FeeConfigBuilder;
|
|
60
|
+
/**
|
|
61
|
+
* Builds and returns the final fee configuration object
|
|
62
|
+
* @throws Error if fee collector account ID is not set or if fee amount is not positive
|
|
63
|
+
* @returns A complete TopicFeeConfig object
|
|
64
|
+
*/
|
|
65
|
+
build(): TopicFeeConfig;
|
|
66
|
+
}
|
package/dist/es/hcs-10/sdk.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { Client, PrivateKey, KeyList, TransactionReceipt, PublicKey } from '@has
|
|
|
2
2
|
import { RetrievedInscriptionResult } from '@kiloscribe/inscription-sdk';
|
|
3
3
|
import { Logger } from '../utils/logger';
|
|
4
4
|
import { HCS10BaseClient } from './base-client';
|
|
5
|
-
import { HCSClientConfig, AgentConfig, CreateAccountResponse, CreateAgentResponse, InscribePfpResponse, StoreHCS11ProfileResponse, AgentRegistrationResult, HandleConnectionRequestResponse, WaitForConnectionConfirmationResponse, GetAccountAndSignerResponse, InboundTopicType, TopicFeeConfig } from './types.d';
|
|
5
|
+
import { HCSClientConfig, AgentConfig, CreateAccountResponse, CreateAgentResponse, InscribePfpResponse, StoreHCS11ProfileResponse, AgentRegistrationResult, HandleConnectionRequestResponse, WaitForConnectionConfirmationResponse, GetAccountAndSignerResponse, InboundTopicType, TopicFeeConfig, FeeConfigBuilderInterface } from './types.d';
|
|
6
6
|
import { AgentBuilder } from './agent-builder';
|
|
7
7
|
export { InboundTopicType } from './types.d';
|
|
8
|
+
export { FeeConfigBuilder } from './fee-config-builder';
|
|
8
9
|
export interface AgentMetadata {
|
|
9
10
|
type: 'autonomous' | 'manual';
|
|
10
11
|
model?: string;
|
|
@@ -43,7 +44,7 @@ export declare class HCS10Client extends HCS10BaseClient {
|
|
|
43
44
|
* @param feeConfig Optional fee configuration for fee-based topics
|
|
44
45
|
* @returns The topic ID of the created inbound topic
|
|
45
46
|
*/
|
|
46
|
-
createInboundTopic(accountId: string, topicType: InboundTopicType, feeConfig?:
|
|
47
|
+
createInboundTopic(accountId: string, topicType: InboundTopicType, feeConfig?: FeeConfigBuilderInterface): Promise<string>;
|
|
47
48
|
/**
|
|
48
49
|
* Creates a new agent with inbound and outbound topics
|
|
49
50
|
* @param builder The agent builder object
|
|
@@ -79,7 +80,7 @@ export declare class HCS10Client extends HCS10BaseClient {
|
|
|
79
80
|
* @param connectionFeeConfig Optional fee configuration for the connection topic
|
|
80
81
|
* @returns Response with connection details
|
|
81
82
|
*/
|
|
82
|
-
handleConnectionRequest(inboundTopicId: string, requestingAccountId: string, connectionRequestId: number, connectionFeeConfig?:
|
|
83
|
+
handleConnectionRequest(inboundTopicId: string, requestingAccountId: string, connectionRequestId: number, connectionFeeConfig?: FeeConfigBuilderInterface): Promise<HandleConnectionRequestResponse>;
|
|
83
84
|
confirmConnection(inboundTopicId: string, connectionTopicId: string, connectedAccountId: string, connectionId: number, operatorId: string, memo: string, submitKey?: PrivateKey): Promise<number>;
|
|
84
85
|
sendMessage(connectionTopicId: string, operatorId: string, data: string, memo?: string, submitKey?: PrivateKey): Promise<void>;
|
|
85
86
|
createTopic(memo: string, adminKey?: boolean | PublicKey | KeyList, submitKey?: boolean | PublicKey | KeyList, feeConfig?: TopicFeeConfig): Promise<string>;
|
|
@@ -105,6 +106,12 @@ export declare class HCS10Client extends HCS10BaseClient {
|
|
|
105
106
|
*/
|
|
106
107
|
waitForConnectionConfirmation(inboundTopicId: string, connectionRequestId: number, maxAttempts?: number, delayMs?: number): Promise<WaitForConnectionConfirmationResponse>;
|
|
107
108
|
getAccountAndSigner(): GetAccountAndSignerResponse;
|
|
109
|
+
/**
|
|
110
|
+
* Checks if a user can submit to a topic and determines if a fee is required
|
|
111
|
+
* @param topicId The topic ID to check
|
|
112
|
+
* @param userAccountId The account ID of the user attempting to submit
|
|
113
|
+
* @returns Object with canSubmit, requiresFee, and optional reason
|
|
114
|
+
*/
|
|
108
115
|
canSubmitToInboundTopic(topicId: string, userAccountId: string): Promise<{
|
|
109
116
|
canSubmit: boolean;
|
|
110
117
|
requiresFee: boolean;
|
package/dist/es/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mirror-node';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey } from '@hashgraph/sdk';
|
|
2
|
-
import { Logger } from '
|
|
2
|
+
import { Logger } from '../utils/logger';
|
|
3
3
|
import { HCSMessage } from '../hcs-10/base-client';
|
|
4
4
|
export interface Balance {
|
|
5
5
|
balance: number;
|
|
@@ -99,20 +99,20 @@ export interface TopicMessagesResponse {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
export interface TopicResponse {
|
|
102
|
-
admin_key:
|
|
102
|
+
admin_key: Key;
|
|
103
103
|
auto_renew_account: string;
|
|
104
104
|
auto_renew_period: number;
|
|
105
105
|
created_timestamp: string;
|
|
106
106
|
custom_fees: CustomFees;
|
|
107
107
|
deleted: boolean;
|
|
108
|
-
fee_exempt_key_list:
|
|
109
|
-
fee_schedule_key:
|
|
108
|
+
fee_exempt_key_list: Key[];
|
|
109
|
+
fee_schedule_key: Key;
|
|
110
110
|
memo: string;
|
|
111
|
-
submit_key:
|
|
111
|
+
submit_key: Key;
|
|
112
112
|
timestamp: Timestamp;
|
|
113
113
|
topic_id: string;
|
|
114
114
|
}
|
|
115
|
-
export interface
|
|
115
|
+
export interface Key {
|
|
116
116
|
_type: string;
|
|
117
117
|
key: string;
|
|
118
118
|
}
|
|
@@ -142,5 +142,8 @@ export declare class HederaMirrorNode {
|
|
|
142
142
|
getTopicFees(topicId: string): Promise<CustomFees | null>;
|
|
143
143
|
getTopicMessages(topicId: string): Promise<HCSMessage[]>;
|
|
144
144
|
requestAccount(accountId: string): Promise<AccountResponse>;
|
|
145
|
-
|
|
145
|
+
checkKeyListAccess(keyBytes: Buffer, userPublicKey: PublicKey): Promise<boolean>;
|
|
146
|
+
private evaluateKeyAccess;
|
|
147
|
+
private evaluateKeyList;
|
|
148
|
+
private compareEd25519Key;
|
|
146
149
|
}
|