@hashgraphonline/standards-sdk 0.1.141-canary.38 → 0.1.141-canary.39
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/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-11/types.d.ts +1 -0
- package/dist/cjs/hcs-11/types.d.ts.map +1 -1
- package/dist/cjs/hcs-21/browser.d.ts +17 -7
- package/dist/cjs/hcs-21/browser.d.ts.map +1 -1
- package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-21/types.d.ts +3 -0
- package/dist/cjs/hcs-21/types.d.ts.map +1 -1
- package/dist/cjs/hcs-21/verify.d.ts.map +1 -1
- package/dist/cjs/inscribe/inscriber.d.ts +2 -1
- package/dist/cjs/inscribe/inscriber.d.ts.map +1 -1
- package/dist/cjs/inscribe/types.d.ts +5 -0
- package/dist/cjs/inscribe/types.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +14 -14
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-11/types.d.ts +1 -0
- package/dist/es/hcs-11/types.d.ts.map +1 -1
- package/dist/es/hcs-21/browser.d.ts +17 -7
- package/dist/es/hcs-21/browser.d.ts.map +1 -1
- package/dist/es/hcs-21/sdk.d.ts.map +1 -1
- package/dist/es/hcs-21/types.d.ts +3 -0
- package/dist/es/hcs-21/types.d.ts.map +1 -1
- package/dist/es/hcs-21/verify.d.ts.map +1 -1
- package/dist/es/inscribe/inscriber.d.ts +2 -1
- package/dist/es/inscribe/inscriber.d.ts.map +1 -1
- package/dist/es/inscribe/types.d.ts +5 -0
- package/dist/es/inscribe/types.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +14 -14
- package/dist/es/standards-sdk.es100.js +1 -1
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es111.js +5 -5
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es122.js +1 -1
- package/dist/es/standards-sdk.es123.js +5 -5
- package/dist/es/standards-sdk.es125.js +93 -5
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +1 -1
- package/dist/es/standards-sdk.es128.js +2 -2
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es135.js +28 -82
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +766 -28
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +12269 -12
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +34 -12266
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es140.js +17 -766
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +168 -38
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +321 -55
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +294 -120
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +322 -191
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +279 -294
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +63 -440
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +55 -330
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +66 -60
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es17.js +1 -1
- package/dist/es/standards-sdk.es19.js +3 -3
- package/dist/es/standards-sdk.es2.js +72 -26
- package/dist/es/standards-sdk.es2.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +2 -2
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es28.js +7 -5
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es36.js +3 -2
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +2 -2
- package/dist/es/standards-sdk.es38.js +1 -1
- package/dist/es/standards-sdk.es54.js +1 -1
- package/dist/es/standards-sdk.es57.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es61.js +1 -1
- package/dist/es/standards-sdk.es63.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +1 -1
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es70.js +1 -1
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es78.js +1 -1
- package/dist/es/standards-sdk.es79.js +1 -1
- package/dist/es/standards-sdk.es8.js +1 -1
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +1 -1
- package/dist/es/standards-sdk.es84.js +3 -1
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +256 -9
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +1 -1
- package/package.json +1 -1
|
@@ -1,79 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return void 0;
|
|
1
|
+
import { isBrowser } from "./standards-sdk.es119.js";
|
|
2
|
+
let nodeRequire;
|
|
3
|
+
function isModuleNotFound(specifier, error) {
|
|
4
|
+
if (!error || typeof error !== "object") {
|
|
5
|
+
return false;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
).toString()}`;
|
|
7
|
+
const code = Reflect.get(error, "code");
|
|
8
|
+
const message = Reflect.get(error, "message");
|
|
9
|
+
const messageText = typeof message === "string" ? message : "";
|
|
10
|
+
if (typeof code === "string" && code.includes("MODULE_NOT_FOUND")) {
|
|
11
|
+
return messageText.includes(specifier);
|
|
14
12
|
}
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"hex"
|
|
21
|
-
)}`;
|
|
22
|
-
}
|
|
23
|
-
if (key?.keyList?.keys?.length > 0) {
|
|
24
|
-
const keys = key.keyList.keys.map((k) => parseKey(k)).filter(Boolean);
|
|
25
|
-
return `KeyList (${keys.length} keys): [${keys.join(", ")}]`;
|
|
13
|
+
if (messageText) {
|
|
14
|
+
const lowered = messageText.toLowerCase();
|
|
15
|
+
if (lowered.includes("cannot find module") || lowered.includes("module not found") || lowered.includes("cannot find package")) {
|
|
16
|
+
return lowered.includes(specifier.toLowerCase());
|
|
17
|
+
}
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
async function resolveNodeRequire() {
|
|
22
|
+
if (nodeRequire !== void 0) {
|
|
23
|
+
return nodeRequire;
|
|
30
24
|
}
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
key.delegatableContractId.realmNum ?? 0,
|
|
35
|
-
key.delegatableContractId.contractNum ?? 0
|
|
36
|
-
).toString()}`;
|
|
25
|
+
if (isBrowser) {
|
|
26
|
+
nodeRequire = null;
|
|
27
|
+
return nodeRequire;
|
|
37
28
|
}
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
try {
|
|
30
|
+
const globalObject = typeof global !== "undefined" ? global : globalThis;
|
|
31
|
+
const req = globalObject.process?.mainModule?.require ?? globalObject.require;
|
|
32
|
+
nodeRequire = typeof req === "function" && typeof req.resolve === "function" ? req : null;
|
|
33
|
+
} catch {
|
|
34
|
+
nodeRequire = null;
|
|
40
35
|
}
|
|
41
|
-
return
|
|
36
|
+
return nodeRequire;
|
|
42
37
|
}
|
|
43
|
-
function
|
|
38
|
+
async function dynamicImport(specifier) {
|
|
44
39
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
const decoded = proto.TransactionList.decode(bytes);
|
|
50
|
-
if (!decoded.transactionList || decoded.transactionList.length === 0) {
|
|
40
|
+
return await import(specifier);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (isModuleNotFound(specifier, error)) {
|
|
51
43
|
return null;
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function optionalImport(specifier) {
|
|
49
|
+
if (isBrowser) {
|
|
50
|
+
return dynamicImport(specifier);
|
|
51
|
+
}
|
|
52
|
+
const requireFn = await resolveNodeRequire();
|
|
53
|
+
if (requireFn) {
|
|
54
|
+
try {
|
|
55
|
+
return requireFn(specifier);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (!isModuleNotFound(specifier, error)) {
|
|
58
|
+
throw error;
|
|
63
59
|
}
|
|
64
60
|
}
|
|
61
|
+
}
|
|
62
|
+
return dynamicImport(specifier);
|
|
63
|
+
}
|
|
64
|
+
function optionalImportSync(specifier) {
|
|
65
|
+
if (isBrowser) {
|
|
65
66
|
return null;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const globalObject = typeof global !== "undefined" ? global : globalThis;
|
|
70
|
+
const req = globalObject.process?.mainModule?.require ?? globalObject.require;
|
|
71
|
+
if (typeof req === "function" && typeof req.resolve === "function") {
|
|
72
|
+
return req(specifier);
|
|
73
|
+
}
|
|
66
74
|
} catch (error) {
|
|
67
|
-
|
|
75
|
+
if (!isModuleNotFound(specifier, error)) {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
function hasTransactionType(transaction, transactionField) {
|
|
71
|
-
const txBody = extractTransactionBody(transaction);
|
|
72
|
-
return !!(txBody && txBody[transactionField]);
|
|
79
|
+
return null;
|
|
73
80
|
}
|
|
74
81
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
parseKey
|
|
82
|
+
optionalImport,
|
|
83
|
+
optionalImportSync
|
|
78
84
|
};
|
|
79
85
|
//# sourceMappingURL=standards-sdk.es148.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es148.js","sources":["../../src/utils/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es148.js","sources":["../../src/utils/dynamic-import.ts"],"sourcesContent":["import { isBrowser } from './is-browser';\n\nlet nodeRequire: NodeRequire | null | undefined;\n\nfunction isModuleNotFound(specifier: string, error: unknown): boolean {\n if (!error || typeof error !== 'object') {\n return false;\n }\n const code = Reflect.get(error, 'code');\n const message = Reflect.get(error, 'message');\n const messageText = typeof message === 'string' ? message : '';\n\n if (typeof code === 'string' && code.includes('MODULE_NOT_FOUND')) {\n return messageText.includes(specifier);\n }\n\n if (messageText) {\n const lowered = messageText.toLowerCase();\n if (\n lowered.includes('cannot find module') ||\n lowered.includes('module not found') ||\n lowered.includes('cannot find package')\n ) {\n return lowered.includes(specifier.toLowerCase());\n }\n }\n\n return false;\n}\n\nasync function resolveNodeRequire(): Promise<NodeRequire | null> {\n if (nodeRequire !== undefined) {\n return nodeRequire;\n }\n\n if (isBrowser) {\n nodeRequire = null;\n return nodeRequire;\n }\n\n try {\n const globalObject =\n typeof global !== 'undefined'\n ? (global as typeof globalThis)\n : globalThis;\n const req =\n globalObject.process?.mainModule?.require ??\n (globalObject as { require?: NodeRequire }).require;\n\n nodeRequire =\n typeof req === 'function' &&\n typeof (req as NodeRequire).resolve === 'function'\n ? (req as NodeRequire)\n : null;\n } catch {\n nodeRequire = null;\n }\n\n return nodeRequire;\n}\n\nasync function dynamicImport<T>(specifier: string): Promise<T | null> {\n try {\n return (await import(specifier)) as T;\n } catch (error) {\n if (isModuleNotFound(specifier, error)) {\n return null;\n }\n throw error as Error;\n }\n}\n\nexport async function optionalImport<T>(specifier: string): Promise<T | null> {\n if (isBrowser) {\n return dynamicImport<T>(specifier);\n }\n\n const requireFn = await resolveNodeRequire();\n if (requireFn) {\n try {\n return requireFn(specifier) as T;\n } catch (error) {\n if (!isModuleNotFound(specifier, error)) {\n throw error as Error;\n }\n }\n }\n\n return dynamicImport<T>(specifier);\n}\n\nexport function optionalImportSync<T>(specifier: string): T | null {\n if (isBrowser) {\n return null;\n }\n\n try {\n const globalObject =\n typeof global !== 'undefined'\n ? (global as typeof globalThis)\n : globalThis;\n const req =\n globalObject.process?.mainModule?.require ??\n (globalObject as { require?: NodeRequire }).require;\n\n if (\n typeof req === 'function' &&\n typeof (req as NodeRequire).resolve === 'function'\n ) {\n return req(specifier) as T;\n }\n } catch (error) {\n if (!isModuleNotFound(specifier, error)) {\n throw error as Error;\n }\n }\n\n return null;\n}\n"],"names":[],"mappings":";AAEA,IAAI;AAEJ,SAAS,iBAAiB,WAAmB,OAAyB;AACpE,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO;AAAA,EACT;AACA,QAAM,OAAO,QAAQ,IAAI,OAAO,MAAM;AACtC,QAAM,UAAU,QAAQ,IAAI,OAAO,SAAS;AAC5C,QAAM,cAAc,OA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AA,EACT;AAEA,MAAI;AACF,UAAM,eACJ,OAAO,WAAW,cACb,SACD;AACN,UAAM,MACJ,aAAa,SAAS,YAAY,WACjC,aAA2C;AAE9C,QACE,OAAO,QAAQ,cACf,OAAQ,IAAoB,YAAY,YACxC;AACA,aAAO,IAAI,SAAS;AAAA,IACtB;AAAA,EACF,SAAS,OAAO;AACd,QAAI,CAAC,iBAAiB,WAAW,KAAK,GAAG;AACvC,YAAM;AAAA,IACR;AAAA,EACF;AAEA,SAAO;AACT;"}
|
|
@@ -8,7 +8,7 @@ import "node:buffer";
|
|
|
8
8
|
import "node:crypto";
|
|
9
9
|
import "@noble/curves/secp256k1.js";
|
|
10
10
|
import "./standards-sdk.es130.js";
|
|
11
|
-
import "./standards-sdk.
|
|
11
|
+
import "./standards-sdk.es136.js";
|
|
12
12
|
import "zod";
|
|
13
13
|
import { buildHcs10SubmitConnectionRequestTx, buildHcs10OutboundConnectionRequestRecordTx, buildHcs10OutboundConnectionCreatedRecordTx } from "./standards-sdk.es23.js";
|
|
14
14
|
import { HRLResolver } from "./standards-sdk.es110.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./standards-sdk.es2.js";
|
|
2
2
|
import { Client, PrivateKey, AccountCreateTransaction, Hbar, CustomFixedFee, AccountId, TokenId, KeyList, TopicMessageSubmitTransaction, Transaction, ScheduleCreateTransaction, Timestamp } from "@hashgraph/sdk";
|
|
3
3
|
import { AccountCreationError, TopicCreationError, ConnectionConfirmationError, PayloadSizeError } from "./standards-sdk.es18.js";
|
|
4
|
-
import { InscriptionSDK } from "./standards-sdk.
|
|
4
|
+
import { InscriptionSDK } from "./standards-sdk.es137.js";
|
|
5
5
|
import { Logger } from "./standards-sdk.es106.js";
|
|
6
6
|
import { accountIdsToExemptKeys } from "./standards-sdk.es108.js";
|
|
7
7
|
import { ProgressReporter } from "./standards-sdk.es109.js";
|
|
@@ -12,7 +12,7 @@ import "node:buffer";
|
|
|
12
12
|
import "node:crypto";
|
|
13
13
|
import "@noble/curves/secp256k1.js";
|
|
14
14
|
import "./standards-sdk.es130.js";
|
|
15
|
-
import "./standards-sdk.
|
|
15
|
+
import "./standards-sdk.es136.js";
|
|
16
16
|
import "zod";
|
|
17
17
|
import "buffer";
|
|
18
18
|
import "ethers";
|
|
@@ -27,7 +27,7 @@ import { InboundTopicType } from "./standards-sdk.es29.js";
|
|
|
27
27
|
import { HCS11Client } from "./standards-sdk.es28.js";
|
|
28
28
|
import { inscribe } from "./standards-sdk.es125.js";
|
|
29
29
|
import { addSeconds } from "date-fns";
|
|
30
|
-
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.
|
|
30
|
+
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.es139.js";
|
|
31
31
|
import { buildHcs10CreateInboundTopicTx, buildHcs10CreateConnectionTopicTx, buildHcs10ConfirmConnectionTx, buildHcs10SendMessageTx, buildHcs10RegistryRegisterTx, buildHcs10CreateOutboundTopicTx, buildHcs10CreateRegistryTopicTx } from "./standards-sdk.es23.js";
|
|
32
32
|
class HCS10Client extends HCS10BaseClient {
|
|
33
33
|
constructor(config) {
|
|
@@ -1,40 +1,87 @@
|
|
|
1
|
-
import { optionalImportSync } from "./standards-sdk.es135.js";
|
|
2
1
|
const accountIdPattern = /^\d+\.\d+\.\d+$/u;
|
|
3
2
|
const prototypeMarker = Symbol.for("standards-sdk.topic-auto-renew.patch");
|
|
4
3
|
const accountMarker = Symbol.for("standards-sdk.account-id.patch");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
11
|
-
const sdkModule = optionalImportSync("@hashgraph/sdk");
|
|
12
|
-
const candidates = [];
|
|
13
|
-
if (accountModule?.default && topicModule?.default) {
|
|
14
|
-
candidates.push({
|
|
15
|
-
accountId: accountModule.default,
|
|
16
|
-
topic: topicModule.default
|
|
17
|
-
});
|
|
4
|
+
const nodeRequire = getNodeRequire();
|
|
5
|
+
if (nodeRequire) {
|
|
6
|
+
bootstrap(nodeRequire);
|
|
7
|
+
} else {
|
|
8
|
+
Reflect.set(globalThis, "__standardsSdkTopicAutoRenewPatched", false);
|
|
18
9
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
function bootstrap(requireFn) {
|
|
11
|
+
const accountModule = safeRequire(
|
|
12
|
+
requireFn,
|
|
13
|
+
"@hashgraph/sdk/lib/account/AccountId.cjs"
|
|
14
|
+
);
|
|
15
|
+
const topicModule = safeRequire(
|
|
16
|
+
requireFn,
|
|
17
|
+
"@hashgraph/sdk/lib/topic/TopicCreateTransaction.cjs"
|
|
18
|
+
);
|
|
19
|
+
const sdkModule = safeRequire(requireFn, "@hashgraph/sdk");
|
|
20
|
+
const candidates = [];
|
|
21
|
+
if (accountModule?.default && topicModule?.default) {
|
|
22
|
+
candidates.push({
|
|
23
|
+
accountId: accountModule.default,
|
|
24
|
+
topic: topicModule.default
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (sdkModule) {
|
|
28
|
+
candidates.push({
|
|
29
|
+
accountId: sdkModule.AccountId ?? sdkModule.default?.AccountId,
|
|
30
|
+
topic: sdkModule.TopicCreateTransaction ?? sdkModule.default?.TopicCreateTransaction
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
patchTopicModule(candidate.topic, candidate.accountId);
|
|
35
|
+
}
|
|
36
|
+
Reflect.set(globalThis, "__standardsSdkTopicAutoRenewPatched", true);
|
|
24
37
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
function getNodeRequire() {
|
|
39
|
+
const moduleConstructor = getModuleConstructor();
|
|
40
|
+
if (moduleConstructor?.createRequire) {
|
|
41
|
+
try {
|
|
42
|
+
return moduleConstructor.createRequire(import.meta.url);
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (typeof require === "function") {
|
|
48
|
+
return require;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function getModuleConstructor() {
|
|
53
|
+
try {
|
|
54
|
+
if (typeof module !== "undefined" && module?.createRequire) {
|
|
55
|
+
return module;
|
|
56
|
+
}
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
if (typeof require === "function") {
|
|
61
|
+
const requiredModule = require("module");
|
|
62
|
+
if (requiredModule?.createRequire) {
|
|
63
|
+
return requiredModule;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
function safeRequire(requireFn, moduleId) {
|
|
71
|
+
try {
|
|
72
|
+
return requireFn(moduleId);
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
28
76
|
}
|
|
29
|
-
Reflect.set(globalThis, "__standardsSdkTopicAutoRenewPatched", patched);
|
|
30
77
|
function patchTopicModule(topicCtor, accountCtor) {
|
|
31
78
|
if (!topicCtor || !accountCtor) {
|
|
32
|
-
return
|
|
79
|
+
return;
|
|
33
80
|
}
|
|
34
81
|
patchAccountId(accountCtor);
|
|
35
82
|
const prototype = topicCtor.prototype;
|
|
36
83
|
if (Reflect.get(prototype, prototypeMarker)) {
|
|
37
|
-
return
|
|
84
|
+
return;
|
|
38
85
|
}
|
|
39
86
|
const originalSet = prototype.setAutoRenewAccountId;
|
|
40
87
|
const originalFreeze = prototype.freezeWith;
|
|
@@ -66,7 +113,6 @@ function patchTopicModule(topicCtor, accountCtor) {
|
|
|
66
113
|
return originalFreeze.call(this, client);
|
|
67
114
|
};
|
|
68
115
|
Reflect.set(prototype, prototypeMarker, true);
|
|
69
|
-
return true;
|
|
70
116
|
}
|
|
71
117
|
function patchAccountId(accountCtor) {
|
|
72
118
|
if (Reflect.get(accountCtor, accountMarker)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es2.js","sources":["../../src/patches/topic-autorenew-patch.ts"],"sourcesContent":["type TopicCreateTransactionCtor =\n (typeof import('@hashgraph/sdk'))['TopicCreateTransaction'];\ntype AccountIdCtor = (typeof import('@hashgraph/sdk'))['AccountId'];\ntype AccountIdInstance = InstanceType<AccountIdCtor>;\nimport { optionalImportSync } from '../utils/dynamic-import';\n\nconst accountIdPattern = /^\\d+\\.\\d+\\.\\d+$/u;\nconst prototypeMarker = Symbol.for('standards-sdk.topic-auto-renew.patch');\nconst accountMarker = Symbol.for('standards-sdk.account-id.patch');\n\nconst accountModule = optionalImportSync<{ default: AccountIdCtor }>(\n '@hashgraph/sdk/lib/account/AccountId.cjs',\n);\nconst topicModule = optionalImportSync<{ default: TopicCreateTransactionCtor }>(\n '@hashgraph/sdk/lib/topic/TopicCreateTransaction.cjs',\n);\nconst sdkModule = optionalImportSync<{\n AccountId?: AccountIdCtor;\n TopicCreateTransaction?: TopicCreateTransactionCtor;\n default?: {\n AccountId?: AccountIdCtor;\n TopicCreateTransaction?: TopicCreateTransactionCtor;\n };\n}>('@hashgraph/sdk');\n\nconst candidates: Array<{\n accountId?: AccountIdCtor;\n topic?: TopicCreateTransactionCtor;\n}> = [];\n\nif (accountModule?.default && topicModule?.default) {\n candidates.push({\n accountId: accountModule.default,\n topic: topicModule.default,\n });\n}\n\nif (sdkModule) {\n candidates.push({\n accountId: sdkModule.AccountId ?? sdkModule.default?.AccountId,\n topic:\n sdkModule.TopicCreateTransaction ?? sdkModule.default?.TopicCreateTransaction,\n });\n}\n\nlet patched = false;\n\nfor (const candidate of candidates) {\n patched = patchTopicModule(candidate.topic, candidate.accountId) || patched;\n}\n\nReflect.set(globalThis, '__standardsSdkTopicAutoRenewPatched', patched);\n\nfunction patchTopicModule(\n topicCtor?: TopicCreateTransactionCtor,\n accountCtor?: AccountIdCtor,\n): boolean {\n if (!topicCtor || !accountCtor) {\n return false;\n }\n\n patchAccountId(accountCtor);\n\n const prototype = topicCtor.prototype;\n\n if (Reflect.get(prototype, prototypeMarker)) {\n return false;\n }\n\n const originalSet = prototype.setAutoRenewAccountId;\n const originalFreeze = prototype.freezeWith;\n\n prototype.setAutoRenewAccountId = function setAutoRenewAccountIdPatched(\n this: TopicPrototype,\n autoRenewAccountId: unknown,\n ) {\n const resolved = resolveAccountId(autoRenewAccountId, accountCtor);\n\n if (resolved) {\n requireNotFrozen(this);\n this._autoRenewAccountId = resolved;\n return this;\n }\n\n return originalSet.call(\n this,\n autoRenewAccountId as AccountIdInstance | string,\n );\n };\n\n prototype.freezeWith = function freezeWithPatched(\n this: TopicPrototype,\n client?: unknown,\n ) {\n if (\n !this.getAutoRenewAccountId ||\n typeof this.getAutoRenewAccountId !== 'function'\n ) {\n return originalFreeze.call(this, client);\n }\n\n const current = this.getAutoRenewAccountId();\n\n if (!current) {\n const transactionAccountId = this.transactionId?.accountId;\n const operatorAccountId = (client as ClientLike | null | undefined)\n ?.operatorAccountId;\n const resolved =\n resolveAccountId(transactionAccountId, accountCtor) ??\n resolveAccountId(operatorAccountId, accountCtor);\n\n if (resolved) {\n this._autoRenewAccountId = resolved;\n }\n }\n\n return originalFreeze.call(this, client);\n };\n\n Reflect.set(prototype, prototypeMarker, true);\n return true;\n}\n\nfunction patchAccountId(accountCtor: AccountIdCtor): void {\n if (Reflect.get(accountCtor, accountMarker)) {\n return;\n }\n\n const originalFromString = accountCtor.fromString.bind(accountCtor);\n\n accountCtor.fromString = function accountIdFromStringPatched(\n value: unknown,\n ): AccountIdInstance {\n if (typeof value === 'string') {\n return originalFromString(value);\n }\n\n const extracted = extractAccountIdString(value);\n\n if (extracted) {\n return originalFromString(extracted);\n }\n\n if (isProtoAccountId(value)) {\n const shard = toNumericString(value.shard);\n const realm = toNumericString(value.realm);\n const num = toNumericString(value.num);\n\n if (shard && realm && num) {\n return originalFromString(`${shard}.${realm}.${num}`);\n }\n }\n\n return originalFromString(value as string);\n };\n\n Reflect.set(accountCtor, accountMarker, true);\n}\n\nfunction resolveAccountId(\n value: unknown,\n accountCtor: AccountIdCtor,\n): AccountIdInstance | null {\n if (value instanceof accountCtor) {\n return value;\n }\n\n if (typeof value === 'string' && accountIdPattern.test(value)) {\n return accountCtor.fromString(value);\n }\n\n const normalized = normalizeAutoRenewValue(value);\n\n if (normalized) {\n return accountCtor.fromString(normalized);\n }\n\n return null;\n}\n\nfunction normalizeAutoRenewValue(value: unknown): string | null {\n if (typeof value === 'string' && accountIdPattern.test(value)) {\n return value;\n }\n\n const extracted = extractAccountIdString(value);\n\n if (extracted) {\n return extracted;\n }\n\n if (isProtoAccountId(value)) {\n const shard = toNumericString(value.shard);\n const realm = toNumericString(value.realm);\n const num = toNumericString(value.num);\n\n if (shard && realm && num) {\n const composed = `${shard}.${realm}.${num}`;\n if (accountIdPattern.test(composed)) {\n return composed;\n }\n }\n }\n\n return null;\n}\n\nfunction extractAccountIdString(value: unknown): string | null {\n if (typeof value !== 'object' || value === null) {\n return null;\n }\n\n const candidate = value as { toString?: () => unknown };\n const method = candidate.toString;\n\n if (typeof method !== 'function') {\n return null;\n }\n\n const result = method.call(value);\n\n if (typeof result !== 'string') {\n return null;\n }\n\n return accountIdPattern.test(result) ? result : null;\n}\n\nfunction isProtoAccountId(value: unknown): value is {\n shard: { toString: () => string };\n realm: { toString: () => string };\n num: { toString: () => string };\n} {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n const candidate = value as Record<string, unknown>;\n\n return (\n hasToString(candidate.shard) &&\n hasToString(candidate.realm) &&\n hasToString(candidate.num)\n );\n}\n\nfunction hasToString(value: unknown): value is { toString: () => string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { toString?: unknown }).toString === 'function'\n );\n}\n\nfunction toNumericString(value: unknown): string | null {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return String(Math.trunc(value));\n }\n\n if (typeof value === 'bigint') {\n return value.toString();\n }\n\n if (hasToString(value)) {\n const result = value.toString();\n if (/^\\d+$/u.test(result)) {\n return result;\n }\n }\n\n return null;\n}\n\nfunction requireNotFrozen(target: TopicPrototype): void {\n const candidate = target as { _requireNotFrozen?: () => void };\n candidate._requireNotFrozen?.();\n}\n\ntype ClientLike = {\n operatorAccountId?: unknown;\n};\n\ntype TopicPrototype = {\n setAutoRenewAccountId?: (...args: unknown[]) => unknown;\n freezeWith?: (...args: unknown[]) => unknown;\n getAutoRenewAccountId?: () => AccountIdInstance | null;\n transactionId?: { accountId?: unknown } | null;\n _autoRenewAccountId?: AccountIdInstance | null;\n [key: string]: unknown;\n};\n"],"names":[],"mappings":";AAMA,MAAM,mBAAmB;AACzB,MAAM,kBAAkB,OAAO,IAAI,sCAAsC;AACzE,MAAM,gBAAgB,OAAO,IAAI,gCAAgC;AAEjE,MAAM,gBAAgB;AAAA,EACpB;AACF;AACA,MAAM,cAAc;AAAA,EAClB;AACF;AACA,MAAM,YAAY,mBAOf,gBAAgB;AAEnB,MAAM,aAGD,CAAA;AAEL,IAAI,eAAe,WAAW,aAAa,SAAS;AAClD,aAAW,KAAK;AAAA,IACd,WAAW,cAAc;AAAA,IACzB,OAAO,YAAY;AAAA,EAAA,CACpB;AACH;AAEA,IAAI,WAAW;AACb,aAAW,KAAK;AAAA,IACd,WAAW,UAAU,aAAa,UAAU,SAAS;AAAA,IACrD,OACE,UAAU,0BAA0B,UAAU,SAAS;AAAA,EAAA,CAC1D;AACH;AAEA,IAAI,UAAU;AAEd,WAAW,aAAa,YAAY;AAClC,YAAU,iBAAiB,UAAU,OAAO,UAAU,SAAS,KAAK;AACtE;AAEA,QAAQ,IAAI,YAAY,uCAAuC,OAAO;AAEtE,SAAS,iBACP,WACA,aACS;AACT,MAAI,CAAC,aAAa,CAAC,aAAa;AAC9B,WAAO;AAAA,EACT;AAEA,iBAAe,WAAW;AAE1B,QAAM,YAAY,UAAU;AAE5B,MAAI,QAAQ,IAAI,WAAW,eAAe,GAAG;AAC3C,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,UAAU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KAAK;AAEhC,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AAEA,SAAO,iBAAiB,KAAK,MAAM,IAAI,SAAS;AAClD;AAEA,SAAS,iBAAiB,OAIxB;AACA,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,YAAY;AAElB,SACE,YAAY,UAAU,KAAK,KAC3B,YAAY,UAAU,KAAK,KAC3B,YAAY,UAAU,GAAG;AAE7B;AAEA,SAAS,YAAY,OAAqD;AACxE,SACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAiC,aAAa;AAE1D;AAEA,SAAS,gBAAgB,OAA+B;AACtD,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG;AACvD,WAAO,OAAO,KAAK,MAAM,KAAK,CAAC;AAAA,EACjC;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,MAAM,SAAA;AAAA,EACf;AAEA,MAAI,YAAY,KAAK,GAAG;AACtB,UAAM,SAAS,MAAM,SAAA;AACrB,QAAI,SAAS,KAAK,MAAM,GAAG;AACzB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,QAA8B;AACtD,QAAM,YAAY;AAClB,YAAU,oBAAA;AACZ;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es2.js","sources":["../../src/patches/topic-autorenew-patch.ts"],"sourcesContent":["type TopicCreateTransactionCtor =\n (typeof import('@hashgraph/sdk'))['TopicCreateTransaction'];\ntype AccountIdCtor = (typeof import('@hashgraph/sdk'))['AccountId'];\ntype AccountIdInstance = InstanceType<AccountIdCtor>;\ntype NodeRequire = (moduleId: string) => unknown;\ntype ModuleConstructor = {\n createRequire?: (url: string | URL | undefined) => NodeRequire;\n};\n\ndeclare const module: ModuleConstructor | undefined;\ndeclare const require: NodeRequire | undefined;\n\nconst accountIdPattern = /^\\d+\\.\\d+\\.\\d+$/u;\nconst prototypeMarker = Symbol.for('standards-sdk.topic-auto-renew.patch');\nconst accountMarker = Symbol.for('standards-sdk.account-id.patch');\n\nconst nodeRequire = getNodeRequire();\n\nif (nodeRequire) {\n bootstrap(nodeRequire);\n} else {\n Reflect.set(globalThis, '__standardsSdkTopicAutoRenewPatched', false);\n}\n\nfunction bootstrap(requireFn: NodeRequire): void {\n const accountModule = safeRequire<{ default: AccountIdCtor }>(\n requireFn,\n '@hashgraph/sdk/lib/account/AccountId.cjs',\n );\n const topicModule = safeRequire<{ default: TopicCreateTransactionCtor }>(\n requireFn,\n '@hashgraph/sdk/lib/topic/TopicCreateTransaction.cjs',\n );\n const sdkModule = safeRequire<{\n AccountId?: AccountIdCtor;\n TopicCreateTransaction?: TopicCreateTransactionCtor;\n default?: {\n AccountId?: AccountIdCtor;\n TopicCreateTransaction?: TopicCreateTransactionCtor;\n };\n }>(requireFn, '@hashgraph/sdk');\n\n const candidates: Array<{\n accountId?: AccountIdCtor;\n topic?: TopicCreateTransactionCtor;\n }> = [];\n\n if (accountModule?.default && topicModule?.default) {\n candidates.push({\n accountId: accountModule.default,\n topic: topicModule.default,\n });\n }\n\n if (sdkModule) {\n candidates.push({\n accountId: sdkModule.AccountId ?? sdkModule.default?.AccountId,\n topic:\n sdkModule.TopicCreateTransaction ??\n sdkModule.default?.TopicCreateTransaction,\n });\n }\n\n for (const candidate of candidates) {\n patchTopicModule(candidate.topic, candidate.accountId);\n }\n\n Reflect.set(globalThis, '__standardsSdkTopicAutoRenewPatched', true);\n}\n\nfunction getNodeRequire(): NodeRequire | null {\n const moduleConstructor = getModuleConstructor();\n\n if (moduleConstructor?.createRequire) {\n try {\n return moduleConstructor.createRequire(import.meta.url);\n } catch {\n return null;\n }\n }\n\n if (typeof require === 'function') {\n return require;\n }\n\n return null;\n}\n\nfunction getModuleConstructor(): ModuleConstructor | null {\n try {\n if (typeof module !== 'undefined' && module?.createRequire) {\n return module;\n }\n } catch {}\n\n try {\n if (typeof require === 'function') {\n const requiredModule = require('module') as ModuleConstructor;\n\n if (requiredModule?.createRequire) {\n return requiredModule;\n }\n }\n } catch {}\n\n return null;\n}\n\nfunction safeRequire<T>(requireFn: NodeRequire, moduleId: string): T | null {\n try {\n return requireFn(moduleId) as T;\n } catch {\n return null;\n }\n}\n\nfunction patchTopicModule(\n topicCtor?: TopicCreateTransactionCtor,\n accountCtor?: AccountIdCtor,\n): void {\n if (!topicCtor || !accountCtor) {\n return;\n }\n\n patchAccountId(accountCtor);\n\n const prototype = topicCtor.prototype;\n\n if (Reflect.get(prototype, prototypeMarker)) {\n return;\n }\n\n const originalSet = prototype.setAutoRenewAccountId;\n const originalFreeze = prototype.freezeWith;\n\n prototype.setAutoRenewAccountId = function setAutoRenewAccountIdPatched(\n this: TopicPrototype,\n autoRenewAccountId: unknown,\n ) {\n const resolved = resolveAccountId(autoRenewAccountId, accountCtor);\n\n if (resolved) {\n requireNotFrozen(this);\n this._autoRenewAccountId = resolved;\n return this;\n }\n\n return originalSet.call(\n this,\n autoRenewAccountId as AccountIdInstance | string,\n );\n };\n\n prototype.freezeWith = function freezeWithPatched(\n this: TopicPrototype,\n client?: unknown,\n ) {\n if (\n !this.getAutoRenewAccountId ||\n typeof this.getAutoRenewAccountId !== 'function'\n ) {\n return originalFreeze.call(this, client);\n }\n\n const current = this.getAutoRenewAccountId();\n\n if (!current) {\n const transactionAccountId = this.transactionId?.accountId;\n const operatorAccountId = (client as ClientLike | null | undefined)\n ?.operatorAccountId;\n const resolved =\n resolveAccountId(transactionAccountId, accountCtor) ??\n resolveAccountId(operatorAccountId, accountCtor);\n\n if (resolved) {\n this._autoRenewAccountId = resolved;\n }\n }\n\n return originalFreeze.call(this, client);\n };\n\n Reflect.set(prototype, prototypeMarker, true);\n}\n\nfunction patchAccountId(accountCtor: AccountIdCtor): void {\n if (Reflect.get(accountCtor, accountMarker)) {\n return;\n }\n\n const originalFromString = accountCtor.fromString.bind(accountCtor);\n\n accountCtor.fromString = function accountIdFromStringPatched(\n value: unknown,\n ): AccountIdInstance {\n if (typeof value === 'string') {\n return originalFromString(value);\n }\n\n const extracted = extractAccountIdString(value);\n\n if (extracted) {\n return originalFromString(extracted);\n }\n\n if (isProtoAccountId(value)) {\n const shard = toNumericString(value.shard);\n const realm = toNumericString(value.realm);\n const num = toNumericString(value.num);\n\n if (shard && realm && num) {\n return originalFromString(`${shard}.${realm}.${num}`);\n }\n }\n\n return originalFromString(value as string);\n };\n\n Reflect.set(accountCtor, accountMarker, true);\n}\n\nfunction resolveAccountId(\n value: unknown,\n accountCtor: AccountIdCtor,\n): AccountIdInstance | null {\n if (value instanceof accountCtor) {\n return value;\n }\n\n if (typeof value === 'string' && accountIdPattern.test(value)) {\n return accountCtor.fromString(value);\n }\n\n const normalized = normalizeAutoRenewValue(value);\n\n if (normalized) {\n return accountCtor.fromString(normalized);\n }\n\n return null;\n}\n\nfunction normalizeAutoRenewValue(value: unknown): string | null {\n if (typeof value === 'string' && accountIdPattern.test(value)) {\n return value;\n }\n\n const extracted = extractAccountIdString(value);\n\n if (extracted) {\n return extracted;\n }\n\n if (isProtoAccountId(value)) {\n const shard = toNumericString(value.shard);\n const realm = toNumericString(value.realm);\n const num = toNumericString(value.num);\n\n if (shard && realm && num) {\n const composed = `${shard}.${realm}.${num}`;\n if (accountIdPattern.test(composed)) {\n return composed;\n }\n }\n }\n\n return null;\n}\n\nfunction extractAccountIdString(value: unknown): string | null {\n if (typeof value !== 'object' || value === null) {\n return null;\n }\n\n const candidate = value as { toString?: () => unknown };\n const method = candidate.toString;\n\n if (typeof method !== 'function') {\n return null;\n }\n\n const result = method.call(value);\n\n if (typeof result !== 'string') {\n return null;\n }\n\n return accountIdPattern.test(result) ? result : null;\n}\n\nfunction isProtoAccountId(value: unknown): value is {\n shard: { toString: () => string };\n realm: { toString: () => string };\n num: { toString: () => string };\n} {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n const candidate = value as Record<string, unknown>;\n\n return (\n hasToString(candidate.shard) &&\n hasToString(candidate.realm) &&\n hasToString(candidate.num)\n );\n}\n\nfunction hasToString(value: unknown): value is { toString: () => string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { toString?: unknown }).toString === 'function'\n );\n}\n\nfunction toNumericString(value: unknown): string | null {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return String(Math.trunc(value));\n }\n\n if (typeof value === 'bigint') {\n return value.toString();\n }\n\n if (hasToString(value)) {\n const result = value.toString();\n if (/^\\d+$/u.test(result)) {\n return result;\n }\n }\n\n return null;\n}\n\nfunction requireNotFrozen(target: TopicPrototype): void {\n const candidate = target as { _requireNotFrozen?: () => void };\n candidate._requireNotFrozen?.();\n}\n\ntype ClientLike = {\n operatorAccountId?: unknown;\n};\n\ntype TopicPrototype = {\n setAutoRenewAccountId?: (...args: unknown[]) => unknown;\n freezeWith?: (...args: unknown[]) => unknown;\n getAutoRenewAccountId?: () => AccountIdInstance | null;\n transactionId?: { accountId?: unknown } | null;\n _autoRenewAccountId?: AccountIdInstance | null;\n [key: string]: unknown;\n};"],"names":[],"mappings":"AAYA,MAAM,mBAAmB;AACzB,MAAM,kBAAkB,OAAO,IAAI,sCAAsC;AACzE,MAAM,gBAAgB,OAAO,IAAI,gCAAgC;AAEjE,MAAM,cAAc,eAAA;AAEpB,IAAI,aAAa;AACf,YAAU,WAAW;AACvB,OAAO;AACL,UAAQ,IAAI,YAAY,uCAAuC,KAAK;AACtE;AAEA,SAAS,UAAU,WAA8B;AAC/C,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,EAAA;AAEF,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,EAAA;AAEF,QAAM,YAAY,YAOf,WAAW,gBAAgB;AAE9B,QAAM,aAGD,CAAA;AAEL,MAAI,eAAe,WAAW,aAAa,SAAS;AAClD,eAAW,KAAK;AAAA,MACd,WAAW,cAAc;AAAA,MACzB,OAAO,YAAY;AAAA,IAAA,CACpB;AAAA,EACH;AAEA,MAAI,WAAW;AACb,eAAW,KA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,iBAAiB,OAIxB;AACA,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,YAAY;AAElB,SACE,YAAY,UAAU,KAAK,KAC3B,YAAY,UAAU,KAAK,KAC3B,YAAY,UAAU,GAAG;AAE7B;AAEA,SAAS,YAAY,OAAqD;AACxE,SACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAiC,aAAa;AAE1D;AAEA,SAAS,gBAAgB,OAA+B;AACtD,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG;AACvD,WAAO,OAAO,KAAK,MAAM,KAAK,CAAC;AAAA,EACjC;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,MAAM,SAAA;AAAA,EACf;AAEA,MAAI,YAAY,KAAK,GAAG;AACtB,UAAM,SAAS,MAAM,SAAA;AACrB,QAAI,SAAS,KAAK,MAAM,GAAG;AACzB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,QAA8B;AACtD,QAAM,YAAY;AAClB,YAAU,oBAAA;AACZ;"}
|
|
@@ -8,14 +8,14 @@ import "node:buffer";
|
|
|
8
8
|
import "node:crypto";
|
|
9
9
|
import "@noble/curves/secp256k1.js";
|
|
10
10
|
import "./standards-sdk.es130.js";
|
|
11
|
-
import "./standards-sdk.
|
|
11
|
+
import "./standards-sdk.es136.js";
|
|
12
12
|
import "zod";
|
|
13
13
|
import "buffer";
|
|
14
14
|
import "ethers";
|
|
15
15
|
import "./standards-sdk.es123.js";
|
|
16
16
|
import "./standards-sdk.es114.js";
|
|
17
17
|
import { getTopicId } from "./standards-sdk.es115.js";
|
|
18
|
-
import { InscriptionSDK } from "./standards-sdk.
|
|
18
|
+
import { InscriptionSDK } from "./standards-sdk.es137.js";
|
|
19
19
|
import { HCS10BaseClient, Hcs10MemoType } from "./standards-sdk.es17.js";
|
|
20
20
|
import * as mime from "mime-types";
|
|
21
21
|
import { AgentBuilder } from "./standards-sdk.es24.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Client, Status, PrivateKey, AccountUpdateTransaction } from "@hashgraph/sdk";
|
|
2
2
|
import { inscribeWithSigner, inscribe } from "./standards-sdk.es125.js";
|
|
3
|
-
import "./standards-sdk.
|
|
3
|
+
import "./standards-sdk.es137.js";
|
|
4
4
|
import { Logger } from "./standards-sdk.es106.js";
|
|
5
5
|
import { HederaMirrorNode } from "./standards-sdk.es127.js";
|
|
6
6
|
import { ProgressReporter } from "./standards-sdk.es109.js";
|
|
@@ -10,7 +10,7 @@ import "node:buffer";
|
|
|
10
10
|
import "node:crypto";
|
|
11
11
|
import "@noble/curves/secp256k1.js";
|
|
12
12
|
import "./standards-sdk.es130.js";
|
|
13
|
-
import "./standards-sdk.
|
|
13
|
+
import "./standards-sdk.es136.js";
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
import "@hashgraph/proto";
|
|
16
16
|
import "buffer";
|
|
@@ -571,7 +571,8 @@ class HCS11Client {
|
|
|
571
571
|
return {
|
|
572
572
|
profileTopicId: topicId,
|
|
573
573
|
transactionId: inscriptionResponse.result.transactionId,
|
|
574
|
-
success: true
|
|
574
|
+
success: true,
|
|
575
|
+
totalCostHbar: inscriptionResponse.costSummary?.totalCostHbar
|
|
575
576
|
};
|
|
576
577
|
} catch (error) {
|
|
577
578
|
progressReporter.failed(
|
|
@@ -593,7 +594,7 @@ class HCS11Client {
|
|
|
593
594
|
return;
|
|
594
595
|
}
|
|
595
596
|
try {
|
|
596
|
-
const { HCS14Client } = await import("./standards-sdk.
|
|
597
|
+
const { HCS14Client } = await import("./standards-sdk.es135.js");
|
|
597
598
|
const hcs14 = new HCS14Client({ client: this.client });
|
|
598
599
|
const did = await hcs14.createDid({
|
|
599
600
|
method: "hedera",
|
|
@@ -701,7 +702,8 @@ class HCS11Client {
|
|
|
701
702
|
}
|
|
702
703
|
progressReporter.completed("Profile creation completed successfully", {
|
|
703
704
|
profileTopicId: inscriptionResult.profileTopicId,
|
|
704
|
-
transactionId: inscriptionResult.transactionId
|
|
705
|
+
transactionId: inscriptionResult.transactionId,
|
|
706
|
+
totalCostHbar: inscriptionResult.totalCostHbar
|
|
705
707
|
});
|
|
706
708
|
return inscriptionResult;
|
|
707
709
|
}
|