@hashgraphonline/standards-sdk 0.0.26 → 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 +72 -43
- 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;
|
|
@@ -31746,7 +31746,8 @@ class HCS11Client {
|
|
|
31746
31746
|
}
|
|
31747
31747
|
const signer = this.auth.signer;
|
|
31748
31748
|
const result = await transaction.signWithSigner(signer);
|
|
31749
|
-
const
|
|
31749
|
+
const frozenTransaction = await result.freezeWithSigner(signer);
|
|
31750
|
+
const response = await frozenTransaction.executeWithSigner(signer);
|
|
31750
31751
|
const receipt = await response.getReceiptWithSigner(signer);
|
|
31751
31752
|
if (receipt.status !== Status.Success) {
|
|
31752
31753
|
return {
|
|
@@ -33290,8 +33291,24 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33290
33291
|
};
|
|
33291
33292
|
}
|
|
33292
33293
|
}
|
|
33293
|
-
async createAndRegisterAgent(name, description, capabilities, metadata, pfpBuffer, pfpFileName, network, existingPfpTopicId) {
|
|
33294
|
+
async createAndRegisterAgent(name, description, capabilities, metadata, pfpBuffer, pfpFileName, network, existingPfpTopicId, options) {
|
|
33294
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);
|
|
33295
33312
|
const agentResult = await this.createAgent(
|
|
33296
33313
|
pfpBuffer,
|
|
33297
33314
|
pfpFileName,
|
|
@@ -33304,17 +33321,41 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33304
33321
|
if (!agentResult.success) {
|
|
33305
33322
|
throw new Error(agentResult.error || "Failed to create agent");
|
|
33306
33323
|
}
|
|
33324
|
+
reportProgress(
|
|
33325
|
+
"preparing",
|
|
33326
|
+
"Agent topics created, preparing registration",
|
|
33327
|
+
30
|
|
33328
|
+
);
|
|
33307
33329
|
const { accountId } = this.getAccountAndSigner();
|
|
33330
|
+
reportProgress("submitting", "Registering with Hedera registry", 40);
|
|
33308
33331
|
const registrationResult = await this.registerAgentWithGuardedRegistry(
|
|
33309
33332
|
accountId,
|
|
33310
33333
|
agentResult.inboundTopicId,
|
|
33311
|
-
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
|
+
}
|
|
33312
33348
|
);
|
|
33313
33349
|
if (!registrationResult.success) {
|
|
33314
33350
|
throw new Error(
|
|
33315
33351
|
registrationResult.error || "Failed to register agent with registry"
|
|
33316
33352
|
);
|
|
33317
33353
|
}
|
|
33354
|
+
reportProgress(
|
|
33355
|
+
"completed",
|
|
33356
|
+
"Agent creation and registration complete",
|
|
33357
|
+
100
|
|
33358
|
+
);
|
|
33318
33359
|
return {
|
|
33319
33360
|
accountId,
|
|
33320
33361
|
operatorId: `${agentResult.outboundTopicId}@${accountId}`,
|
|
@@ -33334,13 +33375,21 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33334
33375
|
const maxAttempts = (options == null ? void 0 : options.maxAttempts) ?? 60;
|
|
33335
33376
|
const delayMs = (options == null ? void 0 : options.delayMs) ?? 2e3;
|
|
33336
33377
|
const progressCallback = options == null ? void 0 : options.progressCallback;
|
|
33337
|
-
|
|
33338
|
-
progressCallback
|
|
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}`);
|
|
33389
|
+
}
|
|
33390
|
+
}
|
|
33391
|
+
};
|
|
33392
|
+
reportProgress("preparing", "Preparing agent registration", 10);
|
|
33344
33393
|
const registrationResult = await this.executeRegistration(
|
|
33345
33394
|
accountId,
|
|
33346
33395
|
inboundTopicId,
|
|
@@ -33351,16 +33400,9 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33351
33400
|
if (!registrationResult.success) {
|
|
33352
33401
|
return registrationResult;
|
|
33353
33402
|
}
|
|
33354
|
-
|
|
33355
|
-
|
|
33356
|
-
|
|
33357
|
-
message: "Submitting registration to registry",
|
|
33358
|
-
progressPercent: 30,
|
|
33359
|
-
details: {
|
|
33360
|
-
transactionId: registrationResult.transactionId
|
|
33361
|
-
}
|
|
33362
|
-
});
|
|
33363
|
-
}
|
|
33403
|
+
reportProgress("submitting", "Submitting registration to registry", 30, {
|
|
33404
|
+
transactionId: registrationResult.transactionId
|
|
33405
|
+
});
|
|
33364
33406
|
if (registrationResult.transaction) {
|
|
33365
33407
|
const transaction = Transaction.fromBytes(
|
|
33366
33408
|
Buffer2.from(registrationResult.transaction, "base64")
|
|
@@ -33379,18 +33421,11 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33379
33421
|
}
|
|
33380
33422
|
this.logger.info(`Successfully processed registration transaction`);
|
|
33381
33423
|
}
|
|
33382
|
-
|
|
33383
|
-
|
|
33384
|
-
|
|
33385
|
-
|
|
33386
|
-
|
|
33387
|
-
details: {
|
|
33388
|
-
accountId,
|
|
33389
|
-
inboundTopicId,
|
|
33390
|
-
transactionId: registrationResult.transactionId
|
|
33391
|
-
}
|
|
33392
|
-
});
|
|
33393
|
-
}
|
|
33424
|
+
reportProgress("confirming", "Confirming registration transaction", 60, {
|
|
33425
|
+
accountId,
|
|
33426
|
+
inboundTopicId,
|
|
33427
|
+
transactionId: registrationResult.transactionId
|
|
33428
|
+
});
|
|
33394
33429
|
const confirmed = await this.waitForRegistrationConfirmation(
|
|
33395
33430
|
registrationResult.transactionId,
|
|
33396
33431
|
network,
|
|
@@ -33398,22 +33433,16 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33398
33433
|
maxAttempts,
|
|
33399
33434
|
delayMs
|
|
33400
33435
|
);
|
|
33401
|
-
|
|
33402
|
-
|
|
33403
|
-
|
|
33404
|
-
|
|
33405
|
-
progressPercent: 100,
|
|
33406
|
-
details: {
|
|
33407
|
-
confirmed,
|
|
33408
|
-
transactionId: registrationResult.transactionId
|
|
33409
|
-
}
|
|
33410
|
-
});
|
|
33411
|
-
}
|
|
33436
|
+
reportProgress("completed", "Agent registration complete", 100, {
|
|
33437
|
+
confirmed,
|
|
33438
|
+
transactionId: registrationResult.transactionId
|
|
33439
|
+
});
|
|
33412
33440
|
return {
|
|
33413
33441
|
...registrationResult,
|
|
33414
33442
|
confirmed
|
|
33415
33443
|
};
|
|
33416
33444
|
} catch (error) {
|
|
33445
|
+
this.logger.error(`Registration error: ${error.message}`);
|
|
33417
33446
|
return {
|
|
33418
33447
|
error: `Error during registration: ${error.message}`,
|
|
33419
33448
|
success: false
|