@missionsquad/mcp-server-tron 1.2.0

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.
Files changed (193) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +537 -0
  3. package/bin/cli.js +51 -0
  4. package/build/core/chains.d.ts +17 -0
  5. package/build/core/chains.js +87 -0
  6. package/build/core/chains.js.map +1 -0
  7. package/build/core/prompts.d.ts +19 -0
  8. package/build/core/prompts.js +485 -0
  9. package/build/core/prompts.js.map +1 -0
  10. package/build/core/resources.d.ts +14 -0
  11. package/build/core/resources.js +42 -0
  12. package/build/core/resources.js.map +1 -0
  13. package/build/core/services/account-data.d.ts +144 -0
  14. package/build/core/services/account-data.js +228 -0
  15. package/build/core/services/account-data.js.map +1 -0
  16. package/build/core/services/account-resource.d.ts +56 -0
  17. package/build/core/services/account-resource.js +133 -0
  18. package/build/core/services/account-resource.js.map +1 -0
  19. package/build/core/services/account.d.ts +141 -0
  20. package/build/core/services/account.js +191 -0
  21. package/build/core/services/account.js.map +1 -0
  22. package/build/core/services/address.d.ts +8 -0
  23. package/build/core/services/address.js +52 -0
  24. package/build/core/services/address.js.map +1 -0
  25. package/build/core/services/agent-wallet.d.ts +62 -0
  26. package/build/core/services/agent-wallet.js +234 -0
  27. package/build/core/services/agent-wallet.js.map +1 -0
  28. package/build/core/services/balance.d.ts +26 -0
  29. package/build/core/services/balance.js +60 -0
  30. package/build/core/services/balance.js.map +1 -0
  31. package/build/core/services/blocks.d.ts +25 -0
  32. package/build/core/services/blocks.js +65 -0
  33. package/build/core/services/blocks.js.map +1 -0
  34. package/build/core/services/broadcast.d.ts +13 -0
  35. package/build/core/services/broadcast.js +24 -0
  36. package/build/core/services/broadcast.js.map +1 -0
  37. package/build/core/services/clients.d.ts +5 -0
  38. package/build/core/services/clients.js +29 -0
  39. package/build/core/services/clients.js.map +1 -0
  40. package/build/core/services/contract-data.d.ts +31 -0
  41. package/build/core/services/contract-data.js +54 -0
  42. package/build/core/services/contract-data.js.map +1 -0
  43. package/build/core/services/contracts.d.ts +108 -0
  44. package/build/core/services/contracts.js +482 -0
  45. package/build/core/services/contracts.js.map +1 -0
  46. package/build/core/services/events.d.ts +56 -0
  47. package/build/core/services/events.js +99 -0
  48. package/build/core/services/events.js.map +1 -0
  49. package/build/core/services/governance.d.ts +78 -0
  50. package/build/core/services/governance.js +207 -0
  51. package/build/core/services/governance.js.map +1 -0
  52. package/build/core/services/index.d.ts +28 -0
  53. package/build/core/services/index.js +81 -0
  54. package/build/core/services/index.js.map +1 -0
  55. package/build/core/services/mempool.d.ts +12 -0
  56. package/build/core/services/mempool.js +32 -0
  57. package/build/core/services/mempool.js.map +1 -0
  58. package/build/core/services/multicall-abi.d.ts +55 -0
  59. package/build/core/services/multicall-abi.js +61 -0
  60. package/build/core/services/multicall-abi.js.map +1 -0
  61. package/build/core/services/nodes.d.ts +8 -0
  62. package/build/core/services/nodes.js +18 -0
  63. package/build/core/services/nodes.js.map +1 -0
  64. package/build/core/services/proposals.d.ts +33 -0
  65. package/build/core/services/proposals.js +95 -0
  66. package/build/core/services/proposals.js.map +1 -0
  67. package/build/core/services/query.d.ts +34 -0
  68. package/build/core/services/query.js +60 -0
  69. package/build/core/services/query.js.map +1 -0
  70. package/build/core/services/staking.d.ts +40 -0
  71. package/build/core/services/staking.js +113 -0
  72. package/build/core/services/staking.js.map +1 -0
  73. package/build/core/services/tokens.d.ts +22 -0
  74. package/build/core/services/tokens.js +68 -0
  75. package/build/core/services/tokens.js.map +1 -0
  76. package/build/core/services/transactions.d.ts +16 -0
  77. package/build/core/services/transactions.js +42 -0
  78. package/build/core/services/transactions.js.map +1 -0
  79. package/build/core/services/transfer.d.ts +24 -0
  80. package/build/core/services/transfer.js +84 -0
  81. package/build/core/services/transfer.js.map +1 -0
  82. package/build/core/services/trongrid-client.d.ts +14 -0
  83. package/build/core/services/trongrid-client.js +19 -0
  84. package/build/core/services/trongrid-client.js.map +1 -0
  85. package/build/core/services/utils.d.ts +13 -0
  86. package/build/core/services/utils.js +39 -0
  87. package/build/core/services/utils.js.map +1 -0
  88. package/build/core/services/wallet.d.ts +13 -0
  89. package/build/core/services/wallet.js +18 -0
  90. package/build/core/services/wallet.js.map +1 -0
  91. package/build/core/tools/account-data.d.ts +2 -0
  92. package/build/core/tools/account-data.js +253 -0
  93. package/build/core/tools/account-data.js.map +1 -0
  94. package/build/core/tools/account-resource.d.ts +2 -0
  95. package/build/core/tools/account-resource.js +269 -0
  96. package/build/core/tools/account-resource.js.map +1 -0
  97. package/build/core/tools/account.d.ts +2 -0
  98. package/build/core/tools/account.js +451 -0
  99. package/build/core/tools/account.js.map +1 -0
  100. package/build/core/tools/address.d.ts +2 -0
  101. package/build/core/tools/address.js +45 -0
  102. package/build/core/tools/address.js.map +1 -0
  103. package/build/core/tools/balance.d.ts +2 -0
  104. package/build/core/tools/balance.js +94 -0
  105. package/build/core/tools/balance.js.map +1 -0
  106. package/build/core/tools/block.d.ts +2 -0
  107. package/build/core/tools/block.js +74 -0
  108. package/build/core/tools/block.js.map +1 -0
  109. package/build/core/tools/broadcast.d.ts +2 -0
  110. package/build/core/tools/broadcast.js +102 -0
  111. package/build/core/tools/broadcast.js.map +1 -0
  112. package/build/core/tools/contract-data.d.ts +2 -0
  113. package/build/core/tools/contract-data.js +159 -0
  114. package/build/core/tools/contract-data.js.map +1 -0
  115. package/build/core/tools/contract.d.ts +2 -0
  116. package/build/core/tools/contract.js +600 -0
  117. package/build/core/tools/contract.js.map +1 -0
  118. package/build/core/tools/event.d.ts +2 -0
  119. package/build/core/tools/event.js +159 -0
  120. package/build/core/tools/event.js.map +1 -0
  121. package/build/core/tools/governance.d.ts +6 -0
  122. package/build/core/tools/governance.js +424 -0
  123. package/build/core/tools/governance.js.map +1 -0
  124. package/build/core/tools/index.d.ts +15 -0
  125. package/build/core/tools/index.js +93 -0
  126. package/build/core/tools/index.js.map +1 -0
  127. package/build/core/tools/mempool.d.ts +2 -0
  128. package/build/core/tools/mempool.js +116 -0
  129. package/build/core/tools/mempool.js.map +1 -0
  130. package/build/core/tools/network.d.ts +2 -0
  131. package/build/core/tools/network.js +114 -0
  132. package/build/core/tools/network.js.map +1 -0
  133. package/build/core/tools/node.d.ts +2 -0
  134. package/build/core/tools/node.js +75 -0
  135. package/build/core/tools/node.js.map +1 -0
  136. package/build/core/tools/proposals.d.ts +6 -0
  137. package/build/core/tools/proposals.js +219 -0
  138. package/build/core/tools/proposals.js.map +1 -0
  139. package/build/core/tools/query.d.ts +2 -0
  140. package/build/core/tools/query.js +399 -0
  141. package/build/core/tools/query.js.map +1 -0
  142. package/build/core/tools/staking.d.ts +2 -0
  143. package/build/core/tools/staking.js +281 -0
  144. package/build/core/tools/staking.js.map +1 -0
  145. package/build/core/tools/transaction.d.ts +2 -0
  146. package/build/core/tools/transaction.js +65 -0
  147. package/build/core/tools/transaction.js.map +1 -0
  148. package/build/core/tools/transfer.d.ts +2 -0
  149. package/build/core/tools/transfer.js +101 -0
  150. package/build/core/tools/transfer.js.map +1 -0
  151. package/build/core/tools/types.d.ts +13 -0
  152. package/build/core/tools/types.js +2 -0
  153. package/build/core/tools/types.js.map +1 -0
  154. package/build/core/tools/wallet.d.ts +2 -0
  155. package/build/core/tools/wallet.js +172 -0
  156. package/build/core/tools/wallet.js.map +1 -0
  157. package/build/index.d.ts +1 -0
  158. package/build/index.js +21 -0
  159. package/build/index.js.map +1 -0
  160. package/build/middleware/auth.d.ts +16 -0
  161. package/build/middleware/auth.js +44 -0
  162. package/build/middleware/auth.js.map +1 -0
  163. package/build/oauth/OAuthService.d.ts +100 -0
  164. package/build/oauth/OAuthService.js +507 -0
  165. package/build/oauth/OAuthService.js.map +1 -0
  166. package/build/oauth/page.d.ts +1 -0
  167. package/build/oauth/page.js +255 -0
  168. package/build/oauth/page.js.map +1 -0
  169. package/build/oauth/types.d.ts +65 -0
  170. package/build/oauth/types.js +2 -0
  171. package/build/oauth/types.js.map +1 -0
  172. package/build/server/http-app.d.ts +9 -0
  173. package/build/server/http-app.js +128 -0
  174. package/build/server/http-app.js.map +1 -0
  175. package/build/server/http-server.d.ts +1 -0
  176. package/build/server/http-server.js +35 -0
  177. package/build/server/http-server.js.map +1 -0
  178. package/build/server/oauth-routes.d.ts +7 -0
  179. package/build/server/oauth-routes.js +157 -0
  180. package/build/server/oauth-routes.js.map +1 -0
  181. package/build/server/server.d.ts +9 -0
  182. package/build/server/server.js +54 -0
  183. package/build/server/server.js.map +1 -0
  184. package/build/tenant/TenantManager.d.ts +35 -0
  185. package/build/tenant/TenantManager.js +167 -0
  186. package/build/tenant/TenantManager.js.map +1 -0
  187. package/build/tenant/context.d.ts +11 -0
  188. package/build/tenant/context.js +23 -0
  189. package/build/tenant/context.js.map +1 -0
  190. package/build/tenant/types.d.ts +16 -0
  191. package/build/tenant/types.js +2 -0
  192. package/build/tenant/types.js.map +1 -0
  193. package/package.json +95 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Read from a smart contract (view/pure functions)
