@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,13 +1,13 @@
|
|
|
1
1
|
import { proto } from "@hashgraph/proto";
|
|
2
|
-
import { Long } from "@hashgraph/sdk";
|
|
3
|
-
import { hasTransactionType, parseKey } from "./standards-sdk.es148.js";
|
|
2
|
+
import { Long, Hbar, HbarUnit, ContractId, AccountId, FileId } from "@hashgraph/sdk";
|
|
4
3
|
import { Buffer } from "buffer";
|
|
5
|
-
|
|
4
|
+
import { hasTransactionType, parseKey } from "./standards-sdk.es146.js";
|
|
5
|
+
class SCSParser {
|
|
6
6
|
/**
|
|
7
|
-
* Parse
|
|
7
|
+
* Parse Smart Contract Service transaction using unified dual-branch approach
|
|
8
8
|
* This handles both regular transactions and signed transaction variants
|
|
9
9
|
*/
|
|
10
|
-
static
|
|
10
|
+
static parseSCSTransaction(transaction, originalBytes) {
|
|
11
11
|
try {
|
|
12
12
|
if (originalBytes || transaction.toBytes) {
|
|
13
13
|
try {
|
|
@@ -38,147 +38,181 @@ class FileParser {
|
|
|
38
38
|
}
|
|
39
39
|
return this.parseFromTransactionInternals(transaction);
|
|
40
40
|
} catch (error) {
|
|
41
|
-
return {
|
|
41
|
+
return {
|
|
42
|
+
type: "UNKNOWN",
|
|
43
|
+
humanReadableType: "Unknown Contract Transaction"
|
|
44
|
+
};
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
|
-
* Parse
|
|
46
|
-
* Handles all
|
|
48
|
+
* Parse contract transaction from protobuf TransactionBody
|
|
49
|
+
* Handles all contract operations from decoded protobuf data
|
|
47
50
|
*/
|
|
48
51
|
static parseFromProtobufTxBody(txBody) {
|
|
49
|
-
if (txBody.
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
+
if (txBody.contractCall) {
|
|
53
|
+
const contractCall = this.parseContractCall(txBody.contractCall);
|
|
54
|
+
if (contractCall) {
|
|
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) {
|
|
52
67
|
return {
|
|
53
|
-
type: "
|
|
54
|
-
humanReadableType: "
|
|
55
|
-
|
|
68
|
+
type: "CONTRACTCREATE",
|
|
69
|
+
humanReadableType: "Contract Create",
|
|
70
|
+
contractCreate
|
|
56
71
|
};
|
|
57
72
|
}
|
|
58
73
|
}
|
|
59
|
-
if (txBody.
|
|
60
|
-
const
|
|
61
|
-
|
|
74
|
+
if (txBody.contractUpdateInstance) {
|
|
75
|
+
const contractUpdate = this.parseContractUpdate(
|
|
76
|
+
txBody.contractUpdateInstance
|
|
77
|
+
);
|
|
78
|
+
if (contractUpdate) {
|
|
62
79
|
return {
|
|
63
|
-
type: "
|
|
64
|
-
humanReadableType: "
|
|
65
|
-
|
|
80
|
+
type: "CONTRACTUPDATE",
|
|
81
|
+
humanReadableType: "Contract Update",
|
|
82
|
+
contractUpdate
|
|
66
83
|
};
|
|
67
84
|
}
|
|
68
85
|
}
|
|
69
|
-
if (txBody.
|
|
70
|
-
const
|
|
71
|
-
|
|
86
|
+
if (txBody.contractDeleteInstance) {
|
|
87
|
+
const contractDelete = this.parseContractDelete(
|
|
88
|
+
txBody.contractDeleteInstance
|
|
89
|
+
);
|
|
90
|
+
if (contractDelete) {
|
|
72
91
|
return {
|
|
73
|
-
type: "
|
|
74
|
-
humanReadableType: "
|
|
75
|
-
|
|
92
|
+
type: "CONTRACTDELETE",
|
|
93
|
+
humanReadableType: "Contract Delete",
|
|
94
|
+
contractDelete
|
|
76
95
|
};
|
|
77
96
|
}
|
|
78
97
|
}
|
|
79
|
-
if (txBody.
|
|
80
|
-
const
|
|
81
|
-
|
|
98
|
+
if (txBody.ethereumTransaction) {
|
|
99
|
+
const ethereumCall = this.parseEthereumTransaction(
|
|
100
|
+
txBody.ethereumTransaction
|
|
101
|
+
);
|
|
102
|
+
if (ethereumCall) {
|
|
82
103
|
return {
|
|
83
|
-
type: "
|
|
84
|
-
humanReadableType: "
|
|
85
|
-
|
|
104
|
+
type: "ETHEREUMTRANSACTION",
|
|
105
|
+
humanReadableType: "Ethereum Transaction",
|
|
106
|
+
ethereumTransaction: ethereumCall
|
|
86
107
|
};
|
|
87
108
|
}
|
|
88
109
|
}
|
|
89
110
|
return {};
|
|
90
111
|
}
|
|
91
112
|
/**
|
|
92
|
-
* Extract
|
|
113
|
+
* Extract contract data from Transaction internal fields
|
|
93
114
|
* This handles cases where data is stored in Transaction object internals
|
|
94
115
|
*/
|
|
95
116
|
static parseFromTransactionInternals(transaction) {
|
|
96
117
|
try {
|
|
97
118
|
const tx = transaction;
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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;
|
|
119
|
+
if (tx._contractId && tx._gas) {
|
|
120
|
+
const contractCall = {
|
|
121
|
+
contractId: tx._contractId.toString(),
|
|
122
|
+
gas: typeof tx._gas === "number" ? tx._gas : Long.fromValue(tx._gas).toNumber(),
|
|
123
|
+
amount: tx._amount ? parseFloat(tx._amount.toString()) : 0
|
|
124
|
+
};
|
|
125
|
+
if (tx._functionParameters) {
|
|
126
|
+
const funcParams = Buffer.from(tx._functionParameters).toString(
|
|
127
|
+
"hex"
|
|
128
|
+
);
|
|
129
|
+
contractCall.functionParameters = funcParams;
|
|
130
|
+
contractCall.functionName = this.extractFunctionName(funcParams);
|
|
121
131
|
}
|
|
122
132
|
return {
|
|
123
|
-
type: "
|
|
124
|
-
humanReadableType: "
|
|
125
|
-
|
|
133
|
+
type: "CONTRACTCALL",
|
|
134
|
+
humanReadableType: "Contract Call",
|
|
135
|
+
contractCall
|
|
126
136
|
};
|
|
127
137
|
}
|
|
128
|
-
if (hasTransactionType(transaction, "
|
|
129
|
-
const
|
|
130
|
-
|
|
138
|
+
if (hasTransactionType(transaction, "contractCreateInstance")) {
|
|
139
|
+
const contractCreate = {
|
|
140
|
+
gas: tx._gas.toString(),
|
|
141
|
+
initialBalance: tx._initialBalance?.toString() || "0"
|
|
131
142
|
};
|
|
132
|
-
if (tx.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
143
|
+
if (tx._fileId) {
|
|
144
|
+
contractCreate.initcodeSource = "fileID";
|
|
145
|
+
contractCreate.initcode = tx._fileId.toString();
|
|
146
|
+
} else if (tx._bytecode) {
|
|
147
|
+
contractCreate.initcodeSource = "bytes";
|
|
148
|
+
contractCreate.initcode = Buffer.from(tx._bytecode).toString("hex");
|
|
149
|
+
}
|
|
150
|
+
if (tx._constructorParameters) {
|
|
151
|
+
contractCreate.constructorParameters = Buffer.from(
|
|
152
|
+
tx._constructorParameters
|
|
153
|
+
).toString("hex");
|
|
138
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();
|
|
166
|
+
}
|
|
167
|
+
if (tx._declineReward !== void 0)
|
|
168
|
+
contractCreate.declineReward = tx._declineReward;
|
|
169
|
+
if (tx._autoRenewPeriod)
|
|
170
|
+
contractCreate.autoRenewPeriod = tx._autoRenewPeriod.toString();
|
|
139
171
|
return {
|
|
140
|
-
type: "
|
|
141
|
-
humanReadableType: "
|
|
142
|
-
|
|
172
|
+
type: "CONTRACTCREATE",
|
|
173
|
+
humanReadableType: "Contract Create",
|
|
174
|
+
contractCreate
|
|
143
175
|
};
|
|
144
176
|
}
|
|
145
|
-
if (hasTransactionType(transaction, "
|
|
146
|
-
const
|
|
147
|
-
|
|
177
|
+
if (hasTransactionType(transaction, "contractUpdateInstance")) {
|
|
178
|
+
const contractUpdate = {
|
|
179
|
+
contractIdToUpdate: tx._contractId.toString()
|
|
148
180
|
};
|
|
149
|
-
if (tx.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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 });
|
|
181
|
+
if (tx._memo) contractUpdate.memo = tx._memo;
|
|
182
|
+
if (tx._adminKey) contractUpdate.adminKey = parseKey(tx._adminKey);
|
|
183
|
+
if (tx._maxAutomaticTokenAssociations !== void 0) {
|
|
184
|
+
contractUpdate.maxAutomaticTokenAssociations = tx._maxAutomaticTokenAssociations;
|
|
161
185
|
}
|
|
162
|
-
if (tx.
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
186
|
+
if (tx._stakedAccountId) {
|
|
187
|
+
contractUpdate.stakedAccountId = tx._stakedAccountId.toString();
|
|
188
|
+
} else if (tx._stakedNodeId !== null && tx._stakedNodeId !== void 0) {
|
|
189
|
+
contractUpdate.stakedNodeId = Long.fromValue(
|
|
190
|
+
tx._stakedNodeId
|
|
191
|
+
).toString();
|
|
167
192
|
}
|
|
193
|
+
if (tx._declineReward !== void 0)
|
|
194
|
+
contractUpdate.declineReward = tx._declineReward;
|
|
195
|
+
if (tx._autoRenewPeriod)
|
|
196
|
+
contractUpdate.autoRenewPeriod = tx._autoRenewPeriod.toString();
|
|
168
197
|
return {
|
|
169
|
-
type: "
|
|
170
|
-
humanReadableType: "
|
|
171
|
-
|
|
198
|
+
type: "CONTRACTUPDATE",
|
|
199
|
+
humanReadableType: "Contract Update",
|
|
200
|
+
contractUpdate
|
|
172
201
|
};
|
|
173
202
|
}
|
|
174
|
-
if (hasTransactionType(transaction, "
|
|
175
|
-
const
|
|
176
|
-
|
|
203
|
+
if (hasTransactionType(transaction, "contractDeleteInstance")) {
|
|
204
|
+
const contractDelete = {
|
|
205
|
+
contractIdToDelete: tx._contractId.toString()
|
|
177
206
|
};
|
|
207
|
+
if (tx._transferAccountId) {
|
|
208
|
+
contractDelete.transferAccountId = tx._transferAccountId.toString();
|
|
209
|
+
} else if (tx._transferContractId) {
|
|
210
|
+
contractDelete.transferContractId = tx._transferContractId.toString();
|
|
211
|
+
}
|
|
178
212
|
return {
|
|
179
|
-
type: "
|
|
180
|
-
humanReadableType: "
|
|
181
|
-
|
|
213
|
+
type: "CONTRACTDELETE",
|
|
214
|
+
humanReadableType: "Contract Delete",
|
|
215
|
+
contractDelete
|
|
182
216
|
};
|
|
183
217
|
}
|
|
184
218
|
return {};
|
|
@@ -187,139 +221,236 @@ class FileParser {
|
|
|
187
221
|
}
|
|
188
222
|
}
|
|
189
223
|
/**
|
|
190
|
-
* Enhanced
|
|
224
|
+
* Enhanced function name extraction from contract call parameters
|
|
225
|
+
* Attempts to decode function selector and map to known function names
|
|
191
226
|
*/
|
|
192
|
-
static
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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)
|
|
257
|
+
*/
|
|
258
|
+
static parseEthereumTransaction(body) {
|
|
259
|
+
if (!body) return void 0;
|
|
260
|
+
const data = {
|
|
261
|
+
contractId: "EVM",
|
|
262
|
+
gas: body.maxGasAllowance ? Long.fromValue(body.maxGasAllowance).toNumber() : 0,
|
|
263
|
+
amount: 0
|
|
264
|
+
};
|
|
265
|
+
if (body.ethereumData && body.ethereumData.length > 0) {
|
|
266
|
+
const ethData = Buffer.from(body.ethereumData).toString("hex");
|
|
267
|
+
data.functionParameters = ethData;
|
|
268
|
+
if (ethData.length >= 8) {
|
|
269
|
+
data.functionName = this.extractFunctionName(ethData);
|
|
233
270
|
}
|
|
234
271
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
272
|
+
return data;
|
|
273
|
+
}
|
|
274
|
+
static parseContractCall(body) {
|
|
275
|
+
if (!body) return void 0;
|
|
276
|
+
const hbarAmount = Hbar.fromTinybars(Long.fromValue(body.amount ?? 0));
|
|
277
|
+
const data = {
|
|
278
|
+
contractId: new ContractId(
|
|
279
|
+
body.contractID.shardNum ?? 0,
|
|
280
|
+
body.contractID.realmNum ?? 0,
|
|
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);
|
|
244
292
|
}
|
|
245
|
-
} else {
|
|
246
|
-
encoded = contentBuffer.toString("base64");
|
|
247
293
|
}
|
|
248
|
-
return
|
|
249
|
-
encoded,
|
|
250
|
-
contentType,
|
|
251
|
-
size
|
|
252
|
-
};
|
|
294
|
+
return data;
|
|
253
295
|
}
|
|
254
|
-
static
|
|
296
|
+
static parseContractCreate(body) {
|
|
255
297
|
if (!body) return void 0;
|
|
256
298
|
const data = {};
|
|
257
|
-
if (body.
|
|
258
|
-
data.
|
|
259
|
-
body.
|
|
260
|
-
).toString()
|
|
299
|
+
if (body.initialBalance) {
|
|
300
|
+
data.initialBalance = Hbar.fromTinybars(
|
|
301
|
+
Long.fromValue(body.initialBalance)
|
|
302
|
+
).toString(HbarUnit.Hbar);
|
|
303
|
+
}
|
|
304
|
+
if (body.gas) {
|
|
305
|
+
data.gas = Long.fromValue(body.gas).toString();
|
|
261
306
|
}
|
|
262
|
-
if (body.
|
|
263
|
-
data.
|
|
307
|
+
if (body.adminKey) {
|
|
308
|
+
data.adminKey = parseKey(body.adminKey);
|
|
264
309
|
}
|
|
265
|
-
if (body.
|
|
266
|
-
data.
|
|
310
|
+
if (body.constructorParameters) {
|
|
311
|
+
data.constructorParameters = Buffer.from(
|
|
312
|
+
body.constructorParameters
|
|
313
|
+
).toString("hex");
|
|
267
314
|
}
|
|
268
315
|
if (body.memo) {
|
|
269
316
|
data.memo = body.memo;
|
|
270
317
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (body.
|
|
277
|
-
data.
|
|
318
|
+
if (body.autoRenewPeriod?.seconds) {
|
|
319
|
+
data.autoRenewPeriod = Long.fromValue(
|
|
320
|
+
body.autoRenewPeriod.seconds
|
|
321
|
+
).toString();
|
|
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();
|
|
278
331
|
}
|
|
279
|
-
if (body.
|
|
280
|
-
data.
|
|
332
|
+
if (body.declineReward !== void 0) {
|
|
333
|
+
data.declineReward = body.declineReward;
|
|
334
|
+
}
|
|
335
|
+
if (body.maxAutomaticTokenAssociations !== void 0) {
|
|
336
|
+
data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations;
|
|
337
|
+
}
|
|
338
|
+
if (body.fileID) {
|
|
339
|
+
data.initcodeSource = "fileID";
|
|
340
|
+
data.initcode = new FileId(
|
|
341
|
+
body.fileID.shardNum ?? 0,
|
|
342
|
+
body.fileID.realmNum ?? 0,
|
|
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");
|
|
281
348
|
}
|
|
282
349
|
return data;
|
|
283
350
|
}
|
|
284
|
-
static
|
|
351
|
+
static parseContractUpdate(body) {
|
|
285
352
|
if (!body) return void 0;
|
|
286
353
|
const data = {};
|
|
287
|
-
if (body.
|
|
288
|
-
data.
|
|
354
|
+
if (body.contractID) {
|
|
355
|
+
data.contractIdToUpdate = new ContractId(
|
|
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);
|
|
289
363
|
}
|
|
290
364
|
if (body.expirationTime?.seconds) {
|
|
291
365
|
data.expirationTime = `${Long.fromValue(
|
|
292
366
|
body.expirationTime.seconds
|
|
293
367
|
).toString()}.${body.expirationTime.nanos}`;
|
|
294
368
|
}
|
|
295
|
-
if (body.
|
|
296
|
-
data.
|
|
369
|
+
if (body.autoRenewPeriod?.seconds) {
|
|
370
|
+
data.autoRenewPeriod = Long.fromValue(
|
|
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;
|
|
297
407
|
}
|
|
298
|
-
if (body.
|
|
299
|
-
data.
|
|
408
|
+
if (body.maxAutomaticTokenAssociations?.value !== void 0) {
|
|
409
|
+
data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations.value;
|
|
300
410
|
}
|
|
301
|
-
if (body.
|
|
302
|
-
data.
|
|
411
|
+
if (body.autoRenewAccountId) {
|
|
412
|
+
data.autoRenewAccountId = new AccountId(
|
|
413
|
+
body.autoRenewAccountId.shardNum ?? 0,
|
|
414
|
+
body.autoRenewAccountId.realmNum ?? 0,
|
|
415
|
+
body.autoRenewAccountId.accountNum ?? 0
|
|
416
|
+
).toString();
|
|
303
417
|
}
|
|
304
418
|
return data;
|
|
305
419
|
}
|
|
306
|
-
static
|
|
420
|
+
static parseContractDelete(body) {
|
|
307
421
|
if (!body) return void 0;
|
|
308
422
|
const data = {};
|
|
309
|
-
if (body.
|
|
310
|
-
data.
|
|
423
|
+
if (body.contractID) {
|
|
424
|
+
data.contractIdToDelete = new ContractId(
|
|
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();
|
|
311
442
|
}
|
|
312
443
|
return data;
|
|
313
444
|
}
|
|
314
445
|
/**
|
|
315
|
-
* Parse
|
|
446
|
+
* Parse SCS (Smart Contract Service) transaction from Transaction object
|
|
316
447
|
* This is the unified entry point that delegates to the comprehensive parsing logic
|
|
317
448
|
*/
|
|
318
449
|
static parseFromTransactionObject(transaction) {
|
|
319
|
-
return this.
|
|
450
|
+
return this.parseSCSTransaction(transaction);
|
|
320
451
|
}
|
|
321
452
|
}
|
|
322
453
|
export {
|
|
323
|
-
|
|
454
|
+
SCSParser
|
|
324
455
|
};
|
|
325
456
|
//# sourceMappingURL=standards-sdk.es144.js.map
|