@hashgraphonline/standards-sdk 0.0.31 → 0.0.32
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 +7 -1
- package/dist/es/standards-sdk.es.js +260 -172
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/umd/hcs-10/base-client.d.ts +7 -1
- package/dist/umd/standards-sdk.umd.js +2 -2
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AccountResponse, HederaMirrorNode, TopicInfo } from '../services/mirror-node';
|
|
1
2
|
import { Logger, LogLevel } from '../utils/logger';
|
|
2
3
|
import { Registration } from './registrations';
|
|
3
|
-
import { HederaMirrorNode, TopicInfo, AccountResponse } from '../services/mirror-node';
|
|
4
4
|
export interface HCS10Config {
|
|
5
5
|
network: 'mainnet' | 'testnet';
|
|
6
6
|
logLevel?: LogLevel;
|
|
@@ -54,6 +54,12 @@ export declare abstract class HCS10BaseClient extends Registration {
|
|
|
54
54
|
retrieveOutboundMessages(agentAccountId: string): Promise<HCSMessage[]>;
|
|
55
55
|
hasConnectionCreated(agentAccountId: string, connectionId: number): Promise<boolean>;
|
|
56
56
|
clearCache(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Gets message content, resolving any HRL references if needed
|
|
59
|
+
* @param data The message data which might be an HRL reference
|
|
60
|
+
* @returns The resolved content
|
|
61
|
+
*/
|
|
62
|
+
getMessageContent(data: string): Promise<string>;
|
|
57
63
|
}
|
|
58
64
|
export declare class HCS10Cache {
|
|
59
65
|
private static instance;
|
|
@@ -15311,176 +15311,6 @@ const {
|
|
|
15311
15311
|
getAdapter,
|
|
15312
15312
|
mergeConfig
|
|
15313
15313
|
} = axios;
|
|
15314
|
-
class Registration {
|
|
15315
|
-
async checkRegistrationStatus(transactionId, network, baseUrl, logger) {
|
|
15316
|
-
try {
|
|
15317
|
-
const response = await fetch(`${baseUrl}/api/request-confirm`, {
|
|
15318
|
-
method: "POST",
|
|
15319
|
-
headers: {
|
|
15320
|
-
"Content-Type": "application/json",
|
|
15321
|
-
"X-Network": network
|
|
15322
|
-
},
|
|
15323
|
-
body: JSON.stringify({ transaction_id: transactionId })
|
|
15324
|
-
});
|
|
15325
|
-
if (!response.ok) {
|
|
15326
|
-
const error = `Failed to confirm registration: ${response.statusText}`;
|
|
15327
|
-
if (logger) {
|
|
15328
|
-
logger.error(error);
|
|
15329
|
-
}
|
|
15330
|
-
throw new Error(error);
|
|
15331
|
-
}
|
|
15332
|
-
return await response.json();
|
|
15333
|
-
} catch (error) {
|
|
15334
|
-
if (logger) {
|
|
15335
|
-
logger.error(`Error checking registration status: ${error.message}`);
|
|
15336
|
-
}
|
|
15337
|
-
throw error;
|
|
15338
|
-
}
|
|
15339
|
-
}
|
|
15340
|
-
async waitForRegistrationConfirmation(transactionId, network, baseUrl, maxAttempts = 60, delayMs = 2e3, logger) {
|
|
15341
|
-
let attempts = 0;
|
|
15342
|
-
while (attempts < maxAttempts) {
|
|
15343
|
-
if (logger) {
|
|
15344
|
-
logger.info(
|
|
15345
|
-
`Checking registration status. Attempt ${attempts + 1}/${maxAttempts}`
|
|
15346
|
-
);
|
|
15347
|
-
}
|
|
15348
|
-
const status = await this.checkRegistrationStatus(
|
|
15349
|
-
transactionId,
|
|
15350
|
-
network,
|
|
15351
|
-
baseUrl,
|
|
15352
|
-
logger
|
|
15353
|
-
);
|
|
15354
|
-
if (status.status === "success") {
|
|
15355
|
-
if (logger) {
|
|
15356
|
-
logger.info("Registration confirmed successfully");
|
|
15357
|
-
}
|
|
15358
|
-
return true;
|
|
15359
|
-
}
|
|
15360
|
-
if (status.status === "failed") {
|
|
15361
|
-
if (logger) {
|
|
15362
|
-
logger.error("Registration confirmation failed");
|
|
15363
|
-
}
|
|
15364
|
-
throw new Error("Registration confirmation failed");
|
|
15365
|
-
}
|
|
15366
|
-
if (logger) {
|
|
15367
|
-
logger.info(
|
|
15368
|
-
`Registration still pending. Waiting ${delayMs}ms before next attempt`
|
|
15369
|
-
);
|
|
15370
|
-
}
|
|
15371
|
-
await new Promise((resolve2) => setTimeout(resolve2, delayMs));
|
|
15372
|
-
attempts++;
|
|
15373
|
-
}
|
|
15374
|
-
if (logger) {
|
|
15375
|
-
logger.warn(`Registration not confirmed after ${maxAttempts} attempts`);
|
|
15376
|
-
}
|
|
15377
|
-
return false;
|
|
15378
|
-
}
|
|
15379
|
-
async executeRegistration(accountId, inboundTopicId, network, baseUrl, logger, metadata = { tags: [] }) {
|
|
15380
|
-
var _a;
|
|
15381
|
-
try {
|
|
15382
|
-
if (logger) {
|
|
15383
|
-
logger.info("Registering agent with guarded registry");
|
|
15384
|
-
}
|
|
15385
|
-
const response = await fetch(`${baseUrl}/api/request-register`, {
|
|
15386
|
-
method: "POST",
|
|
15387
|
-
headers: {
|
|
15388
|
-
"Content-Type": "application/json",
|
|
15389
|
-
Accept: "*/*",
|
|
15390
|
-
"Accept-Language": "en;q=0.5",
|
|
15391
|
-
Origin: baseUrl,
|
|
15392
|
-
Referer: `${baseUrl}/`,
|
|
15393
|
-
"X-Network": network
|
|
15394
|
-
},
|
|
15395
|
-
body: JSON.stringify({
|
|
15396
|
-
accountId,
|
|
15397
|
-
inboundTopicId,
|
|
15398
|
-
metadata
|
|
15399
|
-
})
|
|
15400
|
-
});
|
|
15401
|
-
const data = await response.json();
|
|
15402
|
-
if (!response.ok) {
|
|
15403
|
-
if (((_a = data.details) == null ? void 0 : _a.length) > 0) {
|
|
15404
|
-
return {
|
|
15405
|
-
validationErrors: data.details,
|
|
15406
|
-
error: data.error || "Validation failed",
|
|
15407
|
-
success: false
|
|
15408
|
-
};
|
|
15409
|
-
}
|
|
15410
|
-
return {
|
|
15411
|
-
error: data.error || "Failed to register agent",
|
|
15412
|
-
success: false
|
|
15413
|
-
};
|
|
15414
|
-
}
|
|
15415
|
-
if (logger) {
|
|
15416
|
-
logger.info(
|
|
15417
|
-
`Created new registration request. Transaction ID: ${data.transaction_id}`
|
|
15418
|
-
);
|
|
15419
|
-
}
|
|
15420
|
-
return {
|
|
15421
|
-
transactionId: data.transaction_id,
|
|
15422
|
-
transaction: data.transaction,
|
|
15423
|
-
success: true
|
|
15424
|
-
};
|
|
15425
|
-
} catch (error) {
|
|
15426
|
-
return {
|
|
15427
|
-
error: `Error during registration request: ${error.message}`,
|
|
15428
|
-
success: false
|
|
15429
|
-
};
|
|
15430
|
-
}
|
|
15431
|
-
}
|
|
15432
|
-
async findRegistrations(options = {}, baseUrl = "https://hcs-10.hashgraphonline.com") {
|
|
15433
|
-
var _a;
|
|
15434
|
-
try {
|
|
15435
|
-
const queryParams = new URLSearchParams();
|
|
15436
|
-
(_a = options.tags) == null ? void 0 : _a.forEach((tag) => queryParams.append("tags", tag));
|
|
15437
|
-
if (options.accountId) {
|
|
15438
|
-
queryParams.append("accountId", options.accountId);
|
|
15439
|
-
}
|
|
15440
|
-
if (options.network) {
|
|
15441
|
-
queryParams.append("network", options.network);
|
|
15442
|
-
}
|
|
15443
|
-
const response = await fetch(
|
|
15444
|
-
`${baseUrl}/api/registrations?${queryParams}`,
|
|
15445
|
-
{
|
|
15446
|
-
headers: {
|
|
15447
|
-
Accept: "*/*",
|
|
15448
|
-
"Accept-Language": "en;q=0.5",
|
|
15449
|
-
Origin: baseUrl,
|
|
15450
|
-
Referer: `${baseUrl}/`
|
|
15451
|
-
}
|
|
15452
|
-
}
|
|
15453
|
-
);
|
|
15454
|
-
if (!response.ok) {
|
|
15455
|
-
const error = await response.text();
|
|
15456
|
-
return {
|
|
15457
|
-
registrations: [],
|
|
15458
|
-
error: error || "Failed to fetch registrations",
|
|
15459
|
-
success: false
|
|
15460
|
-
};
|
|
15461
|
-
}
|
|
15462
|
-
const data = await response.json();
|
|
15463
|
-
if (data.error) {
|
|
15464
|
-
return {
|
|
15465
|
-
registrations: [],
|
|
15466
|
-
error: data.error,
|
|
15467
|
-
success: false
|
|
15468
|
-
};
|
|
15469
|
-
}
|
|
15470
|
-
return {
|
|
15471
|
-
registrations: data.registrations || [],
|
|
15472
|
-
success: true
|
|
15473
|
-
};
|
|
15474
|
-
} catch (e) {
|
|
15475
|
-
const error = e;
|
|
15476
|
-
return {
|
|
15477
|
-
registrations: [],
|
|
15478
|
-
error: `Error fetching registrations: ${error.message}`,
|
|
15479
|
-
success: false
|
|
15480
|
-
};
|
|
15481
|
-
}
|
|
15482
|
-
}
|
|
15483
|
-
}
|
|
15484
15314
|
class HederaMirrorNode {
|
|
15485
15315
|
constructor(network, logger) {
|
|
15486
15316
|
this.network = network;
|
|
@@ -15670,6 +15500,176 @@ class HederaMirrorNode {
|
|
|
15670
15500
|
}
|
|
15671
15501
|
}
|
|
15672
15502
|
}
|
|
15503
|
+
class Registration {
|
|
15504
|
+
async checkRegistrationStatus(transactionId, network, baseUrl, logger) {
|
|
15505
|
+
try {
|
|
15506
|
+
const response = await fetch(`${baseUrl}/api/request-confirm`, {
|
|
15507
|
+
method: "POST",
|
|
15508
|
+
headers: {
|
|
15509
|
+
"Content-Type": "application/json",
|
|
15510
|
+
"X-Network": network
|
|
15511
|
+
},
|
|
15512
|
+
body: JSON.stringify({ transaction_id: transactionId })
|
|
15513
|
+
});
|
|
15514
|
+
if (!response.ok) {
|
|
15515
|
+
const error = `Failed to confirm registration: ${response.statusText}`;
|
|
15516
|
+
if (logger) {
|
|
15517
|
+
logger.error(error);
|
|
15518
|
+
}
|
|
15519
|
+
throw new Error(error);
|
|
15520
|
+
}
|
|
15521
|
+
return await response.json();
|
|
15522
|
+
} catch (error) {
|
|
15523
|
+
if (logger) {
|
|
15524
|
+
logger.error(`Error checking registration status: ${error.message}`);
|
|
15525
|
+
}
|
|
15526
|
+
throw error;
|
|
15527
|
+
}
|
|
15528
|
+
}
|
|
15529
|
+
async waitForRegistrationConfirmation(transactionId, network, baseUrl, maxAttempts = 60, delayMs = 2e3, logger) {
|
|
15530
|
+
let attempts = 0;
|
|
15531
|
+
while (attempts < maxAttempts) {
|
|
15532
|
+
if (logger) {
|
|
15533
|
+
logger.info(
|
|
15534
|
+
`Checking registration status. Attempt ${attempts + 1}/${maxAttempts}`
|
|
15535
|
+
);
|
|
15536
|
+
}
|
|
15537
|
+
const status = await this.checkRegistrationStatus(
|
|
15538
|
+
transactionId,
|
|
15539
|
+
network,
|
|
15540
|
+
baseUrl,
|
|
15541
|
+
logger
|
|
15542
|
+
);
|
|
15543
|
+
if (status.status === "success") {
|
|
15544
|
+
if (logger) {
|
|
15545
|
+
logger.info("Registration confirmed successfully");
|
|
15546
|
+
}
|
|
15547
|
+
return true;
|
|
15548
|
+
}
|
|
15549
|
+
if (status.status === "failed") {
|
|
15550
|
+
if (logger) {
|
|
15551
|
+
logger.error("Registration confirmation failed");
|
|
15552
|
+
}
|
|
15553
|
+
throw new Error("Registration confirmation failed");
|
|
15554
|
+
}
|
|
15555
|
+
if (logger) {
|
|
15556
|
+
logger.info(
|
|
15557
|
+
`Registration still pending. Waiting ${delayMs}ms before next attempt`
|
|
15558
|
+
);
|
|
15559
|
+
}
|
|
15560
|
+
await new Promise((resolve2) => setTimeout(resolve2, delayMs));
|
|
15561
|
+
attempts++;
|
|
15562
|
+
}
|
|
15563
|
+
if (logger) {
|
|
15564
|
+
logger.warn(`Registration not confirmed after ${maxAttempts} attempts`);
|
|
15565
|
+
}
|
|
15566
|
+
return false;
|
|
15567
|
+
}
|
|
15568
|
+
async executeRegistration(accountId, inboundTopicId, network, baseUrl, logger, metadata = { tags: [] }) {
|
|
15569
|
+
var _a;
|
|
15570
|
+
try {
|
|
15571
|
+
if (logger) {
|
|
15572
|
+
logger.info("Registering agent with guarded registry");
|
|
15573
|
+
}
|
|
15574
|
+
const response = await fetch(`${baseUrl}/api/request-register`, {
|
|
15575
|
+
method: "POST",
|
|
15576
|
+
headers: {
|
|
15577
|
+
"Content-Type": "application/json",
|
|
15578
|
+
Accept: "*/*",
|
|
15579
|
+
"Accept-Language": "en;q=0.5",
|
|
15580
|
+
Origin: baseUrl,
|
|
15581
|
+
Referer: `${baseUrl}/`,
|
|
15582
|
+
"X-Network": network
|
|
15583
|
+
},
|
|
15584
|
+
body: JSON.stringify({
|
|
15585
|
+
accountId,
|
|
15586
|
+
inboundTopicId,
|
|
15587
|
+
metadata
|
|
15588
|
+
})
|
|
15589
|
+
});
|
|
15590
|
+
const data = await response.json();
|
|
15591
|
+
if (!response.ok) {
|
|
15592
|
+
if (((_a = data.details) == null ? void 0 : _a.length) > 0) {
|
|
15593
|
+
return {
|
|
15594
|
+
validationErrors: data.details,
|
|
15595
|
+
error: data.error || "Validation failed",
|
|
15596
|
+
success: false
|
|
15597
|
+
};
|
|
15598
|
+
}
|
|
15599
|
+
return {
|
|
15600
|
+
error: data.error || "Failed to register agent",
|
|
15601
|
+
success: false
|
|
15602
|
+
};
|
|
15603
|
+
}
|
|
15604
|
+
if (logger) {
|
|
15605
|
+
logger.info(
|
|
15606
|
+
`Created new registration request. Transaction ID: ${data.transaction_id}`
|
|
15607
|
+
);
|
|
15608
|
+
}
|
|
15609
|
+
return {
|
|
15610
|
+
transactionId: data.transaction_id,
|
|
15611
|
+
transaction: data.transaction,
|
|
15612
|
+
success: true
|
|
15613
|
+
};
|
|
15614
|
+
} catch (error) {
|
|
15615
|
+
return {
|
|
15616
|
+
error: `Error during registration request: ${error.message}`,
|
|
15617
|
+
success: false
|
|
15618
|
+
};
|
|
15619
|
+
}
|
|
15620
|
+
}
|
|
15621
|
+
async findRegistrations(options = {}, baseUrl = "https://hcs-10.hashgraphonline.com") {
|
|
15622
|
+
var _a;
|
|
15623
|
+
try {
|
|
15624
|
+
const queryParams = new URLSearchParams();
|
|
15625
|
+
(_a = options.tags) == null ? void 0 : _a.forEach((tag) => queryParams.append("tags", tag));
|
|
15626
|
+
if (options.accountId) {
|
|
15627
|
+
queryParams.append("accountId", options.accountId);
|
|
15628
|
+
}
|
|
15629
|
+
if (options.network) {
|
|
15630
|
+
queryParams.append("network", options.network);
|
|
15631
|
+
}
|
|
15632
|
+
const response = await fetch(
|
|
15633
|
+
`${baseUrl}/api/registrations?${queryParams}`,
|
|
15634
|
+
{
|
|
15635
|
+
headers: {
|
|
15636
|
+
Accept: "*/*",
|
|
15637
|
+
"Accept-Language": "en;q=0.5",
|
|
15638
|
+
Origin: baseUrl,
|
|
15639
|
+
Referer: `${baseUrl}/`
|
|
15640
|
+
}
|
|
15641
|
+
}
|
|
15642
|
+
);
|
|
15643
|
+
if (!response.ok) {
|
|
15644
|
+
const error = await response.text();
|
|
15645
|
+
return {
|
|
15646
|
+
registrations: [],
|
|
15647
|
+
error: error || "Failed to fetch registrations",
|
|
15648
|
+
success: false
|
|
15649
|
+
};
|
|
15650
|
+
}
|
|
15651
|
+
const data = await response.json();
|
|
15652
|
+
if (data.error) {
|
|
15653
|
+
return {
|
|
15654
|
+
registrations: [],
|
|
15655
|
+
error: data.error,
|
|
15656
|
+
success: false
|
|
15657
|
+
};
|
|
15658
|
+
}
|
|
15659
|
+
return {
|
|
15660
|
+
registrations: data.registrations || [],
|
|
15661
|
+
success: true
|
|
15662
|
+
};
|
|
15663
|
+
} catch (e) {
|
|
15664
|
+
const error = e;
|
|
15665
|
+
return {
|
|
15666
|
+
registrations: [],
|
|
15667
|
+
error: `Error fetching registrations: ${error.message}`,
|
|
15668
|
+
success: false
|
|
15669
|
+
};
|
|
15670
|
+
}
|
|
15671
|
+
}
|
|
15672
|
+
}
|
|
15673
15673
|
class HCS10BaseClient extends Registration {
|
|
15674
15674
|
constructor(config) {
|
|
15675
15675
|
super();
|
|
@@ -15874,6 +15874,37 @@ class HCS10BaseClient extends Registration {
|
|
|
15874
15874
|
clearCache() {
|
|
15875
15875
|
HCS10Cache.getInstance().clear();
|
|
15876
15876
|
}
|
|
15877
|
+
/**
|
|
15878
|
+
* Gets message content, resolving any HRL references if needed
|
|
15879
|
+
* @param data The message data which might be an HRL reference
|
|
15880
|
+
* @returns The resolved content
|
|
15881
|
+
*/
|
|
15882
|
+
async getMessageContent(data) {
|
|
15883
|
+
const hrlPattern = /^hcs:\/\/(\d+)\/([0-9.]+)$/;
|
|
15884
|
+
const match = data.match(hrlPattern);
|
|
15885
|
+
if (!match) {
|
|
15886
|
+
return data;
|
|
15887
|
+
}
|
|
15888
|
+
const [_, standard, topicId] = match;
|
|
15889
|
+
this.logger.info(
|
|
15890
|
+
`Resolving HRL reference: standard=${standard}, topicId=${topicId}`
|
|
15891
|
+
);
|
|
15892
|
+
try {
|
|
15893
|
+
const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${this.network}`;
|
|
15894
|
+
const response = await axios.get(cdnUrl);
|
|
15895
|
+
if (!response.data) {
|
|
15896
|
+
throw new Error(`Failed to fetch content from topic: ${topicId}`);
|
|
15897
|
+
}
|
|
15898
|
+
return response.data.content || response.data.text || JSON.stringify(response.data);
|
|
15899
|
+
} catch (error) {
|
|
15900
|
+
this.logger.error(
|
|
15901
|
+
`Error resolving HRL reference: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
15902
|
+
);
|
|
15903
|
+
throw new Error(
|
|
15904
|
+
`Failed to resolve HRL reference: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
15905
|
+
);
|
|
15906
|
+
}
|
|
15907
|
+
}
|
|
15877
15908
|
}
|
|
15878
15909
|
class HCS10Cache {
|
|
15879
15910
|
constructor() {
|
|
@@ -32450,6 +32481,35 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
32450
32481
|
data,
|
|
32451
32482
|
m: memo
|
|
32452
32483
|
};
|
|
32484
|
+
const payloadString = JSON.stringify(payload);
|
|
32485
|
+
const isLargePayload = Buffer2.from(payloadString).length > 1e3;
|
|
32486
|
+
if (isLargePayload) {
|
|
32487
|
+
this.logger.info(
|
|
32488
|
+
"Message payload exceeds 1000 bytes, storing via inscription"
|
|
32489
|
+
);
|
|
32490
|
+
try {
|
|
32491
|
+
const contentBuffer = Buffer2.from(data);
|
|
32492
|
+
const fileName = `message-${Date.now()}.json`;
|
|
32493
|
+
const inscriptionResult = await this.inscribeFile(
|
|
32494
|
+
contentBuffer,
|
|
32495
|
+
fileName
|
|
32496
|
+
);
|
|
32497
|
+
if (inscriptionResult == null ? void 0 : inscriptionResult.topic_id) {
|
|
32498
|
+
payload.data = `hcs://1/${inscriptionResult.topic_id}`;
|
|
32499
|
+
this.logger.info(
|
|
32500
|
+
`Large message inscribed with topic ID: ${inscriptionResult.topic_id}`
|
|
32501
|
+
);
|
|
32502
|
+
} else {
|
|
32503
|
+
throw new Error("Failed to inscribe large message content");
|
|
32504
|
+
}
|
|
32505
|
+
} catch (error) {
|
|
32506
|
+
this.logger.error("Error inscribing large message:", error);
|
|
32507
|
+
throw new Error(
|
|
32508
|
+
`Failed to handle large message: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
32509
|
+
);
|
|
32510
|
+
}
|
|
32511
|
+
}
|
|
32512
|
+
this.logger.info("Submitting message to connection topic", payload);
|
|
32453
32513
|
await this.submitPayload(
|
|
32454
32514
|
connectionTopicId,
|
|
32455
32515
|
payload,
|
|
@@ -32507,9 +32567,9 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
32507
32567
|
async submitPayload(topicId, payload, submitKey, requiresFee = false) {
|
|
32508
32568
|
const message = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
32509
32569
|
const payloadSizeInBytes = Buffer2.byteLength(message, "utf8");
|
|
32510
|
-
if (payloadSizeInBytes >
|
|
32570
|
+
if (payloadSizeInBytes > 1e3) {
|
|
32511
32571
|
throw new PayloadSizeError(
|
|
32512
|
-
"Payload size exceeds
|
|
32572
|
+
"Payload size exceeds 1000 bytes limit",
|
|
32513
32573
|
payloadSizeInBytes
|
|
32514
32574
|
);
|
|
32515
32575
|
}
|
|
@@ -33096,6 +33156,34 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
33096
33156
|
data,
|
|
33097
33157
|
m: memo
|
|
33098
33158
|
};
|
|
33159
|
+
const payloadString = JSON.stringify(payload);
|
|
33160
|
+
const isLargePayload = Buffer2.from(payloadString).length > 1e3;
|
|
33161
|
+
if (isLargePayload) {
|
|
33162
|
+
this.logger.info(
|
|
33163
|
+
"Message payload exceeds 1000 bytes, storing via inscription"
|
|
33164
|
+
);
|
|
33165
|
+
try {
|
|
33166
|
+
const contentBuffer = Buffer2.from(data);
|
|
33167
|
+
const fileName = `message-${Date.now()}.json`;
|
|
33168
|
+
const inscriptionResult = await this.inscribeFile(
|
|
33169
|
+
contentBuffer,
|
|
33170
|
+
fileName
|
|
33171
|
+
);
|
|
33172
|
+
if (inscriptionResult == null ? void 0 : inscriptionResult.topic_id) {
|
|
33173
|
+
payload.data = `hcs://1/${inscriptionResult.topic_id}`;
|
|
33174
|
+
this.logger.info(
|
|
33175
|
+
`Large message inscribed with topic ID: ${inscriptionResult.topic_id}`
|
|
33176
|
+
);
|
|
33177
|
+
} else {
|
|
33178
|
+
throw new Error("Failed to inscribe large message content");
|
|
33179
|
+
}
|
|
33180
|
+
} catch (error) {
|
|
33181
|
+
this.logger.error("Error inscribing large message:", error);
|
|
33182
|
+
throw new Error(
|
|
33183
|
+
`Failed to handle large message: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
33184
|
+
);
|
|
33185
|
+
}
|
|
33186
|
+
}
|
|
33099
33187
|
await this.submitPayload(connectionTopicId, payload);
|
|
33100
33188
|
}
|
|
33101
33189
|
async submitConnectionRequest(inboundTopicId, requestingAccountId, operatorId, memo) {
|