3
+ */
4
+ export declare function readContract(params: {
5
+ address: string;
6
+ functionName: string;
7
+ args?: any[];
8
+ abi?: any[];
9
+ }, network?: string): Promise<any>;
10
+ /**
11
+ * Write to a smart contract (state changing functions).
12
+ * Builds unsigned tx via triggerSmartContract, signs with agent-wallet, broadcasts.
13
+ */
14
+ export declare function writeContract(params: {
15
+ address: string;
16
+ functionName: string;
17
+ args?: any[];
18
+ value?: string;
19
+ abi?: any[];
20
+ }, network?: string): Promise<string>;
21
+ /**
22
+ * Fetch contract ABI via TronWeb (available for verified contracts)
23
+ */
24
+ export declare function fetchContractABI(contractAddress: string, network?: string): Promise<any>;
25
+ /**
26
+ * Get full contract metadata from the chain (including bytecode and ABI if available)
27
+ */
28
+ export declare function getContract(contractAddress: string, network?: string): Promise<any>;
29
+ /**
30
+ * Get high-level contract info: ABI, function list and raw metadata.
31
+ */
32
+ export declare function getContractInfo(contractAddress: string, network?: string): Promise<{
33
+ address: string;
34
+ network: string;
35
+ abi: any;
36
+ functions: string[];
37
+ contract: unknown;
38
+ }>;
39
+ /**
40
+ * Update contract setting: consume_user_resource_percent (user pay ratio)
41
+ */
42
+ export declare function updateSetting(contractAddress: string, consumeUserResourcePercent: number, network?: string): Promise<string>;
43
+ /**
44
+ * Update contract originEnergyLimit (max energy the contract creator will pay per execution)
45
+ */
46
+ export declare function updateEnergyLimit(contractAddress: string, originEnergyLimit: number, network?: string): Promise<string>;
47
+ /**
48
+ * Clear the ABI of a contract on-chain.
49
+ * This removes the ABI metadata associated with the contract (ClearABIContract).
50
+ */
51
+ export declare function clearABI(contractAddress: string, network?: string): Promise<string>;
52
+ /**
53
+ * Parse ABI (helper to ensure correct format for TronWeb if needed)
54
+ */
55
+ export declare function parseABI(abiJson: string | any[]): any[];
56
+ /**
57
+ * Get readable function signatures from ABI
58
+ */
59
+ export declare function getReadableFunctions(abi: any[]): string[];
60
+ /**
61
+ * Helper to get a specific function definition from ABI
62
+ */
63
+ export declare function getFunctionFromABI(abi: any[], functionName: string): any;
64
+ /**
65
+ * Multicall (Simulated or Native Multicall2/3)
66
+ */
67
+ export declare function multicall(params: {
68
+ calls: Array<{
69
+ address: string;
70
+ functionName: string;
71
+ args?: any[];
72
+ abi: any[];
73
+ allowFailure?: boolean;
74
+ }>;
75
+ multicallAddress?: string;
76
+ version?: 2 | 3;
77
+ allowFailure?: boolean;
78
+ }, network?: string): Promise<any>;
79
+ /**
80
+ * Deploy a smart contract to the TRON network
81
+ */
82
+ export declare function deployContract(params: {
83
+ abi: any[];
84
+ bytecode: string;
85
+ args?: any[];
86
+ name?: string;
87
+ feeLimit?: number;
88
+ originEnergyLimit?: number;
89
+ userPercentage?: number;
90
+ }, network?: string): Promise<{
91
+ txID: any;
92
+ contractAddress: string;
93
+ message: string;
94
+ }>;
95
+ /**
96
+ * Estimate energy consumption for a contract call
97
+ */
98
+ export declare function estimateEnergy(params: {
99
+ address: string;
100
+ functionName: string;
101
+ args?: any[];
102
+ abi: any[];
103
+ ownerAddress?: string;
104
+ }, network?: string): Promise<{
105
+ energyUsed: number;
106
+ energyPenalty: number;
107
+ totalEnergy: number;
108
+ }>;
@@ -0,0 +1,482 @@
1
+ import { getTronWeb } from "./clients.js";
2
+ import { getOwnerAddress, buildSignBroadcast, signTransaction } from "./agent-wallet.js";
3
+ import { MULTICALL2_ABI, MULTICALL3_ABI } from "./multicall-abi.js";
4
+ import { waitForTransaction } from "./transactions.js";
5
+ /**
6
+ * Read from a smart contract (view/pure functions)
7
+ */
8
+ export async function readContract(params, network = "mainnet") {
9
+ const tronWeb = getTronWeb(network);
10
+ try {
11
+ let contract;
12
+ if (params.abi) {
13
+ contract = tronWeb.contract(params.abi, params.address);
14
+ }
15
+ else {
16
+ contract = await tronWeb.contract().at(params.address);
17
+ }
18
+ const method = contract.methods[params.functionName];
19
+ if (!method) {
20
+ throw new Error(`Function ${params.functionName} not found in contract`);
21
+ }
22
+ const args = params.args || [];
23
+ const result = await method(...args).call();
24
+ return result;
25
+ }
26
+ catch (error) {
27
+ throw new Error(`Read contract failed: ${error.message}`);
28
+ }
29
+ }
30
+ /**
31
+ * Write to a smart contract (state changing functions).
32
+ * Builds unsigned tx via triggerSmartContract, signs with agent-wallet, broadcasts.
33
+ */
34
+ export async function writeContract(params, network = "mainnet") {
35
+ const tronWeb = getTronWeb(network);
36
+ const ownerAddress = await getOwnerAddress();
37
+ try {
38
+ // Get ABI: from params or fetch from chain
39
+ let abi;
40
+ if (params.abi) {
41
+ abi = params.abi;
42
+ }
43
+ else {
44
+ const contractData = await tronWeb.trx.getContract(params.address);
45
+ if (!contractData?.abi?.entrys) {
46
+ throw new Error("Could not fetch ABI for contract. Please provide it explicitly.");
47
+ }
48
+ abi = contractData.abi.entrys;
49
+ }
50
+ // Find function in ABI
51
+ const func = abi.find((item) => item.type === "function" && item.name === params.functionName);
52
+ if (!func) {
53
+ throw new Error(`Function ${params.functionName} not found in contract ABI`);
54
+ }
55
+ // Build function signature with tuple support via expandType
56
+ const inputTypes = (func.inputs || []).map((i) => expandType(i));
57
+ const functionSelector = `${params.functionName}(${inputTypes.join(",")})`;
58
+ // Map args to typed parameters
59
+ const args = params.args || [];
60
+ const typedParams = args.map((val, index) => ({
61
+ type: inputTypes[index],
62
+ value: val,
63
+ }));
64
+ const options = {};
65
+ if (params.value) {
66
+ options.callValue = params.value;
67
+ }
68
+ const { transaction, result: triggerResult } = await tronWeb.transactionBuilder.triggerSmartContract(params.address, functionSelector, options, typedParams, ownerAddress);
69
+ if (!triggerResult || !triggerResult.result) {
70
+ throw new Error(`Failed to build contract write transaction: ${JSON.stringify(triggerResult)}`);
71
+ }
72
+ return await buildSignBroadcast(transaction, network);
73
+ }
74
+ catch (error) {
75
+ throw new Error(`Write contract failed: ${error.message}`);
76
+ }
77
+ }
78
+ /**
79
+ * Fetch contract ABI via TronWeb (available for verified contracts)
80
+ */
81
+ export async function fetchContractABI(contractAddress, network = "mainnet") {
82
+ const tronWeb = getTronWeb(network);
83
+ try {
84
+ const contract = await tronWeb.trx.getContract(contractAddress);
85
+ if (contract && contract.abi) {
86
+ return contract.abi.entrys;
87
+ }
88
+ throw new Error("ABI not found in contract data");
89
+ }
90
+ catch (error) {
91
+ throw new Error(`Failed to fetch ABI: ${error.message}`);
92
+ }
93
+ }
94
+ /**
95
+ * Get full contract metadata from the chain (including bytecode and ABI if available)
96
+ */
97
+ export async function getContract(contractAddress, network = "mainnet") {
98
+ const tronWeb = getTronWeb(network);
99
+ try {
100
+ const contract = await tronWeb.trx.getContract(contractAddress);
101
+ return contract;
102
+ }
103
+ catch (error) {
104
+ throw new Error(`Failed to get contract: ${error.message}`);
105
+ }
106
+ }
107
+ /**
108
+ * Get high-level contract info: ABI, function list and raw metadata.
109
+ */
110
+ export async function getContractInfo(contractAddress, network = "mainnet") {
111
+ try {
112
+ const tronWeb = getTronWeb(network);
113
+ const hexAddress = tronWeb.address.toHex(contractAddress);
114
+ // Use full node HTTP API: /wallet/getcontractinfo
115
+ const contract = await tronWeb.fullNode.request("wallet/getcontractinfo", {
116
+ value: hexAddress,
117
+ visible: false,
118
+ }, "post");
119
+ const abi = contract?.abi?.entrys || [];
120
+ const functions = Array.isArray(abi) ? getReadableFunctions(abi) : [];
121
+ return {
122
+ address: contractAddress,
123
+ network,
124
+ abi,
125
+ functions,
126
+ contract,
127
+ };
128
+ }
129
+ catch (error) {
130
+ throw new Error(`Failed to get contract info: ${error.message}`);
131
+ }
132
+ }
133
+ /**
134
+ * Update contract setting: consume_user_resource_percent (user pay ratio)
135
+ */
136
+ export async function updateSetting(contractAddress, consumeUserResourcePercent, network = "mainnet") {
137
+ const tronWeb = getTronWeb(network);
138
+ const ownerAddress = await getOwnerAddress();
139
+ try {
140
+ const tx = await tronWeb.transactionBuilder.updateSetting(contractAddress, consumeUserResourcePercent, ownerAddress);
141
+ return await buildSignBroadcast(tx, network);
142
+ }
143
+ catch (error) {
144
+ throw new Error(`Failed to update setting: ${error.message}`);
145
+ }
146
+ }
147
+ /**
148
+ * Update contract originEnergyLimit (max energy the contract creator will pay per execution)
149
+ */
150
+ export async function updateEnergyLimit(contractAddress, originEnergyLimit, network = "mainnet") {
151
+ const tronWeb = getTronWeb(network);
152
+ const ownerAddress = await getOwnerAddress();
153
+ try {
154
+ const tx = await tronWeb.transactionBuilder.updateEnergyLimit(contractAddress, originEnergyLimit, ownerAddress);
155
+ return await buildSignBroadcast(tx, network);
156
+ }
157
+ catch (error) {
158
+ throw new Error(`Failed to update energy limit: ${error.message}`);
159
+ }
160
+ }
161
+ /**
162
+ * Clear the ABI of a contract on-chain.
163
+ * This removes the ABI metadata associated with the contract (ClearABIContract).
164
+ */
165
+ export async function clearABI(contractAddress, network = "mainnet") {
166
+ const tronWeb = getTronWeb(network);
167
+ const ownerAddress = await getOwnerAddress();
168
+ try {
169
+ const tx = await tronWeb.transactionBuilder.clearABI(contractAddress, ownerAddress);
170
+ return await buildSignBroadcast(tx, network);
171
+ }
172
+ catch (error) {
173
+ throw new Error(`Failed to clear ABI: ${error.message}`);
174
+ }
175
+ }
176
+ /**
177
+ * Parse ABI (helper to ensure correct format for TronWeb if needed)
178
+ */
179
+ export function parseABI(abiJson) {
180
+ let abi;
181
+ if (typeof abiJson === "string") {
182
+ abi = JSON.parse(abiJson);
183
+ }
184
+ else {
185
+ abi = abiJson;
186
+ }
187
+ // Deep copy and normalize field names/types to lowercase to ensure TronWeb compatibility
188
+ return abi.map((item) => {
189
+ const newItem = { ...item };
190
+ if (newItem.type && typeof newItem.type === "string") {
191
+ newItem.type = newItem.type.toLowerCase();
192
+ }
193
+ if (newItem.stateMutability && typeof newItem.stateMutability === "string") {
194
+ newItem.stateMutability = newItem.stateMutability.toLowerCase();
195
+ }
196
+ return newItem;
197
+ });
198
+ }
199
+ /**
200
+ * Expand an ABI parameter to its canonical type string for function signature generation.
201
+ * Handles tuple types by recursively expanding components.
202
+ * e.g. { type: "tuple", components: [{type:"address"},{type:"uint256"}] } → "(address,uint256)"
203
+ * e.g. { type: "tuple[]", components: [...] } → "(address,uint256)[]"
204
+ */
205
+ function expandType(param) {
206
+ if (!param.type.startsWith("tuple")) {
207
+ return param.type;
208
+ }
209
+ // Extract array suffix: "tuple[]" → "[]", "tuple[3]" → "[3]", "tuple" → ""
210
+ const suffix = param.type.slice("tuple".length);
211
+ const inner = (param.components || []).map(expandType).join(",");
212
+ return `(${inner})${suffix}`;
213
+ }
214
+ /**
215
+ * Get readable function signatures from ABI
216
+ */
217
+ export function getReadableFunctions(abi) {
218
+ return abi
219
+ .filter((item) => item.type === "function")
220
+ .map((item) => {
221
+ const inputs = item.inputs
222
+ ? item.inputs.map((i) => `${i.type} ${i.name}`).join(", ")
223
+ : "";
224
+ const outputs = item.outputs
225
+ ? item.outputs.map((i) => `${i.type} ${i.name || ""}`).join(", ")
226
+ : "";
227
+ return `${item.name}(${inputs}) -> (${outputs})`;
228
+ });
229
+ }
230
+ /**
231
+ * Helper to get a specific function definition from ABI
232
+ */
233
+ export function getFunctionFromABI(abi, functionName) {
234
+ const func = abi.find((item) => item.type === "function" && item.name === functionName);
235
+ if (!func) {
236
+ throw new Error(`Function ${functionName} not found in ABI`);
237
+ }
238
+ return func;
239
+ }
240
+ /**
241
+ * Multicall (Simulated or Native Multicall2/3)
242
+ */
243
+ export async function multicall(params, network = "mainnet") {
244
+ const { calls, version = 3, allowFailure: globalAllowFailure = true } = params;
245
+ const mAddress = params.multicallAddress;
246
+ const fallbackToSimulation = async (error) => {
247
+ if (error)
248
+ console.error(`Multicall failed, falling back to simulation: ${error}`);
249
+ const results = await Promise.allSettled(calls.map((call) => readContract(call, network)));
250
+ return results.map((result, idx) => {
251
+ if (result.status === "fulfilled") {
252
+ return { success: true, result: result.value };
253
+ }
254
+ else {
255
+ return {
256
+ success: false,
257
+ error: `Call to ${calls[idx].functionName} failed: ${result.reason}`,
258
+ };
259
+ }
260
+ });
261
+ };
262
+ if (!mAddress) {
263
+ return fallbackToSimulation();
264
+ }
265
+ const tronWeb = getTronWeb(network);
266
+ try {
267
+ const callDataWithFuncs = calls.map((call) => {
268
+ const func = call.abi.find((i) => i.name === call.functionName && i.type === "function");
269
+ if (!func) {
270
+ throw new Error(`Function ${call.functionName} not found in ABI for ${call.address}`);
271
+ }
272
+ const inputs = func.inputs || [];
273
+ const types = inputs.map((i) => i.type);
274
+ const signature = `${call.functionName}(${types.join(",")})`;
275
+ const fullHash = tronWeb.sha3(signature);
276
+ const selector = fullHash.startsWith("0x")
277
+ ? fullHash.slice(0, 10)
278
+ : "0x" + fullHash.slice(0, 8);
279
+ const values = call.args || [];
280
+ const encodedArgs = tronWeb.utils.abi.encodeParams(types, values).replace(/^0x/, "");
281
+ const callData = selector + encodedArgs;
282
+ const callAllowFailure = call.allowFailure !== undefined ? call.allowFailure : globalAllowFailure;
283
+ return {
284
+ callData: version === 3 ? [call.address, callAllowFailure, callData] : [call.address, callData],
285
+ func,
286
+ };
287
+ });
288
+ const encodedCalls = callDataWithFuncs.map((item) => item.callData);
289
+ const multicallAbi = version === 3 ? MULTICALL3_ABI : MULTICALL2_ABI;
290
+ const method = version === 3 ? "aggregate3" : "tryAggregate";
291
+ const multicallArgs = version === 3 ? [encodedCalls] : [!globalAllowFailure, encodedCalls];
292
+ const contract = tronWeb.contract(multicallAbi, mAddress);
293
+ const results = await contract[method](...multicallArgs).call();
294
+ // TronWeb might wrap the result array in another array
295
+ const finalResults = Array.isArray(results) &&
296
+ results.length === 1 &&
297
+ Array.isArray(results[0]) &&
298
+ (Array.isArray(results[0][0]) || typeof results[0][0] === "object")
299
+ ? results[0]
300
+ : results;
301
+ return finalResults.map((res, index) => {
302
+ const success = res.success !== undefined ? res.success : res[0];
303
+ const returnData = res.returnData !== undefined ? res.returnData : res[1];
304
+ if (!success) {
305
+ return {
306
+ success: false,
307
+ error: `Call to ${calls[index].functionName} failed in multicall`,
308
+ };
309
+ }
310
+ const func = callDataWithFuncs[index].func;
311
+ const outputs = func.outputs || [];
312
+ const outputTypes = outputs.map((o) => o.type);
313
+ const outputNames = outputs.map((o) => o.name || "");
314
+ try {
315
+ const decoded = tronWeb.utils.abi.decodeParams(outputNames, outputTypes, returnData, true);
316
+ let result;
317
+ if (outputTypes.length === 1) {
318
+ if (typeof decoded === "object" && !Array.isArray(decoded)) {
319
+ // TronWeb decodeParams returns an object with both index keys and named keys
320
+ // For example: { "0": 123n, "timestamp": 123n }
321
+ // We want to return the raw value if it's a single output,
322
+ // but we need to be careful if the user expects the object structure.
323
+ // MCP tools usually prefer the raw value for single outputs for simplicity.
324
+ const entries = Object.entries(decoded);
325
+ const namedEntry = entries.find(([k]) => isNaN(Number(k)) && k !== "");
326
+ // If it's a single output AND it has a name, we return the WHOLE object
327
+ // so results[0].result.timestamp works.
328
+ // If it has NO name (just "0"), we return the raw value.
329
+ if (namedEntry) {
330
+ result = decoded;
331
+ }
332
+ else {
333
+ result = entries[0] ? entries[0][1] : decoded;
334
+ }
335
+ }
336
+ else {
337
+ result = Array.isArray(decoded) && decoded.length === 1 ? decoded[0] : decoded;
338
+ }
339
+ }
340
+ else {
341
+ result = decoded;
342
+ }
343
+ return { success: true, result };
344
+ }
345
+ catch (e) {
346
+ return {
347
+ success: false,
348
+ error: `Failed to decode ${calls[index].functionName}: ${e.message}`,
349
+ };
350
+ }
351
+ });
352
+ }
353
+ catch (error) {
354
+ return fallbackToSimulation(error.message);
355
+ }
356
+ }
357
+ /**
358
+ * Deploy a smart contract to the TRON network
359
+ */
360
+ export async function deployContract(params, network = "mainnet") {
361
+ const tronWeb = getTronWeb(network);
362
+ const ownerAddress = await getOwnerAddress();
363
+ try {
364
+ const ownerHex = tronWeb.address.toHex(ownerAddress);
365
+ const deploymentOptions = {
366
+ abi: params.abi,
367
+ bytecode: params.bytecode.startsWith("0x") ? params.bytecode : "0x" + params.bytecode,
368
+ feeLimit: params.feeLimit || 1_000_000_000,
369
+ name: params.name || "Contract",
370
+ parameters: params.args || [],
371
+ originEnergyLimit: params.originEnergyLimit || 10_000_000,
372
+ userPercentage: params.userPercentage || 0,
373
+ };
374
+ // 1. Create unsigned transaction
375
+ const transaction = await tronWeb.transactionBuilder.createSmartContract(deploymentOptions, ownerHex);
376
+ // 2. Sign and broadcast
377
+ const signedTx = await signTransaction(transaction);
378
+ const result = await tronWeb.trx.sendRawTransaction(signedTx);
379
+ if (result && result.result) {
380
+ const txID = result.transaction.txID;
381
+ // Contract address is only available after tx is confirmed; get it from getTransactionInfo
382
+ const info = await waitForTransaction(txID, network);
383
+ // Check if transaction actually succeeded
384
+ if (info.receipt && info.receipt.result && info.receipt.result !== "SUCCESS") {
385
+ const revertReason = info.resMessage
386
+ ? Buffer.from(info.resMessage, "hex").toString()
387
+ : "Unknown revert reason";
388
+ throw new Error(`Contract deployment failed with status ${info.receipt.result}: ${revertReason}`);
389
+ }
390
+ const contractAddressHex = info?.contract_address;
391
+ let contractAddress;
392
+ if (contractAddressHex) {
393
+ const hex = contractAddressHex.replace(/^0x/, "");
394
+ // TRON contract_address from API is often 20 bytes (40 hex chars); base58 needs 41 prefix
395
+ const withPrefix = hex.length === 40 && !hex.startsWith("41") ? "41" + hex : hex;
396
+ const decoded = tronWeb.address.fromHex(withPrefix);
397
+ contractAddress = typeof decoded === "string" ? decoded : undefined;
398
+ }
399
+ if (!contractAddress) {
400
+ throw new Error("Contract deployed but failed to resolve contract address");
401
+ }
402
+ return {
403
+ txID,
404
+ contractAddress,
405
+ message: "Contract deployment successful",
406
+ };
407
+ }
408
+ else {
409
+ throw new Error(`Broadcast failed: ${JSON.stringify(result)}`);
410
+ }
411
+ }
412
+ catch (error) {
413
+ throw new Error(`Deploy contract failed: ${error.message}`);
414
+ }
415
+ }
416
+ /**
417
+ * Estimate energy consumption for a contract call
418
+ */
419
+ export async function estimateEnergy(params, network = "mainnet") {
420
+ const tronWeb = getTronWeb(network);
421
+ try {
422
+ const ownerAddress = params.ownerAddress || tronWeb.defaultAddress.base58;
423
+ if (!ownerAddress) {
424
+ throw new Error("Missing ownerAddress for energy estimation. Please provide an address or configure a wallet.");
425
+ }
426
+ // Use normalized ABI
427
+ const normalizedAbi = parseABI(params.abi);
428
+ // Find function definition in normalized ABI, handling overloaded functions (same name, different params)
429
+ const args = params.args || [];
430
+ const candidates = normalizedAbi.filter((item) => item.type === "function" && item.name === params.functionName);
431
+ if (candidates.length === 0) {
432
+ throw new Error(`Function ${params.functionName} not found in ABI`);
433
+ }
434
+ // Match by args count to resolve overloads
435
+ const matched = candidates.filter((item) => (item.inputs || []).length === args.length);
436
+ if (matched.length === 0) {
437
+ const overloads = candidates
438
+ .map((item) => `${params.functionName}(${(item.inputs || []).map((i) => i.type).join(", ")})`)
439
+ .join(" | ");
440
+ throw new Error(`No overload of ${params.functionName} accepts ${args.length} argument(s). Available: ${overloads}`);
441
+ }
442
+ if (matched.length > 1) {
443
+ // Multiple overloads with same arg count (different types) — cannot auto-resolve
444
+ const overloads = matched
445
+ .map((item) => `${params.functionName}(${(item.inputs || []).map((i) => i.type).join(", ")})`)
446
+ .join(" | ");
447
+ throw new Error(`Ambiguous overload for ${params.functionName} with ${args.length} argument(s). ` +
448
+ `Candidates: ${overloads}. Please specify the exact function signature.`);
449
+ }
450
+ const func = matched[0];
451
+ // Build function signature: name(type1,type2,...)
452
+ // expandType handles tuple/struct params (e.g. tuple → (address,uint256))
453
+ const inputTypes = (func.inputs || []).map((i) => expandType(i));
454
+ const signature = `${params.functionName}(${inputTypes.join(",")})`;
455
+ // Map args to Typed Parameters format: [{type: '...', value: '...'}]
456
+ const typedParams = args.map((val, index) => {
457
+ return {
458
+ type: inputTypes[index],
459
+ value: val,
460
+ };
461
+ });
462
+ // TronWeb's triggerConstantContract with signature and typed parameters
463
+ const result = await tronWeb.transactionBuilder.triggerConstantContract(params.address, signature, {}, typedParams, ownerAddress);
464
+ if (result && result.result && result.result.result) {
465
+ return {
466
+ energyUsed: result.energy_used || 0,
467
+ energyPenalty: result.energy_penalty || 0,
468
+ totalEnergy: (result.energy_used || 0) + (result.energy_penalty || 0),
469
+ };
470
+ }
471
+ else {
472
+ const errorMsg = result && result.result && result.result.message
473
+ ? Buffer.from(result.result.message, "hex").toString()
474
+ : JSON.stringify(result);
475
+ throw new Error(`Estimate energy failed: ${errorMsg}`);
476
+ }
477
+ }
478
+ catch (error) {
479
+ throw new Error(`Estimate energy error: ${error.message}`);
480
+ }
481
+ }
482
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/core/services/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAKC,EACD,OAAO,GAAG,SAAS;IAEnB,MAAM,OAAO,GAAG,UAAU,C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