@hashgraphonline/standards-sdk 0.1.141-canary.31 → 0.1.141-canary.34
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-21/base-client.d.ts +2 -1
- package/dist/cjs/hcs-21/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-21/sdk.d.ts +26 -0
- package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-21/types.d.ts +11 -1
- package/dist/cjs/hcs-21/types.d.ts.map +1 -1
- package/dist/cjs/services/types.d.ts +1 -0
- package/dist/cjs/services/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-21/base-client.d.ts +2 -1
- package/dist/es/hcs-21/base-client.d.ts.map +1 -1
- package/dist/es/hcs-21/sdk.d.ts +26 -0
- package/dist/es/hcs-21/sdk.d.ts.map +1 -1
- package/dist/es/hcs-21/types.d.ts +11 -1
- package/dist/es/hcs-21/types.d.ts.map +1 -1
- package/dist/es/services/types.d.ts +1 -0
- package/dist/es/services/types.d.ts.map +1 -1
- 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 +1 -1
- package/dist/es/standards-sdk.es126.js +1 -1
- package/dist/es/standards-sdk.es128.js +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es138.js +42 -766
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +12265 -33
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +766 -172
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +55 -321
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +120 -294
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +191 -322
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +294 -279
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +440 -63
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +267 -12210
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +69 -49
- 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.es20.js +2 -2
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es28.js +2 -2
- 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 +2 -2
- 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.es61.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 +4 -3
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +1 -1
- package/dist/es/standards-sdk.es83.js +24 -0
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +70 -1
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +1 -1
- package/package.json +63 -61
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { proto } from "@hashgraph/proto";
|
|
2
|
-
import { Long
|
|
2
|
+
import { Long } from "@hashgraph/sdk";
|
|
3
|
+
import { hasTransactionType, parseKey } from "./standards-sdk.es148.js";
|
|
3
4
|
import { Buffer } from "buffer";
|
|
4
|
-
|
|
5
|
-
class SCSParser {
|
|
5
|
+
class FileParser {
|
|
6
6
|
/**
|
|
7
|
-
* Parse
|
|
7
|
+
* Parse File Service transaction using unified dual-branch approach
|
|
8
8
|
* This handles both regular transactions and signed transaction variants
|
|
9
9
|
*/
|
|
10
|
-
static
|
|
10
|
+
static parseFileTransaction(transaction, originalBytes) {
|
|
11
11
|
try {
|
|
12
12
|
if (originalBytes || transaction.toBytes) {
|
|
13
13
|
try {
|
|
@@ -38,181 +38,147 @@ class SCSParser {
|
|
|
38
38
|
}
|
|
39
39
|
return this.parseFromTransactionInternals(transaction);
|
|
40
40
|
} catch (error) {
|
|
41
|
-
return {
|
|
42
|
-
type: "UNKNOWN",
|
|
43
|
-
humanReadableType: "Unknown Contract Transaction"
|
|
44
|
-
};
|
|
41
|
+
return { type: "UNKNOWN", humanReadableType: "Unknown File Transaction" };
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
|
-
* Parse
|
|
49
|
-
* Handles all
|
|
45
|
+
* Parse file transaction from protobuf TransactionBody
|
|
46
|
+
* Handles all file operations from decoded protobuf data
|
|
50
47
|
*/
|
|
51
48
|
static parseFromProtobufTxBody(txBody) {
|
|
52
|
-
if (txBody.
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
return {
|
|
56
|
-
type: "CONTRACTCALL",
|
|
57
|
-
humanReadableType: "Contract Call",
|
|
58
|
-
contractCall
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (txBody.contractCreateInstance) {
|
|
63
|
-
const contractCreate = this.parseContractCreate(
|
|
64
|
-
txBody.contractCreateInstance
|
|
65
|
-
);
|
|
66
|
-
if (contractCreate) {
|
|
49
|
+
if (txBody.fileCreate) {
|
|
50
|
+
const fileCreate = this.parseFileCreate(txBody.fileCreate);
|
|
51
|
+
if (fileCreate) {
|
|
67
52
|
return {
|
|
68
|
-
type: "
|
|
69
|
-
humanReadableType: "
|
|
70
|
-
|
|
53
|
+
type: "FILECREATE",
|
|
54
|
+
humanReadableType: "File Create",
|
|
55
|
+
fileCreate
|
|
71
56
|
};
|
|
72
57
|
}
|
|
73
58
|
}
|
|
74
|
-
if (txBody.
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
if (contractUpdate) {
|
|
59
|
+
if (txBody.fileAppend) {
|
|
60
|
+
const fileAppend = this.parseFileAppend(txBody.fileAppend);
|
|
61
|
+
if (fileAppend) {
|
|
79
62
|
return {
|
|
80
|
-
type: "
|
|
81
|
-
humanReadableType: "
|
|
82
|
-
|
|
63
|
+
type: "FILEAPPEND",
|
|
64
|
+
humanReadableType: "File Append",
|
|
65
|
+
fileAppend
|
|
83
66
|
};
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
|
-
if (txBody.
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
);
|
|
90
|
-
if (contractDelete) {
|
|
69
|
+
if (txBody.fileUpdate) {
|
|
70
|
+
const fileUpdate = this.parseFileUpdate(txBody.fileUpdate);
|
|
71
|
+
if (fileUpdate) {
|
|
91
72
|
return {
|
|
92
|
-
type: "
|
|
93
|
-
humanReadableType: "
|
|
94
|
-
|
|
73
|
+
type: "FILEUPDATE",
|
|
74
|
+
humanReadableType: "File Update",
|
|
75
|
+
fileUpdate
|
|
95
76
|
};
|
|
96
77
|
}
|
|
97
78
|
}
|
|
98
|
-
if (txBody.
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
);
|
|
102
|
-
if (ethereumCall) {
|
|
79
|
+
if (txBody.fileDelete) {
|
|
80
|
+
const fileDelete = this.parseFileDelete(txBody.fileDelete);
|
|
81
|
+
if (fileDelete) {
|
|
103
82
|
return {
|
|
104
|
-
type: "
|
|
105
|
-
humanReadableType: "
|
|
106
|
-
|
|
83
|
+
type: "FILEDELETE",
|
|
84
|
+
humanReadableType: "File Delete",
|
|
85
|
+
fileDelete
|
|
107
86
|
};
|
|
108
87
|
}
|
|
109
88
|
}
|
|
110
89
|
return {};
|
|
111
90
|
}
|
|
112
91
|
/**
|
|
113
|
-
* Extract
|
|
92
|
+
* Extract file data from Transaction internal fields
|
|
114
93
|
* This handles cases where data is stored in Transaction object internals
|
|
115
94
|
*/
|
|
116
95
|
static parseFromTransactionInternals(transaction) {
|
|
117
96
|
try {
|
|
118
97
|
const tx = transaction;
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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;
|
|
131
121
|
}
|
|
132
122
|
return {
|
|
133
|
-
type: "
|
|
134
|
-
humanReadableType: "
|
|
135
|
-
|
|
123
|
+
type: "FILECREATE",
|
|
124
|
+
humanReadableType: "File Create",
|
|
125
|
+
fileCreate
|
|
136
126
|
};
|
|
137
127
|
}
|
|
138
|
-
if (hasTransactionType(transaction, "
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
initialBalance: tx._initialBalance?.toString() || "0"
|
|
128
|
+
if (hasTransactionType(transaction, "fileAppend")) {
|
|
129
|
+
const fileAppend = {
|
|
130
|
+
fileId: tx._fileId.toString()
|
|
142
131
|
};
|
|
143
|
-
if (tx.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
if (tx._constructorParameters) {
|
|
151
|
-
contractCreate.constructorParameters = Buffer.from(
|
|
152
|
-
tx._constructorParameters
|
|
153
|
-
).toString("hex");
|
|
154
|
-
}
|
|
155
|
-
if (tx._memo) contractCreate.memo = tx._memo;
|
|
156
|
-
if (tx._adminKey) contractCreate.adminKey = parseKey(tx._adminKey);
|
|
157
|
-
if (tx._maxAutomaticTokenAssociations !== void 0) {
|
|
158
|
-
contractCreate.maxAutomaticTokenAssociations = tx._maxAutomaticTokenAssociations;
|
|
159
|
-
}
|
|
160
|
-
if (tx._stakedAccountId) {
|
|
161
|
-
contractCreate.stakedAccountId = tx._stakedAccountId.toString();
|
|
162
|
-
} else if (tx._stakedNodeId !== null && tx._stakedNodeId !== void 0) {
|
|
163
|
-
contractCreate.stakedNodeId = Long.fromValue(
|
|
164
|
-
tx._stakedNodeId
|
|
165
|
-
).toString();
|
|
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
|
+
}
|
|
166
138
|
}
|
|
167
|
-
if (tx._declineReward !== void 0)
|
|
168
|
-
contractCreate.declineReward = tx._declineReward;
|
|
169
|
-
if (tx._autoRenewPeriod)
|
|
170
|
-
contractCreate.autoRenewPeriod = tx._autoRenewPeriod.toString();
|
|
171
139
|
return {
|
|
172
|
-
type: "
|
|
173
|
-
humanReadableType: "
|
|
174
|
-
|
|
140
|
+
type: "FILEAPPEND",
|
|
141
|
+
humanReadableType: "File Append",
|
|
142
|
+
fileAppend
|
|
175
143
|
};
|
|
176
144
|
}
|
|
177
|
-
if (hasTransactionType(transaction, "
|
|
178
|
-
const
|
|
179
|
-
|
|
145
|
+
if (hasTransactionType(transaction, "fileUpdate")) {
|
|
146
|
+
const fileUpdate = {
|
|
147
|
+
fileId: tx._fileId.toString()
|
|
180
148
|
};
|
|
181
|
-
if (tx.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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 });
|
|
185
161
|
}
|
|
186
|
-
if (tx.
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
).toString();
|
|
162
|
+
if (tx._expirationTime) {
|
|
163
|
+
fileUpdate.expirationTime = tx._expirationTime.toString();
|
|
164
|
+
}
|
|
165
|
+
if (tx._memo) {
|
|
166
|
+
fileUpdate.memo = tx._memo;
|
|
192
167
|
}
|
|
193
|
-
if (tx._declineReward !== void 0)
|
|
194
|
-
contractUpdate.declineReward = tx._declineReward;
|
|
195
|
-
if (tx._autoRenewPeriod)
|
|
196
|
-
contractUpdate.autoRenewPeriod = tx._autoRenewPeriod.toString();
|
|
197
168
|
return {
|
|
198
|
-
type: "
|
|
199
|
-
humanReadableType: "
|
|
200
|
-
|
|
169
|
+
type: "FILEUPDATE",
|
|
170
|
+
humanReadableType: "File Update",
|
|
171
|
+
fileUpdate
|
|
201
172
|
};
|
|
202
173
|
}
|
|
203
|
-
if (hasTransactionType(transaction, "
|
|
204
|
-
const
|
|
205
|
-
|
|
174
|
+
if (hasTransactionType(transaction, "fileDelete")) {
|
|
175
|
+
const fileDelete = {
|
|
176
|
+
fileId: tx._fileId.toString()
|
|
206
177
|
};
|
|
207
|
-
if (tx._transferAccountId) {
|
|
208
|
-
contractDelete.transferAccountId = tx._transferAccountId.toString();
|
|
209
|
-
} else if (tx._transferContractId) {
|
|
210
|
-
contractDelete.transferContractId = tx._transferContractId.toString();
|
|
211
|
-
}
|
|
212
178
|
return {
|
|
213
|
-
type: "
|
|
214
|
-
humanReadableType: "
|
|
215
|
-
|
|
179
|
+
type: "FILEDELETE",
|
|
180
|
+
humanReadableType: "File Delete",
|
|
181
|
+
fileDelete
|
|
216
182
|
};
|
|
217
183
|
}
|
|
218
184
|
return {};
|
|
@@ -221,236 +187,139 @@ class SCSParser {
|
|
|
221
187
|
}
|
|
222
188
|
}
|
|
223
189
|
/**
|
|
224
|
-
* Enhanced
|
|
225
|
-
* Attempts to decode function selector and map to known function names
|
|
226
|
-
*/
|
|
227
|
-
static extractFunctionName(functionParameters) {
|
|
228
|
-
if (functionParameters.length < 8) return "unknown";
|
|
229
|
-
const selector = functionParameters.substring(0, 8);
|
|
230
|
-
const commonSelectors = {
|
|
231
|
-
a9059cbb: "transfer",
|
|
232
|
-
"095ea7b3": "approve",
|
|
233
|
-
"23b872dd": "transferFrom",
|
|
234
|
-
"70a08231": "balanceOf",
|
|
235
|
-
dd62ed3e: "allowance",
|
|
236
|
-
"18160ddd": "totalSupply",
|
|
237
|
-
"06fdde03": "name",
|
|
238
|
-
"95d89b41": "symbol",
|
|
239
|
-
"313ce567": "decimals",
|
|
240
|
-
"42842e0e": "safeTransferFrom",
|
|
241
|
-
b88d4fde: "safeTransferFrom",
|
|
242
|
-
e985e9c5: "isApprovedForAll",
|
|
243
|
-
a22cb465: "setApprovalForAll",
|
|
244
|
-
"6352211e": "ownerOf",
|
|
245
|
-
c87b56dd: "tokenURI",
|
|
246
|
-
"01ffc9a7": "supportsInterface",
|
|
247
|
-
"40c10f19": "mint",
|
|
248
|
-
"42966c68": "burn",
|
|
249
|
-
f2fde38b: "transferOwnership",
|
|
250
|
-
"715018a6": "renounceOwnership",
|
|
251
|
-
"8da5cb5b": "owner"
|
|
252
|
-
};
|
|
253
|
-
return commonSelectors[selector] || selector;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Parse Ethereum Transaction (was completely missing from original parser)
|
|
190
|
+
* Enhanced content analysis with type detection and metadata
|
|
257
191
|
*/
|
|
258
|
-
static
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
192
|
+
static analyzeContent(contents) {
|
|
193
|
+
const size = contents.length;
|
|
194
|
+
const contentBuffer = Buffer.from(contents);
|
|
195
|
+
let contentType;
|
|
196
|
+
if (size >= 4) {
|
|
197
|
+
const header = contentBuffer.subarray(0, 4);
|
|
198
|
+
const headerHex = header.toString("hex");
|
|
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";
|
|
270
233
|
}
|
|
271
234
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
body.contractID.contractNum ?? 0
|
|
282
|
-
).toString(),
|
|
283
|
-
gas: Long.fromValue(body.gas ?? 0).toNumber(),
|
|
284
|
-
amount: parseFloat(hbarAmount.toString(HbarUnit.Hbar))
|
|
285
|
-
};
|
|
286
|
-
if (body.functionParameters) {
|
|
287
|
-
data.functionParameters = Buffer.from(body.functionParameters).toString(
|
|
288
|
-
"hex"
|
|
289
|
-
);
|
|
290
|
-
if (data.functionParameters.length >= 8) {
|
|
291
|
-
data.functionName = this.extractFunctionName(data.functionParameters);
|
|
235
|
+
let encoded;
|
|
236
|
+
if (contentType?.startsWith("text/") || contentType === "application/json") {
|
|
237
|
+
try {
|
|
238
|
+
encoded = contentBuffer.toString("utf8");
|
|
239
|
+
if (encoded.includes("�") || /[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(encoded)) {
|
|
240
|
+
encoded = contentBuffer.toString("base64");
|
|
241
|
+
}
|
|
242
|
+
} catch {
|
|
243
|
+
encoded = contentBuffer.toString("base64");
|
|
292
244
|
}
|
|
245
|
+
} else {
|
|
246
|
+
encoded = contentBuffer.toString("base64");
|
|
293
247
|
}
|
|
294
|
-
return
|
|
248
|
+
return {
|
|
249
|
+
encoded,
|
|
250
|
+
contentType,
|
|
251
|
+
size
|
|
252
|
+
};
|
|
295
253
|
}
|
|
296
|
-
static
|
|
254
|
+
static parseFileCreate(body) {
|
|
297
255
|
if (!body) return void 0;
|
|
298
256
|
const data = {};
|
|
299
|
-
if (body.
|
|
300
|
-
data.
|
|
301
|
-
|
|
302
|
-
).toString(
|
|
303
|
-
}
|
|
304
|
-
if (body.gas) {
|
|
305
|
-
data.gas = Long.fromValue(body.gas).toString();
|
|
257
|
+
if (body.expirationTime?.seconds) {
|
|
258
|
+
data.expirationTime = `${Long.fromValue(
|
|
259
|
+
body.expirationTime.seconds
|
|
260
|
+
).toString()}.${body.expirationTime.nanos}`;
|
|
306
261
|
}
|
|
307
|
-
if (body.
|
|
308
|
-
data.
|
|
262
|
+
if (body.keys) {
|
|
263
|
+
data.keys = parseKey({ keyList: body.keys });
|
|
309
264
|
}
|
|
310
|
-
if (body.
|
|
311
|
-
data.
|
|
312
|
-
body.constructorParameters
|
|
313
|
-
).toString("hex");
|
|
265
|
+
if (body.contents) {
|
|
266
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
314
267
|
}
|
|
315
268
|
if (body.memo) {
|
|
316
269
|
data.memo = body.memo;
|
|
317
270
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
if (body.stakedAccountId) {
|
|
324
|
-
data.stakedAccountId = new AccountId(
|
|
325
|
-
body.stakedAccountId.shardNum ?? 0,
|
|
326
|
-
body.stakedAccountId.realmNum ?? 0,
|
|
327
|
-
body.stakedAccountId.accountNum ?? 0
|
|
328
|
-
).toString();
|
|
329
|
-
} else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0) {
|
|
330
|
-
data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
|
|
331
|
-
}
|
|
332
|
-
if (body.declineReward !== void 0) {
|
|
333
|
-
data.declineReward = body.declineReward;
|
|
334
|
-
}
|
|
335
|
-
if (body.maxAutomaticTokenAssociations !== void 0) {
|
|
336
|
-
data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations;
|
|
337
|
-
}
|
|
271
|
+
return data;
|
|
272
|
+
}
|
|
273
|
+
static parseFileAppend(body) {
|
|
274
|
+
if (!body) return void 0;
|
|
275
|
+
const data = {};
|
|
338
276
|
if (body.fileID) {
|
|
339
|
-
data.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
body.fileID.fileNum ?? 0
|
|
344
|
-
).toString();
|
|
345
|
-
} else if (body.initcode && body.initcode.length > 0) {
|
|
346
|
-
data.initcodeSource = "bytes";
|
|
347
|
-
data.initcode = Buffer.from(body.initcode).toString("hex");
|
|
277
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
278
|
+
}
|
|
279
|
+
if (body.contents) {
|
|
280
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
348
281
|
}
|
|
349
282
|
return data;
|
|
350
283
|
}
|
|
351
|
-
static
|
|
284
|
+
static parseFileUpdate(body) {
|
|
352
285
|
if (!body) return void 0;
|
|
353
286
|
const data = {};
|
|
354
|
-
if (body.
|
|
355
|
-
data.
|
|
356
|
-
body.contractID.shardNum ?? 0,
|
|
357
|
-
body.contractID.realmNum ?? 0,
|
|
358
|
-
body.contractID.contractNum ?? 0
|
|
359
|
-
).toString();
|
|
360
|
-
}
|
|
361
|
-
if (body.adminKey) {
|
|
362
|
-
data.adminKey = parseKey(body.adminKey);
|
|
287
|
+
if (body.fileID) {
|
|
288
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
363
289
|
}
|
|
364
290
|
if (body.expirationTime?.seconds) {
|
|
365
291
|
data.expirationTime = `${Long.fromValue(
|
|
366
292
|
body.expirationTime.seconds
|
|
367
293
|
).toString()}.${body.expirationTime.nanos}`;
|
|
368
294
|
}
|
|
369
|
-
if (body.
|
|
370
|
-
data.
|
|
371
|
-
body.autoRenewPeriod.seconds
|
|
372
|
-
).toString();
|
|
373
|
-
}
|
|
374
|
-
if (body.memo) {
|
|
375
|
-
const memoUnion = body.memo;
|
|
376
|
-
if (memoUnion && typeof memoUnion === "object" && Object.prototype.hasOwnProperty.call(memoUnion, "value")) {
|
|
377
|
-
const value = memoUnion.value;
|
|
378
|
-
if (value === null || value === void 0) {
|
|
379
|
-
data.memo = void 0;
|
|
380
|
-
} else {
|
|
381
|
-
data.memo = String(value);
|
|
382
|
-
}
|
|
383
|
-
} else if (typeof memoUnion === "string") {
|
|
384
|
-
data.memo = memoUnion;
|
|
385
|
-
} else {
|
|
386
|
-
data.memo = void 0;
|
|
387
|
-
}
|
|
388
|
-
} else {
|
|
389
|
-
data.memo = void 0;
|
|
390
|
-
}
|
|
391
|
-
if (body.stakedAccountId) {
|
|
392
|
-
data.stakedAccountId = new AccountId(
|
|
393
|
-
body.stakedAccountId.shardNum ?? 0,
|
|
394
|
-
body.stakedAccountId.realmNum ?? 0,
|
|
395
|
-
body.stakedAccountId.accountNum ?? 0
|
|
396
|
-
).toString();
|
|
397
|
-
data.stakedNodeId = void 0;
|
|
398
|
-
} else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0 && Long.fromValue(body.stakedNodeId).notEquals(-1)) {
|
|
399
|
-
data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
|
|
400
|
-
data.stakedAccountId = void 0;
|
|
401
|
-
} else {
|
|
402
|
-
data.stakedNodeId = void 0;
|
|
403
|
-
data.stakedAccountId = void 0;
|
|
404
|
-
}
|
|
405
|
-
if (body.declineReward?.value !== void 0) {
|
|
406
|
-
data.declineReward = body.declineReward.value;
|
|
295
|
+
if (body.keys) {
|
|
296
|
+
data.keys = parseKey({ keyList: body.keys });
|
|
407
297
|
}
|
|
408
|
-
if (body.
|
|
409
|
-
data.
|
|
298
|
+
if (body.contents) {
|
|
299
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
410
300
|
}
|
|
411
|
-
if (body.
|
|
412
|
-
data.
|
|
413
|
-
body.autoRenewAccountId.shardNum ?? 0,
|
|
414
|
-
body.autoRenewAccountId.realmNum ?? 0,
|
|
415
|
-
body.autoRenewAccountId.accountNum ?? 0
|
|
416
|
-
).toString();
|
|
301
|
+
if (body.memo?.value !== void 0) {
|
|
302
|
+
data.memo = body.memo.value;
|
|
417
303
|
}
|
|
418
304
|
return data;
|
|
419
305
|
}
|
|
420
|
-
static
|
|
306
|
+
static parseFileDelete(body) {
|
|
421
307
|
if (!body) return void 0;
|
|
422
308
|
const data = {};
|
|
423
|
-
if (body.
|
|
424
|
-
data.
|
|
425
|
-
body.contractID.shardNum ?? 0,
|
|
426
|
-
body.contractID.realmNum ?? 0,
|
|
427
|
-
body.contractID.contractNum ?? 0
|
|
428
|
-
).toString();
|
|
429
|
-
}
|
|
430
|
-
if (body.transferAccountID) {
|
|
431
|
-
data.transferAccountId = new AccountId(
|
|
432
|
-
body.transferAccountID.shardNum ?? 0,
|
|
433
|
-
body.transferAccountID.realmNum ?? 0,
|
|
434
|
-
body.transferAccountID.accountNum ?? 0
|
|
435
|
-
).toString();
|
|
436
|
-
} else if (body.transferContractID) {
|
|
437
|
-
data.transferContractId = new ContractId(
|
|
438
|
-
body.transferContractID.shardNum ?? 0,
|
|
439
|
-
body.transferContractID.realmNum ?? 0,
|
|
440
|
-
body.transferContractID.contractNum ?? 0
|
|
441
|
-
).toString();
|
|
309
|
+
if (body.fileID) {
|
|
310
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
442
311
|
}
|
|
443
312
|
return data;
|
|
444
313
|
}
|
|
445
314
|
/**
|
|
446
|
-
* Parse
|
|
315
|
+
* Parse File Service transaction from Transaction object
|
|
447
316
|
* This is the unified entry point that delegates to the comprehensive parsing logic
|
|
448
317
|
*/
|
|
449
318
|
static parseFromTransactionObject(transaction) {
|
|
450
|
-
return this.
|
|
319
|
+
return this.parseFileTransaction(transaction);
|
|
451
320
|
}
|
|
452
321
|
}
|
|
453
322
|
export {
|
|
454
|
-
|
|
323
|
+
FileParser
|
|
455
324
|
};
|
|
456
325
|
//# sourceMappingURL=standards-sdk.es144.js.map
|