@hashgraphonline/standards-sdk 0.0.30 → 0.0.31
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 +8 -0
- package/dist/es/standards-sdk.es.js +57 -17
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/umd/hcs-10/base-client.d.ts +8 -0
- package/dist/umd/standards-sdk.umd.js +1 -1
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -23,6 +23,13 @@ export interface HCSMessage {
|
|
|
23
23
|
sequence_number: number;
|
|
24
24
|
operator_id?: string;
|
|
25
25
|
}
|
|
26
|
+
export interface ProfileResponse {
|
|
27
|
+
profile: any;
|
|
28
|
+
topicInfo?: TopicInfo;
|
|
29
|
+
profileTopicId?: string;
|
|
30
|
+
success: boolean;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
26
33
|
export declare abstract class HCS10BaseClient extends Registration {
|
|
27
34
|
protected network: string;
|
|
28
35
|
protected logger: Logger;
|
|
@@ -42,6 +49,7 @@ export declare abstract class HCS10BaseClient extends Registration {
|
|
|
42
49
|
getAccountMemo(accountId: string): Promise<string | null>;
|
|
43
50
|
protected getTopicInfoFromMemo(memo: string): Promise<TopicInfo | null>;
|
|
44
51
|
getTopicInfo(accountId: string): Promise<TopicInfo | null>;
|
|
52
|
+
retrieveProfile(accountId: string): Promise<ProfileResponse>;
|
|
45
53
|
retrieveOutboundConnectTopic(accountId: string): Promise<TopicInfo>;
|
|
46
54
|
retrieveOutboundMessages(agentAccountId: string): Promise<HCSMessage[]>;
|
|
47
55
|
hasConnectionCreated(agentAccountId: string, connectionId: number): Promise<boolean>;
|
|
@@ -15746,25 +15746,31 @@ class HCS10BaseClient extends Registration {
|
|
|
15746
15746
|
}
|
|
15747
15747
|
return topicInfo;
|
|
15748
15748
|
}
|
|
15749
|
-
async
|
|
15750
|
-
this.logger.info(`Retrieving
|
|
15751
|
-
const cachedInfo = await this.getTopicInfo(accountId);
|
|
15752
|
-
if (cachedInfo) return cachedInfo;
|
|
15749
|
+
async retrieveProfile(accountId) {
|
|
15750
|
+
this.logger.info(`Retrieving profile for account: ${accountId}`);
|
|
15753
15751
|
try {
|
|
15754
15752
|
const accountMemo = await this.getAccountMemo(accountId);
|
|
15755
15753
|
if (!accountMemo) {
|
|
15756
|
-
|
|
15754
|
+
return {
|
|
15755
|
+
profile: null,
|
|
15756
|
+
success: false,
|
|
15757
|
+
error: `Failed to retrieve memo for account ID: ${accountId}`
|
|
15758
|
+
};
|
|
15757
15759
|
}
|
|
15758
15760
|
if (!accountMemo.startsWith("hcs-11:")) {
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15761
|
+
return {
|
|
15762
|
+
profile: null,
|
|
15763
|
+
success: false,
|
|
15764
|
+
error: `Invalid memo format: ${accountMemo}. Memo must start with 'hcs-11:'`
|
|
15765
|
+
};
|
|
15762
15766
|
}
|
|
15763
15767
|
const hrlMatch = accountMemo.match(/^hcs-11:hcs:\/\/(\d+)\/(.+)$/);
|
|
15764
15768
|
if (!hrlMatch) {
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15769
|
+
return {
|
|
15770
|
+
profile: null,
|
|
15771
|
+
success: false,
|
|
15772
|
+
error: `Invalid HCS-11 memo format: ${accountMemo}. Expected format: hcs-11:hcs://{standard}/{topicId}`
|
|
15773
|
+
};
|
|
15768
15774
|
}
|
|
15769
15775
|
const [, standard, profileTopicId] = hrlMatch;
|
|
15770
15776
|
this.logger.info(
|
|
@@ -15773,11 +15779,47 @@ class HCS10BaseClient extends Registration {
|
|
|
15773
15779
|
const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${profileTopicId}?network=${this.network}`;
|
|
15774
15780
|
const profileResponse = await axios.get(cdnUrl);
|
|
15775
15781
|
if (!profileResponse.data) {
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15782
|
+
return {
|
|
15783
|
+
profile: null,
|
|
15784
|
+
success: false,
|
|
15785
|
+
error: `Failed to fetch profile from topic: ${profileTopicId}`
|
|
15786
|
+
};
|
|
15779
15787
|
}
|
|
15780
15788
|
const profile = profileResponse.data;
|
|
15789
|
+
let topicInfo = null;
|
|
15790
|
+
if (profile.inboundTopicId && profile.outboundTopicId) {
|
|
15791
|
+
topicInfo = {
|
|
15792
|
+
inboundTopic: profile.inboundTopicId,
|
|
15793
|
+
outboundTopic: profile.outboundTopicId
|
|
15794
|
+
};
|
|
15795
|
+
const cacheKey = `${accountId}-${this.network}`;
|
|
15796
|
+
HCS10Cache.getInstance().set(cacheKey, topicInfo);
|
|
15797
|
+
}
|
|
15798
|
+
return {
|
|
15799
|
+
profile,
|
|
15800
|
+
topicInfo,
|
|
15801
|
+
profileTopicId,
|
|
15802
|
+
success: true
|
|
15803
|
+
};
|
|
15804
|
+
} catch (error) {
|
|
15805
|
+
this.logger.error("Failed to retrieve profile:", error);
|
|
15806
|
+
return {
|
|
15807
|
+
profile: null,
|
|
15808
|
+
success: false,
|
|
15809
|
+
error: error instanceof Error ? error.message : String(error)
|
|
15810
|
+
};
|
|
15811
|
+
}
|
|
15812
|
+
}
|
|
15813
|
+
async retrieveOutboundConnectTopic(accountId) {
|
|
15814
|
+
this.logger.info(`Retrieving topics for account: ${accountId}`);
|
|
15815
|
+
const cachedInfo = await this.getTopicInfo(accountId);
|
|
15816
|
+
if (cachedInfo) return cachedInfo;
|
|
15817
|
+
try {
|
|
15818
|
+
const profileResponse = await this.retrieveProfile(accountId);
|
|
15819
|
+
if (!profileResponse.success) {
|
|
15820
|
+
throw new Error(profileResponse.error);
|
|
15821
|
+
}
|
|
15822
|
+
const profile = profileResponse.profile;
|
|
15781
15823
|
if (!profile.inboundTopicId || !profile.outboundTopicId) {
|
|
15782
15824
|
throw new Error(
|
|
15783
15825
|
`Invalid HCS-11 profile for HCS-10 agent: missing inboundTopicId or outboundTopicId`
|
|
@@ -15797,9 +15839,7 @@ class HCS10BaseClient extends Registration {
|
|
|
15797
15839
|
}
|
|
15798
15840
|
async retrieveOutboundMessages(agentAccountId) {
|
|
15799
15841
|
try {
|
|
15800
|
-
const topicInfo = await this.retrieveOutboundConnectTopic(
|
|
15801
|
-
agentAccountId
|
|
15802
|
-
);
|
|
15842
|
+
const topicInfo = await this.retrieveOutboundConnectTopic(agentAccountId);
|
|
15803
15843
|
if (!topicInfo) {
|
|
15804
15844
|
this.logger.warn(
|
|
15805
15845
|
`No outbound connect topic found for agentAccountId: ${agentAccountId}`
|