@hashgraphonline/standards-sdk 0.1.175 → 0.1.176
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/README.md +23 -0
- package/dist/browser/services/registry-broker/client/base-client.d.ts +9 -5
- package/dist/browser/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/client/skills.d.ts +9 -5
- package/dist/browser/services/registry-broker/client/skills.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/schemas.d.ts +2870 -8
- package/dist/browser/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/types.d.ts +36 -1
- package/dist/browser/services/registry-broker/types.d.ts.map +1 -1
- package/dist/browser/standards-sdk.browser.js +155 -1
- package/dist/browser/standards-sdk.browser.js.map +1 -1
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts +9 -5
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/client/skills.d.ts +9 -5
- package/dist/browser-root/services/registry-broker/client/skills.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/schemas.d.ts +2870 -8
- package/dist/browser-root/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/types.d.ts +36 -1
- package/dist/browser-root/services/registry-broker/types.d.ts.map +1 -1
- package/dist/browser-root/standards-sdk.root-browser.js +308 -1
- package/dist/browser-root/standards-sdk.root-browser.js.map +1 -1
- package/dist/cjs/services/registry-broker/client/base-client.d.ts +9 -5
- package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/skills.d.ts +9 -5
- package/dist/cjs/services/registry-broker/client/skills.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +2870 -8
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/types.d.ts +36 -1
- package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/services/registry-broker/client/base-client.d.ts +9 -5
- package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/skills.d.ts +9 -5
- package/dist/es/services/registry-broker/client/skills.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +2870 -8
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/services/registry-broker/types.d.ts +36 -1
- package/dist/es/services/registry-broker/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es116.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es127.js +1 -1
- package/dist/es/standards-sdk.es128.js +5 -5
- package/dist/es/standards-sdk.es138.js +1 -1
- package/dist/es/standards-sdk.es139.js +1 -1
- package/dist/es/standards-sdk.es140.js +5 -5
- package/dist/es/standards-sdk.es142.js +3 -3
- package/dist/es/standards-sdk.es143.js +1 -1
- package/dist/es/standards-sdk.es145.js +24 -3
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +1 -1
- package/dist/es/standards-sdk.es148.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es160.js +1778 -12461
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +12461 -1608
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +51 -167
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +88 -306
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +71 -336
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +186 -439
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +695 -314
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +63 -66
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +158 -90
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +314 -65
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +345 -55
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +443 -71
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +315 -184
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +68 -565
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +1 -1
- package/dist/es/standards-sdk.es176.js +1 -1
- package/dist/es/standards-sdk.es178.js +2 -2
- package/dist/es/standards-sdk.es179.js +1 -1
- package/dist/es/standards-sdk.es18.js +2 -2
- package/dist/es/standards-sdk.es180.js +1 -1
- package/dist/es/standards-sdk.es181.js +2 -2
- package/dist/es/standards-sdk.es182.js +1 -1
- package/dist/es/standards-sdk.es183.js +1 -1
- package/dist/es/standards-sdk.es19.js +2 -2
- package/dist/es/standards-sdk.es27.js +2 -2
- package/dist/es/standards-sdk.es30.js +1 -1
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es35.js +2 -2
- package/dist/es/standards-sdk.es36.js +1 -1
- package/dist/es/standards-sdk.es37.js +1 -1
- package/dist/es/standards-sdk.es56.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.es62.js +1 -1
- package/dist/es/standards-sdk.es63.js +2 -2
- package/dist/es/standards-sdk.es64.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.es67.js +1 -1
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es75.js +1 -1
- package/dist/es/standards-sdk.es84.js +1 -1
- package/package.json +2 -1
|
@@ -1,175 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
10
19
|
}
|
|
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();
|
|
17
|
-
}
|
|
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;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
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
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return data;
|
|
60
|
-
}
|
|
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;
|
|
99
|
-
}
|
|
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}`;
|
|
105
|
-
}
|
|
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 {};
|
|
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;
|
|
169
44
|
}
|
|
170
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));
|
|
171
53
|
}
|
|
172
54
|
export {
|
|
173
|
-
|
|
55
|
+
base58Decode,
|
|
56
|
+
base58Encode,
|
|
57
|
+
multibaseB58btcDecode
|
|
174
58
|
};
|
|
175
59
|
//# sourceMappingURL=standards-sdk.es163.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es163.js","sources":["../../src/utils/parsers/hcs-parser.ts"],"sourcesContent":["import { proto } from '@hashgraph/proto';\nimport { AccountId, Long, Transaction } from '@hashgraph/sdk';\nimport {\n ConsensusCreateTopicData,\n ConsensusSubmitMessageData,\n ConsensusUpdateTopicData,\n ConsensusDeleteTopicData,\n} from '../transaction-parser-types';\nimport { parseKey } from './parser-utils';\nimport { Buffer } from 'buffer';\n\nexport class HCSParser {\n static parseConsensusCreateTopic(\n body: proto.IConsensusCreateTopicTransactionBody,\n ): ConsensusCreateTopicData | undefined {\n if (!body) return undefined;\n const data: ConsensusCreateTopicData = {};\n if (body.memo) {\n data.memo = body.memo;\n }\n data.adminKey = parseKey(body.adminKey);\n data.submitKey = parseKey(body.submitKey);\n if (body.autoRenewPeriod?.seconds) {\n data.autoRenewPeriod = Long.fromValue(\n body.autoRenewPeriod.seconds,\n ).toString();\n }\n if (body.autoRenewAccount) {\n data.autoRenewAccountId = new AccountId(\n body.autoRenewAccount.shardNum ?? 0,\n body.autoRenewAccount.realmNum ?? 0,\n body.autoRenewAccount.accountNum ?? 0,\n ).toString();\n }\n return data;\n }\n\n static parseConsensusSubmitMessage(\n body: proto.IConsensusSubmitMessageTransactionBody,\n ): ConsensusSubmitMessageData | undefined {\n if (!body) return undefined;\n const data: ConsensusSubmitMessageData = {};\n if (body.topicID) {\n data.topicId = `${body.topicID.shardNum ?? 0}.${\n body.topicID.realmNum ?? 0\n }.${body.topicID.topicNum ?? 0}`;\n }\n if (body.message?.length > 0) {\n const messageBuffer = Buffer.from(body.message);\n const utf8String = messageBuffer.toString('utf8');\n if (\n /[\\x00-\\x08\\x0B\\x0E-\\x1F\\x7F]/.test(utf8String) ||\n utf8String.includes('\\uFFFD')\n ) {\n data.message = messageBuffer.toString('base64');\n data.messageEncoding = 'base64';\n } else {\n data.message = utf8String;\n data.messageEncoding = 'utf8';\n }\n }\n if (body.chunkInfo) {\n if (body.chunkInfo.initialTransactionID) {\n const txId = body.chunkInfo.initialTransactionID.accountID;\n const taValidStart =\n body.chunkInfo.initialTransactionID.transactionValidStart;\n if (txId && taValidStart) {\n data.chunkInfoInitialTransactionID = `${txId.shardNum ?? 0}.${\n txId.realmNum ?? 0\n }.${txId.accountNum ?? 0}@${taValidStart.seconds ?? 0}.${\n taValidStart.nanos ?? 0\n }`;\n }\n }\n if (\n body.chunkInfo.number !== undefined &&\n body.chunkInfo.number !== null\n ) {\n data.chunkInfoNumber = body.chunkInfo.number;\n }\n if (body.chunkInfo.total !== undefined && body.chunkInfo.total !== null) {\n data.chunkInfoTotal = body.chunkInfo.total;\n }\n }\n return data;\n }\n\n static parseConsensusUpdateTopic(\n body: proto.IConsensusUpdateTopicTransactionBody,\n ): ConsensusUpdateTopicData | undefined {\n if (!body) return undefined;\n const data: ConsensusUpdateTopicData = {};\n if (body.topicID) {\n data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum}.${body.topicID.topicNum}`;\n }\n if (body.memo?.value !== undefined) {\n data.memo = body.memo.value;\n }\n if (body.adminKey === null) {\n data.clearAdminKey = true;\n data.adminKey = undefined;\n } else if (body.adminKey) {\n data.adminKey = parseKey(body.adminKey);\n } else {\n data.adminKey = undefined;\n }\n if (body.submitKey === null) {\n data.clearSubmitKey = true;\n data.submitKey = undefined;\n } else if (body.submitKey) {\n data.submitKey = parseKey(body.submitKey);\n } else {\n data.submitKey = undefined;\n }\n if (body.autoRenewPeriod?.seconds) {\n data.autoRenewPeriod = Long.fromValue(\n body.autoRenewPeriod.seconds,\n ).toString();\n }\n if (body.autoRenewAccount) {\n data.autoRenewAccountId = new AccountId(\n body.autoRenewAccount.shardNum ?? 0,\n body.autoRenewAccount.realmNum ?? 0,\n body.autoRenewAccount.accountNum ?? 0,\n ).toString();\n }\n return data;\n }\n\n static parseConsensusDeleteTopic(\n body: proto.IConsensusDeleteTopicTransactionBody,\n ): ConsensusDeleteTopicData | undefined {\n if (!body) return undefined;\n const data: ConsensusDeleteTopicData = {};\n if (body.topicID) {\n data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum ?? 0}.${\n body.topicID.topicNum ?? 0\n }`;\n }\n return data;\n }\n\n /**\n * Parse HCS transaction from Transaction object with comprehensive extraction\n * This is the unified entry point that handles both protobuf and internal field extraction\n */\n static parseFromTransactionObject(transaction: Transaction): {\n type?: string;\n humanReadableType?: string;\n [key: string]: unknown;\n } {\n try {\n const transactionBody = (\n transaction as unknown as { _transactionBody?: unknown }\n )._transactionBody as proto.ITransactionBody | undefined;\n\n if (!transactionBody) {\n return {};\n }\n\n if (transactionBody.consensusCreateTopic) {\n const consensusCreateTopic = this.parseConsensusCreateTopic(\n transactionBody.consensusCreateTopic,\n );\n if (consensusCreateTopic) {\n return {\n type: 'TOPICCREATE',\n humanReadableType: 'Topic Create',\n consensusCreateTopic,\n };\n }\n }\n\n if (transactionBody.consensusSubmitMessage) {\n const consensusSubmitMessage = this.parseConsensusSubmitMessage(\n transactionBody.consensusSubmitMessage,\n );\n if (consensusSubmitMessage) {\n return {\n type: 'CONSENSUSSUBMITMESSAGE',\n humanReadableType: 'Submit Message',\n consensusSubmitMessage,\n };\n }\n }\n\n if (transactionBody.consensusUpdateTopic) {\n const consensusUpdateTopic = this.parseConsensusUpdateTopic(\n transactionBody.consensusUpdateTopic,\n );\n if (consensusUpdateTopic) {\n return {\n type: 'TOPICUPDATE',\n humanReadableType: 'Topic Update',\n consensusUpdateTopic,\n };\n }\n }\n\n if (transactionBody.consensusDeleteTopic) {\n const consensusDeleteTopic = this.parseConsensusDeleteTopic(\n transactionBody.consensusDeleteTopic,\n );\n if (consensusDeleteTopic) {\n return {\n type: 'TOPICDELETE',\n humanReadableType: 'Topic Delete',\n consensusDeleteTopic,\n };\n }\n }\n\n return {};\n } catch (error) {\n return {};\n }\n }\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,UAAU;AAAA,EACrB,OAAO,0BACL,MACsC;AACtC,QAAI,CAAC,KAAM,QAAO;AAClB,UAAM,OAAiC,CAAA;AACvC,QAAI,KAAK,MAAM;AACb,WAAK,OAAO,KAAK;AAAA,IACnB;AACA,SAAK,WAAW,SAAS,KAAK,QAAQ;AACtC,SAAK,YAAY,SAAS,KAAK,SAAS;AACxC,QAAI,KAAK,iBAAiB,SAAS;AACjC,WAAK,kBAAkB,KAAK;AAAA,QAC1B,KAAK,gBAAgB;AAAA,MAAA,EACrB,SAAA;AAAA,IACJ;AACA,QAAI,KAAK,kBAAkB;AACzB,WAAK,qBAAqB,IAAI;AAAA,QAC5B,KAAK,iBAAiB,YAAY;AAAA,QAClC,KAAK,iBAAiB,YAAY;AAAA,QAClC,KAAK,iBAAiB,cAAc;AAAA,MAAA,EAC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AI;AACF,YAAM,kBACJ,YACA;AAEF,UAAI,CAAC,iBAAiB;AACpB,eAAO,CAAA;AAAA,MACT;AAEA,UAAI,gBAAgB,sBAAsB;AACxC,cAAM,uBAAuB,KAAK;AAAA,UAChC,gBAAgB;AAAA,QAAA;AAElB,YAAI,sBAAsB;AACxB,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,mBAAmB;AAAA,YACnB;AAAA,UAAA;AAAA,QAEJ;AAAA,MACF;AAEA,UAAI,gBAAgB,wBAAwB;AAC1C,cAAM,yBAAyB,KAAK;AAAA,UAClC,gBAAgB;AAAA,QAAA;AAElB,YAAI,wBAAwB;AAC1B,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,mBAAmB;AAAA,YACnB;AAAA,UAAA;AAAA,QAEJ;AAAA,MACF;AAEA,UAAI,gBAAgB,sBAAsB;AACxC,cAAM,uBAAuB,KAAK;AAAA,UAChC,gBAAgB;AAAA,QAAA;AAElB,YAAI,sBAAsB;AACxB,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,mBAAmB;AAAA,YACnB;AAAA,UAAA;AAAA,QAEJ;AAAA,MACF;AAEA,UAAI,gBAAgB,sBAAsB;AACxC,cAAM,uBAAuB,KAAK;AAAA,UAChC,gBAAgB;AAAA,QAAA;AAElB,YAAI,sBAAsB;AACxB,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,mBAAmB;AAAA,YACnB;AAAA,UAAA;AAAA,QAEJ;AAAA,MACF;AAEA,aAAO,CAAA;AAAA,IACT,SAAS,OAAO;AACd,aAAO,CAAA;AAAA,IACT;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es163.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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WAAS,IAAI,GAAG,IAAI,OAAO,IAAK,MAAK,KAAK,CAAC;AAC3C,OAAK,QAAA;AACL,SAAO,WAAW,KAAK,IAAI;AAC7B;AAEO,SAAS,sBAAsB,OAA2B;AAC/D,MAAI,CAAC,MAAM,WAAW,GAAG,EAAG,OAAM,IAAI,MAAM,6BAA6B;AACzE,SAAO,aAAa,MAAM,MAAM,CAAC,CAAC;AACpC;"}
|
|
@@ -1,325 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
if (originalBytes || transaction.toBytes) {
|
|
13
|
-
try {
|
|
14
|
-
const bytesToParse = originalBytes || transaction.toBytes();
|
|
15
|
-
const decoded = proto.TransactionList.decode(bytesToParse);
|
|
16
|
-
if (decoded.transactionList && decoded.transactionList.length > 0) {
|
|
17
|
-
const tx = decoded.transactionList[0];
|
|
18
|
-
let txBody = null;
|
|
19
|
-
if (tx.bodyBytes && tx.bodyBytes.length > 0) {
|
|
20
|
-
txBody = proto.TransactionBody.decode(tx.bodyBytes);
|
|
21
|
-
} else if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {
|
|
22
|
-
const signedTx = proto.SignedTransaction.decode(
|
|
23
|
-
tx.signedTransactionBytes
|
|
24
|
-
);
|
|
25
|
-
if (signedTx.bodyBytes) {
|
|
26
|
-
txBody = proto.TransactionBody.decode(signedTx.bodyBytes);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (txBody) {
|
|
30
|
-
const protoResult = this.parseFromProtobufTxBody(txBody);
|
|
31
|
-
if (protoResult.type && protoResult.type !== "UNKNOWN") {
|
|
32
|
-
return protoResult;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} catch (protoError) {
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return this.parseFromTransactionInternals(transaction);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return { type: "UNKNOWN", humanReadableType: "Unknown File Transaction" };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Parse file transaction from protobuf TransactionBody
|
|
46
|
-
* Handles all file operations from decoded protobuf data
|
|
47
|
-
*/
|
|
48
|
-
static parseFromProtobufTxBody(txBody) {
|
|
49
|
-
if (txBody.fileCreate) {
|
|
50
|
-
const fileCreate = this.parseFileCreate(txBody.fileCreate);
|
|
51
|
-
if (fileCreate) {
|
|
52
|
-
return {
|
|
53
|
-
type: "FILECREATE",
|
|
54
|
-
humanReadableType: "File Create",
|
|
55
|
-
fileCreate
|
|
56
|
-
};
|
|
1
|
+
import { isBrowser } from "./standards-sdk.es136.js";
|
|
2
|
+
let nodeRequire;
|
|
3
|
+
const isNodeRuntime = () => typeof process !== "undefined" && Boolean(process.versions?.node);
|
|
4
|
+
function getNodeRequireSync() {
|
|
5
|
+
try {
|
|
6
|
+
const moduleNamespace = process.getBuiltinModule?.("module");
|
|
7
|
+
if (typeof moduleNamespace?.createRequire === "function") {
|
|
8
|
+
const requireFromModule = moduleNamespace.createRequire(import.meta.url);
|
|
9
|
+
if (typeof requireFromModule.resolve === "function") {
|
|
10
|
+
return requireFromModule;
|
|
57
11
|
}
|
|
58
12
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
type: "FILEAPPEND",
|
|
64
|
-
humanReadableType: "File Append",
|
|
65
|
-
fileAppend
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (txBody.fileUpdate) {
|
|
70
|
-
const fileUpdate = this.parseFileUpdate(txBody.fileUpdate);
|
|
71
|
-
if (fileUpdate) {
|
|
72
|
-
return {
|
|
73
|
-
type: "FILEUPDATE",
|
|
74
|
-
humanReadableType: "File Update",
|
|
75
|
-
fileUpdate
|
|
76
|
-
};
|
|
77
|
-
}
|
|
13
|
+
const globalObject = typeof global !== "undefined" ? global : globalThis;
|
|
14
|
+
const runtimeRequire = globalObject.process?.mainModule?.require ?? globalObject.require ?? Function('return typeof require === "function" ? require : undefined;')();
|
|
15
|
+
if (typeof runtimeRequire === "function" && typeof runtimeRequire.resolve === "function") {
|
|
16
|
+
return runtimeRequire;
|
|
78
17
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (fileDelete) {
|
|
82
|
-
return {
|
|
83
|
-
type: "FILEDELETE",
|
|
84
|
-
humanReadableType: "File Delete",
|
|
85
|
-
fileDelete
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return {};
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
90
20
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
const tx = transaction;
|
|
98
|
-
if (hasTransactionType(transaction, "fileCreate")) {
|
|
99
|
-
const fileCreate = {};
|
|
100
|
-
if (tx._contents) {
|
|
101
|
-
const contentInfo = this.analyzeContent(tx._contents);
|
|
102
|
-
fileCreate.contents = contentInfo.encoded;
|
|
103
|
-
if (contentInfo.contentType) {
|
|
104
|
-
fileCreate.contentType = contentInfo.contentType;
|
|
105
|
-
}
|
|
106
|
-
if (contentInfo.size) {
|
|
107
|
-
fileCreate.contentSize = contentInfo.size;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (tx._keys && tx._keys.length > 0) {
|
|
111
|
-
const keyList = {
|
|
112
|
-
keys: tx._keys
|
|
113
|
-
};
|
|
114
|
-
fileCreate.keys = parseKey({ keyList });
|
|
115
|
-
}
|
|
116
|
-
if (tx._expirationTime) {
|
|
117
|
-
fileCreate.expirationTime = tx._expirationTime.toString();
|
|
118
|
-
}
|
|
119
|
-
if (tx._memo) {
|
|
120
|
-
fileCreate.memo = tx._memo;
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
type: "FILECREATE",
|
|
124
|
-
humanReadableType: "File Create",
|
|
125
|
-
fileCreate
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (hasTransactionType(transaction, "fileAppend")) {
|
|
129
|
-
const fileAppend = {
|
|
130
|
-
fileId: tx._fileId.toString()
|
|
131
|
-
};
|
|
132
|
-
if (tx._contents) {
|
|
133
|
-
const contentInfo = this.analyzeContent(tx._contents);
|
|
134
|
-
fileAppend.contents = contentInfo.encoded;
|
|
135
|
-
if (contentInfo.size) {
|
|
136
|
-
fileAppend.contentSize = contentInfo.size;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
type: "FILEAPPEND",
|
|
141
|
-
humanReadableType: "File Append",
|
|
142
|
-
fileAppend
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
if (hasTransactionType(transaction, "fileUpdate")) {
|
|
146
|
-
const fileUpdate = {
|
|
147
|
-
fileId: tx._fileId.toString()
|
|
148
|
-
};
|
|
149
|
-
if (tx._contents) {
|
|
150
|
-
const contentInfo = this.analyzeContent(tx._contents);
|
|
151
|
-
fileUpdate.contents = contentInfo.encoded;
|
|
152
|
-
if (contentInfo.size) {
|
|
153
|
-
fileUpdate.contentSize = contentInfo.size;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (tx._keys && tx._keys.length > 0) {
|
|
157
|
-
const keyList = {
|
|
158
|
-
keys: tx._keys
|
|
159
|
-
};
|
|
160
|
-
fileUpdate.keys = parseKey({ keyList });
|
|
161
|
-
}
|
|
162
|
-
if (tx._expirationTime) {
|
|
163
|
-
fileUpdate.expirationTime = tx._expirationTime.toString();
|
|
164
|
-
}
|
|
165
|
-
if (tx._memo) {
|
|
166
|
-
fileUpdate.memo = tx._memo;
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
type: "FILEUPDATE",
|
|
170
|
-
humanReadableType: "File Update",
|
|
171
|
-
fileUpdate
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
if (hasTransactionType(transaction, "fileDelete")) {
|
|
175
|
-
const fileDelete = {
|
|
176
|
-
fileId: tx._fileId.toString()
|
|
177
|
-
};
|
|
178
|
-
return {
|
|
179
|
-
type: "FILEDELETE",
|
|
180
|
-
humanReadableType: "File Delete",
|
|
181
|
-
fileDelete
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
return {};
|
|
185
|
-
} catch (error) {
|
|
186
|
-
return {};
|
|
187
|
-
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function isModuleNotFound(specifier, error) {
|
|
24
|
+
if (!error || typeof error !== "object") {
|
|
25
|
+
return false;
|
|
188
26
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const signatures = {
|
|
200
|
-
"89504e47": "image/png",
|
|
201
|
-
ffd8ffe0: "image/jpeg",
|
|
202
|
-
ffd8ffe1: "image/jpeg",
|
|
203
|
-
"47494638": "image/gif",
|
|
204
|
-
"25504446": "application/pdf",
|
|
205
|
-
"504b0304": "application/zip",
|
|
206
|
-
"7f454c46": "application/x-executable",
|
|
207
|
-
d0cf11e0: "application/msoffice"
|
|
208
|
-
};
|
|
209
|
-
contentType = signatures[headerHex.toLowerCase()];
|
|
210
|
-
}
|
|
211
|
-
if (!contentType) {
|
|
212
|
-
try {
|
|
213
|
-
const textContent = contentBuffer.toString("utf8");
|
|
214
|
-
const hasControlChars = /[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(
|
|
215
|
-
textContent
|
|
216
|
-
);
|
|
217
|
-
const hasReplacementChars = textContent.includes("�");
|
|
218
|
-
if (!hasControlChars && !hasReplacementChars) {
|
|
219
|
-
if (textContent.trim().startsWith("{") && textContent.trim().endsWith("}")) {
|
|
220
|
-
contentType = "application/json";
|
|
221
|
-
} else if (textContent.includes("<?xml") || textContent.includes("<html")) {
|
|
222
|
-
contentType = "text/xml";
|
|
223
|
-
} else if (textContent.includes("<!DOCTYPE html")) {
|
|
224
|
-
contentType = "text/html";
|
|
225
|
-
} else {
|
|
226
|
-
contentType = "text/plain";
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
contentType = "application/octet-stream";
|
|
230
|
-
}
|
|
231
|
-
} catch {
|
|
232
|
-
contentType = "application/octet-stream";
|
|
233
|
-
}
|
|
27
|
+
const code = Reflect.get(error, "code");
|
|
28
|
+
const message = Reflect.get(error, "message");
|
|
29
|
+
const messageText = typeof message === "string" ? message : "";
|
|
30
|
+
if (typeof code === "string" && code.includes("MODULE_NOT_FOUND")) {
|
|
31
|
+
return messageText.includes(specifier);
|
|
32
|
+
}
|
|
33
|
+
if (messageText) {
|
|
34
|
+
const lowered = messageText.toLowerCase();
|
|
35
|
+
if (lowered.includes("cannot find module") || lowered.includes("module not found") || lowered.includes("cannot find package")) {
|
|
36
|
+
return lowered.includes(specifier.toLowerCase());
|
|
234
37
|
}
|
|
235
|
-
|
|
236
|
-
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
async function resolveNodeRequire() {
|
|
42
|
+
if (nodeRequire !== void 0) {
|
|
43
|
+
return nodeRequire;
|
|
44
|
+
}
|
|
45
|
+
if (isBrowser && !isNodeRuntime()) {
|
|
46
|
+
nodeRequire = null;
|
|
47
|
+
return nodeRequire;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
nodeRequire = getNodeRequireSync();
|
|
51
|
+
} catch {
|
|
52
|
+
nodeRequire = null;
|
|
53
|
+
}
|
|
54
|
+
return nodeRequire;
|
|
55
|
+
}
|
|
56
|
+
async function dynamicImport(specifier) {
|
|
57
|
+
try {
|
|
58
|
+
return await import(
|
|
59
|
+
/* webpackIgnore: true */
|
|
60
|
+
specifier
|
|
61
|
+
);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (isModuleNotFound(specifier, error)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function optionalImport(specifier, options = {}) {
|
|
70
|
+
if (isBrowser && !isNodeRuntime()) {
|
|
71
|
+
return dynamicImport(specifier);
|
|
72
|
+
}
|
|
73
|
+
if (!options.preferImport) {
|
|
74
|
+
const requireFn = await resolveNodeRequire();
|
|
75
|
+
if (requireFn) {
|
|
237
76
|
try {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
77
|
+
return requireFn(specifier);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (!isModuleNotFound(specifier, error)) {
|
|
80
|
+
throw error;
|
|
241
81
|
}
|
|
242
|
-
} catch {
|
|
243
|
-
encoded = contentBuffer.toString("base64");
|
|
244
82
|
}
|
|
245
|
-
} else {
|
|
246
|
-
encoded = contentBuffer.toString("base64");
|
|
247
|
-
}
|
|
248
|
-
return {
|
|
249
|
-
encoded,
|
|
250
|
-
contentType,
|
|
251
|
-
size
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
static parseFileCreate(body) {
|
|
255
|
-
if (!body) return void 0;
|
|
256
|
-
const data = {};
|
|
257
|
-
if (body.expirationTime?.seconds) {
|
|
258
|
-
data.expirationTime = `${Long.fromValue(
|
|
259
|
-
body.expirationTime.seconds
|
|
260
|
-
).toString()}.${body.expirationTime.nanos}`;
|
|
261
|
-
}
|
|
262
|
-
if (body.keys) {
|
|
263
|
-
data.keys = parseKey({ keyList: body.keys });
|
|
264
|
-
}
|
|
265
|
-
if (body.contents) {
|
|
266
|
-
data.contents = Buffer.from(body.contents).toString("base64");
|
|
267
|
-
}
|
|
268
|
-
if (body.memo) {
|
|
269
|
-
data.memo = body.memo;
|
|
270
83
|
}
|
|
271
|
-
return data;
|
|
272
84
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
if (body.contents) {
|
|
280
|
-
data.contents = Buffer.from(body.contents).toString("base64");
|
|
281
|
-
}
|
|
282
|
-
return data;
|
|
85
|
+
return dynamicImport(specifier);
|
|
86
|
+
}
|
|
87
|
+
function optionalImportSync(specifier) {
|
|
88
|
+
if (isBrowser && !isNodeRuntime()) {
|
|
89
|
+
return null;
|
|
283
90
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
91
|
+
try {
|
|
92
|
+
const requireFn = getNodeRequireSync();
|
|
93
|
+
if (requireFn) {
|
|
94
|
+
return requireFn(specifier);
|
|
289
95
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
).toString()}.${body.expirationTime.nanos}`;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (!isModuleNotFound(specifier, error)) {
|
|
98
|
+
throw error;
|
|
294
99
|
}
|
|
295
|
-
if (body.keys) {
|
|
296
|
-
data.keys = parseKey({ keyList: body.keys });
|
|
297
|
-
}
|
|
298
|
-
if (body.contents) {
|
|
299
|
-
data.contents = Buffer.from(body.contents).toString("base64");
|
|
300
|
-
}
|
|
301
|
-
if (body.memo?.value !== void 0) {
|
|
302
|
-
data.memo = body.memo.value;
|
|
303
|
-
}
|
|
304
|
-
return data;
|
|
305
|
-
}
|
|
306
|
-
static parseFileDelete(body) {
|
|
307
|
-
if (!body) return void 0;
|
|
308
|
-
const data = {};
|
|
309
|
-
if (body.fileID) {
|
|
310
|
-
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
311
|
-
}
|
|
312
|
-
return data;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Parse File Service transaction from Transaction object
|
|
316
|
-
* This is the unified entry point that delegates to the comprehensive parsing logic
|
|
317
|
-
*/
|
|
318
|
-
static parseFromTransactionObject(transaction) {
|
|
319
|
-
return this.parseFileTransaction(transaction);
|
|
320
100
|
}
|
|
101
|
+
return null;
|
|
321
102
|
}
|
|
322
103
|
export {
|
|
323
|
-
|
|
104
|
+
optionalImport,
|
|
105
|
+
optionalImportSync
|
|
324
106
|
};
|
|
325
107
|
//# sourceMappingURL=standards-sdk.es164.js.map
|