@hashgraphonline/standards-sdk 0.0.51 → 0.0.53
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/base-client.d.ts +58 -8
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/hcs-10/browser.d.ts +6 -19
- package/dist/es/hcs-10/browser.d.ts.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts +10 -28
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +2 -1
- package/dist/es/standards-sdk.es10.js +92 -70
- package/dist/es/standards-sdk.es10.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +3 -4
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +16 -39
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +5 -40
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +37 -35
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +34 -72
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +37 -3
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +78 -2
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +3 -2
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +2 -34
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +2 -33
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +34 -9
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +31 -32
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +12 -0
- package/dist/es/standards-sdk.es112.js.map +1 -0
- package/dist/es/standards-sdk.es113.js +37 -0
- package/dist/es/standards-sdk.es113.js.map +1 -0
- package/dist/es/standards-sdk.es12.js +3 -2
- package/dist/es/standards-sdk.es12.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es16.js +2 -1
- package/dist/es/standards-sdk.es16.js.map +1 -1
- package/dist/es/standards-sdk.es17.js +3 -2
- package/dist/es/standards-sdk.es17.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +1767 -3
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +3 -4167
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +3839 -6296
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +1041 -36
- package/dist/es/standards-sdk.es22.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +5 -48
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +36 -2
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +46 -1039
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +6626 -4
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +2 -101
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +419 -2
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +2 -16
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +120 -4
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +87 -405
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +2 -2
- package/dist/es/standards-sdk.es33.js +15 -119
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +409 -2282
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +2282 -2
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +159 -24
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +4 -2
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +2 -84
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +3 -23
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es40.js +181 -134
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +425 -78
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +21 -170
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +125 -181
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +13 -433
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +22 -18
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +16 -126
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +13 -10
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +37 -22
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +10 -21
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +68 -124
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +54 -14
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +1283 -38
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +143 -13
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +86 -56
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +79 -1284
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +2 -2
- package/dist/es/standards-sdk.es57.js +1 -1
- package/dist/es/standards-sdk.es58.js +19 -789
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +780 -130
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +170 -23
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +140 -23
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +359 -33
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +4 -360
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +178 -5
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +73 -171
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +107 -74
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +45 -107
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +9 -51
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +96 -9
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es70.js +3 -96
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +2 -4
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +113 -2
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +70 -108
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +5 -73
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +4 -5
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +220 -4
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +51 -214
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +67 -56
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +21 -69
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +183 -53
- package/dist/es/standards-sdk.es8.js.map +1 -1
- package/dist/es/standards-sdk.es80.js +25 -19
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +23 -29
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +36 -61
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +27 -45
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +62 -9
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +45 -60
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +10 -6
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +62 -12
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +5 -6
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +13 -43
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/es/standards-sdk.es90.js +7 -2
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +39 -130
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +2 -172
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +134 -30
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +171 -14
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +13 -4
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +13 -4
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +31 -12
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +15 -13
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +3 -15
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/umd/hcs-10/base-client.d.ts +58 -8
- package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
- package/dist/umd/hcs-10/browser.d.ts +6 -19
- package/dist/umd/hcs-10/browser.d.ts.map +1 -1
- package/dist/umd/hcs-10/sdk.d.ts +10 -28
- package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +23 -19
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import Buffer from "./standards-sdk.es19.js";
|
|
1
2
|
import { Client, PrivateKey, AccountCreateTransaction, Hbar, CustomFixedFee, AccountId, KeyList, TopicCreateTransaction, PublicKey, TopicMessageSubmitTransaction, TopicId, Transaction } from "@hashgraph/sdk";
|
|
2
3
|
import { AccountCreationError, TopicCreationError, ConnectionConfirmationError, PayloadSizeError } from "./standards-sdk.es6.js";
|
|
3
|
-
import { InscriptionSDK } from "./standards-sdk.
|
|
4
|
+
import { InscriptionSDK } from "./standards-sdk.es26.js";
|
|
4
5
|
import { Logger } from "./standards-sdk.es13.js";
|
|
5
|
-
import { HCS10BaseClient } from "./standards-sdk.es8.js";
|
|
6
|
-
import { m as mimeTypesExports } from "./standards-sdk.
|
|
6
|
+
import { HCS10BaseClient, Hcs10MemoType } from "./standards-sdk.es8.js";
|
|
7
|
+
import { m as mimeTypesExports } from "./standards-sdk.es20.js";
|
|
7
8
|
import { InboundTopicType } from "./standards-sdk.es18.js";
|
|
8
9
|
import { HCS11Client } from "./standards-sdk.es12.js";
|
|
9
10
|
import { accountIdsToExemptKeys } from "./standards-sdk.es14.js";
|
|
@@ -12,7 +13,8 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
12
13
|
super({
|
|
13
14
|
network: config.network,
|
|
14
15
|
logLevel: config.logLevel,
|
|
15
|
-
prettyPrint: config.prettyPrint
|
|
16
|
+
prettyPrint: config.prettyPrint,
|
|
17
|
+
feeAmount: config.feeAmount
|
|
16
18
|
});
|
|
17
19
|
this.client = config.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
|
|
18
20
|
this.operatorPrivateKey = PrivateKey.fromString(config.operatorPrivateKey);
|
|
@@ -26,7 +28,6 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
26
28
|
module: "HCS-SDK"
|
|
27
29
|
});
|
|
28
30
|
this.guardedRegistryBaseUrl = config.guardedRegistryBaseUrl || "https://moonscape.tech";
|
|
29
|
-
this.feeAmount = config.feeAmount || 5;
|
|
30
31
|
this.hcs11Client = new HCS11Client({
|
|
31
32
|
network: config.network,
|
|
32
33
|
auth: {
|
|
@@ -66,37 +67,53 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
|
-
* Creates an inbound topic
|
|
70
|
-
* @param accountId
|
|
70
|
+
* Creates an inbound topic for an agent
|
|
71
|
+
* @param accountId The account ID associated with the inbound topic
|
|
71
72
|
* @param topicType Type of inbound topic (public, controlled, or fee-based)
|
|
72
|
-
* @param
|
|
73
|
+
* @param ttl Optional Time-To-Live for the topic memo, defaults to 60
|
|
74
|
+
* @param feeConfigBuilder Optional fee configuration builder for fee-based topics
|
|
73
75
|
* @returns The topic ID of the created inbound topic
|
|
74
76
|
*/
|
|
75
|
-
async createInboundTopic(accountId, topicType,
|
|
76
|
-
this.
|
|
77
|
-
|
|
77
|
+
async createInboundTopic(accountId, topicType, ttl = 60, feeConfigBuilder) {
|
|
78
|
+
const memo = this._generateHcs10Memo(Hcs10MemoType.INBOUND, {
|
|
79
|
+
accountId,
|
|
80
|
+
ttl
|
|
81
|
+
});
|
|
82
|
+
let submitKey;
|
|
83
|
+
let feeConfig;
|
|
78
84
|
switch (topicType) {
|
|
79
85
|
case InboundTopicType.PUBLIC:
|
|
80
|
-
|
|
86
|
+
submitKey = false;
|
|
87
|
+
break;
|
|
81
88
|
case InboundTopicType.CONTROLLED:
|
|
82
|
-
|
|
89
|
+
submitKey = true;
|
|
90
|
+
break;
|
|
83
91
|
case InboundTopicType.FEE_BASED:
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
submitKey = true;
|
|
93
|
+
if (!feeConfigBuilder) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
"Fee configuration builder is required for fee-based topics"
|
|
96
|
+
);
|
|
86
97
|
}
|
|
87
|
-
|
|
98
|
+
feeConfig = feeConfigBuilder.build();
|
|
99
|
+
break;
|
|
88
100
|
default:
|
|
89
101
|
throw new Error(`Unsupported inbound topic type: ${topicType}`);
|
|
90
102
|
}
|
|
103
|
+
return this.createTopic(memo, true, submitKey, feeConfig);
|
|
91
104
|
}
|
|
92
105
|
/**
|
|
93
106
|
* Creates a new agent with inbound and outbound topics
|
|
94
107
|
* @param builder The agent builder object
|
|
108
|
+
* @param ttl Optional Time-To-Live for the topic memos, defaults to 60
|
|
95
109
|
* @returns Object with topic IDs
|
|
96
110
|
*/
|
|
97
|
-
async createAgent(builder) {
|
|
111
|
+
async createAgent(builder, ttl = 60) {
|
|
98
112
|
const config = builder.build();
|
|
99
|
-
const
|
|
113
|
+
const outboundMemo = this._generateHcs10Memo(Hcs10MemoType.OUTBOUND, {
|
|
114
|
+
ttl
|
|
115
|
+
});
|
|
116
|
+
const outboundTopicId = await this.createTopic(outboundMemo, true, true);
|
|
100
117
|
this.logger.info(`Created new outbound topic ID: ${outboundTopicId}`);
|
|
101
118
|
const accountId = this.client.operatorAccountId?.toString();
|
|
102
119
|
if (!accountId) {
|
|
@@ -105,9 +122,9 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
105
122
|
const inboundTopicId = await this.createInboundTopic(
|
|
106
123
|
accountId,
|
|
107
124
|
config.inboundTopicType,
|
|
125
|
+
ttl,
|
|
108
126
|
config.inboundTopicType === InboundTopicType.FEE_BASED ? config.feeConfig : void 0
|
|
109
127
|
);
|
|
110
|
-
this.logger.info(`Created new inbound topic ID: ${inboundTopicId}`);
|
|
111
128
|
let pfpTopicId = config.existingPfpTopicId || "";
|
|
112
129
|
if (!pfpTopicId && config.pfpBuffer && config.pfpBuffer.length > 0) {
|
|
113
130
|
this.logger.info("Inscribing new profile picture");
|
|
@@ -116,9 +133,13 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
116
133
|
config.pfpFileName
|
|
117
134
|
);
|
|
118
135
|
pfpTopicId = pfpResult.pfpTopicId;
|
|
119
|
-
this.logger.info(
|
|
136
|
+
this.logger.info(
|
|
137
|
+
`Profile picture inscribed with topic ID: ${pfpTopicId}`
|
|
138
|
+
);
|
|
120
139
|
} else if (config.existingPfpTopicId) {
|
|
121
|
-
this.logger.info(
|
|
140
|
+
this.logger.info(
|
|
141
|
+
`Using existing profile picture with topic ID: ${config.existingPfpTopicId}`
|
|
142
|
+
);
|
|
122
143
|
}
|
|
123
144
|
const profileResult = await this.storeHCS11Profile(
|
|
124
145
|
config.name,
|
|
@@ -134,8 +155,8 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
134
155
|
const profileTopicId = profileResult.profileTopicId;
|
|
135
156
|
this.logger.info(`Profile stored with topic ID: ${profileTopicId}`);
|
|
136
157
|
return {
|
|
137
|
-
outboundTopicId,
|
|
138
158
|
inboundTopicId,
|
|
159
|
+
outboundTopicId,
|
|
139
160
|
pfpTopicId,
|
|
140
161
|
profileTopicId
|
|
141
162
|
};
|
|
@@ -198,12 +219,16 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
198
219
|
this.logger.info("Inscribing profile picture for HCS-11 profile");
|
|
199
220
|
const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);
|
|
200
221
|
if (!pfpResult.success) {
|
|
201
|
-
this.logger.error(
|
|
222
|
+
this.logger.error(
|
|
223
|
+
"Failed to inscribe profile picture, continuing without PFP"
|
|
224
|
+
);
|
|
202
225
|
} else {
|
|
203
226
|
pfpTopicId = pfpResult.pfpTopicId;
|
|
204
227
|
}
|
|
205
228
|
} else if (existingPfpTopicId) {
|
|
206
|
-
this.logger.info(
|
|
229
|
+
this.logger.info(
|
|
230
|
+
`Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`
|
|
231
|
+
);
|
|
207
232
|
}
|
|
208
233
|
const agentType = this.hcs11Client.getAgentTypeFromMetadata({
|
|
209
234
|
type: metadata.type || "autonomous"
|
|
@@ -300,10 +325,15 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
300
325
|
* @param requestingAccountId Requesting account ID
|
|
301
326
|
* @param connectionRequestId Connection request ID
|
|
302
327
|
* @param connectionFeeConfig Optional fee configuration for the connection topic
|
|
328
|
+
* @param ttl Optional ttl parameter with default
|
|
303
329
|
* @returns Response with connection details
|
|
304
330
|
*/
|
|
305
|
-
async handleConnectionRequest(inboundTopicId, requestingAccountId, connectionRequestId, connectionFeeConfig) {
|
|
306
|
-
const memo =
|
|
331
|
+
async handleConnectionRequest(inboundTopicId, requestingAccountId, connectionRequestId, connectionFeeConfig, ttl = 60) {
|
|
332
|
+
const memo = this._generateHcs10Memo(Hcs10MemoType.CONNECTION, {
|
|
333
|
+
ttl,
|
|
334
|
+
inboundTopicId,
|
|
335
|
+
connectionId: connectionRequestId
|
|
336
|
+
});
|
|
307
337
|
this.logger.info(
|
|
308
338
|
`Handling connection request ${connectionRequestId} from ${requestingAccountId}`
|
|
309
339
|
);
|
|
@@ -371,7 +401,16 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
371
401
|
connection_id: connectionId,
|
|
372
402
|
m: memo
|
|
373
403
|
};
|
|
374
|
-
const
|
|
404
|
+
const submissionCheck = await this.canSubmitToTopic(
|
|
405
|
+
inboundTopicId,
|
|
406
|
+
this.client.operatorAccountId?.toString() || ""
|
|
407
|
+
);
|
|
408
|
+
const result = await this.submitPayload(
|
|
409
|
+
inboundTopicId,
|
|
410
|
+
payload,
|
|
411
|
+
submitKey,
|
|
412
|
+
submissionCheck.requiresFee
|
|
413
|
+
);
|
|
375
414
|
const sequenceNumber = result.topicSequenceNumber?.toNumber();
|
|
376
415
|
if (!sequenceNumber) {
|
|
377
416
|
throw new ConnectionConfirmationError(
|
|
@@ -381,7 +420,7 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
381
420
|
return sequenceNumber;
|
|
382
421
|
}
|
|
383
422
|
async sendMessage(connectionTopicId, operatorId, data, memo, submitKey) {
|
|
384
|
-
const submissionCheck = await this.
|
|
423
|
+
const submissionCheck = await this.canSubmitToTopic(
|
|
385
424
|
connectionTopicId,
|
|
386
425
|
this.client.operatorAccountId?.toString() || ""
|
|
387
426
|
);
|
|
@@ -462,18 +501,6 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
462
501
|
const topicId = receipt.topicId.toString();
|
|
463
502
|
return topicId;
|
|
464
503
|
}
|
|
465
|
-
async submitMessage(topicId, message, submitKey) {
|
|
466
|
-
const submissionCheck = await this.canSubmitToInboundTopic(
|
|
467
|
-
topicId,
|
|
468
|
-
this.client.operatorAccountId?.toString() || ""
|
|
469
|
-
);
|
|
470
|
-
return this.submitPayload(
|
|
471
|
-
topicId,
|
|
472
|
-
message,
|
|
473
|
-
submitKey,
|
|
474
|
-
submissionCheck.requiresFee
|
|
475
|
-
);
|
|
476
|
-
}
|
|
477
504
|
async submitPayload(topicId, payload, submitKey, requiresFee = false) {
|
|
478
505
|
const message = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
479
506
|
const payloadSizeInBytes = Buffer.byteLength(message, "utf8");
|
|
@@ -508,7 +535,7 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
508
535
|
return receipt;
|
|
509
536
|
}
|
|
510
537
|
async submitConnectionRequest(inboundTopicId, requestingAccountId, operatorId, memo) {
|
|
511
|
-
const submissionCheck = await this.
|
|
538
|
+
const submissionCheck = await this.canSubmitToTopic(
|
|
512
539
|
inboundTopicId,
|
|
513
540
|
requestingAccountId
|
|
514
541
|
);
|
|
@@ -549,26 +576,6 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
549
576
|
);
|
|
550
577
|
return response;
|
|
551
578
|
}
|
|
552
|
-
async recordOutboundConnectionConfirmation({
|
|
553
|
-
outboundTopicId,
|
|
554
|
-
connectionRequestId,
|
|
555
|
-
confirmedRequestId,
|
|
556
|
-
connectionTopicId,
|
|
557
|
-
operatorId,
|
|
558
|
-
memo
|
|
559
|
-
}) {
|
|
560
|
-
const payload = {
|
|
561
|
-
p: "hcs-10",
|
|
562
|
-
op: "connection_created",
|
|
563
|
-
connection_topic_id: connectionTopicId,
|
|
564
|
-
outbound_topic_id: outboundTopicId,
|
|
565
|
-
confirmed_request_id: confirmedRequestId,
|
|
566
|
-
connection_request_id: connectionRequestId,
|
|
567
|
-
operator_id: operatorId,
|
|
568
|
-
m: memo
|
|
569
|
-
};
|
|
570
|
-
return await this.submitPayload(outboundTopicId, payload);
|
|
571
|
-
}
|
|
572
579
|
async inscribeFile(buffer, fileName) {
|
|
573
580
|
this.logger.info("Inscribing file");
|
|
574
581
|
if (!this.client.operatorAccountId) {
|
|
@@ -669,69 +676,6 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
669
676
|
signer: this.operatorPrivateKey
|
|
670
677
|
};
|
|
671
678
|
}
|
|
672
|
-
/**
|
|
673
|
-
* Checks if a user can submit to a topic and determines if a fee is required
|
|
674
|
-
* @param topicId The topic ID to check
|
|
675
|
-
* @param userAccountId The account ID of the user attempting to submit
|
|
676
|
-
* @returns Object with canSubmit, requiresFee, and optional reason
|
|
677
|
-
*/
|
|
678
|
-
async canSubmitToInboundTopic(topicId, userAccountId) {
|
|
679
|
-
try {
|
|
680
|
-
const topicInfo = await this.mirrorNode.getTopicInfo(topicId);
|
|
681
|
-
if (!topicInfo) {
|
|
682
|
-
return {
|
|
683
|
-
canSubmit: false,
|
|
684
|
-
requiresFee: false,
|
|
685
|
-
reason: "Topic does not exist"
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
if (!topicInfo.submit_key?.key) {
|
|
689
|
-
return { canSubmit: true, requiresFee: false };
|
|
690
|
-
}
|
|
691
|
-
try {
|
|
692
|
-
const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);
|
|
693
|
-
if (topicInfo.submit_key._type === "ProtobufEncoded") {
|
|
694
|
-
const keyBytes = Buffer.from(topicInfo.submit_key.key, "hex");
|
|
695
|
-
const hasAccess = await this.mirrorNode.checkKeyListAccess(
|
|
696
|
-
keyBytes,
|
|
697
|
-
userPublicKey
|
|
698
|
-
);
|
|
699
|
-
if (hasAccess) {
|
|
700
|
-
return { canSubmit: true, requiresFee: false };
|
|
701
|
-
}
|
|
702
|
-
} else {
|
|
703
|
-
const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);
|
|
704
|
-
if (userPublicKey.toString() === topicSubmitKey.toString()) {
|
|
705
|
-
return { canSubmit: true, requiresFee: false };
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
} catch (error) {
|
|
709
|
-
this.logger.error(
|
|
710
|
-
`Key validation error: ${error instanceof Error ? error.message : String(error)}`
|
|
711
|
-
);
|
|
712
|
-
}
|
|
713
|
-
if (topicInfo.fee_schedule_key?.key && topicInfo.custom_fees?.fixed_fees?.length > 0) {
|
|
714
|
-
return {
|
|
715
|
-
canSubmit: true,
|
|
716
|
-
requiresFee: true,
|
|
717
|
-
reason: "Requires fee payment via HIP-991"
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
return {
|
|
721
|
-
canSubmit: false,
|
|
722
|
-
requiresFee: false,
|
|
723
|
-
reason: "User does not have submit permission for this topic"
|
|
724
|
-
};
|
|
725
|
-
} catch (error) {
|
|
726
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
727
|
-
this.logger.error(`Topic submission validation error: ${errorMessage}`);
|
|
728
|
-
return {
|
|
729
|
-
canSubmit: false,
|
|
730
|
-
requiresFee: false,
|
|
731
|
-
reason: `Error: ${errorMessage}`
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
679
|
/**
|
|
736
680
|
* Creates and registers an agent with a Guarded registry.
|
|
737
681
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es5.js","sources":["../../src/hcs-10/sdk.ts"],"sourcesContent":["import {\n Client,\n AccountCreateTransaction,\n PrivateKey,\n Hbar,\n KeyList,\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n TopicId,\n Transaction,\n TransactionResponse,\n TransactionReceipt,\n PublicKey,\n AccountId,\n CustomFixedFee,\n} from '@hashgraph/sdk';\nimport {\n PayloadSizeError,\n AccountCreationError,\n TopicCreationError,\n ConnectionConfirmationError,\n} from './errors';\nimport {\n InscriptionSDK,\n RetrievedInscriptionResult,\n} from '@kiloscribe/inscription-sdk';\nimport { Logger, LogLevel } from '../utils/logger';\nimport { HCS10BaseClient } from './base-client';\nimport * as mime from 'mime-types';\nimport {\n HCSClientConfig,\n AgentConfig,\n CreateAccountResponse,\n CreateAgentResponse,\n InscribePfpResponse,\n StoreHCS11ProfileResponse,\n AgentRegistrationResult,\n HandleConnectionRequestResponse,\n WaitForConnectionConfirmationResponse,\n GetAccountAndSignerResponse,\n InboundTopicType,\n TopicFeeConfig,\n FeeConfigBuilderInterface,\n AgentCreationState,\n} from './types';\nimport { HCS11Client } from '../hcs-11';\nimport { AgentBuilder } from './agent-builder';\nimport { accountIdsToExemptKeys } from '../utils/topic-fee-utils';\n\nexport { InboundTopicType } from './types';\nexport { FeeConfigBuilder } from './fee-config-builder';\n\nexport interface AgentMetadata {\n type: 'autonomous' | 'manual';\n model?: string;\n socials?: {\n twitter?: string;\n discord?: string;\n github?: string;\n website?: string;\n x?: string;\n linkedin?: string;\n youtube?: string;\n telegram?: string;\n };\n creator?: string;\n properties?: Record<string, any>;\n}\n\n/**\n * Progress report data for registration operations\n */\nexport interface RegistrationProgressData {\n stage: 'preparing' | 'submitting' | 'confirming' | 'verifying' | 'completed';\n message: string;\n progressPercent?: number;\n details?: Record<string, any>;\n}\n\n/**\n * Progress callback function type for registration operations\n */\nexport type RegistrationProgressCallback = (\n data: RegistrationProgressData\n) => void;\n\nexport class HCS10Client extends HCS10BaseClient {\n private client: Client;\n private operatorPrivateKey: PrivateKey;\n protected declare network: string;\n protected declare logger: Logger;\n protected guardedRegistryBaseUrl: string;\n private hcs11Client: HCS11Client;\n private feeAmount: number;\n\n constructor(config: HCSClientConfig) {\n super({\n network: config.network,\n logLevel: config.logLevel,\n prettyPrint: config.prettyPrint\n });\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.operatorPrivateKey = PrivateKey.fromString(config.operatorPrivateKey);\n this.network = config.network;\n this.client.setOperator(\n config.operatorId,\n this.operatorPrivateKey.toString()\n );\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-SDK',\n });\n this.guardedRegistryBaseUrl =\n config.guardedRegistryBaseUrl || 'https://moonscape.tech';\n this.feeAmount = config.feeAmount || 5;\n\n this.hcs11Client = new HCS11Client({\n network: config.network,\n auth: {\n operatorId: config.operatorId,\n privateKey: config.operatorPrivateKey,\n },\n logLevel: config.logLevel,\n });\n }\n\n public getClient() {\n return this.client;\n }\n\n /**\n * Creates a new Hedera account\n * @returns Object with account ID and private key\n */\n async createAccount(): Promise<CreateAccountResponse> {\n this.logger.info('Creating new account');\n const newKey = PrivateKey.generate();\n\n const accountTransaction = new AccountCreateTransaction()\n .setKey(newKey.publicKey)\n .setInitialBalance(new Hbar(10));\n\n this.logger.debug('Executing account creation transaction');\n const accountResponse = await accountTransaction.execute(this.client);\n const accountReceipt = await accountResponse.getReceipt(this.client);\n const newAccountId = accountReceipt.accountId;\n\n if (!newAccountId) {\n this.logger.error('Account creation failed: accountId is null');\n throw new AccountCreationError(\n 'Failed to create account: accountId is null'\n );\n }\n\n this.logger.info(\n `Account created successfully: ${newAccountId.toString()}`\n );\n return {\n accountId: newAccountId.toString(),\n privateKey: newKey.toString(),\n };\n }\n\n /**\n * Creates an inbound topic with the specified configuration\n * @param accountId Account ID associated with the topic\n * @param topicType Type of inbound topic (public, controlled, or fee-based)\n * @param feeConfig Optional fee configuration for fee-based topics\n * @returns The topic ID of the created inbound topic\n */\n async createInboundTopic(\n accountId: string,\n topicType: InboundTopicType,\n feeConfig?: FeeConfigBuilderInterface\n ): Promise<string> {\n this.logger.info(`Creating ${topicType} inbound topic`);\n const memo = `hcs-10:0:60:0:${accountId}`;\n\n switch (topicType) {\n case InboundTopicType.PUBLIC:\n return this.createTopic(memo, true, false);\n\n case InboundTopicType.CONTROLLED:\n return this.createTopic(memo, true, true);\n\n case InboundTopicType.FEE_BASED:\n if (!feeConfig) {\n throw new Error('Fee configuration is required for fee-based topics');\n }\n return this.createTopic(memo, true, true, feeConfig.build());\n\n default:\n throw new Error(`Unsupported inbound topic type: ${topicType}`);\n }\n }\n\n /**\n * Creates a new agent with inbound and outbound topics\n * @param builder The agent builder object\n * @returns Object with topic IDs\n */\n async createAgent(builder: AgentBuilder): Promise<CreateAgentResponse> {\n const config = builder.build();\n const outboundTopicId = await this.createTopic('hcs-10:0:60:1', true, true);\n this.logger.info(`Created new outbound topic ID: ${outboundTopicId}`);\n\n const accountId = this.client.operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n const inboundTopicId = await this.createInboundTopic(\n accountId,\n config.inboundTopicType,\n config.inboundTopicType === InboundTopicType.FEE_BASED\n ? config.feeConfig\n : undefined\n );\n this.logger.info(`Created new inbound topic ID: ${inboundTopicId}`);\n\n let pfpTopicId = config.existingPfpTopicId || '';\n \n if (!pfpTopicId && config.pfpBuffer && config.pfpBuffer.length > 0) {\n this.logger.info('Inscribing new profile picture');\n const pfpResult = await this.inscribePfp(\n config.pfpBuffer,\n config.pfpFileName\n );\n pfpTopicId = pfpResult.pfpTopicId;\n this.logger.info(`Profile picture inscribed with topic ID: ${pfpTopicId}`);\n } else if (config.existingPfpTopicId) {\n this.logger.info(`Using existing profile picture with topic ID: ${config.existingPfpTopicId}`);\n }\n\n const profileResult = await this.storeHCS11Profile(\n config.name,\n config.description,\n inboundTopicId,\n outboundTopicId,\n config.capabilities,\n config.metadata,\n config.pfpBuffer && config.pfpBuffer.length > 0 ? config.pfpBuffer : undefined,\n config.pfpFileName,\n config.existingPfpTopicId\n );\n const profileTopicId = profileResult.profileTopicId;\n this.logger.info(`Profile stored with topic ID: ${profileTopicId}`);\n\n return {\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n };\n }\n\n /**\n * Inscribes a profile picture to Hedera\n * @param buffer Profile picture buffer\n * @param fileName Filename\n * @returns Response with topic ID and transaction ID\n */\n async inscribePfp(\n buffer: Buffer,\n fileName: string\n ): Promise<InscribePfpResponse> {\n try {\n this.logger.info('Inscribing profile picture using HCS-11 client');\n\n const imageResult = await this.hcs11Client.inscribeImage(\n buffer,\n fileName\n );\n\n if (!imageResult.success) {\n this.logger.error(\n `Failed to inscribe profile picture: ${imageResult.error}`\n );\n throw new Error(\n imageResult?.error || 'Failed to inscribe profile picture'\n );\n }\n\n this.logger.info(\n `Successfully inscribed profile picture with topic ID: ${imageResult.imageTopicId}`\n );\n return {\n pfpTopicId: imageResult.imageTopicId,\n transactionId: imageResult.transactionId,\n success: true,\n };\n } catch (error: any) {\n this.logger.error(`Error inscribing profile picture: ${error.message}`);\n return {\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n /**\n * Stores an HCS-11 profile for an agent\n * @param agentName Agent name\n * @param agentDescription Agent description\n * @param inboundTopicId Inbound topic ID\n * @param outboundTopicId Outbound topic ID\n * @param capabilities Agent capability tags\n * @param metadata Additional metadata\n * @param pfpBuffer Optional profile picture buffer\n * @param pfpFileName Optional profile picture filename\n * @returns Response with topic IDs and transaction ID\n */\n async storeHCS11Profile(\n agentName: string,\n agentDescription: string,\n inboundTopicId: string,\n outboundTopicId: string,\n capabilities: number[] = [],\n metadata: AgentMetadata,\n pfpBuffer?: Buffer,\n pfpFileName?: string,\n existingPfpTopicId?: string\n ): Promise<StoreHCS11ProfileResponse> {\n try {\n let pfpTopicId = existingPfpTopicId || '';\n \n if (!pfpTopicId && pfpBuffer && pfpFileName) {\n this.logger.info('Inscribing profile picture for HCS-11 profile');\n const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);\n if (!pfpResult.success) {\n this.logger.error('Failed to inscribe profile picture, continuing without PFP');\n } else {\n pfpTopicId = pfpResult.pfpTopicId;\n }\n } else if (existingPfpTopicId) {\n this.logger.info(`Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`);\n }\n\n const agentType = this.hcs11Client.getAgentTypeFromMetadata({\n type: metadata.type || 'autonomous',\n } as AgentMetadata);\n\n const formattedSocials = metadata.socials\n ? Object.entries(metadata.socials)\n .filter(([_, handle]) => handle)\n .map(([platform, handle]) => ({\n platform: platform === 'x' ? 'twitter' : platform,\n handle,\n }))\n : undefined;\n\n const profile = this.hcs11Client.createAIAgentProfile(\n agentName,\n agentType,\n capabilities,\n metadata.model || 'unknown',\n {\n alias: agentName.toLowerCase().replace(/\\s+/g, '_'),\n bio: agentDescription,\n profileImage: pfpTopicId ? `hcs://1/${pfpTopicId}` : undefined,\n socials: formattedSocials,\n properties: metadata.properties,\n inboundTopicId,\n outboundTopicId,\n creator: metadata.creator,\n }\n );\n\n const profileResult = await this.hcs11Client.createAndInscribeProfile(\n profile,\n true\n );\n\n if (!profileResult.success) {\n this.logger.error(`Failed to inscribe profile: ${profileResult.error}`);\n throw new Error(profileResult.error || 'Failed to inscribe profile');\n }\n\n this.logger.info(\n `Profile inscribed with topic ID: ${profileResult.profileTopicId}, transaction ID: ${profileResult.transactionId}`\n );\n\n return {\n profileTopicId: profileResult.profileTopicId,\n pfpTopicId,\n transactionId: profileResult.transactionId,\n success: true,\n };\n } catch (error: any) {\n this.logger.error(`Error storing HCS-11 profile: ${error.message}`);\n return {\n profileTopicId: '',\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n private async setupFees(\n transaction: TopicCreateTransaction,\n feeConfig: TopicFeeConfig,\n additionalExemptAccounts: string[] = []\n ): Promise<void> {\n if (!this.client.operatorPublicKey) {\n return;\n }\n\n this.logger.info('Setting up topic with custom fees');\n\n const customFee = new CustomFixedFee()\n .setAmount(Number(feeConfig.feeAmount.amount))\n .setFeeCollectorAccountId(\n AccountId.fromString(feeConfig.feeCollectorAccountId)\n );\n\n let exemptAccountIds = [\n ...(feeConfig.exemptAccounts || []),\n ...additionalExemptAccounts,\n ];\n\n console.log('exemptAccountIds', exemptAccountIds);\n\n if (exemptAccountIds.length > 0) {\n const uniqueExemptAccountIds = Array.from(new Set(exemptAccountIds));\n const filteredExemptAccounts = uniqueExemptAccountIds.filter(\n (account) => account !== this.client.operatorAccountId?.toString()\n );\n\n let exemptKeys: PublicKey[] = [];\n if (filteredExemptAccounts.length > 0) {\n try {\n exemptKeys = await accountIdsToExemptKeys(\n filteredExemptAccounts,\n this.network,\n this.logger\n );\n } catch (error) {\n this.logger.warn(\n `Error getting exempt keys: ${error}, continuing without exempt keys`\n );\n }\n }\n\n if (exemptKeys.length > 0) {\n transaction.setFeeExemptKeys(exemptKeys);\n }\n }\n\n transaction\n .setFeeScheduleKey(this.client.operatorPublicKey)\n .setCustomFees([customFee]);\n }\n\n /**\n * Handles a connection request from another account\n * @param inboundTopicId Inbound topic ID\n * @param requestingAccountId Requesting account ID\n * @param connectionRequestId Connection request ID\n * @param connectionFeeConfig Optional fee configuration for the connection topic\n * @returns Response with connection details\n */\n async handleConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n connectionRequestId: number,\n connectionFeeConfig?: FeeConfigBuilderInterface\n ): Promise<HandleConnectionRequestResponse> {\n const memo = `hcs-10:${inboundTopicId}:${connectionRequestId}`;\n this.logger.info(\n `Handling connection request ${connectionRequestId} from ${requestingAccountId}`\n );\n\n const accountId = this.getClient().operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n let requesterKey = await this.mirrorNode.getPublicKey(requestingAccountId);\n const accountKey = await this.mirrorNode.getPublicKey(accountId);\n\n if (!accountKey) {\n throw new Error('Failed to retrieve public key');\n }\n\n const thresholdKey = new KeyList([accountKey, requesterKey], 1);\n\n let connectionTopicId: string;\n\n try {\n if (connectionFeeConfig) {\n const feeConfig = connectionFeeConfig.build();\n const modifiedFeeConfig = {\n ...feeConfig,\n exemptAccounts: [...(feeConfig.exemptAccounts || [])],\n };\n\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey,\n modifiedFeeConfig\n );\n } else {\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey\n );\n }\n\n this.logger.info(`Created new connection topic ID: ${connectionTopicId}`);\n } catch (error) {\n this.logger.error(`Failed to create connection topic: ${error}`);\n throw new TopicCreationError(\n `Failed to create connection topic: ${error}`\n );\n }\n\n const operatorId = `${inboundTopicId}@${accountId}`;\n\n const confirmedConnectionSequenceNumber = await this.confirmConnection(\n inboundTopicId,\n connectionTopicId,\n requestingAccountId,\n connectionRequestId,\n operatorId,\n 'Connection accepted. Looking forward to collaborating!'\n );\n\n return {\n connectionTopicId,\n confirmedConnectionSequenceNumber,\n operatorId,\n };\n }\n\n async confirmConnection(\n inboundTopicId: string,\n connectionTopicId: string,\n connectedAccountId: string,\n connectionId: number,\n operatorId: string,\n memo: string,\n submitKey?: PrivateKey\n ): Promise<number> {\n this.logger.info(`Confirming connection with ID ${connectionId}`);\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n connected_account_id: connectedAccountId,\n operator_id: operatorId,\n connection_id: connectionId,\n m: memo,\n };\n\n const result = await this.submitPayload(inboundTopicId, payload, submitKey);\n const sequenceNumber = result.topicSequenceNumber?.toNumber();\n\n if (!sequenceNumber) {\n throw new ConnectionConfirmationError(\n 'Failed to confirm connection: sequence number is null'\n );\n }\n\n return sequenceNumber;\n }\n\n async sendMessage(\n connectionTopicId: string,\n operatorId: string,\n data: string,\n memo?: string,\n submitKey?: PrivateKey\n ): Promise<void> {\n const submissionCheck = await this.canSubmitToInboundTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const payload = {\n p: 'hcs-10',\n op: 'message',\n operator_id: operatorId,\n data,\n m: memo,\n };\n\n const payloadString = JSON.stringify(payload);\n const isLargePayload = Buffer.from(payloadString).length > 1000;\n\n if (isLargePayload) {\n this.logger.info(\n 'Message payload exceeds 1000 bytes, storing via inscription'\n );\n try {\n const contentBuffer = Buffer.from(data);\n const fileName = `message-${Date.now()}.json`;\n const inscriptionResult = await this.inscribeFile(\n contentBuffer,\n fileName\n );\n\n if (inscriptionResult?.topic_id) {\n payload.data = `hcs://1/${inscriptionResult.topic_id}`;\n this.logger.info(\n `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`\n );\n } else {\n throw new Error('Failed to inscribe large message content');\n }\n } catch (error) {\n this.logger.error('Error inscribing large message:', error);\n throw new Error(\n `Failed to handle large message: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n }\n\n this.logger.info('Submitting message to connection topic', payload);\n await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n }\n\n async createTopic(\n memo: string,\n adminKey?: boolean | PublicKey | KeyList,\n submitKey?: boolean | PublicKey | KeyList,\n feeConfig?: TopicFeeConfig\n ): Promise<string> {\n this.logger.info('Creating topic');\n const transaction = new TopicCreateTransaction().setTopicMemo(memo);\n\n if (adminKey) {\n if (\n typeof adminKey === 'boolean' &&\n adminKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setAdminKey(this.client.operatorPublicKey);\n transaction.setAutoRenewAccountId(this.client.operatorAccountId!);\n } else if (adminKey instanceof PublicKey || adminKey instanceof KeyList) {\n transaction.setAdminKey(adminKey);\n if (this.client.operatorAccountId) {\n transaction.setAutoRenewAccountId(this.client.operatorAccountId);\n }\n }\n }\n\n if (submitKey) {\n if (\n typeof submitKey === 'boolean' &&\n submitKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setSubmitKey(this.client.operatorPublicKey);\n } else if (\n submitKey instanceof PublicKey ||\n submitKey instanceof KeyList\n ) {\n transaction.setSubmitKey(submitKey);\n }\n }\n\n if (feeConfig) {\n await this.setupFees(transaction, feeConfig);\n }\n\n this.logger.debug('Executing topic creation transaction');\n const txResponse = await transaction.execute(this.client);\n const receipt = await txResponse.getReceipt(this.client);\n\n if (!receipt.topicId) {\n this.logger.error('Failed to create topic: topicId is null');\n throw new Error('Failed to create topic: topicId is null');\n }\n\n const topicId = receipt.topicId.toString();\n return topicId;\n }\n\n async submitMessage(\n topicId: string,\n message: string,\n submitKey?: PrivateKey\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToInboundTopic(\n topicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n return this.submitPayload(\n topicId,\n message,\n submitKey,\n submissionCheck.requiresFee\n );\n }\n\n private async submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee: boolean = false\n ): Promise<TransactionReceipt> {\n const message =\n typeof payload === 'string' ? payload : JSON.stringify(payload);\n\n const payloadSizeInBytes = Buffer.byteLength(message, 'utf8');\n if (payloadSizeInBytes > 1000) {\n throw new PayloadSizeError(\n 'Payload size exceeds 1000 bytes limit',\n payloadSizeInBytes\n );\n }\n\n const transaction = new TopicMessageSubmitTransaction()\n .setTopicId(TopicId.fromString(topicId))\n .setMessage(message);\n\n if (requiresFee) {\n this.logger.info(\n 'Topic requires fee payment, setting max transaction fee'\n );\n transaction.setMaxTransactionFee(new Hbar(this.feeAmount));\n transaction.setTransactionMemo('HIP-991 Fee Payment');\n }\n\n let transactionResponse: TransactionResponse;\n if (submitKey) {\n transaction.freezeWith(this.client);\n const signedTransaction = await transaction.sign(submitKey);\n transactionResponse = await signedTransaction.execute(this.client);\n } else {\n transactionResponse = await transaction.execute(this.client);\n }\n\n const receipt = await transactionResponse.getReceipt(this.client);\n if (!receipt) {\n this.logger.error('Failed to submit message: receipt is null');\n throw new Error('Failed to submit message: receipt is null');\n }\n this.logger.info('Message submitted successfully');\n return receipt;\n }\n\n async submitConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n operatorId: string,\n memo: string\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToInboundTopic(\n inboundTopicId,\n requestingAccountId\n );\n\n if (!submissionCheck.canSubmit) {\n throw new Error(`Cannot submit to topic: ${submissionCheck.reason}`);\n }\n\n const connectionRequestMessage = {\n p: 'hcs-10',\n op: 'connection_request',\n operator_id: operatorId,\n memo: memo,\n };\n\n const requiresFee = submissionCheck.requiresFee;\n const response = await this.submitPayload(\n inboundTopicId,\n connectionRequestMessage,\n undefined,\n requiresFee\n );\n\n this.logger.info(\n `Submitted connection request to topic ID: ${inboundTopicId}`\n );\n\n const outboundTopic = await this.retrieveOutboundConnectTopic(\n requestingAccountId\n );\n\n const responseSequenceNumber = response.topicSequenceNumber?.toNumber();\n\n if (!responseSequenceNumber) {\n throw new Error('Failed to get response sequence number');\n }\n\n await this.submitPayload(\n outboundTopic.outboundTopic,\n {\n ...connectionRequestMessage,\n outbound_topic_id: outboundTopic.outboundTopic,\n connection_request_id: responseSequenceNumber,\n },\n this.operatorPrivateKey\n );\n\n return response;\n }\n\n async recordOutboundConnectionConfirmation({\n outboundTopicId,\n connectionRequestId,\n confirmedRequestId,\n connectionTopicId,\n operatorId,\n memo,\n }: {\n outboundTopicId: string;\n connectionRequestId: number;\n confirmedRequestId: number;\n connectionTopicId: string;\n operatorId: string;\n memo: string;\n }) {\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n outbound_topic_id: outboundTopicId,\n confirmed_request_id: confirmedRequestId,\n connection_request_id: connectionRequestId,\n operator_id: operatorId,\n m: memo,\n };\n\n return await this.submitPayload(outboundTopicId, payload);\n }\n\n async inscribeFile(\n buffer: Buffer,\n fileName: string\n ): Promise<RetrievedInscriptionResult> {\n this.logger.info('Inscribing file');\n if (!this.client.operatorAccountId) {\n this.logger.error('Operator account ID is not set');\n throw new Error('Operator account ID is not set');\n }\n\n if (!this.operatorPrivateKey) {\n this.logger.error('Operator private key is not set');\n throw new Error('Operator private key is not set');\n }\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const sdk = await InscriptionSDK.createWithAuth({\n type: 'server',\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n });\n\n const result = await sdk.inscribeAndExecute(\n {\n file: {\n type: 'base64',\n base64: buffer.toString('base64'),\n fileName,\n mimeType,\n },\n holderId: this.client.operatorAccountId.toString(),\n mode: 'file',\n network: this.network as 'testnet' | 'mainnet',\n },\n {\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n }\n );\n\n if (!result.transactionId || !result.jobId) {\n this.logger.error('Failed to inscribe, no transaction ID or job ID.');\n throw new Error('Failed to inscribe, no transaction ID or job ID.');\n }\n\n if (result.transactionId && result.jobId) {\n this.logger.info(\n `Transaction ID: ${result.transactionId}, Job ID: ${result.jobId}`\n );\n }\n\n const status = await sdk.waitForInscription(result.jobId, 30, 4000, true);\n return status;\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n (m) => m.op === 'connection_created'\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n this.logger.info('Connection confirmation found');\n return {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`\n );\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`\n );\n }\n\n getAccountAndSigner(): GetAccountAndSignerResponse {\n return {\n accountId: this.client.operatorAccountId!.toString()!,\n signer: this.operatorPrivateKey,\n };\n }\n\n /**\n * Checks if a user can submit to a topic and determines if a fee is required\n * @param topicId The topic ID to check\n * @param userAccountId The account ID of the user attempting to submit\n * @returns Object with canSubmit, requiresFee, and optional reason\n */\n async canSubmitToInboundTopic(\n topicId: string,\n userAccountId: string\n ): Promise<{ canSubmit: boolean; requiresFee: boolean; reason?: string }> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'Topic does not exist',\n };\n }\n\n if (!topicInfo.submit_key?.key) {\n return { canSubmit: true, requiresFee: false };\n }\n\n try {\n const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);\n\n if (topicInfo.submit_key._type === 'ProtobufEncoded') {\n const keyBytes = Buffer.from(topicInfo.submit_key.key, 'hex');\n const hasAccess = await this.mirrorNode.checkKeyListAccess(\n keyBytes,\n userPublicKey\n );\n\n if (hasAccess) {\n return { canSubmit: true, requiresFee: false };\n }\n } else {\n const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);\n if (userPublicKey.toString() === topicSubmitKey.toString()) {\n return { canSubmit: true, requiresFee: false };\n }\n }\n } catch (error) {\n this.logger.error(\n `Key validation error: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n\n if (\n topicInfo.fee_schedule_key?.key &&\n topicInfo.custom_fees?.fixed_fees?.length > 0\n ) {\n return {\n canSubmit: true,\n requiresFee: true,\n reason: 'Requires fee payment via HIP-991',\n };\n }\n\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'User does not have submit permission for this topic',\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger.error(`Topic submission validation error: ${errorMessage}`);\n return {\n canSubmit: false,\n requiresFee: false,\n reason: `Error: ${errorMessage}`,\n };\n }\n }\n\n /**\n * Creates and registers an agent with a Guarded registry.\n *\n * This function performs the following steps:\n * 1. Creates a new account if no existing account is provided.\n * 2. Initializes an HCS10 client with the new account.\n * 3. Creates an agent on the client.\n * 4. Registers the agent with the Hashgraph Online Guarded Registry.\n *\n * @param builder The agent builder object\n * @param options Optional configuration including progress callback and state management\n * @returns Agent registration result\n */\n async createAndRegisterAgent(\n builder: AgentBuilder,\n options?: {\n baseUrl?: string;\n progressCallback?: RegistrationProgressCallback;\n existingState?: AgentCreationState;\n }\n ): Promise<AgentRegistrationResult> {\n try {\n const config = builder.build();\n const progressCallback = options?.progressCallback;\n const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;\n let state = options?.existingState || undefined;\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: { state },\n });\n }\n\n const account = config.existingAccount || (await this.createAccount());\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created account or using existing account',\n progressPercent: 20,\n details: { state, account },\n });\n }\n\n const agentClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: PrivateKey.fromString(\n account.privateKey\n ).publicKey.toString(),\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Initialized agent client',\n progressPercent: 30,\n details: { state },\n });\n }\n\n const { outboundTopicId, inboundTopicId, pfpTopicId, profileTopicId } =\n await agentClient.createAgent(builder);\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Created agent with topics and profile',\n progressPercent: 60,\n details: {\n state,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n },\n });\n }\n\n const operatorId = `${inboundTopicId}@${account.accountId}`;\n\n const registrationResult =\n await agentClient.registerAgentWithGuardedRegistry(\n account.accountId,\n config.network,\n {\n progressCallback: (data) => {\n // Adjust progress to fit into the 60-100% range\n const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: {\n ...data.details,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n operatorId,\n state: data.details?.state || state,\n },\n });\n }\n },\n existingState: state,\n }\n );\n\n if (!registrationResult.success) {\n return registrationResult;\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent creation and registration complete',\n progressPercent: 100,\n details: {\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n operatorId,\n state: registrationResult.state,\n },\n });\n }\n\n return {\n ...registrationResult,\n metadata: {\n accountId: account.accountId,\n privateKey: account.privateKey,\n operatorId,\n inboundTopicId,\n outboundTopicId,\n profileTopicId,\n pfpTopicId,\n },\n };\n } catch (error: any) {\n this.logger.error(\n `Failed to create and register agent: ${error.message}`\n );\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry\n * @param accountId Account ID to register\n * @param inboundTopicId Inbound topic ID for the agent\n * @param network Network type ('mainnet' or 'testnet')\n * @param options Optional configuration including progress callback and confirmation settings\n * @returns Registration result\n */\n async registerAgentWithGuardedRegistry(\n accountId: string,\n network: string = this.network,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n maxAttempts?: number;\n delayMs?: number;\n existingState?: AgentCreationState;\n }\n ): Promise<AgentRegistrationResult> {\n try {\n this.logger.info('Registering agent with guarded registry');\n\n const maxAttempts = options?.maxAttempts ?? 60;\n const delayMs = options?.delayMs ?? 2000;\n const progressCallback = options?.progressCallback;\n let state =\n options?.existingState ||\n ({\n currentStage: 'registration',\n completedPercentage: 0,\n createdResources: [],\n } as AgentCreationState);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: {\n state,\n },\n });\n }\n\n const registrationResult = await this.executeRegistration(\n accountId,\n network,\n this.guardedRegistryBaseUrl,\n this.logger\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Submitting registration to registry',\n progressPercent: 30,\n details: {\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n if (registrationResult.transaction) {\n const transaction = Transaction.fromBytes(\n Buffer.from(registrationResult.transaction, 'base64')\n );\n\n this.logger.info(`Processing registration transaction`);\n await transaction.execute(this.client);\n this.logger.info(`Successfully processed registration transaction`);\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'confirming',\n message: 'Confirming registration transaction',\n progressPercent: 60,\n details: {\n accountId,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n const confirmed = await this.waitForRegistrationConfirmation(\n registrationResult.transactionId!,\n network,\n this.guardedRegistryBaseUrl,\n maxAttempts,\n delayMs,\n this.logger\n );\n\n state.currentStage = 'complete';\n state.completedPercentage = 100;\n if (!state.createdResources) {\n state.createdResources = [];\n }\n if (registrationResult.transactionId) {\n state.createdResources.push(\n `registration:${registrationResult.transactionId}`\n );\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent registration complete',\n progressPercent: 100,\n details: {\n confirmed,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n return {\n ...registrationResult,\n confirmed,\n state,\n };\n } catch (error: any) {\n this.logger.error(`Failed to register agent: ${error.message}`);\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry. Should be called by a registry.\n * @param registryTopicId - The topic ID of the guarded registry.\n * @param accountId - The account ID of the agent\n * @param inboundTopicId - The topic ID of the inbound topic\n * @param memo - The memo of the agent\n * @param submitKey - The submit key of the agent\n */\n async registerAgent(\n registryTopicId: string,\n accountId: string,\n inboundTopicId: string,\n memo: string,\n submitKey?: PrivateKey\n ): Promise<void> {\n this.logger.info('Registering agent');\n const payload = {\n p: 'hcs-10',\n op: 'register',\n account_id: accountId,\n inbound_topic_id: inboundTopicId,\n m: memo,\n };\n\n await this.submitPayload(registryTopicId, payload, submitKey);\n }\n\n async getInboundTopicType(topicId: string): Promise<InboundTopicType> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n throw new Error('Topic does not exist');\n }\n\n const hasSubmitKey = topicInfo.submit_key && topicInfo.submit_key.key;\n\n if (!hasSubmitKey) {\n return InboundTopicType.PUBLIC;\n }\n\n const hasFeeScheduleKey =\n topicInfo.fee_schedule_key && topicInfo.fee_schedule_key.key;\n\n if (hasFeeScheduleKey && topicInfo.custom_fees) {\n const customFees = topicInfo.custom_fees;\n\n if (\n customFees &&\n customFees.fixed_fees &&\n customFees.fixed_fees.length > 0\n ) {\n this.logger.info(\n `Topic ${topicId} is fee-based with ${customFees.fixed_fees.length} custom fees`\n );\n return InboundTopicType.FEE_BASED;\n }\n }\n\n return InboundTopicType.CONTROLLED;\n } catch (error: any) {\n this.logger.error(`Error determining topic type: ${error.message}`);\n throw new Error(`Failed to determine topic type: ${error.message}`);\n }\n }\n\n getNetwork(): string {\n return this.network;\n }\n\n getLogger(): Logger {\n return this.logger;\n }\n}\n"],"names":["mime.lookup"],"mappings":";;;;;;;;;AAsFO,MAAM,oBAAoB,gBAAgB;AAAA,EAS/C,YAAY,QAAyB;AAC7B,UAAA;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,MACjB,aAAa,OAAO;AAAA,IAAA,CACrB;AACI,SAAA,SACH,OAAO,YAAY,YAAY,OAAO,WAAW,IAAI,OAAO,WAAW;AACzE,SAAK,qBAAqB,WAAW,WAAW,OAAO,kBAAkB;AACzE,SAAK,UAAU,OAAO;AACtB,SAAK,OAAO;AAAA,MACV,OAAO;AAAA,MACP,KAAK,mBAAmB,SAAS;AAAA,IACnC;AACK,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,IAAA,CACT;AACI,SAAA,yBACH,OAAO,0BAA0B;AAC9B,SAAA,YAAY,OAAO,aAAa;AAEhC,SAAA,cAAc,IAAI,YAAY;AAAA,MACjC,SAAS,OAAO;AAAA,MAChB,MAAM;AAAA,QACJ,YAAY,OAAO;AAAA,QACnB,YAAY,OAAO;AAAA,MACrB;AAAA,MACA,UAAU,OAAO;AAAA,IAAA,CAClB;AAAA,EAAA;AAAA,EAGI,YAAY;AACjB,WAAO,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,MAAM,gBAAgD;AAC/C,SAAA,OAAO,KA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AAA,qBAAqB,UAAU,aAAa;AAC9C,cAAM,aAAa,UAAU;AAE7B,YACE,cACA,WAAW,cACX,WAAW,WAAW,SAAS,GAC/B;AACA,eAAK,OAAO;AAAA,YACV,SAAS,OAAO,sBAAsB,WAAW,WAAW,MAAM;AAAA,UACpE;AACA,iBAAO,iBAAiB;AAAA,QAAA;AAAA,MAC1B;AAGF,aAAO,iBAAiB;AAAA,aACjB,OAAY;AACnB,WAAK,OAAO,MAAM,iCAAiC,MAAM,OAAO,EAAE;AAClE,YAAM,IAAI,MAAM,mCAAmC,MAAM,OAAO,EAAE;AAAA,IAAA;AAAA,EACpE;AAAA,EAGF,aAAqB;AACnB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,YAAoB;AAClB,WAAO,KAAK;AAAA,EAAA;AAEhB;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es5.js","sources":["../../src/hcs-10/sdk.ts"],"sourcesContent":["import {\n Client,\n AccountCreateTransaction,\n PrivateKey,\n Hbar,\n KeyList,\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n TopicId,\n Transaction,\n TransactionResponse,\n TransactionReceipt,\n PublicKey,\n AccountId,\n CustomFixedFee,\n} from '@hashgraph/sdk';\nimport {\n PayloadSizeError,\n AccountCreationError,\n TopicCreationError,\n ConnectionConfirmationError,\n} from './errors';\nimport {\n InscriptionSDK,\n RetrievedInscriptionResult,\n} from '@kiloscribe/inscription-sdk';\nimport { Logger, LogLevel } from '../utils/logger';\nimport { HCS10BaseClient } from './base-client';\nimport * as mime from 'mime-types';\nimport {\n HCSClientConfig,\n AgentConfig,\n CreateAccountResponse,\n CreateAgentResponse,\n InscribePfpResponse,\n StoreHCS11ProfileResponse,\n AgentRegistrationResult,\n HandleConnectionRequestResponse,\n WaitForConnectionConfirmationResponse,\n GetAccountAndSignerResponse,\n InboundTopicType,\n TopicFeeConfig,\n FeeConfigBuilderInterface,\n AgentCreationState,\n} from './types';\nimport { HCS11Client } from '../hcs-11';\nimport { AgentBuilder } from './agent-builder';\nimport { accountIdsToExemptKeys } from '../utils/topic-fee-utils';\nimport { Hcs10MemoType } from './base-client';\n\nexport { InboundTopicType } from './types';\nexport { FeeConfigBuilder } from './fee-config-builder';\n\nexport interface AgentMetadata {\n type: 'autonomous' | 'manual';\n model?: string;\n socials?: {\n twitter?: string;\n discord?: string;\n github?: string;\n website?: string;\n x?: string;\n linkedin?: string;\n youtube?: string;\n telegram?: string;\n };\n creator?: string;\n properties?: Record<string, any>;\n}\n\n/**\n * Progress report data for registration operations\n */\nexport interface RegistrationProgressData {\n stage: 'preparing' | 'submitting' | 'confirming' | 'verifying' | 'completed';\n message: string;\n progressPercent?: number;\n details?: Record<string, any>;\n}\n\n/**\n * Progress callback function type for registration operations\n */\nexport type RegistrationProgressCallback = (\n data: RegistrationProgressData\n) => void;\n\nexport class HCS10Client extends HCS10BaseClient {\n private client: Client;\n private operatorPrivateKey: PrivateKey;\n protected declare network: string;\n protected declare logger: Logger;\n protected guardedRegistryBaseUrl: string;\n private hcs11Client: HCS11Client;\n\n constructor(config: HCSClientConfig) {\n super({\n network: config.network,\n logLevel: config.logLevel,\n prettyPrint: config.prettyPrint,\n feeAmount: config.feeAmount,\n });\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.operatorPrivateKey = PrivateKey.fromString(config.operatorPrivateKey);\n this.network = config.network;\n this.client.setOperator(\n config.operatorId,\n this.operatorPrivateKey.toString()\n );\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-SDK',\n });\n this.guardedRegistryBaseUrl =\n config.guardedRegistryBaseUrl || 'https://moonscape.tech';\n\n this.hcs11Client = new HCS11Client({\n network: config.network,\n auth: {\n operatorId: config.operatorId,\n privateKey: config.operatorPrivateKey,\n },\n logLevel: config.logLevel,\n });\n }\n\n public getClient() {\n return this.client;\n }\n\n /**\n * Creates a new Hedera account\n * @returns Object with account ID and private key\n */\n async createAccount(): Promise<CreateAccountResponse> {\n this.logger.info('Creating new account');\n const newKey = PrivateKey.generate();\n\n const accountTransaction = new AccountCreateTransaction()\n .setKey(newKey.publicKey)\n .setInitialBalance(new Hbar(10));\n\n this.logger.debug('Executing account creation transaction');\n const accountResponse = await accountTransaction.execute(this.client);\n const accountReceipt = await accountResponse.getReceipt(this.client);\n const newAccountId = accountReceipt.accountId;\n\n if (!newAccountId) {\n this.logger.error('Account creation failed: accountId is null');\n throw new AccountCreationError(\n 'Failed to create account: accountId is null'\n );\n }\n\n this.logger.info(\n `Account created successfully: ${newAccountId.toString()}`\n );\n return {\n accountId: newAccountId.toString(),\n privateKey: newKey.toString(),\n };\n }\n\n /**\n * Creates an inbound topic for an agent\n * @param accountId The account ID associated with the inbound topic\n * @param topicType Type of inbound topic (public, controlled, or fee-based)\n * @param ttl Optional Time-To-Live for the topic memo, defaults to 60\n * @param feeConfigBuilder Optional fee configuration builder for fee-based topics\n * @returns The topic ID of the created inbound topic\n */\n async createInboundTopic(\n accountId: string,\n topicType: InboundTopicType,\n ttl: number = 60,\n feeConfigBuilder?: FeeConfigBuilderInterface\n ): Promise<string> {\n const memo = this._generateHcs10Memo(Hcs10MemoType.INBOUND, {\n accountId,\n ttl,\n });\n\n let submitKey: boolean | PublicKey | KeyList | undefined;\n let feeConfig: TopicFeeConfig | undefined;\n\n switch (topicType) {\n case InboundTopicType.PUBLIC:\n submitKey = false;\n break;\n case InboundTopicType.CONTROLLED:\n submitKey = true;\n break;\n case InboundTopicType.FEE_BASED:\n submitKey = true;\n if (!feeConfigBuilder) {\n throw new Error(\n 'Fee configuration builder is required for fee-based topics'\n );\n }\n feeConfig = feeConfigBuilder.build();\n break;\n default:\n throw new Error(`Unsupported inbound topic type: ${topicType}`);\n }\n\n return this.createTopic(memo, true, submitKey, feeConfig);\n }\n\n /**\n * Creates a new agent with inbound and outbound topics\n * @param builder The agent builder object\n * @param ttl Optional Time-To-Live for the topic memos, defaults to 60\n * @returns Object with topic IDs\n */\n async createAgent(\n builder: AgentBuilder,\n ttl: number = 60\n ): Promise<CreateAgentResponse> {\n const config = builder.build();\n const outboundMemo = this._generateHcs10Memo(Hcs10MemoType.OUTBOUND, {\n ttl,\n });\n const outboundTopicId = await this.createTopic(outboundMemo, true, true);\n this.logger.info(`Created new outbound topic ID: ${outboundTopicId}`);\n\n const accountId = this.client.operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n const inboundTopicId = await this.createInboundTopic(\n accountId,\n config.inboundTopicType,\n ttl,\n config.inboundTopicType === InboundTopicType.FEE_BASED\n ? config.feeConfig\n : undefined\n );\n\n let pfpTopicId = config.existingPfpTopicId || '';\n\n if (!pfpTopicId && config.pfpBuffer && config.pfpBuffer.length > 0) {\n this.logger.info('Inscribing new profile picture');\n const pfpResult = await this.inscribePfp(\n config.pfpBuffer,\n config.pfpFileName\n );\n pfpTopicId = pfpResult.pfpTopicId;\n this.logger.info(\n `Profile picture inscribed with topic ID: ${pfpTopicId}`\n );\n } else if (config.existingPfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${config.existingPfpTopicId}`\n );\n }\n\n const profileResult = await this.storeHCS11Profile(\n config.name,\n config.description,\n inboundTopicId,\n outboundTopicId,\n config.capabilities,\n config.metadata,\n config.pfpBuffer && config.pfpBuffer.length > 0\n ? config.pfpBuffer\n : undefined,\n config.pfpFileName,\n config.existingPfpTopicId\n );\n const profileTopicId = profileResult.profileTopicId;\n this.logger.info(`Profile stored with topic ID: ${profileTopicId}`);\n\n return {\n inboundTopicId,\n outboundTopicId,\n pfpTopicId,\n profileTopicId,\n };\n }\n\n /**\n * Inscribes a profile picture to Hedera\n * @param buffer Profile picture buffer\n * @param fileName Filename\n * @returns Response with topic ID and transaction ID\n */\n async inscribePfp(\n buffer: Buffer,\n fileName: string\n ): Promise<InscribePfpResponse> {\n try {\n this.logger.info('Inscribing profile picture using HCS-11 client');\n\n const imageResult = await this.hcs11Client.inscribeImage(\n buffer,\n fileName\n );\n\n if (!imageResult.success) {\n this.logger.error(\n `Failed to inscribe profile picture: ${imageResult.error}`\n );\n throw new Error(\n imageResult?.error || 'Failed to inscribe profile picture'\n );\n }\n\n this.logger.info(\n `Successfully inscribed profile picture with topic ID: ${imageResult.imageTopicId}`\n );\n return {\n pfpTopicId: imageResult.imageTopicId,\n transactionId: imageResult.transactionId,\n success: true,\n };\n } catch (error: any) {\n this.logger.error(`Error inscribing profile picture: ${error.message}`);\n return {\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n /**\n * Stores an HCS-11 profile for an agent\n * @param agentName Agent name\n * @param agentDescription Agent description\n * @param inboundTopicId Inbound topic ID\n * @param outboundTopicId Outbound topic ID\n * @param capabilities Agent capability tags\n * @param metadata Additional metadata\n * @param pfpBuffer Optional profile picture buffer\n * @param pfpFileName Optional profile picture filename\n * @returns Response with topic IDs and transaction ID\n */\n async storeHCS11Profile(\n agentName: string,\n agentDescription: string,\n inboundTopicId: string,\n outboundTopicId: string,\n capabilities: number[] = [],\n metadata: AgentMetadata,\n pfpBuffer?: Buffer,\n pfpFileName?: string,\n existingPfpTopicId?: string\n ): Promise<StoreHCS11ProfileResponse> {\n try {\n let pfpTopicId = existingPfpTopicId || '';\n\n if (!pfpTopicId && pfpBuffer && pfpFileName) {\n this.logger.info('Inscribing profile picture for HCS-11 profile');\n const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);\n if (!pfpResult.success) {\n this.logger.error(\n 'Failed to inscribe profile picture, continuing without PFP'\n );\n } else {\n pfpTopicId = pfpResult.pfpTopicId;\n }\n } else if (existingPfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`\n );\n }\n\n const agentType = this.hcs11Client.getAgentTypeFromMetadata({\n type: metadata.type || 'autonomous',\n } as AgentMetadata);\n\n const formattedSocials = metadata.socials\n ? Object.entries(metadata.socials)\n .filter(([_, handle]) => handle)\n .map(([platform, handle]) => ({\n platform: platform === 'x' ? 'twitter' : platform,\n handle,\n }))\n : undefined;\n\n const profile = this.hcs11Client.createAIAgentProfile(\n agentName,\n agentType,\n capabilities,\n metadata.model || 'unknown',\n {\n alias: agentName.toLowerCase().replace(/\\s+/g, '_'),\n bio: agentDescription,\n profileImage: pfpTopicId ? `hcs://1/${pfpTopicId}` : undefined,\n socials: formattedSocials,\n properties: metadata.properties,\n inboundTopicId,\n outboundTopicId,\n creator: metadata.creator,\n }\n );\n\n const profileResult = await this.hcs11Client.createAndInscribeProfile(\n profile,\n true\n );\n\n if (!profileResult.success) {\n this.logger.error(`Failed to inscribe profile: ${profileResult.error}`);\n throw new Error(profileResult.error || 'Failed to inscribe profile');\n }\n\n this.logger.info(\n `Profile inscribed with topic ID: ${profileResult.profileTopicId}, transaction ID: ${profileResult.transactionId}`\n );\n\n return {\n profileTopicId: profileResult.profileTopicId,\n pfpTopicId,\n transactionId: profileResult.transactionId,\n success: true,\n };\n } catch (error: any) {\n this.logger.error(`Error storing HCS-11 profile: ${error.message}`);\n return {\n profileTopicId: '',\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n private async setupFees(\n transaction: TopicCreateTransaction,\n feeConfig: TopicFeeConfig,\n additionalExemptAccounts: string[] = []\n ): Promise<void> {\n if (!this.client.operatorPublicKey) {\n return;\n }\n\n this.logger.info('Setting up topic with custom fees');\n\n const customFee = new CustomFixedFee()\n .setAmount(Number(feeConfig.feeAmount.amount))\n .setFeeCollectorAccountId(\n AccountId.fromString(feeConfig.feeCollectorAccountId)\n );\n\n let exemptAccountIds = [\n ...(feeConfig.exemptAccounts || []),\n ...additionalExemptAccounts,\n ];\n\n console.log('exemptAccountIds', exemptAccountIds);\n\n if (exemptAccountIds.length > 0) {\n const uniqueExemptAccountIds = Array.from(new Set(exemptAccountIds));\n const filteredExemptAccounts = uniqueExemptAccountIds.filter(\n (account) => account !== this.client.operatorAccountId?.toString()\n );\n\n let exemptKeys: PublicKey[] = [];\n if (filteredExemptAccounts.length > 0) {\n try {\n exemptKeys = await accountIdsToExemptKeys(\n filteredExemptAccounts,\n this.network,\n this.logger\n );\n } catch (error) {\n this.logger.warn(\n `Error getting exempt keys: ${error}, continuing without exempt keys`\n );\n }\n }\n\n if (exemptKeys.length > 0) {\n transaction.setFeeExemptKeys(exemptKeys);\n }\n }\n\n transaction\n .setFeeScheduleKey(this.client.operatorPublicKey)\n .setCustomFees([customFee]);\n }\n\n /**\n * Handles a connection request from another account\n * @param inboundTopicId Inbound topic ID\n * @param requestingAccountId Requesting account ID\n * @param connectionRequestId Connection request ID\n * @param connectionFeeConfig Optional fee configuration for the connection topic\n * @param ttl Optional ttl parameter with default\n * @returns Response with connection details\n */\n async handleConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n connectionRequestId: number,\n connectionFeeConfig?: FeeConfigBuilderInterface,\n ttl: number = 60\n ): Promise<HandleConnectionRequestResponse> {\n const memo = this._generateHcs10Memo(Hcs10MemoType.CONNECTION, {\n ttl,\n inboundTopicId,\n connectionId: connectionRequestId,\n });\n this.logger.info(\n `Handling connection request ${connectionRequestId} from ${requestingAccountId}`\n );\n\n const accountId = this.getClient().operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n let requesterKey = await this.mirrorNode.getPublicKey(requestingAccountId);\n const accountKey = await this.mirrorNode.getPublicKey(accountId);\n\n if (!accountKey) {\n throw new Error('Failed to retrieve public key');\n }\n\n const thresholdKey = new KeyList([accountKey, requesterKey], 1);\n\n let connectionTopicId: string;\n\n try {\n if (connectionFeeConfig) {\n const feeConfig = connectionFeeConfig.build();\n const modifiedFeeConfig = {\n ...feeConfig,\n exemptAccounts: [...(feeConfig.exemptAccounts || [])],\n };\n\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey,\n modifiedFeeConfig\n );\n } else {\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey\n );\n }\n\n this.logger.info(`Created new connection topic ID: ${connectionTopicId}`);\n } catch (error) {\n this.logger.error(`Failed to create connection topic: ${error}`);\n throw new TopicCreationError(\n `Failed to create connection topic: ${error}`\n );\n }\n\n const operatorId = `${inboundTopicId}@${accountId}`;\n\n const confirmedConnectionSequenceNumber = await this.confirmConnection(\n inboundTopicId,\n connectionTopicId,\n requestingAccountId,\n connectionRequestId,\n operatorId,\n 'Connection accepted. Looking forward to collaborating!'\n );\n\n return {\n connectionTopicId,\n confirmedConnectionSequenceNumber,\n operatorId,\n };\n }\n\n async confirmConnection(\n inboundTopicId: string,\n connectionTopicId: string,\n connectedAccountId: string,\n connectionId: number,\n operatorId: string,\n memo: string,\n submitKey?: PrivateKey\n ): Promise<number> {\n this.logger.info(`Confirming connection with ID ${connectionId}`);\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n connected_account_id: connectedAccountId,\n operator_id: operatorId,\n connection_id: connectionId,\n m: memo,\n };\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const result = await this.submitPayload(\n inboundTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n\n const sequenceNumber = result.topicSequenceNumber?.toNumber();\n\n if (!sequenceNumber) {\n throw new ConnectionConfirmationError(\n 'Failed to confirm connection: sequence number is null'\n );\n }\n\n return sequenceNumber;\n }\n\n async sendMessage(\n connectionTopicId: string,\n operatorId: string,\n data: string,\n memo?: string,\n submitKey?: PrivateKey\n ): Promise<void> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const payload = {\n p: 'hcs-10',\n op: 'message',\n operator_id: operatorId,\n data,\n m: memo,\n };\n\n const payloadString = JSON.stringify(payload);\n const isLargePayload = Buffer.from(payloadString).length > 1000;\n\n if (isLargePayload) {\n this.logger.info(\n 'Message payload exceeds 1000 bytes, storing via inscription'\n );\n try {\n const contentBuffer = Buffer.from(data);\n const fileName = `message-${Date.now()}.json`;\n const inscriptionResult = await this.inscribeFile(\n contentBuffer,\n fileName\n );\n\n if (inscriptionResult?.topic_id) {\n payload.data = `hcs://1/${inscriptionResult.topic_id}`;\n this.logger.info(\n `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`\n );\n } else {\n throw new Error('Failed to inscribe large message content');\n }\n } catch (error) {\n this.logger.error('Error inscribing large message:', error);\n throw new Error(\n `Failed to handle large message: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n }\n\n this.logger.info('Submitting message to connection topic', payload);\n await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n }\n\n async createTopic(\n memo: string,\n adminKey?: boolean | PublicKey | KeyList,\n submitKey?: boolean | PublicKey | KeyList,\n feeConfig?: TopicFeeConfig\n ): Promise<string> {\n this.logger.info('Creating topic');\n const transaction = new TopicCreateTransaction().setTopicMemo(memo);\n\n if (adminKey) {\n if (\n typeof adminKey === 'boolean' &&\n adminKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setAdminKey(this.client.operatorPublicKey);\n transaction.setAutoRenewAccountId(this.client.operatorAccountId!);\n } else if (adminKey instanceof PublicKey || adminKey instanceof KeyList) {\n transaction.setAdminKey(adminKey);\n if (this.client.operatorAccountId) {\n transaction.setAutoRenewAccountId(this.client.operatorAccountId);\n }\n }\n }\n\n if (submitKey) {\n if (\n typeof submitKey === 'boolean' &&\n submitKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setSubmitKey(this.client.operatorPublicKey);\n } else if (\n submitKey instanceof PublicKey ||\n submitKey instanceof KeyList\n ) {\n transaction.setSubmitKey(submitKey);\n }\n }\n\n if (feeConfig) {\n await this.setupFees(transaction, feeConfig);\n }\n\n this.logger.debug('Executing topic creation transaction');\n const txResponse = await transaction.execute(this.client);\n const receipt = await txResponse.getReceipt(this.client);\n\n if (!receipt.topicId) {\n this.logger.error('Failed to create topic: topicId is null');\n throw new Error('Failed to create topic: topicId is null');\n }\n\n const topicId = receipt.topicId.toString();\n return topicId;\n }\n\n public async submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee: boolean = false\n ): Promise<TransactionReceipt> {\n const message =\n typeof payload === 'string' ? payload : JSON.stringify(payload);\n\n const payloadSizeInBytes = Buffer.byteLength(message, 'utf8');\n if (payloadSizeInBytes > 1000) {\n throw new PayloadSizeError(\n 'Payload size exceeds 1000 bytes limit',\n payloadSizeInBytes\n );\n }\n\n const transaction = new TopicMessageSubmitTransaction()\n .setTopicId(TopicId.fromString(topicId))\n .setMessage(message);\n\n if (requiresFee) {\n this.logger.info(\n 'Topic requires fee payment, setting max transaction fee'\n );\n transaction.setMaxTransactionFee(new Hbar(this.feeAmount));\n transaction.setTransactionMemo('HIP-991 Fee Payment');\n }\n\n let transactionResponse: TransactionResponse;\n if (submitKey) {\n transaction.freezeWith(this.client);\n const signedTransaction = await transaction.sign(submitKey);\n transactionResponse = await signedTransaction.execute(this.client);\n } else {\n transactionResponse = await transaction.execute(this.client);\n }\n\n const receipt = await transactionResponse.getReceipt(this.client);\n if (!receipt) {\n this.logger.error('Failed to submit message: receipt is null');\n throw new Error('Failed to submit message: receipt is null');\n }\n this.logger.info('Message submitted successfully');\n return receipt;\n }\n\n async submitConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n operatorId: string,\n memo: string\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n requestingAccountId\n );\n\n if (!submissionCheck.canSubmit) {\n throw new Error(`Cannot submit to topic: ${submissionCheck.reason}`);\n }\n\n const connectionRequestMessage = {\n p: 'hcs-10',\n op: 'connection_request',\n operator_id: operatorId,\n memo: memo,\n };\n\n const requiresFee = submissionCheck.requiresFee;\n const response = await this.submitPayload(\n inboundTopicId,\n connectionRequestMessage,\n undefined,\n requiresFee\n );\n\n this.logger.info(\n `Submitted connection request to topic ID: ${inboundTopicId}`\n );\n\n const outboundTopic = await this.retrieveOutboundConnectTopic(\n requestingAccountId\n );\n\n const responseSequenceNumber = response.topicSequenceNumber?.toNumber();\n\n if (!responseSequenceNumber) {\n throw new Error('Failed to get response sequence number');\n }\n\n await this.submitPayload(\n outboundTopic.outboundTopic,\n {\n ...connectionRequestMessage,\n outbound_topic_id: outboundTopic.outboundTopic,\n connection_request_id: responseSequenceNumber,\n },\n this.operatorPrivateKey\n );\n\n return response;\n }\n\n async inscribeFile(\n buffer: Buffer,\n fileName: string\n ): Promise<RetrievedInscriptionResult> {\n this.logger.info('Inscribing file');\n if (!this.client.operatorAccountId) {\n this.logger.error('Operator account ID is not set');\n throw new Error('Operator account ID is not set');\n }\n\n if (!this.operatorPrivateKey) {\n this.logger.error('Operator private key is not set');\n throw new Error('Operator private key is not set');\n }\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const sdk = await InscriptionSDK.createWithAuth({\n type: 'server',\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n });\n\n const result = await sdk.inscribeAndExecute(\n {\n file: {\n type: 'base64',\n base64: buffer.toString('base64'),\n fileName,\n mimeType,\n },\n holderId: this.client.operatorAccountId.toString(),\n mode: 'file',\n network: this.network as 'testnet' | 'mainnet',\n },\n {\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n }\n );\n\n if (!result.transactionId || !result.jobId) {\n this.logger.error('Failed to inscribe, no transaction ID or job ID.');\n throw new Error('Failed to inscribe, no transaction ID or job ID.');\n }\n\n if (result.transactionId && result.jobId) {\n this.logger.info(\n `Transaction ID: ${result.transactionId}, Job ID: ${result.jobId}`\n );\n }\n\n const status = await sdk.waitForInscription(result.jobId, 30, 4000, true);\n return status;\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n (m) => m.op === 'connection_created'\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n this.logger.info('Connection confirmation found');\n return {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`\n );\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`\n );\n }\n\n getAccountAndSigner(): GetAccountAndSignerResponse {\n return {\n accountId: this.client.operatorAccountId!.toString()!,\n signer: this.operatorPrivateKey,\n };\n }\n\n /**\n * Creates and registers an agent with a Guarded registry.\n *\n * This function performs the following steps:\n * 1. Creates a new account if no existing account is provided.\n * 2. Initializes an HCS10 client with the new account.\n * 3. Creates an agent on the client.\n * 4. Registers the agent with the Hashgraph Online Guarded Registry.\n *\n * @param builder The agent builder object\n * @param options Optional configuration including progress callback and state management\n * @returns Agent registration result\n */\n async createAndRegisterAgent(\n builder: AgentBuilder,\n options?: {\n baseUrl?: string;\n progressCallback?: RegistrationProgressCallback;\n existingState?: AgentCreationState;\n }\n ): Promise<AgentRegistrationResult> {\n try {\n const config = builder.build();\n const progressCallback = options?.progressCallback;\n const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;\n let state = options?.existingState || undefined;\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: { state },\n });\n }\n\n const account = config.existingAccount || (await this.createAccount());\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created account or using existing account',\n progressPercent: 20,\n details: { state, account },\n });\n }\n\n const agentClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: PrivateKey.fromString(\n account.privateKey\n ).publicKey.toString(),\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Initialized agent client',\n progressPercent: 30,\n details: { state },\n });\n }\n\n const { outboundTopicId, inboundTopicId, pfpTopicId, profileTopicId } =\n await agentClient.createAgent(builder);\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Created agent with topics and profile',\n progressPercent: 60,\n details: {\n state,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n },\n });\n }\n\n const operatorId = `${inboundTopicId}@${account.accountId}`;\n\n const registrationResult =\n await agentClient.registerAgentWithGuardedRegistry(\n account.accountId,\n config.network,\n {\n progressCallback: (data) => {\n const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: {\n ...data.details,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n operatorId,\n state: data.details?.state || state,\n },\n });\n }\n },\n existingState: state,\n }\n );\n\n if (!registrationResult.success) {\n return registrationResult;\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent creation and registration complete',\n progressPercent: 100,\n details: {\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n operatorId,\n state: registrationResult.state,\n },\n });\n }\n\n return {\n ...registrationResult,\n metadata: {\n accountId: account.accountId,\n privateKey: account.privateKey,\n operatorId,\n inboundTopicId,\n outboundTopicId,\n profileTopicId,\n pfpTopicId,\n },\n };\n } catch (error: any) {\n this.logger.error(\n `Failed to create and register agent: ${error.message}`\n );\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry\n * @param accountId Account ID to register\n * @param inboundTopicId Inbound topic ID for the agent\n * @param network Network type ('mainnet' or 'testnet')\n * @param options Optional configuration including progress callback and confirmation settings\n * @returns Registration result\n */\n async registerAgentWithGuardedRegistry(\n accountId: string,\n network: string = this.network,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n maxAttempts?: number;\n delayMs?: number;\n existingState?: AgentCreationState;\n }\n ): Promise<AgentRegistrationResult> {\n try {\n this.logger.info('Registering agent with guarded registry');\n\n const maxAttempts = options?.maxAttempts ?? 60;\n const delayMs = options?.delayMs ?? 2000;\n const progressCallback = options?.progressCallback;\n let state =\n options?.existingState ||\n ({\n currentStage: 'registration',\n completedPercentage: 0,\n createdResources: [],\n } as AgentCreationState);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: {\n state,\n },\n });\n }\n\n const registrationResult = await this.executeRegistration(\n accountId,\n network,\n this.guardedRegistryBaseUrl,\n this.logger\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Submitting registration to registry',\n progressPercent: 30,\n details: {\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n if (registrationResult.transaction) {\n const transaction = Transaction.fromBytes(\n Buffer.from(registrationResult.transaction, 'base64')\n );\n\n this.logger.info(`Processing registration transaction`);\n await transaction.execute(this.client);\n this.logger.info(`Successfully processed registration transaction`);\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'confirming',\n message: 'Confirming registration transaction',\n progressPercent: 60,\n details: {\n accountId,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n const confirmed = await this.waitForRegistrationConfirmation(\n registrationResult.transactionId!,\n network,\n this.guardedRegistryBaseUrl,\n maxAttempts,\n delayMs,\n this.logger\n );\n\n state.currentStage = 'complete';\n state.completedPercentage = 100;\n if (!state.createdResources) {\n state.createdResources = [];\n }\n if (registrationResult.transactionId) {\n state.createdResources.push(\n `registration:${registrationResult.transactionId}`\n );\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent registration complete',\n progressPercent: 100,\n details: {\n confirmed,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n return {\n ...registrationResult,\n confirmed,\n state,\n };\n } catch (error: any) {\n this.logger.error(`Failed to register agent: ${error.message}`);\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry. Should be called by a registry.\n * @param registryTopicId - The topic ID of the guarded registry.\n * @param accountId - The account ID of the agent\n * @param inboundTopicId - The topic ID of the inbound topic\n * @param memo - The memo of the agent\n * @param submitKey - The submit key of the agent\n */\n async registerAgent(\n registryTopicId: string,\n accountId: string,\n inboundTopicId: string,\n memo: string,\n submitKey?: PrivateKey\n ): Promise<void> {\n this.logger.info('Registering agent');\n const payload = {\n p: 'hcs-10',\n op: 'register',\n account_id: accountId,\n inbound_topic_id: inboundTopicId,\n m: memo,\n };\n\n await this.submitPayload(registryTopicId, payload, submitKey);\n }\n\n async getInboundTopicType(topicId: string): Promise<InboundTopicType> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n throw new Error('Topic does not exist');\n }\n\n const hasSubmitKey = topicInfo.submit_key && topicInfo.submit_key.key;\n\n if (!hasSubmitKey) {\n return InboundTopicType.PUBLIC;\n }\n\n const hasFeeScheduleKey =\n topicInfo.fee_schedule_key && topicInfo.fee_schedule_key.key;\n\n if (hasFeeScheduleKey && topicInfo.custom_fees) {\n const customFees = topicInfo.custom_fees;\n\n if (\n customFees &&\n customFees.fixed_fees &&\n customFees.fixed_fees.length > 0\n ) {\n this.logger.info(\n `Topic ${topicId} is fee-based with ${customFees.fixed_fees.length} custom fees`\n );\n return InboundTopicType.FEE_BASED;\n }\n }\n\n return InboundTopicType.CONTROLLED;\n } catch (error: any) {\n this.logger.error(`Error determining topic type: ${error.message}`);\n throw new Error(`Failed to determine topic type: ${error.message}`);\n }\n }\n\n getNetwork(): string {\n return this.network;\n }\n\n getLogger(): Logger {\n return this.logger;\n }\n}\n"],"names":["mime.lookup"],"mappings":";;;;;;;;;;AAuFO,MAAM,oBAAoB,gBAAgB;AAAA,EAQ/C,YAAY,QAAyB;AAC7B,UAAA;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,MACjB,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,IAAA,CACnB;AACI,SAAA,SACH,OAAO,YAAY,YAAY,OAAO,WAAW,IAAI,OAAO,WAAW;AACzE,SAAK,qBAAqB,WAAW,WAAW,OAAO,kBAAkB;AACzE,SAAK,UAAU,OAAO;AACtB,SAAK,OAAO;AAAA,MACV,OAAO;AAAA,MACP,KAAK,mBAAmB,SAAS;AAAA,IACnC;AACK,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,IAAA,CACT;AACI,SAAA,yBACH,OAAO,0BAA0B;AAE9B,SAAA,cAAc,IAAI,YAAY;AAAA,MACjC,SAAS,OAAO;AAAA,MAChB,MAAM;AAAA,QACJ,YAAY,OAAO;AAAA,QACnB,YAAY,OAAO;AAAA,MACrB;AAAA,MACA,UAAU,OAAO;AAAA,IAAA,CAClB;AAAA,EAAA;AAAA,EAGI,YAAY;AACjB,WAAO,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd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