@hashgraphonline/standards-sdk 0.0.27 → 0.0.29
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 +64 -41
- 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 +2 -2
- 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;
|
|
@@ -31745,8 +31745,7 @@ class HCS11Client {
|
|
|
31745
31745
|
throw new Error("No valid authentication method provided");
|
|
31746
31746
|
}
|
|
31747
31747
|
const signer = this.auth.signer;
|
|
31748
|
-
const
|
|
31749
|
-
const frozenTransaction = await result.freezeWithSigner(signer);
|
|
31748
|
+
const frozenTransaction = await transaction.freezeWithSigner(signer);
|
|
31750
31749
|
const response = await frozenTransaction.executeWithSigner(signer);
|
|
31751
31750
|
const receipt = await response.getReceiptWithSigner(signer);
|
|
31752
31751
|
if (receipt.status !== Status.Success) {
|
|
@@ -33291,8 +33290,24 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33291
33290
|
};
|
|
33292
33291
|
}
|
|
33293
33292
|
}
|
|
33294
|
-
async createAndRegisterAgent(name, description, capabilities, metadata, pfpBuffer, pfpFileName, network, existingPfpTopicId) {
|
|
33293
|
+
async createAndRegisterAgent(name, description, capabilities, metadata, pfpBuffer, pfpFileName, network, existingPfpTopicId, options) {
|
|
33295
33294
|
try {
|
|
33295
|
+
const progressCallback = options == null ? void 0 : options.progressCallback;
|
|
33296
|
+
const reportProgress = (stage, message, percent, details) => {
|
|
33297
|
+
if (progressCallback) {
|
|
33298
|
+
try {
|
|
33299
|
+
progressCallback({
|
|
33300
|
+
stage,
|
|
33301
|
+
message,
|
|
33302
|
+
progressPercent: percent,
|
|
33303
|
+
details
|
|
33304
|
+
});
|
|
33305
|
+
} catch (err) {
|
|
33306
|
+
this.logger.warn(`Error in progress callback: ${err}`);
|
|
33307
|
+
}
|
|
33308
|
+
}
|
|
33309
|
+
};
|
|
33310
|
+
reportProgress("preparing", "Creating agent topics and profile", 10);
|
|
33296
33311
|
const agentResult = await this.createAgent(
|
|
33297
33312
|
pfpBuffer,
|
|
33298
33313
|
pfpFileName,
|
|
@@ -33305,17 +33320,41 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33305
33320
|
if (!agentResult.success) {
|
|
33306
33321
|
throw new Error(agentResult.error || "Failed to create agent");
|
|
33307
33322
|
}
|
|
33323
|
+
reportProgress(
|
|
33324
|
+
"preparing",
|
|
33325
|
+
"Agent topics created, preparing registration",
|
|
33326
|
+
30
|
|
33327
|
+
);
|
|
33308
33328
|
const { accountId } = this.getAccountAndSigner();
|
|
33329
|
+
reportProgress("submitting", "Registering with Hedera registry", 40);
|
|
33309
33330
|
const registrationResult = await this.registerAgentWithGuardedRegistry(
|
|
33310
33331
|
accountId,
|
|
33311
33332
|
agentResult.inboundTopicId,
|
|
33312
|
-
network
|
|
33333
|
+
network,
|
|
33334
|
+
{
|
|
33335
|
+
progressCallback: (progress) => {
|
|
33336
|
+
const adjustedPercent = 40 + (progress.progressPercent || 0) * 0.6;
|
|
33337
|
+
reportProgress(
|
|
33338
|
+
progress.stage,
|
|
33339
|
+
progress.message,
|
|
33340
|
+
adjustedPercent,
|
|
33341
|
+
progress.details
|
|
33342
|
+
);
|
|
33343
|
+
},
|
|
33344
|
+
maxAttempts: options == null ? void 0 : options.maxAttempts,
|
|
33345
|
+
delayMs: options == null ? void 0 : options.delayMs
|
|
33346
|
+
}
|
|
33313
33347
|
);
|
|
33314
33348
|
if (!registrationResult.success) {
|
|
33315
33349
|
throw new Error(
|
|
33316
33350
|
registrationResult.error || "Failed to register agent with registry"
|
|
33317
33351
|
);
|
|
33318
33352
|
}
|
|
33353
|
+
reportProgress(
|
|
33354
|
+
"completed",
|
|
33355
|
+
"Agent creation and registration complete",
|
|
33356
|
+
100
|
|
33357
|
+
);
|
|
33319
33358
|
return {
|
|
33320
33359
|
accountId,
|
|
33321
33360
|
operatorId: `${agentResult.outboundTopicId}@${accountId}`,
|
|
@@ -33335,22 +33374,21 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33335
33374
|
const maxAttempts = (options == null ? void 0 : options.maxAttempts) ?? 60;
|
|
33336
33375
|
const delayMs = (options == null ? void 0 : options.delayMs) ?? 2e3;
|
|
33337
33376
|
const progressCallback = options == null ? void 0 : options.progressCallback;
|
|
33338
|
-
|
|
33339
|
-
|
|
33340
|
-
|
|
33341
|
-
|
|
33342
|
-
|
|
33343
|
-
|
|
33377
|
+
const reportProgress = (stage, message, percent, details) => {
|
|
33378
|
+
if (progressCallback) {
|
|
33379
|
+
try {
|
|
33380
|
+
progressCallback({
|
|
33381
|
+
stage,
|
|
33382
|
+
message,
|
|
33383
|
+
progressPercent: percent,
|
|
33384
|
+
details
|
|
33385
|
+
});
|
|
33386
|
+
} catch (err) {
|
|
33387
|
+
this.logger.warn(`Error in progress callback: ${err}`);
|
|
33344
33388
|
}
|
|
33345
|
-
} catch (error) {
|
|
33346
|
-
this.logger.error(`Error in progress callback: ${error}`);
|
|
33347
33389
|
}
|
|
33348
33390
|
};
|
|
33349
|
-
reportProgress(
|
|
33350
|
-
stage: "preparing",
|
|
33351
|
-
message: "Preparing agent registration",
|
|
33352
|
-
progressPercent: 10
|
|
33353
|
-
});
|
|
33391
|
+
reportProgress("preparing", "Preparing agent registration", 10);
|
|
33354
33392
|
const registrationResult = await this.executeRegistration(
|
|
33355
33393
|
accountId,
|
|
33356
33394
|
inboundTopicId,
|
|
@@ -33361,13 +33399,8 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33361
33399
|
if (!registrationResult.success) {
|
|
33362
33400
|
return registrationResult;
|
|
33363
33401
|
}
|
|
33364
|
-
reportProgress({
|
|
33365
|
-
|
|
33366
|
-
message: "Submitting registration to registry",
|
|
33367
|
-
progressPercent: 30,
|
|
33368
|
-
details: {
|
|
33369
|
-
transactionId: registrationResult.transactionId
|
|
33370
|
-
}
|
|
33402
|
+
reportProgress("submitting", "Submitting registration to registry", 30, {
|
|
33403
|
+
transactionId: registrationResult.transactionId
|
|
33371
33404
|
});
|
|
33372
33405
|
if (registrationResult.transaction) {
|
|
33373
33406
|
const transaction = Transaction.fromBytes(
|
|
@@ -33387,15 +33420,10 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33387
33420
|
}
|
|
33388
33421
|
this.logger.info(`Successfully processed registration transaction`);
|
|
33389
33422
|
}
|
|
33390
|
-
reportProgress({
|
|
33391
|
-
|
|
33392
|
-
|
|
33393
|
-
|
|
33394
|
-
details: {
|
|
33395
|
-
accountId,
|
|
33396
|
-
inboundTopicId,
|
|
33397
|
-
transactionId: registrationResult.transactionId
|
|
33398
|
-
}
|
|
33423
|
+
reportProgress("confirming", "Confirming registration transaction", 60, {
|
|
33424
|
+
accountId,
|
|
33425
|
+
inboundTopicId,
|
|
33426
|
+
transactionId: registrationResult.transactionId
|
|
33399
33427
|
});
|
|
33400
33428
|
const confirmed = await this.waitForRegistrationConfirmation(
|
|
33401
33429
|
registrationResult.transactionId,
|
|
@@ -33404,14 +33432,9 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33404
33432
|
maxAttempts,
|
|
33405
33433
|
delayMs
|
|
33406
33434
|
);
|
|
33407
|
-
reportProgress({
|
|
33408
|
-
|
|
33409
|
-
|
|
33410
|
-
progressPercent: 100,
|
|
33411
|
-
details: {
|
|
33412
|
-
confirmed,
|
|
33413
|
-
transactionId: registrationResult.transactionId
|
|
33414
|
-
}
|
|
33435
|
+
reportProgress("completed", "Agent registration complete", 100, {
|
|
33436
|
+
confirmed,
|
|
33437
|
+
transactionId: registrationResult.transactionId
|
|
33415
33438
|
});
|
|
33416
33439
|
return {
|
|
33417
33440
|
...registrationResult,
|