@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,55 @@
1
+ export declare const MULTICALL2_ABI: {
2
+ inputs: ({
3
+ internalType: string;
4
+ name: string;
5
+ type: string;
6
+ components?: undefined;
7
+ } | {
8
+ components: {
9
+ internalType: string;
10
+ name: string;
11
+ type: string;
12
+ }[];
13
+ internalType: string;
14
+ name: string;
15
+ type: string;
16
+ })[];
17
+ name: string;
18
+ outputs: {
19
+ components: {
20
+ internalType: string;
21
+ name: string;
22
+ type: string;
23
+ }[];
24
+ internalType: string;
25
+ name: string;
26
+ type: string;
27
+ }[];
28
+ stateMutability: string;
29
+ type: string;
30
+ }[];
31
+ export declare const MULTICALL3_ABI: {
32
+ inputs: {
33
+ components: {
34
+ internalType: string;
35
+ name: string;
36
+ type: string;
37
+ }[];
38
+ internalType: string;
39
+ name: string;
40
+ type: string;
41
+ }[];
42
+ name: string;
43
+ outputs: {
44
+ components: {
45
+ internalType: string;
46
+ name: string;
47
+ type: string;
48
+ }[];
49
+ internalType: string;
50
+ name: string;
51
+ type: string;
52
+ }[];
53
+ stateMutability: string;
54
+ type: string;
55
+ }[];
@@ -0,0 +1,61 @@
1
+ export const MULTICALL2_ABI = [
2
+ {
3
+ inputs: [
4
+ { internalType: "bool", name: "requireSuccess", type: "bool" },
5
+ {
6
+ components: [
7
+ { internalType: "address", name: "target", type: "address" },
8
+ { internalType: "bytes", name: "callData", type: "bytes" },
9
+ ],
10
+ internalType: "struct Multicall2.Call[]",
11
+ name: "calls",
12
+ type: "tuple[]",
13
+ },
14
+ ],
15
+ name: "tryAggregate",
16
+ outputs: [
17
+ {
18
+ components: [
19
+ { internalType: "bool", name: "success", type: "bool" },
20
+ { internalType: "bytes", name: "returnData", type: "bytes" },
21
+ ],
22
+ internalType: "struct Multicall2.Result[]",
23
+ name: "returnData",
24
+ type: "tuple[]",
25
+ },
26
+ ],
27
+ stateMutability: "view",
28
+ type: "function",
29
+ },
30
+ ];
31
+ export const MULTICALL3_ABI = [
32
+ {
33
+ inputs: [
34
+ {
35
+ components: [
36
+ { internalType: "address", name: "target", type: "address" },
37
+ { internalType: "bool", name: "allowFailure", type: "bool" },
38
+ { internalType: "bytes", name: "callData", type: "bytes" },
39
+ ],
40
+ internalType: "struct Multicall3.Call3[]",
41
+ name: "calls",
42
+ type: "tuple[]",
43
+ },
44
+ ],
45
+ name: "aggregate3",
46
+ outputs: [
47
+ {
48
+ components: [
49
+ { internalType: "bool", name: "success", type: "bool" },
50
+ { internalType: "bytes", name: "returnData", type: "bytes" },
51
+ ],
52
+ internalType: "struct Multicall3.Result[]",
53
+ name: "returnData",
54
+ type: "tuple[]",
55
+ },
56
+ ],
57
+ stateMutability: "view",
58
+ type: "function",
59
+ },
60
+ ];
61
+ //# sourceMappingURL=multicall-abi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multicall-abi.js","sourceRoot":"","sources":["../../../src/core/services/multicall-abi.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B;QACE,MAAM,EAAE;YACN,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,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AE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE;oBACvD,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE;iBAC7D;gBACD,YAAY,EAAE,4BAA4B;gBAC1C,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * List all connected node addresses on the network
3
+ */
4
+ export declare function listNodes(network?: string): Promise<string[]>;
5
+ /**
6
+ * Get detailed information about the current node
7
+ */
8
+ export declare function getNodeInfo(network?: string): Promise<Record<string, unknown>>;
@@ -0,0 +1,18 @@
1
+ import { getTronWeb } from "./clients.js";
2
+ /**
3
+ * List all connected node addresses on the network
4
+ */
5
+ export async function listNodes(network = "mainnet") {
6
+ const tronWeb = getTronWeb(network);
7
+ const nodes = await tronWeb.trx.listNodes();
8
+ return nodes;
9
+ }
10
+ /**
11
+ * Get detailed information about the current node
12
+ */
13
+ export async function getNodeInfo(network = "mainnet") {
14
+ const tronWeb = getTronWeb(network);
15
+ const info = await tronWeb.trx.getNodeInfo();
16
+ return info;
17
+ }
18
+ //# sourceMappingURL=nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/core/services/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAO,GAAG,SAAS;IACjD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;IAC5C,OAAO,KAAiB,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAO,GAAG,SAAS;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;IAC7C,OAAO,IAA+B,CAAC;AACzC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * List all network proposals
3
+ * @param network Network name (mainnet, nile, shasta)
4
+ */
5
+ export declare function listProposals(network?: string): Promise<unknown>;
6
+ /**
7
+ * Get a specific proposal by its ID
8
+ * @param proposalId The proposal ID (number)
9
+ * @param network Network name
10
+ */
11
+ export declare function getProposalById(proposalId: number, network?: string): Promise<unknown>;
12
+ /**
13
+ * Create a new network proposal (SR only)
14
+ * @param parameters Object mapping chain parameter keys (number) to their proposed values (number)
15
+ * @param network Network name
16
+ * @returns Transaction hash
17
+ */
18
+ export declare function createProposal(parameters: Record<number, number>, network?: string): Promise<string>;
19
+ /**
20
+ * Vote to approve a proposal (SR only)
21
+ * @param proposalId The ID of the proposal to approve
22
+ * @param approve Whether to approve (true) or disapprove (false)
23
+ * @param network Network name
24
+ * @returns Transaction hash
25
+ */
26
+ export declare function approveProposal(proposalId: number, approve: boolean, network?: string): Promise<string>;
27
+ /**
28
+ * Delete a proposal (SR only, proposer only)
29
+ * @param proposalId The ID of the proposal to delete
30
+ * @param network Network name
31
+ * @returns Transaction hash
32
+ */
33
+ export declare function deleteProposal(proposalId: number, network?: string): Promise<string>;
@@ -0,0 +1,95 @@
1
+ import { getTronWeb } from "./clients.js";
2
+ import { getOwnerAddress, buildSignBroadcast } from "./agent-wallet.js";
3
+ // ============================================================================
4
+ // PROPOSAL READ OPERATIONS
5
+ // ============================================================================
6
+ /**
7
+ * List all network proposals
8
+ * @param network Network name (mainnet, nile, shasta)
9
+ */
10
+ export async function listProposals(network = "mainnet") {
11
+ const tronWeb = getTronWeb(network);
12
+ try {
13
+ const proposals = await tronWeb.trx.listProposals();
14
+ return proposals;
15
+ }
16
+ catch (error) {
17
+ throw new Error(`Failed to list proposals: ${error.message}`);
18
+ }
19
+ }
20
+ /**
21
+ * Get a specific proposal by its ID
22
+ * @param proposalId The proposal ID (number)
23
+ * @param network Network name
24
+ */
25
+ export async function getProposalById(proposalId, network = "mainnet") {
26
+ const tronWeb = getTronWeb(network);
27
+ try {
28
+ const proposal = await tronWeb.trx.getProposal(proposalId);
29
+ return proposal;
30
+ }
31
+ catch (error) {
32
+ throw new Error(`Failed to get proposal #${proposalId}: ${error.message}`);
33
+ }
34
+ }
35
+ // ============================================================================
36
+ // PROPOSAL WRITE OPERATIONS (SR only)
37
+ // ============================================================================
38
+ /**
39
+ * Create a new network proposal (SR only)
40
+ * @param parameters Object mapping chain parameter keys (number) to their proposed values (number)
41
+ * @param network Network name
42
+ * @returns Transaction hash
43
+ */
44
+ export async function createProposal(parameters, network = "mainnet") {
45
+ const tronWeb = getTronWeb(network);
46
+ const ownerAddress = await getOwnerAddress();
47
+ try {
48
+ // TronWeb expects [{key, value}] format, not a plain object
49
+ const proposalParams = Object.entries(parameters).map(([k, v]) => ({
50
+ key: Number(k),
51
+ value: v,
52
+ }));
53
+ const transaction = await tronWeb.transactionBuilder.createProposal(proposalParams, ownerAddress);
54
+ return await buildSignBroadcast(transaction, network);
55
+ }
56
+ catch (error) {
57
+ throw new Error(`Failed to create proposal: ${error.message}`);
58
+ }
59
+ }
60
+ /**
61
+ * Vote to approve a proposal (SR only)
62
+ * @param proposalId The ID of the proposal to approve
63
+ * @param approve Whether to approve (true) or disapprove (false)
64
+ * @param network Network name
65
+ * @returns Transaction hash
66
+ */
67
+ export async function approveProposal(proposalId, approve, network = "mainnet") {
68
+ const tronWeb = getTronWeb(network);
69
+ const ownerAddress = await getOwnerAddress();
70
+ try {
71
+ const transaction = await tronWeb.transactionBuilder.voteProposal(proposalId, approve, ownerAddress);
72
+ return await buildSignBroadcast(transaction, network);
73
+ }
74
+ catch (error) {
75
+ throw new Error(`Failed to approve proposal: ${error.message}`);
76
+ }
77
+ }
78
+ /**
79
+ * Delete a proposal (SR only, proposer only)
80
+ * @param proposalId The ID of the proposal to delete
81
+ * @param network Network name
82
+ * @returns Transaction hash
83
+ */
84
+ export async function deleteProposal(proposalId, network = "mainnet") {
85
+ const tronWeb = getTronWeb(network);
86
+ const ownerAddress = await getOwnerAddress();
87
+ try {
88
+ const transaction = await tronWeb.transactionBuilder.deleteProposal(proposalId, ownerAddress);
89
+ return await buildSignBroadcast(transaction, network);
90
+ }
91
+ catch (error) {
92
+ throw new Error(`Failed to delete proposal: ${error.message}`);
93
+ }
94
+ }
95
+ //# sourceMappingURL=proposals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proposals.js","sourceRoot":"","sources":["../../../src/core/services/proposals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAExE,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAO,GAAG,SAAS;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UAAkB,EAAE,OAAO,GAAG,SAAS;IAC3E,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,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E,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAC/D,UAAU,EACV,OAAO,EACP,YAAmB,CACpB,CAAC;QACF,OAAO,MAAM,kBAAkB,CAAC,WAAkB,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAAkB,EAAE,OAAO,GAAG,SAAS;IAC1E,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,MAAM,eAAe,EAAE,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,cAAc,CACjE,UAAU,EACV,YAAmB,CACpB,CAAC;QACF,OAAO,MAAM,kBAAkB,CAAC,WAAkB,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Get the latest N blocks (GetBlockByLatestNum)
3
+ */
4
+ export declare function getBlockByLatestNum(num: number, network?: string): Promise<any>;
5
+ /**
6
+ * Get blocks in a range [startNum, endNum) (GetBlockByLimitNext)
7
+ * Note: TronWeb's getBlockRange(start, end) wraps this endpoint but adjusts endNum internally.
8
+ * We call fullNode.request directly to match the raw FullNode API semantics.
9
+ */
10
+ export declare function getBlockByLimitNext(startNum: number, endNum: number, network?: string): Promise<any>;
11
+ /**
12
+ * Get all balance change operations in a block (GetBlockBalance)
13
+ */
14
+ export declare function getBlockBalance(hash: string, number: number, network?: string): Promise<any>;
15
+ /**
16
+ * Get TransactionInfo for all transactions in a specific block (GetTransactionInfoByBlockNum)
17
+ */
18
+ export declare function getTransactionInfoByBlockNum(num: number, network?: string): Promise<any>;
19
+ /**
20
+ * Get the list of accounts that have signed a transaction (GetApprovedList)
21
+ */
22
+ export declare function getApprovedList(transaction: Record<string, unknown>, network?: string): Promise<any>;
23
+ /**
24
+ * Get historical energy unit price (GetEnergyPrices)
25
+ */
26
+ export declare function getEnergyPrices(network?: string): Promise<any>;
27
+ /**
28
+ * Get historical bandwidth unit price (GetBandwidthPrices)
29
+ */
30
+ export declare function getBandwidthPrices(network?: string): Promise<any>;
31
+ /**
32
+ * Get the amount of TRX burned from on-chain transaction fees (GetBurnTRX)
33
+ */
34
+ export declare function getBurnTrx(network?: string): Promise<any>;
@@ -0,0 +1,60 @@
1
+ import { getTronWeb } from "./clients.js";
2
+ /**
3
+ * Get the latest N blocks (GetBlockByLatestNum)
4
+ */
5
+ export async function getBlockByLatestNum(num, network = "mainnet") {
6
+ const tronWeb = getTronWeb(network);
7
+ return tronWeb.fullNode.request("wallet/getblockbylatestnum", { num }, "post");
8
+ }
9
+ /**
10
+ * Get blocks in a range [startNum, endNum) (GetBlockByLimitNext)
11
+ * Note: TronWeb's getBlockRange(start, end) wraps this endpoint but adjusts endNum internally.
12
+ * We call fullNode.request directly to match the raw FullNode API semantics.
13
+ */
14
+ export async function getBlockByLimitNext(startNum, endNum, network = "mainnet") {
15
+ const tronWeb = getTronWeb(network);
16
+ return tronWeb.fullNode.request("wallet/getblockbylimitnext", { startNum, endNum }, "post");
17
+ }
18
+ /**
19
+ * Get all balance change operations in a block (GetBlockBalance)
20
+ */
21
+ export async function getBlockBalance(hash, number, network = "mainnet") {
22
+ const tronWeb = getTronWeb(network);
23
+ return tronWeb.fullNode.request("wallet/getblockbalance", { hash, number, visible: true }, "post");
24
+ }
25
+ /**
26
+ * Get TransactionInfo for all transactions in a specific block (GetTransactionInfoByBlockNum)
27
+ */
28
+ export async function getTransactionInfoByBlockNum(num, network = "mainnet") {
29
+ const tronWeb = getTronWeb(network);
30
+ return tronWeb.fullNode.request("wallet/gettransactioninfobyblocknum", { num }, "post");
31
+ }
32
+ /**
33
+ * Get the list of accounts that have signed a transaction (GetApprovedList)
34
+ */
35
+ export async function getApprovedList(transaction, network = "mainnet") {
36
+ const tronWeb = getTronWeb(network);
37
+ return tronWeb.trx.getApprovedList(transaction);
38
+ }
39
+ /**
40
+ * Get historical energy unit price (GetEnergyPrices)
41
+ */
42
+ export async function getEnergyPrices(network = "mainnet") {
43
+ const tronWeb = getTronWeb(network);
44
+ return tronWeb.trx.getEnergyPrices();
45
+ }
46
+ /**
47
+ * Get historical bandwidth unit price (GetBandwidthPrices)
48
+ */
49
+ export async function getBandwidthPrices(network = "mainnet") {
50
+ const tronWeb = getTronWeb(network);
51
+ return tronWeb.trx.getBandwidthPrices();
52
+ }
53
+ /**
54
+ * Get the amount of TRX burned from on-chain transaction fees (GetBurnTRX)
55
+ */
56
+ export async function getBurnTrx(network = "mainnet") {
57
+ const tronWeb = getTronWeb(network);
58
+ return tronWeb.fullNode.request("wallet/getburntrx", {}, "post");
59
+ }
60
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/core/services/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAW,EAAE,OAAO,GAAG,SAAS;IACxE,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAgB,EAChB,MA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AkB,CAAC,OAAO,GAAG,SAAS;IAC1D,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAO,GAAG,SAAS;IAClD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Freeze TRX to get resources (Stake 2.0)
3
+ * @param amount Amount to freeze in Sun (decimal string to preserve precision for large values)
4
+ * @param resource Resource type: "BANDWIDTH" or "ENERGY"
5
+ * @param network Network name (mainnet, nile, shasta)
6
+ * @returns Transaction hash
7
+ */
8
+ export declare function freezeBalanceV2(amount: string, resource?: "BANDWIDTH" | "ENERGY", network?: string): Promise<string>;
9
+ /**
10
+ * Unfreeze TRX to release resources (Stake 2.0)
11
+ * @param amount Amount to unfreeze in Sun (decimal string to preserve precision for large values)
12
+ * @param resource Resource type: "BANDWIDTH" or "ENERGY"
13
+ * @param network Network name (mainnet, nile, shasta)
14
+ * @returns Transaction hash
15
+ */
16
+ export declare function unfreezeBalanceV2(amount: string, resource?: "BANDWIDTH" | "ENERGY", network?: string): Promise<string>;
17
+ /**
18
+ * Withdraw expired unfrozen balance (Stake 2.0)
19
+ * After the unfreezing period is over, this must be called to return TRX to available balance.
20
+ * @param network Network name (mainnet, nile, shasta)
21
+ * @returns Transaction hash
22
+ */
23
+ export declare function withdrawExpireUnfreeze(network?: string): Promise<string>;
24
+ /**
25
+ * Get remaining available unstake (unfreeze) operations for an address (Stake 2.0)
26
+ */
27
+ export declare function getAvailableUnfreezeCount(address: string, network?: string): Promise<any>;
28
+ /**
29
+ * Get withdrawable unstaked amount for an address at a given timestamp (Stake 2.0)
30
+ */
31
+ export declare function getCanWithdrawUnfreezeAmount(address: string, network?: string, timestampMs?: number): Promise<{
32
+ amountSun: bigint;
33
+ timestampMs: number;
34
+ }>;
35
+ /**
36
+ * Cancel all unfreeze operations (Stake 2.0)
37
+ * @param network Network name (mainnet, nile, shasta)
38
+ * @returns Transaction hash
39
+ */
40
+ export declare function cancelAllUnfreezeV2(network?: string): Promise<string>;
@@ -0,0 +1,113 @@
1
+ import { getTronWeb } from "./clients.js";
2
+ import { getOwnerAddress, buildSignBroadcast } from "./agent-wallet.js";
3
+ /**
4
+ * Freeze TRX to get resources (Stake 2.0)
5
+ * @param amount Amount to freeze in Sun (decimal string to preserve precision for large values)
6
+ * @param resource Resource type: "BANDWIDTH" or "ENERGY"
7
+ * @param network Network name (mainnet, nile, shasta)
8
+ * @returns Transaction hash
9
+ */
10
+ export async function freezeBalanceV2(amount, resource = "BANDWIDTH", network = "mainnet") {
11
+ const tronWeb = getTronWeb(network);
12
+ const ownerAddress = await getOwnerAddress();
13
+ try {
14
+ const transaction = await tronWeb.transactionBuilder.freezeBalanceV2(amount, resource, ownerAddress);
15
+ return await buildSignBroadcast(transaction, network);
16
+ }
17
+ catch (error) {
18
+ throw new Error(`Failed to freeze balance V2: ${error.message}`);
19
+ }
20
+ }
21
+ /**
22
+ * Unfreeze TRX to release resources (Stake 2.0)
23
+ * @param amount Amount to unfreeze in Sun (decimal string to preserve precision for large values)
24
+ * @param resource Resource type: "BANDWIDTH" or "ENERGY"
25
+ * @param network Network name (mainnet, nile, shasta)
26
+ * @returns Transaction hash
27
+ */
28
+ export async function unfreezeBalanceV2(amount, resource = "BANDWIDTH", network = "mainnet") {
29
+ const tronWeb = getTronWeb(network);
30
+ const ownerAddress = await getOwnerAddress();
31
+ try {
32
+ const transaction = await tronWeb.transactionBuilder.unfreezeBalanceV2(amount, resource, ownerAddress);
33
+ return await buildSignBroadcast(transaction, network);
34
+ }
35
+ catch (error) {
36
+ throw new Error(`Failed to unfreeze balance V2: ${error.message}`);
37
+ }
38
+ }
39
+ /**
40
+ * Withdraw expired unfrozen balance (Stake 2.0)
41
+ * After the unfreezing period is over, this must be called to return TRX to available balance.
42
+ * @param network Network name (mainnet, nile, shasta)
43
+ * @returns Transaction hash
44
+ */
45
+ export async function withdrawExpireUnfreeze(network = "mainnet") {
46
+ const tronWeb = getTronWeb(network);
47
+ const ownerAddress = await getOwnerAddress();
48
+ try {
49
+ const transaction = await tronWeb.transactionBuilder.withdrawExpireUnfreeze(ownerAddress);
50
+ return await buildSignBroadcast(transaction, network);
51
+ }
52
+ catch (error) {
53
+ throw new Error(`Failed to withdraw expire unfreeze: ${error.message}`);
54
+ }
55
+ }
56
+ /**
57
+ * Get remaining available unstake (unfreeze) operations for an address (Stake 2.0)
58
+ */
59
+ export async function getAvailableUnfreezeCount(address, network = "mainnet") {
60
+ const tronWeb = getTronWeb(network);
61
+ try {
62
+ const ownerAddress = tronWeb.address.toHex(address);
63
+ const res = await tronWeb.fullNode.request("wallet/getavailableunfreezecount", { owner_address: ownerAddress }, "post");
64
+ if (typeof res?.count !== "number") {
65
+ throw new Error(`Unexpected response from getavailableunfreezecount: ${JSON.stringify(res)}`);
66
+ }
67
+ return res.count;
68
+ }
69
+ catch (error) {
70
+ throw new Error(`Failed to get available unfreeze count: ${error.message}`);
71
+ }
72
+ }
73
+ /**
74
+ * Get withdrawable unstaked amount for an address at a given timestamp (Stake 2.0)
75
+ */
76
+ export async function getCanWithdrawUnfreezeAmount(address, network = "mainnet", timestampMs) {
77
+ const tronWeb = getTronWeb(network);
78
+ try {
79
+ const ownerAddress = tronWeb.address.toHex(address);
80
+ const ts = timestampMs ?? Date.now();
81
+ const res = await tronWeb.fullNode.request("wallet/getcanwithdrawunfreezeamount", {
82
+ owner_address: ownerAddress,
83
+ timestamp: ts,
84
+ }, "post");
85
+ const rawAmount = res?.amount;
86
+ if (rawAmount === undefined ||
87
+ (typeof rawAmount !== "number" && typeof rawAmount !== "string")) {
88
+ throw new Error(`Unexpected response from getcanwithdrawunfreezeamount: ${JSON.stringify(res)}`);
89
+ }
90
+ const amountSun = BigInt(rawAmount);
91
+ return { amountSun, timestampMs: ts };
92
+ }
93
+ catch (error) {
94
+ throw new Error(`Failed to get can withdraw unfreeze amount: ${error.message}`);
95
+ }
96
+ }
97
+ /**
98
+ * Cancel all unfreeze operations (Stake 2.0)
99
+ * @param network Network name (mainnet, nile, shasta)
100
+ * @returns Transaction hash
101
+ */
102
+ export async function cancelAllUnfreezeV2(network = "mainnet") {
103
+ const tronWeb = getTronWeb(network);
104
+ const ownerAddress = await getOwnerAddress();
105
+ try {
106
+ const transaction = await tronWeb.transactionBuilder.cancelAllUnfreezeV2(ownerAddress);
107
+ return await buildSignBroadcast(transaction, network);
108
+ }
109
+ catch (error) {
110
+ throw new Error(`Failed to cancel all unfreeze V2: ${error.message}`);
111
+ }
112
+ }
113
+ //# sourceMappingURL=staking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staking.js","sourceRoot":"","sources":["../../../src/core/services/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,WAAmC,WAAW,EAC9C,OAAO,GAAG,SAAS;IAEnB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,MAAM,eAAe,EAAE,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAClE,MAAa,EACb,QAAQ,EACR,YAAY,CACb,CAAC;QACF,OAAO,MAAM,kBAAkB,CAAC,WAAkB,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,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C,EAChE,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0DAA0D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAChF,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QACpC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACxC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,+CAA+C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAClF,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAO,GAAG,SAAS;IAC3D,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,MAAM,eAAe,EAAE,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAO,OAAO,CAAC,kBAA0B,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QAChG,OAAO,MAAM,kBAAkB,CAAC,WAAkB,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Get TRC20 token information
3
+ */
4
+ export declare function getTRC20TokenInfo(tokenAddress: string, network?: string): Promise<{
5
+ name: string;
6
+ symbol: string;
7
+ decimals: number;
8
+ totalSupply: bigint;
9
+ formattedTotalSupply: string;
10
+ }>;
11
+ /**
12
+ * Get TRC721 token metadata
13
+ */
14
+ export declare function getTRC721TokenMetadata(tokenAddress: string, tokenId: bigint, network?: string): Promise<{
15
+ name: string;
16
+ symbol: string;
17
+ tokenURI: string;
18
+ }>;
19
+ /**
20
+ * Get TRC1155 token URI
21
+ */
22
+ export declare function getTRC1155TokenURI(tokenAddress: string, tokenId: bigint, network?: string): Promise<string>;
@@ -0,0 +1,68 @@
1
+ import { getTronWeb } from "./clients.js";
2
+ /**
3
+ * Get TRC20 token information
4
+ */
5
+ export async function getTRC20TokenInfo(tokenAddress, network = "mainnet") {
6
+ const tronWeb = getTronWeb(network);
7
+ try {
8
+ const contract = await tronWeb.contract().at(tokenAddress);
9
+ const [name, symbol, decimals, totalSupply] = await Promise.all([
10
+ contract.methods.name().call(),
11
+ contract.methods.symbol().call(),
12
+ contract.methods.decimals().call(),
13
+ contract.methods.totalSupply().call(),
14
+ ]);
15
+ const decimalsNum = Number(decimals);
16
+ const totalSupplyBigInt = BigInt(totalSupply.toString());
17
+ const divisor = BigInt(10) ** BigInt(decimalsNum);
18
+ // Formatting total supply
19
+ const formattedTotalSupply = (Number(totalSupplyBigInt) / Number(divisor)).toString();
20
+ return {
21
+ name,
22
+ symbol,
23
+ decimals: decimalsNum,
24
+ totalSupply: totalSupplyBigInt,
25
+ formattedTotalSupply,
26
+ };
27
+ }
28
+ catch (error) {
29
+ throw new Error(`Failed to get TRC20 token info: ${error.message}`);
30
+ }
31
+ }
32
+ /**
33
+ * Get TRC721 token metadata
34
+ */
35
+ export async function getTRC721TokenMetadata(tokenAddress, tokenId, network = "mainnet") {
36
+ const tronWeb = getTronWeb(network);
37
+ try {
38
+ const contract = await tronWeb.contract().at(tokenAddress);
39
+ const [name, symbol, tokenURI] = await Promise.all([
40
+ contract.methods.name().call(),
41
+ contract.methods.symbol().call(),
42
+ contract.methods.tokenURI(tokenId.toString()).call(),
43
+ ]);
44
+ return {
45
+ name,
46
+ symbol,
47
+ tokenURI,
48
+ };
49
+ }
50
+ catch (error) {
51
+ throw new Error(`Failed to get TRC721 metadata: ${error.message}`);
52
+ }
53
+ }
54
+ /**
55
+ * Get TRC1155 token URI
56
+ */
57
+ export async function getTRC1155TokenURI(tokenAddress, tokenId, network = "mainnet") {
58
+ const tronWeb = getTronWeb(network);
59
+ try {
60
+ const contract = await tronWeb.contract().at(tokenAddress);
61
+ const uri = await contract.methods.uri(tokenId.toString()).call();
62
+ return uri;
63
+ }
64
+ catch (error) {
65
+ throw new Error(`Failed to get TRC1155 URI: ${error.message}`);
66
+ }
67
+ }
68
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/core/services/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,YAAoB,EACpB,UAAkB,SAAS;IAQ3B,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAEpC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;QAE3D,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC9D,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE;YAC9B,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;YAChC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;YAClC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;SACtC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QACrC,MAAM,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;QAElD,0BAA0B;QAC1B,MAAM,oBAAoB,GAAG,CAAC,MAAM,CAAC,iBAA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