@hashgraphonline/standards-sdk 0.1.144-feat-solana-register.canary.d5edcec.80 → 0.1.144-feat-xmpt.canary.94e47b6.82
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-14/issuers/hiero.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-14/issuers/hiero.d.ts.map +1 -1
- package/dist/es/standards-sdk.es110.js +5 -5
- package/dist/es/standards-sdk.es120.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es122.js +5 -5
- package/dist/es/standards-sdk.es127.js +1 -1
- package/dist/es/standards-sdk.es130.js +1 -1
- package/dist/es/standards-sdk.es137.js +1 -1
- package/dist/es/standards-sdk.es150.js +54 -15
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +76 -48
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +160 -72
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +289 -139
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +298 -274
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +369 -262
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +194 -316
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +64 -319
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +15 -74
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +1 -1
- package/dist/es/standards-sdk.es58.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es62.js +1 -1
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hiero.d.ts","sourceRoot":"","sources":["../../../../src/hcs-14/issuers/hiero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAyB,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"hiero.d.ts","sourceRoot":"","sources":["../../../../src/hcs-14/issuers/hiero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAyB,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAwGrD,qBAAa,iBAAkB,YAAW,SAAS;IACjD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAaxB;IAEF,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI3B,KAAK,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;CAoBvD"}
|
|
@@ -5,11 +5,11 @@ import { ethers } from "ethers";
|
|
|
5
5
|
import { TransactionParsingError } from "./standards-sdk.es111.js";
|
|
6
6
|
import { resolveTransactionSummary } from "./standards-sdk.es112.js";
|
|
7
7
|
import { HTSParser } from "./standards-sdk.es120.js";
|
|
8
|
-
import { HCSParser } from "./standards-sdk.
|
|
9
|
-
import { FileParser } from "./standards-sdk.
|
|
10
|
-
import { CryptoParser } from "./standards-sdk.
|
|
11
|
-
import { SCSParser } from "./standards-sdk.
|
|
12
|
-
import { UtilParser } from "./standards-sdk.
|
|
8
|
+
import { HCSParser } from "./standards-sdk.es152.js";
|
|
9
|
+
import { FileParser } from "./standards-sdk.es153.js";
|
|
10
|
+
import { CryptoParser } from "./standards-sdk.es154.js";
|
|
11
|
+
import { SCSParser } from "./standards-sdk.es155.js";
|
|
12
|
+
import { UtilParser } from "./standards-sdk.es156.js";
|
|
13
13
|
import { ScheduleParser } from "./standards-sdk.es121.js";
|
|
14
14
|
import { transactionParserRegistry } from "./standards-sdk.es122.js";
|
|
15
15
|
import { getTransactionTypeFromBody, getHumanReadableTransactionType } from "./standards-sdk.es123.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proto } from "@hashgraph/proto";
|
|
2
2
|
import { AccountId, Long, TokenId } from "@hashgraph/sdk";
|
|
3
|
-
import { parseKey, hasTransactionType, extractTransactionBody } from "./standards-sdk.
|
|
3
|
+
import { parseKey, hasTransactionType, extractTransactionBody } from "./standards-sdk.es157.js";
|
|
4
4
|
import { Buffer } from "buffer";
|
|
5
5
|
class HTSParser {
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proto } from "@hashgraph/proto";
|
|
2
|
-
import { hasTransactionType, parseKey } from "./standards-sdk.
|
|
2
|
+
import { hasTransactionType, parseKey } from "./standards-sdk.es157.js";
|
|
3
3
|
import { AccountId, Long, ScheduleId } from "@hashgraph/sdk";
|
|
4
4
|
class ScheduleParser {
|
|
5
5
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { HTSParser } from "./standards-sdk.es120.js";
|
|
2
|
-
import { HCSParser } from "./standards-sdk.
|
|
3
|
-
import { CryptoParser } from "./standards-sdk.
|
|
4
|
-
import { FileParser } from "./standards-sdk.
|
|
5
|
-
import { SCSParser } from "./standards-sdk.
|
|
2
|
+
import { HCSParser } from "./standards-sdk.es152.js";
|
|
3
|
+
import { CryptoParser } from "./standards-sdk.es154.js";
|
|
4
|
+
import { FileParser } from "./standards-sdk.es153.js";
|
|
5
|
+
import { SCSParser } from "./standards-sdk.es155.js";
|
|
6
6
|
import { ScheduleParser } from "./standards-sdk.es121.js";
|
|
7
|
-
import { UtilParser } from "./standards-sdk.
|
|
7
|
+
import { UtilParser } from "./standards-sdk.es156.js";
|
|
8
8
|
const transactionParserRegistry = {
|
|
9
9
|
TOKENCREATE: {
|
|
10
10
|
bodyField: "tokenCreation",
|
|
@@ -3,7 +3,7 @@ import { Buffer } from "buffer";
|
|
|
3
3
|
import { randomBytes } from "crypto";
|
|
4
4
|
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
5
5
|
import { registerEncryptionKeyResponseSchema } from "./standards-sdk.es149.js";
|
|
6
|
-
import { optionalImport } from "./standards-sdk.
|
|
6
|
+
import { optionalImport } from "./standards-sdk.es151.js";
|
|
7
7
|
import { RegistryBrokerClient } from "./standards-sdk.es135.js";
|
|
8
8
|
const getFs = async () => {
|
|
9
9
|
const fsModule = await optionalImport("node:fs");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { creditPurchaseResponseSchema, x402MinimumsResponseSchema, x402CreditPurchaseResponseSchema } from "./standards-sdk.es149.js";
|
|
2
2
|
import { RegistryBrokerClient } from "./standards-sdk.es135.js";
|
|
3
3
|
import { normalizeHexPrivateKey } from "./standards-sdk.es159.js";
|
|
4
|
-
import { optionalImport } from "./standards-sdk.
|
|
4
|
+
import { optionalImport } from "./standards-sdk.es151.js";
|
|
5
5
|
async function loadX402Dependencies(client) {
|
|
6
6
|
const [{ default: axios }, x402Axios, x402Types] = await Promise.all([
|
|
7
7
|
import("axios"),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { optionalImport, optionalImportSync } from "./standards-sdk.
|
|
1
|
+
import { optionalImport, optionalImportSync } from "./standards-sdk.es151.js";
|
|
2
2
|
const unsupported = (method) => new Error(`${method} is not supported by the in-memory signer`);
|
|
3
3
|
let cachedSdk = null;
|
|
4
4
|
const loadHashgraphSdk = () => {
|
|
@@ -1,20 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
2
|
+
const BASE = 58;
|
|
3
|
+
function base58Encode(bytes) {
|
|
4
|
+
if (bytes.length === 0) return "";
|
|
5
|
+
let zeros = 0;
|
|
6
|
+
while (zeros < bytes.length && bytes[zeros] === 0) zeros++;
|
|
7
|
+
if (zeros === bytes.length) return "1".repeat(zeros);
|
|
8
|
+
const digits = [0];
|
|
9
|
+
for (let i = zeros; i < bytes.length; i++) {
|
|
10
|
+
let carry = bytes[i];
|
|
11
|
+
for (let j = 0; j < digits.length; j++) {
|
|
12
|
+
const val = (digits[j] << 8) + carry;
|
|
13
|
+
digits[j] = val % BASE;
|
|
14
|
+
carry = val / BASE | 0;
|
|
15
|
+
}
|
|
16
|
+
while (carry > 0) {
|
|
17
|
+
digits.push(carry % BASE);
|
|
18
|
+
carry = carry / BASE | 0;
|
|
19
|
+
}
|
|
15
20
|
}
|
|
21
|
+
let result = "";
|
|
22
|
+
for (let i = 0; i < zeros; i++) result += "1";
|
|
23
|
+
for (let i = digits.length - 1; i >= 0; i--) result += ALPHABET[digits[i]];
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function base58Decode(text) {
|
|
27
|
+
if (text.length === 0) return new Uint8Array(0);
|
|
28
|
+
let zeros = 0;
|
|
29
|
+
while (zeros < text.length && text[zeros] === "1") zeros++;
|
|
30
|
+
const b256 = [];
|
|
31
|
+
for (let i = zeros; i < text.length; i++) {
|
|
32
|
+
const ch = text[i];
|
|
33
|
+
const val = ALPHABET.indexOf(ch);
|
|
34
|
+
if (val === -1) throw new Error("Invalid Base58 character");
|
|
35
|
+
let carry = val;
|
|
36
|
+
for (let j = 0; j < b256.length; j++) {
|
|
37
|
+
const x = b256[j] * BASE + carry;
|
|
38
|
+
b256[j] = x & 255;
|
|
39
|
+
carry = x >> 8;
|
|
40
|
+
}
|
|
41
|
+
while (carry > 0) {
|
|
42
|
+
b256.push(carry & 255);
|
|
43
|
+
carry >>= 8;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (let i = 0; i < zeros; i++) b256.push(0);
|
|
47
|
+
b256.reverse();
|
|
48
|
+
return Uint8Array.from(b256);
|
|
49
|
+
}
|
|
50
|
+
function multibaseB58btcDecode(zText) {
|
|
51
|
+
if (!zText.startsWith("z")) throw new Error("Invalid multibase base58btc");
|
|
52
|
+
return base58Decode(zText.slice(1));
|
|
16
53
|
}
|
|
17
54
|
export {
|
|
18
|
-
|
|
55
|
+
base58Decode,
|
|
56
|
+
base58Encode,
|
|
57
|
+
multibaseB58btcDecode
|
|
19
58
|
};
|
|
20
59
|
//# sourceMappingURL=standards-sdk.es150.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es150.js","sources":["../../src/hcs-
|
|
1
|
+
{"version":3,"file":"standards-sdk.es150.js","sources":["../../src/hcs-14/base58.ts"],"sourcesContent":["/**\n * Minimal Base58 encoder/decoder (Bitcoin alphabet) with no external dependencies.\n */\n\nconst ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\nconst BASE = 58;\n\nfunction countLeadingZeros(bytes: Uint8Array): number {\n let zeros = 0;\n for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {\n zeros++;\n }\n return zeros;\n}\n\nexport function base58Encode(bytes: Uint8Array): string {\n if (bytes.length === 0) return '';\n\n let zeros = 0;\n while (zeros < bytes.length && bytes[zeros] === 0) zeros++;\n\n if (zeros === bytes.length) return '1'.repeat(zeros);\n\n const digits: number[] = [0];\n for (let i = zeros; i < bytes.length; i++) {\n let carry = bytes[i];\n for (let j = 0; j < digits.length; j++) {\n const val = (digits[j] << 8) + carry;\n digits[j] = val % BASE;\n carry = (val / BASE) | 0;\n }\n while (carry > 0) {\n digits.push(carry % BASE);\n carry = (carry / BASE) | 0;\n }\n }\n\n let result = '';\n for (let i = 0; i < zeros; i++) result += '1';\n for (let i = digits.length - 1; i >= 0; i--) result += ALPHABET[digits[i]];\n return result;\n}\n\nexport function base58Decode(text: string): Uint8Array {\n if (text.length === 0) return new Uint8Array(0);\n\n let zeros = 0;\n while (zeros < text.length && text[zeros] === '1') zeros++;\n\n const b256: number[] = [];\n for (let i = zeros; i < text.length; i++) {\n const ch = text[i];\n const val = ALPHABET.indexOf(ch);\n if (val === -1) throw new Error('Invalid Base58 character');\n\n let carry = val;\n for (let j = 0; j < b256.length; j++) {\n const x = b256[j] * BASE + carry;\n b256[j] = x & 0xff;\n carry = x >> 8;\n }\n while (carry > 0) {\n b256.push(carry & 0xff);\n carry >>= 8;\n }\n }\n\n for (let i = 0; i < zeros; i++) b256.push(0);\n b256.reverse();\n return Uint8Array.from(b256);\n}\n\nexport function multibaseB58btcDecode(zText: string): Uint8Array {\n if (!zText.startsWith('z')) throw new Error('Invalid multibase base58btc');\n return base58Decode(zText.slice(1));\n}\n"],"names":[],"mappings":"AAIA,MAAM,WAAW;AACjB,MAAM,OAAO;AAUN,SAAS,aAAa,OAA2B;AACtD,MAAI,MAAM,WAAW,EAAG,QAAO;AAE/B,MAAI,QAAQ;AACZ,SAAO,QAAQ,MAAM,UAAU,MAAM,KAAK,MAAM,EAAG;AAEnD,MAAI,UAAU,MAAM,OAAQ,QAAO,IAAI,OAAO,KAAK;AAEnD,QAAM,SAAmB,CAAC,CAAC;AAC3B,WAAS,IAAI,OAAO,IAAI,MAAM,QAAQ,KAAK;AACzC,QAAI,QAAQ,MAAM,CAAC;AACnB,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,YAAM,OAAO,OAAO,CAAC,KAAK,KAAK;AAC/B,aAAO,CAAC,IAAI,MAAM;AAClB,cAAS,MAAM,OAAQ;AAAA,IACzB;AACA,WAAO,QAAQ,GAAG;AAChB,aAAO,KAAK,QAAQ,IAAI;AACxB,cAAS,QAAQ,OAAQ;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,SAAS;AACb,WAAS,IAAI,GAA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
-
|
|
17
|
-
digits.push(carry % BASE);
|
|
18
|
-
carry = carry / BASE | 0;
|
|
1
|
+
import { isBrowser } from "./standards-sdk.es118.js";
|
|
2
|
+
let nodeRequire;
|
|
3
|
+
function isModuleNotFound(specifier, error) {
|
|
4
|
+
if (!error || typeof error !== "object") {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
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);
|
|
12
|
+
}
|
|
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());
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
async function resolveNodeRequire() {
|
|
22
|
+
if (nodeRequire !== void 0) {
|
|
23
|
+
return nodeRequire;
|
|
24
|
+
}
|
|
25
|
+
if (isBrowser) {
|
|
26
|
+
nodeRequire = null;
|
|
27
|
+
return nodeRequire;
|
|
28
|
+
}
|
|
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;
|
|
35
|
+
}
|
|
36
|
+
return nodeRequire;
|
|
25
37
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const ch = text[i];
|
|
33
|
-
const val = ALPHABET.indexOf(ch);
|
|
34
|
-
if (val === -1) throw new Error("Invalid Base58 character");
|
|
35
|
-
let carry = val;
|
|
36
|
-
for (let j = 0; j < b256.length; j++) {
|
|
37
|
-
const x = b256[j] * BASE + carry;
|
|
38
|
-
b256[j] = x & 255;
|
|
39
|
-
carry = x >> 8;
|
|
38
|
+
async function dynamicImport(specifier) {
|
|
39
|
+
try {
|
|
40
|
+
return await import(specifier);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (isModuleNotFound(specifier, error)) {
|
|
43
|
+
return null;
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function optionalImport(specifier, options = {}) {
|
|
49
|
+
if (isBrowser) {
|
|
50
|
+
return dynamicImport(specifier);
|
|
51
|
+
}
|
|
52
|
+
if (!options.preferImport) {
|
|
53
|
+
const requireFn = await resolveNodeRequire();
|
|
54
|
+
if (requireFn) {
|
|
55
|
+
try {
|
|
56
|
+
return requireFn(specifier);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (!isModuleNotFound(specifier, error)) {
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
44
62
|
}
|
|
45
63
|
}
|
|
46
|
-
|
|
47
|
-
b256.reverse();
|
|
48
|
-
return Uint8Array.from(b256);
|
|
64
|
+
return dynamicImport(specifier);
|
|
49
65
|
}
|
|
50
|
-
function
|
|
51
|
-
if (
|
|
52
|
-
|
|
66
|
+
function optionalImportSync(specifier) {
|
|
67
|
+
if (isBrowser) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const globalObject = typeof global !== "undefined" ? global : globalThis;
|
|
72
|
+
const req = globalObject.process?.mainModule?.require ?? globalObject.require;
|
|
73
|
+
if (typeof req === "function" && typeof req.resolve === "function") {
|
|
74
|
+
return req(specifier);
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
if (!isModuleNotFound(specifier, error)) {
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
53
82
|
}
|
|
54
83
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
multibaseB58btcDecode
|
|
84
|
+
optionalImport,
|
|
85
|
+
optionalImportSync
|
|
58
86
|
};
|
|
59
87
|
//# sourceMappingURL=standards-sdk.es151.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es151.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es151.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\ntype OptionalImportOptions = {\n preferImport?: boolean;\n};\n\nexport async function optionalImport<T>(\n specifier: string,\n options: OptionalImportOptions = {},\n): Promise<T | null> {\n if (isBrowser) {\n return dynamicImport<T>(specifier);\n }\n\n if (!options.preferImport) {\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\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,OAAO,YAAY,WAAW,UAAU;AAE5D,MAAI,OAAO,SAAS,YAAY,KAAK,SAAS,kBAAkB,GAAG;AACjE,WAAO,YAAY,SAAS,SAAS;AAAA,EACvC;AAEA,MAAI,aAAa;AACf,UAAM,UAAU,YAAY,YAAA;AAC5B,QACE,QAAQ,SAAS,oBAAoB,KACrC,QAAQ,SAAS,kBAAkB,KACnC,QAAQ,SAAS,qBAAqB,GACtC;AACA,aAAO,QAAQ,SAAS,UAAU,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iB,WAAW,KAAK,GAAG;AACvC,YAAM;AAAA,IACR;AAAA,EACF;AAEA,SAAO;AACT;"}
|
|
@@ -1,87 +1,175 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (typeof code === "string" && code.includes("MODULE_NOT_FOUND")) {
|
|
11
|
-
return messageText.includes(specifier);
|
|
12
|
-
}
|
|
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());
|
|
1
|
+
import { Long, AccountId } from "@hashgraph/sdk";
|
|
2
|
+
import { parseKey } from "./standards-sdk.es157.js";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
class HCSParser {
|
|
5
|
+
static parseConsensusCreateTopic(body) {
|
|
6
|
+
if (!body) return void 0;
|
|
7
|
+
const data = {};
|
|
8
|
+
if (body.memo) {
|
|
9
|
+
data.memo = body.memo;
|
|
17
10
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
if (isBrowser) {
|
|
26
|
-
nodeRequire = null;
|
|
27
|
-
return nodeRequire;
|
|
28
|
-
}
|
|
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;
|
|
35
|
-
}
|
|
36
|
-
return nodeRequire;
|
|
37
|
-
}
|
|
38
|
-
async function dynamicImport(specifier) {
|
|
39
|
-
try {
|
|
40
|
-
return await import(specifier);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
if (isModuleNotFound(specifier, error)) {
|
|
43
|
-
return null;
|
|
11
|
+
data.adminKey = parseKey(body.adminKey);
|
|
12
|
+
data.submitKey = parseKey(body.submitKey);
|
|
13
|
+
if (body.autoRenewPeriod?.seconds) {
|
|
14
|
+
data.autoRenewPeriod = Long.fromValue(
|
|
15
|
+
body.autoRenewPeriod.seconds
|
|
16
|
+
).toString();
|
|
44
17
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
18
|
+
if (body.autoRenewAccount) {
|
|
19
|
+
data.autoRenewAccountId = new AccountId(
|
|
20
|
+
body.autoRenewAccount.shardNum ?? 0,
|
|
21
|
+
body.autoRenewAccount.realmNum ?? 0,
|
|
22
|
+
body.autoRenewAccount.accountNum ?? 0
|
|
23
|
+
).toString();
|
|
24
|
+
}
|
|
25
|
+
return data;
|
|
51
26
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
27
|
+
static parseConsensusSubmitMessage(body) {
|
|
28
|
+
if (!body) return void 0;
|
|
29
|
+
const data = {};
|
|
30
|
+
if (body.topicID) {
|
|
31
|
+
data.topicId = `${body.topicID.shardNum ?? 0}.${body.topicID.realmNum ?? 0}.${body.topicID.topicNum ?? 0}`;
|
|
32
|
+
}
|
|
33
|
+
if (body.message?.length > 0) {
|
|
34
|
+
const messageBuffer = Buffer.from(body.message);
|
|
35
|
+
const utf8String = messageBuffer.toString("utf8");
|
|
36
|
+
if (/[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(utf8String) || utf8String.includes("�")) {
|
|
37
|
+
data.message = messageBuffer.toString("base64");
|
|
38
|
+
data.messageEncoding = "base64";
|
|
39
|
+
} else {
|
|
40
|
+
data.message = utf8String;
|
|
41
|
+
data.messageEncoding = "utf8";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (body.chunkInfo) {
|
|
45
|
+
if (body.chunkInfo.initialTransactionID) {
|
|
46
|
+
const txId = body.chunkInfo.initialTransactionID.accountID;
|
|
47
|
+
const taValidStart = body.chunkInfo.initialTransactionID.transactionValidStart;
|
|
48
|
+
if (txId && taValidStart) {
|
|
49
|
+
data.chunkInfoInitialTransactionID = `${txId.shardNum ?? 0}.${txId.realmNum ?? 0}.${txId.accountNum ?? 0}@${taValidStart.seconds ?? 0}.${taValidStart.nanos ?? 0}`;
|
|
60
50
|
}
|
|
61
51
|
}
|
|
52
|
+
if (body.chunkInfo.number !== void 0 && body.chunkInfo.number !== null) {
|
|
53
|
+
data.chunkInfoNumber = body.chunkInfo.number;
|
|
54
|
+
}
|
|
55
|
+
if (body.chunkInfo.total !== void 0 && body.chunkInfo.total !== null) {
|
|
56
|
+
data.chunkInfoTotal = body.chunkInfo.total;
|
|
57
|
+
}
|
|
62
58
|
}
|
|
59
|
+
return data;
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
static parseConsensusUpdateTopic(body) {
|
|
62
|
+
if (!body) return void 0;
|
|
63
|
+
const data = {};
|
|
64
|
+
if (body.topicID) {
|
|
65
|
+
data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum}.${body.topicID.topicNum}`;
|
|
66
|
+
}
|
|
67
|
+
if (body.memo?.value !== void 0) {
|
|
68
|
+
data.memo = body.memo.value;
|
|
69
|
+
}
|
|
70
|
+
if (body.adminKey === null) {
|
|
71
|
+
data.clearAdminKey = true;
|
|
72
|
+
data.adminKey = void 0;
|
|
73
|
+
} else if (body.adminKey) {
|
|
74
|
+
data.adminKey = parseKey(body.adminKey);
|
|
75
|
+
} else {
|
|
76
|
+
data.adminKey = void 0;
|
|
77
|
+
}
|
|
78
|
+
if (body.submitKey === null) {
|
|
79
|
+
data.clearSubmitKey = true;
|
|
80
|
+
data.submitKey = void 0;
|
|
81
|
+
} else if (body.submitKey) {
|
|
82
|
+
data.submitKey = parseKey(body.submitKey);
|
|
83
|
+
} else {
|
|
84
|
+
data.submitKey = void 0;
|
|
85
|
+
}
|
|
86
|
+
if (body.autoRenewPeriod?.seconds) {
|
|
87
|
+
data.autoRenewPeriod = Long.fromValue(
|
|
88
|
+
body.autoRenewPeriod.seconds
|
|
89
|
+
).toString();
|
|
90
|
+
}
|
|
91
|
+
if (body.autoRenewAccount) {
|
|
92
|
+
data.autoRenewAccountId = new AccountId(
|
|
93
|
+
body.autoRenewAccount.shardNum ?? 0,
|
|
94
|
+
body.autoRenewAccount.realmNum ?? 0,
|
|
95
|
+
body.autoRenewAccount.accountNum ?? 0
|
|
96
|
+
).toString();
|
|
97
|
+
}
|
|
98
|
+
return data;
|
|
69
99
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
|
|
100
|
+
static parseConsensusDeleteTopic(body) {
|
|
101
|
+
if (!body) return void 0;
|
|
102
|
+
const data = {};
|
|
103
|
+
if (body.topicID) {
|
|
104
|
+
data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum ?? 0}.${body.topicID.topicNum ?? 0}`;
|
|
75
105
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
106
|
+
return data;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parse HCS transaction from Transaction object with comprehensive extraction
|
|
110
|
+
* This is the unified entry point that handles both protobuf and internal field extraction
|
|
111
|
+
*/
|
|
112
|
+
static parseFromTransactionObject(transaction) {
|
|
113
|
+
try {
|
|
114
|
+
const transactionBody = transaction._transactionBody;
|
|
115
|
+
if (!transactionBody) {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
if (transactionBody.consensusCreateTopic) {
|
|
119
|
+
const consensusCreateTopic = this.parseConsensusCreateTopic(
|
|
120
|
+
transactionBody.consensusCreateTopic
|
|
121
|
+
);
|
|
122
|
+
if (consensusCreateTopic) {
|
|
123
|
+
return {
|
|
124
|
+
type: "TOPICCREATE",
|
|
125
|
+
humanReadableType: "Topic Create",
|
|
126
|
+
consensusCreateTopic
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (transactionBody.consensusSubmitMessage) {
|
|
131
|
+
const consensusSubmitMessage = this.parseConsensusSubmitMessage(
|
|
132
|
+
transactionBody.consensusSubmitMessage
|
|
133
|
+
);
|
|
134
|
+
if (consensusSubmitMessage) {
|
|
135
|
+
return {
|
|
136
|
+
type: "CONSENSUSSUBMITMESSAGE",
|
|
137
|
+
humanReadableType: "Submit Message",
|
|
138
|
+
consensusSubmitMessage
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (transactionBody.consensusUpdateTopic) {
|
|
143
|
+
const consensusUpdateTopic = this.parseConsensusUpdateTopic(
|
|
144
|
+
transactionBody.consensusUpdateTopic
|
|
145
|
+
);
|
|
146
|
+
if (consensusUpdateTopic) {
|
|
147
|
+
return {
|
|
148
|
+
type: "TOPICUPDATE",
|
|
149
|
+
humanReadableType: "Topic Update",
|
|
150
|
+
consensusUpdateTopic
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (transactionBody.consensusDeleteTopic) {
|
|
155
|
+
const consensusDeleteTopic = this.parseConsensusDeleteTopic(
|
|
156
|
+
transactionBody.consensusDeleteTopic
|
|
157
|
+
);
|
|
158
|
+
if (consensusDeleteTopic) {
|
|
159
|
+
return {
|
|
160
|
+
type: "TOPICDELETE",
|
|
161
|
+
humanReadableType: "Topic Delete",
|
|
162
|
+
consensusDeleteTopic
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {};
|
|
167
|
+
} catch (error) {
|
|
168
|
+
return {};
|
|
79
169
|
}
|
|
80
170
|
}
|
|
81
|
-
return null;
|
|
82
171
|
}
|
|
83
172
|
export {
|
|
84
|
-
|
|
85
|
-
optionalImportSync
|
|
173
|
+
HCSParser
|
|
86
174
|
};
|
|
87
175
|
//# sourceMappingURL=standards-sdk.es152.js.map
|