@hashgraphonline/standards-sdk 0.0.27 → 0.0.28
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 +5 -1
- package/dist/es/hcs-10/index.d.ts +1 -0
- package/dist/es/standards-sdk.es.js +63 -39
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/umd/hcs-10/browser.d.ts +5 -1
- package/dist/umd/hcs-10/index.d.ts +1 -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
|
@@ -66,7 +66,11 @@ export declare class BrowserHCSClient extends HCS10BaseClient {
|
|
|
66
66
|
error?: string;
|
|
67
67
|
success: boolean;
|
|
68
68
|
}>;
|
|
69
|
-
createAndRegisterAgent(name: string, description: string, capabilities: number[], metadata: AgentMetadata, pfpBuffer: Buffer, pfpFileName: string, network: NetworkType, existingPfpTopicId?: string
|
|
69
|
+
createAndRegisterAgent(name: string, description: string, capabilities: number[], metadata: AgentMetadata, pfpBuffer: Buffer, pfpFileName: string, network: NetworkType, existingPfpTopicId?: string, options?: {
|
|
70
|
+
progressCallback?: RegistrationProgressCallback;
|
|
71
|
+
maxAttempts?: number;
|
|
72
|
+
delayMs?: number;
|
|
73
|
+
}): Promise<BrowserAgentConfig>;
|
|
70
74
|
registerAgentWithGuardedRegistry(accountId: string, inboundTopicId: string, network?: string, options?: {
|
|
71
75
|
progressCallback?: RegistrationProgressCallback;
|
|
72
76
|
maxAttempts?: number;
|
|
@@ -33291,8 +33291,24 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33291
33291
|
};
|
|
33292
33292
|
}
|
|
33293
33293
|
}
|
|
33294
|
-
async createAndRegisterAgent(name, description, capabilities, metadata, pfpBuffer, pfpFileName, network, existingPfpTopicId) {
|
|
33294
|
+
async createAndRegisterAgent(name, description, capabilities, metadata, pfpBuffer, pfpFileName, network, existingPfpTopicId, options) {
|
|
33295
33295
|
try {
|
|
33296
|
+
const progressCallback = options == null ? void 0 : options.progressCallback;
|
|
33297
|
+
const reportProgress = (stage, message, percent, details) => {
|
|
33298
|
+
if (progressCallback) {
|
|
33299
|
+
try {
|
|
33300
|
+
progressCallback({
|
|
33301
|
+
stage,
|
|
33302
|
+
message,
|
|
33303
|
+
progressPercent: percent,
|
|
33304
|
+
details
|
|
33305
|
+
});
|
|
33306
|
+
} catch (err) {
|
|
33307
|
+
this.logger.warn(`Error in progress callback: ${err}`);
|
|
33308
|
+
}
|
|
33309
|
+
}
|
|
33310
|
+
};
|
|
33311
|
+
reportProgress("preparing", "Creating agent topics and profile", 10);
|
|
33296
33312
|
const agentResult = await this.createAgent(
|
|
33297
33313
|
pfpBuffer,
|
|
33298
33314
|
pfpFileName,
|
|
@@ -33305,17 +33321,41 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33305
33321
|
if (!agentResult.success) {
|
|
33306
33322
|
throw new Error(agentResult.error || "Failed to create agent");
|
|
33307
33323
|
}
|
|
33324
|
+
reportProgress(
|
|
33325
|
+
"preparing",
|
|
33326
|
+
"Agent topics created, preparing registration",
|
|
33327
|
+
30
|
|
33328
|
+
);
|
|
33308
33329
|
const { accountId } = this.getAccountAndSigner();
|
|
33330
|
+
reportProgress("submitting", "Registering with Hedera registry", 40);
|
|
33309
33331
|
const registrationResult = await this.registerAgentWithGuardedRegistry(
|
|
33310
33332
|
accountId,
|
|
33311
33333
|
agentResult.inboundTopicId,
|
|
33312
|
-
network
|
|
33334
|
+
network,
|
|
33335
|
+
{
|
|
33336
|
+
progressCallback: (progress) => {
|
|
33337
|
+
const adjustedPercent = 40 + (progress.progressPercent || 0) * 0.6;
|
|
33338
|
+
reportProgress(
|
|
33339
|
+
progress.stage,
|
|
33340
|
+
progress.message,
|
|
33341
|
+
adjustedPercent,
|
|
33342
|
+
progress.details
|
|
33343
|
+
);
|
|
33344
|
+
},
|
|
33345
|
+
maxAttempts: options == null ? void 0 : options.maxAttempts,
|
|
33346
|
+
delayMs: options == null ? void 0 : options.delayMs
|
|
33347
|
+
}
|
|
33313
33348
|
);
|
|
33314
33349
|
if (!registrationResult.success) {
|
|
33315
33350
|
throw new Error(
|
|
33316
33351
|
registrationResult.error || "Failed to register agent with registry"
|
|
33317
33352
|
);
|
|
33318
33353
|
}
|
|
33354
|
+
reportProgress(
|
|
33355
|
+
"completed",
|
|
33356
|
+
"Agent creation and registration complete",
|
|
33357
|
+
100
|
|
33358
|
+
);
|
|
33319
33359
|
return {
|
|
33320
33360
|
accountId,
|
|
33321
33361
|
operatorId: `${agentResult.outboundTopicId}@${accountId}`,
|
|
@@ -33335,22 +33375,21 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33335
33375
|
const maxAttempts = (options == null ? void 0 : options.maxAttempts) ?? 60;
|
|
33336
33376
|
const delayMs = (options == null ? void 0 : options.delayMs) ?? 2e3;
|
|
33337
33377
|
const progressCallback = options == null ? void 0 : options.progressCallback;
|
|
33338
|
-
|
|
33339
|
-
|
|
33340
|
-
|
|
33341
|
-
|
|
33342
|
-
|
|
33343
|
-
|
|
33378
|
+
const reportProgress = (stage, message, percent, details) => {
|
|
33379
|
+
if (progressCallback) {
|
|
33380
|
+
try {
|
|
33381
|
+
progressCallback({
|
|
33382
|
+
stage,
|
|
33383
|
+
message,
|
|
33384
|
+
progressPercent: percent,
|
|
33385
|
+
details
|
|
33386
|
+
});
|
|
33387
|
+
} catch (err) {
|
|
33388
|
+
this.logger.warn(`Error in progress callback: ${err}`);
|
|
33344
33389
|
}
|
|
33345
|
-
} catch (error) {
|
|
33346
|
-
this.logger.error(`Error in progress callback: ${error}`);
|
|
33347
33390
|
}
|
|
33348
33391
|
};
|
|
33349
|
-
reportProgress(
|
|
33350
|
-
stage: "preparing",
|
|
33351
|
-
message: "Preparing agent registration",
|
|
33352
|
-
progressPercent: 10
|
|
33353
|
-
});
|
|
33392
|
+
reportProgress("preparing", "Preparing agent registration", 10);
|
|
33354
33393
|
const registrationResult = await this.executeRegistration(
|
|
33355
33394
|
accountId,
|
|
33356
33395
|
inboundTopicId,
|
|
@@ -33361,13 +33400,8 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33361
33400
|
if (!registrationResult.success) {
|
|
33362
33401
|
return registrationResult;
|
|
33363
33402
|
}
|
|
33364
|
-
reportProgress({
|
|
33365
|
-
|
|
33366
|
-
message: "Submitting registration to registry",
|
|
33367
|
-
progressPercent: 30,
|
|
33368
|
-
details: {
|
|
33369
|
-
transactionId: registrationResult.transactionId
|
|
33370
|
-
}
|
|
33403
|
+
reportProgress("submitting", "Submitting registration to registry", 30, {
|
|
33404
|
+
transactionId: registrationResult.transactionId
|
|
33371
33405
|
});
|
|
33372
33406
|
if (registrationResult.transaction) {
|
|
33373
33407
|
const transaction = Transaction.fromBytes(
|
|
@@ -33387,15 +33421,10 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33387
33421
|
}
|
|
33388
33422
|
this.logger.info(`Successfully processed registration transaction`);
|
|
33389
33423
|
}
|
|
33390
|
-
reportProgress({
|
|
33391
|
-
|
|
33392
|
-
|
|
33393
|
-
|
|
33394
|
-
details: {
|
|
33395
|
-
accountId,
|
|
33396
|
-
inboundTopicId,
|
|
33397
|
-
transactionId: registrationResult.transactionId
|
|
33398
|
-
}
|
|
33424
|
+
reportProgress("confirming", "Confirming registration transaction", 60, {
|
|
33425
|
+
accountId,
|
|
33426
|
+
inboundTopicId,
|
|
33427
|
+
transactionId: registrationResult.transactionId
|
|
33399
33428
|
});
|
|
33400
33429
|
const confirmed = await this.waitForRegistrationConfirmation(
|
|
33401
33430
|
registrationResult.transactionId,
|
|
@@ -33404,14 +33433,9 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33404
33433
|
maxAttempts,
|
|
33405
33434
|
delayMs
|
|
33406
33435
|
);
|
|
33407
|
-
reportProgress({
|
|
33408
|
-
|
|
33409
|
-
|
|
33410
|
-
progressPercent: 100,
|
|
33411
|
-
details: {
|
|
33412
|
-
confirmed,
|
|
33413
|
-
transactionId: registrationResult.transactionId
|
|
33414
|
-
}
|
|
33436
|
+
reportProgress("completed", "Agent registration complete", 100, {
|
|
33437
|
+
confirmed,
|
|
33438
|
+
transactionId: registrationResult.transactionId
|
|
33415
33439
|
});
|
|
33416
33440
|
return {
|
|
33417
33441
|
...registrationResult,
|