@hashgraphonline/standards-sdk 0.0.23 → 0.0.24
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/browser.d.ts +2 -2
- package/dist/es/hcs-10/sdk.d.ts +17 -3
- package/dist/es/standards-sdk.es.js +119 -4
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/umd/hcs-10/browser.d.ts +2 -2
- package/dist/umd/hcs-10/sdk.d.ts +17 -3
- package/dist/umd/standards-sdk.umd.js +1 -1
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { HashinalsWalletConnectSDK } from '@hashgraphonline/hashinal-wc';
|
|
|
3
3
|
import { Logger, LogLevel } from '../utils/logger';
|
|
4
4
|
import { RetrievedInscriptionResult } from '@kiloscribe/inscription-sdk';
|
|
5
5
|
import { HCS10BaseClient } from './base-client';
|
|
6
|
-
import { AgentConfig, NetworkType } from './types.d';
|
|
6
|
+
import { AgentConfig, NetworkType, RegistrationProgressCallback } from './types.d';
|
|
7
7
|
export type BrowserHCSClientConfig = {
|
|
8
8
|
network: 'mainnet' | 'testnet';
|
|
9
9
|
hwc: HashinalsWalletConnectSDK;
|
|
@@ -67,7 +67,7 @@ export declare class BrowserHCSClient extends HCS10BaseClient {
|
|
|
67
67
|
success: boolean;
|
|
68
68
|
}>;
|
|
69
69
|
createAndRegisterAgent(name: string, description: string, capabilities: number[], metadata: AgentMetadata, pfpBuffer: Buffer, pfpFileName: string, network: NetworkType, existingPfpTopicId?: string): Promise<BrowserAgentConfig>;
|
|
70
|
-
registerAgentWithGuardedRegistry(accountId: string, inboundTopicId: string, network?: string,
|
|
70
|
+
registerAgentWithGuardedRegistry(accountId: string, inboundTopicId: string, network?: string, progressCallbackOrMaxAttempts?: RegistrationProgressCallback | number, maxAttemptsOrDelayMs?: number, delayMsParam?: number): Promise<{
|
|
71
71
|
error?: string;
|
|
72
72
|
success: boolean;
|
|
73
73
|
transaction?: any;
|
package/dist/es/hcs-10/sdk.d.ts
CHANGED
|
@@ -22,6 +22,19 @@ export interface AgentMetadata {
|
|
|
22
22
|
creator?: string;
|
|
23
23
|
properties?: Record<string, any>;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Progress report data for registration operations
|
|
27
|
+
*/
|
|
28
|
+
export interface RegistrationProgressData {
|
|
29
|
+
stage: 'preparing' | 'submitting' | 'confirming' | 'verifying' | 'completed';
|
|
30
|
+
message: string;
|
|
31
|
+
progressPercent?: number;
|
|
32
|
+
details?: Record<string, any>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Progress callback function type for registration operations
|
|
36
|
+
*/
|
|
37
|
+
export type RegistrationProgressCallback = (data: RegistrationProgressData) => void;
|
|
25
38
|
export declare class HCS10Client extends HCS10BaseClient {
|
|
26
39
|
private client;
|
|
27
40
|
private operatorPrivateKey;
|
|
@@ -135,11 +148,12 @@ export declare class HCS10Client extends HCS10BaseClient {
|
|
|
135
148
|
* @param accountId Account ID to register
|
|
136
149
|
* @param inboundTopicId Inbound topic ID for the agent
|
|
137
150
|
* @param network Network type ('mainnet' or 'testnet')
|
|
138
|
-
* @param
|
|
139
|
-
* @param
|
|
151
|
+
* @param progressCallbackOrMaxAttempts Optional callback to report registration progress for UI or maxAttempts
|
|
152
|
+
* @param maxAttemptsOrDelayMs Optional maximum attempts for confirmation or delay between attempts
|
|
153
|
+
* @param delayMsParam Optional delay between confirmation attempts
|
|
140
154
|
* @returns Registration result
|
|
141
155
|
*/
|
|
142
|
-
registerAgentWithGuardedRegistry(accountId: string, inboundTopicId: string, network?: string,
|
|
156
|
+
registerAgentWithGuardedRegistry(accountId: string, inboundTopicId: string, network?: string, progressCallbackOrMaxAttempts?: RegistrationProgressCallback | number, maxAttemptsOrDelayMs?: number, delayMsParam?: number): Promise<AgentRegistrationResult>;
|
|
143
157
|
/**
|
|
144
158
|
* Registers an agent with the guarded registry. Should be called by a registry.
|
|
145
159
|
* @param registryTopicId - The topic ID of the guarded registry.
|
|
@@ -32770,13 +32770,38 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
32770
32770
|
* @param accountId Account ID to register
|
|
32771
32771
|
* @param inboundTopicId Inbound topic ID for the agent
|
|
32772
32772
|
* @param network Network type ('mainnet' or 'testnet')
|
|
32773
|
-
* @param
|
|
32774
|
-
* @param
|
|
32773
|
+
* @param progressCallbackOrMaxAttempts Optional callback to report registration progress for UI or maxAttempts
|
|
32774
|
+
* @param maxAttemptsOrDelayMs Optional maximum attempts for confirmation or delay between attempts
|
|
32775
|
+
* @param delayMsParam Optional delay between confirmation attempts
|
|
32775
32776
|
* @returns Registration result
|
|
32776
32777
|
*/
|
|
32777
|
-
async registerAgentWithGuardedRegistry(accountId, inboundTopicId, network = this.network,
|
|
32778
|
+
async registerAgentWithGuardedRegistry(accountId, inboundTopicId, network = this.network, progressCallbackOrMaxAttempts, maxAttemptsOrDelayMs, delayMsParam) {
|
|
32778
32779
|
try {
|
|
32779
32780
|
this.logger.info("Registering agent with guarded registry");
|
|
32781
|
+
let progressCallback;
|
|
32782
|
+
let maxAttempts = 60;
|
|
32783
|
+
let delayMs = 2e3;
|
|
32784
|
+
if (typeof progressCallbackOrMaxAttempts === "function") {
|
|
32785
|
+
progressCallback = progressCallbackOrMaxAttempts;
|
|
32786
|
+
if (typeof maxAttemptsOrDelayMs === "number") {
|
|
32787
|
+
maxAttempts = maxAttemptsOrDelayMs;
|
|
32788
|
+
}
|
|
32789
|
+
if (typeof delayMsParam === "number") {
|
|
32790
|
+
delayMs = delayMsParam;
|
|
32791
|
+
}
|
|
32792
|
+
} else if (typeof progressCallbackOrMaxAttempts === "number") {
|
|
32793
|
+
maxAttempts = progressCallbackOrMaxAttempts;
|
|
32794
|
+
if (typeof maxAttemptsOrDelayMs === "number") {
|
|
32795
|
+
delayMs = maxAttemptsOrDelayMs;
|
|
32796
|
+
}
|
|
32797
|
+
}
|
|
32798
|
+
if (progressCallback) {
|
|
32799
|
+
progressCallback({
|
|
32800
|
+
stage: "preparing",
|
|
32801
|
+
message: "Preparing agent registration",
|
|
32802
|
+
progressPercent: 10
|
|
32803
|
+
});
|
|
32804
|
+
}
|
|
32780
32805
|
const registrationResult = await this.executeRegistration(
|
|
32781
32806
|
accountId,
|
|
32782
32807
|
inboundTopicId,
|
|
@@ -32787,6 +32812,16 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
32787
32812
|
if (!registrationResult.success) {
|
|
32788
32813
|
return registrationResult;
|
|
32789
32814
|
}
|
|
32815
|
+
if (progressCallback) {
|
|
32816
|
+
progressCallback({
|
|
32817
|
+
stage: "submitting",
|
|
32818
|
+
message: "Submitting registration to registry",
|
|
32819
|
+
progressPercent: 30,
|
|
32820
|
+
details: {
|
|
32821
|
+
transactionId: registrationResult.transactionId
|
|
32822
|
+
}
|
|
32823
|
+
});
|
|
32824
|
+
}
|
|
32790
32825
|
if (registrationResult.transaction) {
|
|
32791
32826
|
const transaction = Transaction.fromBytes(
|
|
32792
32827
|
Buffer2.from(registrationResult.transaction, "base64")
|
|
@@ -32795,6 +32830,18 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
32795
32830
|
await transaction.execute(this.client);
|
|
32796
32831
|
this.logger.info(`Successfully processed registration transaction`);
|
|
32797
32832
|
}
|
|
32833
|
+
if (progressCallback) {
|
|
32834
|
+
progressCallback({
|
|
32835
|
+
stage: "confirming",
|
|
32836
|
+
message: "Confirming registration transaction",
|
|
32837
|
+
progressPercent: 60,
|
|
32838
|
+
details: {
|
|
32839
|
+
accountId,
|
|
32840
|
+
inboundTopicId,
|
|
32841
|
+
transactionId: registrationResult.transactionId
|
|
32842
|
+
}
|
|
32843
|
+
});
|
|
32844
|
+
}
|
|
32798
32845
|
const confirmed = await this.waitForRegistrationConfirmation(
|
|
32799
32846
|
registrationResult.transactionId,
|
|
32800
32847
|
network,
|
|
@@ -32803,6 +32850,17 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
32803
32850
|
delayMs,
|
|
32804
32851
|
this.logger
|
|
32805
32852
|
);
|
|
32853
|
+
if (progressCallback) {
|
|
32854
|
+
progressCallback({
|
|
32855
|
+
stage: "completed",
|
|
32856
|
+
message: "Agent registration complete",
|
|
32857
|
+
progressPercent: 100,
|
|
32858
|
+
details: {
|
|
32859
|
+
confirmed,
|
|
32860
|
+
transactionId: registrationResult.transactionId
|
|
32861
|
+
}
|
|
32862
|
+
});
|
|
32863
|
+
}
|
|
32806
32864
|
return {
|
|
32807
32865
|
...registrationResult,
|
|
32808
32866
|
confirmed
|
|
@@ -33285,9 +33343,33 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33285
33343
|
throw new Error(`Failed to create and register agent: ${error.message}`);
|
|
33286
33344
|
}
|
|
33287
33345
|
}
|
|
33288
|
-
async registerAgentWithGuardedRegistry(accountId, inboundTopicId, network = this.network,
|
|
33346
|
+
async registerAgentWithGuardedRegistry(accountId, inboundTopicId, network = this.network, progressCallbackOrMaxAttempts, maxAttemptsOrDelayMs, delayMsParam) {
|
|
33289
33347
|
try {
|
|
33290
33348
|
this.logger.info("Registering agent with guarded registry");
|
|
33349
|
+
let progressCallback;
|
|
33350
|
+
let maxAttempts = 60;
|
|
33351
|
+
let delayMs = 2e3;
|
|
33352
|
+
if (typeof progressCallbackOrMaxAttempts === "function") {
|
|
33353
|
+
progressCallback = progressCallbackOrMaxAttempts;
|
|
33354
|
+
if (typeof maxAttemptsOrDelayMs === "number") {
|
|
33355
|
+
maxAttempts = maxAttemptsOrDelayMs;
|
|
33356
|
+
}
|
|
33357
|
+
if (typeof delayMsParam === "number") {
|
|
33358
|
+
delayMs = delayMsParam;
|
|
33359
|
+
}
|
|
33360
|
+
} else if (typeof progressCallbackOrMaxAttempts === "number") {
|
|
33361
|
+
maxAttempts = progressCallbackOrMaxAttempts;
|
|
33362
|
+
if (typeof maxAttemptsOrDelayMs === "number") {
|
|
33363
|
+
delayMs = maxAttemptsOrDelayMs;
|
|
33364
|
+
}
|
|
33365
|
+
}
|
|
33366
|
+
if (progressCallback) {
|
|
33367
|
+
progressCallback({
|
|
33368
|
+
stage: "preparing",
|
|
33369
|
+
message: "Preparing agent registration",
|
|
33370
|
+
progressPercent: 10
|
|
33371
|
+
});
|
|
33372
|
+
}
|
|
33291
33373
|
const registrationResult = await this.executeRegistration(
|
|
33292
33374
|
accountId,
|
|
33293
33375
|
inboundTopicId,
|
|
@@ -33298,6 +33380,16 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33298
33380
|
if (!registrationResult.success) {
|
|
33299
33381
|
return registrationResult;
|
|
33300
33382
|
}
|
|
33383
|
+
if (progressCallback) {
|
|
33384
|
+
progressCallback({
|
|
33385
|
+
stage: "submitting",
|
|
33386
|
+
message: "Submitting registration to registry",
|
|
33387
|
+
progressPercent: 30,
|
|
33388
|
+
details: {
|
|
33389
|
+
transactionId: registrationResult.transactionId
|
|
33390
|
+
}
|
|
33391
|
+
});
|
|
33392
|
+
}
|
|
33301
33393
|
if (registrationResult.transaction) {
|
|
33302
33394
|
const transaction = Transaction.fromBytes(
|
|
33303
33395
|
Buffer2.from(registrationResult.transaction, "base64")
|
|
@@ -33316,6 +33408,18 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33316
33408
|
}
|
|
33317
33409
|
this.logger.info(`Successfully processed registration transaction`);
|
|
33318
33410
|
}
|
|
33411
|
+
if (progressCallback) {
|
|
33412
|
+
progressCallback({
|
|
33413
|
+
stage: "confirming",
|
|
33414
|
+
message: "Confirming registration transaction",
|
|
33415
|
+
progressPercent: 60,
|
|
33416
|
+
details: {
|
|
33417
|
+
accountId,
|
|
33418
|
+
inboundTopicId,
|
|
33419
|
+
transactionId: registrationResult.transactionId
|
|
33420
|
+
}
|
|
33421
|
+
});
|
|
33422
|
+
}
|
|
33319
33423
|
const confirmed = await this.waitForRegistrationConfirmation(
|
|
33320
33424
|
registrationResult.transactionId,
|
|
33321
33425
|
network,
|
|
@@ -33323,6 +33427,17 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33323
33427
|
maxAttempts,
|
|
33324
33428
|
delayMs
|
|
33325
33429
|
);
|
|
33430
|
+
if (progressCallback) {
|
|
33431
|
+
progressCallback({
|
|
33432
|
+
stage: "completed",
|
|
33433
|
+
message: "Agent registration complete",
|
|
33434
|
+
progressPercent: 100,
|
|
33435
|
+
details: {
|
|
33436
|
+
confirmed,
|
|
33437
|
+
transactionId: registrationResult.transactionId
|
|
33438
|
+
}
|
|
33439
|
+
});
|
|
33440
|
+
}
|
|
33326
33441
|
return {
|
|
33327
33442
|
...registrationResult,
|
|
33328
33443
|
confirmed
|