@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.
- package/LICENSE +21 -0
- package/README.md +537 -0
- package/bin/cli.js +51 -0
- package/build/core/chains.d.ts +17 -0
- package/build/core/chains.js +87 -0
- package/build/core/chains.js.map +1 -0
- package/build/core/prompts.d.ts +19 -0
- package/build/core/prompts.js +485 -0
- package/build/core/prompts.js.map +1 -0
- package/build/core/resources.d.ts +14 -0
- package/build/core/resources.js +42 -0
- package/build/core/resources.js.map +1 -0
- package/build/core/services/account-data.d.ts +144 -0
- package/build/core/services/account-data.js +228 -0
- package/build/core/services/account-data.js.map +1 -0
- package/build/core/services/account-resource.d.ts +56 -0
- package/build/core/services/account-resource.js +133 -0
- package/build/core/services/account-resource.js.map +1 -0
- package/build/core/services/account.d.ts +141 -0
- package/build/core/services/account.js +191 -0
- package/build/core/services/account.js.map +1 -0
- package/build/core/services/address.d.ts +8 -0
- package/build/core/services/address.js +52 -0
- package/build/core/services/address.js.map +1 -0
- package/build/core/services/agent-wallet.d.ts +62 -0
- package/build/core/services/agent-wallet.js +234 -0
- package/build/core/services/agent-wallet.js.map +1 -0
- package/build/core/services/balance.d.ts +26 -0
- package/build/core/services/balance.js +60 -0
- package/build/core/services/balance.js.map +1 -0
- package/build/core/services/blocks.d.ts +25 -0
- package/build/core/services/blocks.js +65 -0
- package/build/core/services/blocks.js.map +1 -0
- package/build/core/services/broadcast.d.ts +13 -0
- package/build/core/services/broadcast.js +24 -0
- package/build/core/services/broadcast.js.map +1 -0
- package/build/core/services/clients.d.ts +5 -0
- package/build/core/services/clients.js +29 -0
- package/build/core/services/clients.js.map +1 -0
- package/build/core/services/contract-data.d.ts +31 -0
- package/build/core/services/contract-data.js +54 -0
- package/build/core/services/contract-data.js.map +1 -0
- package/build/core/services/contracts.d.ts +108 -0
- package/build/core/services/contracts.js +482 -0
- package/build/core/services/contracts.js.map +1 -0
- package/build/core/services/events.d.ts +56 -0
- package/build/core/services/events.js +99 -0
- package/build/core/services/events.js.map +1 -0
- package/build/core/services/governance.d.ts +78 -0
- package/build/core/services/governance.js +207 -0
- package/build/core/services/governance.js.map +1 -0
- package/build/core/services/index.d.ts +28 -0
- package/build/core/services/index.js +81 -0
- package/build/core/services/index.js.map +1 -0
- package/build/core/services/mempool.d.ts +12 -0
- package/build/core/services/mempool.js +32 -0
- package/build/core/services/mempool.js.map +1 -0
- package/build/core/services/multicall-abi.d.ts +55 -0
- package/build/core/services/multicall-abi.js +61 -0
- package/build/core/services/multicall-abi.js.map +1 -0
- package/build/core/services/nodes.d.ts +8 -0
- package/build/core/services/nodes.js +18 -0
- package/build/core/services/nodes.js.map +1 -0
- package/build/core/services/proposals.d.ts +33 -0
- package/build/core/services/proposals.js +95 -0
- package/build/core/services/proposals.js.map +1 -0
- package/build/core/services/query.d.ts +34 -0
- package/build/core/services/query.js +60 -0
- package/build/core/services/query.js.map +1 -0
- package/build/core/services/staking.d.ts +40 -0
- package/build/core/services/staking.js +113 -0
- package/build/core/services/staking.js.map +1 -0
- package/build/core/services/tokens.d.ts +22 -0
- package/build/core/services/tokens.js +68 -0
- package/build/core/services/tokens.js.map +1 -0
- package/build/core/services/transactions.d.ts +16 -0
- package/build/core/services/transactions.js +42 -0
- package/build/core/services/transactions.js.map +1 -0
- package/build/core/services/transfer.d.ts +24 -0
- package/build/core/services/transfer.js +84 -0
- package/build/core/services/transfer.js.map +1 -0
- package/build/core/services/trongrid-client.d.ts +14 -0
- package/build/core/services/trongrid-client.js +19 -0
- package/build/core/services/trongrid-client.js.map +1 -0
- package/build/core/services/utils.d.ts +13 -0
- package/build/core/services/utils.js +39 -0
- package/build/core/services/utils.js.map +1 -0
- package/build/core/services/wallet.d.ts +13 -0
- package/build/core/services/wallet.js +18 -0
- package/build/core/services/wallet.js.map +1 -0
- package/build/core/tools/account-data.d.ts +2 -0
- package/build/core/tools/account-data.js +253 -0
- package/build/core/tools/account-data.js.map +1 -0
- package/build/core/tools/account-resource.d.ts +2 -0
- package/build/core/tools/account-resource.js +269 -0
- package/build/core/tools/account-resource.js.map +1 -0
- package/build/core/tools/account.d.ts +2 -0
- package/build/core/tools/account.js +451 -0
- package/build/core/tools/account.js.map +1 -0
- package/build/core/tools/address.d.ts +2 -0
- package/build/core/tools/address.js +45 -0
- package/build/core/tools/address.js.map +1 -0
- package/build/core/tools/balance.d.ts +2 -0
- package/build/core/tools/balance.js +94 -0
- package/build/core/tools/balance.js.map +1 -0
- package/build/core/tools/block.d.ts +2 -0
- package/build/core/tools/block.js +74 -0
- package/build/core/tools/block.js.map +1 -0
- package/build/core/tools/broadcast.d.ts +2 -0
- package/build/core/tools/broadcast.js +102 -0
- package/build/core/tools/broadcast.js.map +1 -0
- package/build/core/tools/contract-data.d.ts +2 -0
- package/build/core/tools/contract-data.js +159 -0
- package/build/core/tools/contract-data.js.map +1 -0
- package/build/core/tools/contract.d.ts +2 -0
- package/build/core/tools/contract.js +600 -0
- package/build/core/tools/contract.js.map +1 -0
- package/build/core/tools/event.d.ts +2 -0
- package/build/core/tools/event.js +159 -0
- package/build/core/tools/event.js.map +1 -0
- package/build/core/tools/governance.d.ts +6 -0
- package/build/core/tools/governance.js +424 -0
- package/build/core/tools/governance.js.map +1 -0
- package/build/core/tools/index.d.ts +15 -0
- package/build/core/tools/index.js +93 -0
- package/build/core/tools/index.js.map +1 -0
- package/build/core/tools/mempool.d.ts +2 -0
- package/build/core/tools/mempool.js +116 -0
- package/build/core/tools/mempool.js.map +1 -0
- package/build/core/tools/network.d.ts +2 -0
- package/build/core/tools/network.js +114 -0
- package/build/core/tools/network.js.map +1 -0
- package/build/core/tools/node.d.ts +2 -0
- package/build/core/tools/node.js +75 -0
- package/build/core/tools/node.js.map +1 -0
- package/build/core/tools/proposals.d.ts +6 -0
- package/build/core/tools/proposals.js +219 -0
- package/build/core/tools/proposals.js.map +1 -0
- package/build/core/tools/query.d.ts +2 -0
- package/build/core/tools/query.js +399 -0
- package/build/core/tools/query.js.map +1 -0
- package/build/core/tools/staking.d.ts +2 -0
- package/build/core/tools/staking.js +281 -0
- package/build/core/tools/staking.js.map +1 -0
- package/build/core/tools/transaction.d.ts +2 -0
- package/build/core/tools/transaction.js +65 -0
- package/build/core/tools/transaction.js.map +1 -0
- package/build/core/tools/transfer.d.ts +2 -0
- package/build/core/tools/transfer.js +101 -0
- package/build/core/tools/transfer.js.map +1 -0
- package/build/core/tools/types.d.ts +13 -0
- package/build/core/tools/types.js +2 -0
- package/build/core/tools/types.js.map +1 -0
- package/build/core/tools/wallet.d.ts +2 -0
- package/build/core/tools/wallet.js +172 -0
- package/build/core/tools/wallet.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +21 -0
- package/build/index.js.map +1 -0
- package/build/middleware/auth.d.ts +16 -0
- package/build/middleware/auth.js +44 -0
- package/build/middleware/auth.js.map +1 -0
- package/build/oauth/OAuthService.d.ts +100 -0
- package/build/oauth/OAuthService.js +507 -0
- package/build/oauth/OAuthService.js.map +1 -0
- package/build/oauth/page.d.ts +1 -0
- package/build/oauth/page.js +255 -0
- package/build/oauth/page.js.map +1 -0
- package/build/oauth/types.d.ts +65 -0
- package/build/oauth/types.js +2 -0
- package/build/oauth/types.js.map +1 -0
- package/build/server/http-app.d.ts +9 -0
- package/build/server/http-app.js +128 -0
- package/build/server/http-app.js.map +1 -0
- package/build/server/http-server.d.ts +1 -0
- package/build/server/http-server.js +35 -0
- package/build/server/http-server.js.map +1 -0
- package/build/server/oauth-routes.d.ts +7 -0
- package/build/server/oauth-routes.js +157 -0
- package/build/server/oauth-routes.js.map +1 -0
- package/build/server/server.d.ts +9 -0
- package/build/server/server.js +54 -0
- package/build/server/server.js.map +1 -0
- package/build/tenant/TenantManager.d.ts +35 -0
- package/build/tenant/TenantManager.js +167 -0
- package/build/tenant/TenantManager.js.map +1 -0
- package/build/tenant/context.d.ts +11 -0
- package/build/tenant/context.js +23 -0
- package/build/tenant/context.js.map +1 -0
- package/build/tenant/types.d.ts +16 -0
- package/build/tenant/types.js +2 -0
- package/build/tenant/types.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
type EventResult = any;
|
|
2
|
+
export interface FormattedEvent {
|
|
3
|
+
eventName: string;
|
|
4
|
+
signature: string;
|
|
5
|
+
transactionId: string;
|
|
6
|
+
blockNumber: number;
|
|
7
|
+
blockTimestamp: number;
|
|
8
|
+
contractAddress: string;
|
|
9
|
+
callerContractAddress: string;
|
|
10
|
+
confirmed: boolean;
|
|
11
|
+
params: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export interface FormattedEventResponse {
|
|
14
|
+
events: FormattedEvent[];
|
|
15
|
+
totalEvents: number;
|
|
16
|
+
fingerprint?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Format raw event data into a clean, LLM-friendly structure:
|
|
20
|
+
* - Removes duplicate positional keys (0, 1, 2...) from result
|
|
21
|
+
* - Converts hex addresses to base58 in params
|
|
22
|
+
* - Flattens result_type into params as "name (type): value"
|
|
23
|
+
* - Inverts _unconfirmed to confirmed
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatEventData(raw: EventResult): FormattedEventResponse;
|
|
26
|
+
/**
|
|
27
|
+
* Get events emitted by a specific transaction
|
|
28
|
+
*/
|
|
29
|
+
export declare function getEventsByTransactionId(transactionId: string, options?: {
|
|
30
|
+
onlyConfirmed?: boolean;
|
|
31
|
+
}, network?: string): Promise<EventResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Get events emitted by a specific contract address
|
|
34
|
+
*/
|
|
35
|
+
export declare function getEventsByContractAddress(contractAddress: string, options?: {
|
|
36
|
+
eventName?: string;
|
|
37
|
+
limit?: number;
|
|
38
|
+
fingerprint?: string;
|
|
39
|
+
onlyConfirmed?: boolean;
|
|
40
|
+
orderBy?: "block_timestamp,desc" | "block_timestamp,asc";
|
|
41
|
+
}, network?: string): Promise<EventResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Get events from a specific block number
|
|
44
|
+
*/
|
|
45
|
+
export declare function getEventsByBlockNumber(blockNumber: number, options?: {
|
|
46
|
+
onlyConfirmed?: boolean;
|
|
47
|
+
limit?: number;
|
|
48
|
+
fingerprint?: string;
|
|
49
|
+
}, network?: string): Promise<EventResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Get events from the latest block
|
|
52
|
+
*/
|
|
53
|
+
export declare function getEventsOfLatestBlock(options?: {
|
|
54
|
+
onlyConfirmed?: boolean;
|
|
55
|
+
}, network?: string): Promise<EventResult>;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { getTronWeb } from "./clients.js";
|
|
2
|
+
import { toBase58Address } from "./address.js";
|
|
3
|
+
/**
|
|
4
|
+
* Convert a hex address (0x-prefixed) to TRON base58 format.
|
|
5
|
+
* Returns the original value if not a hex address.
|
|
6
|
+
*/
|
|
7
|
+
function hexToBase58(value) {
|
|
8
|
+
if (typeof value === "string" && value.startsWith("0x") && value.length === 42) {
|
|
9
|
+
try {
|
|
10
|
+
return toBase58Address("41" + value.slice(2));
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Format raw event data into a clean, LLM-friendly structure:
|
|
20
|
+
* - Removes duplicate positional keys (0, 1, 2...) from result
|
|
21
|
+
* - Converts hex addresses to base58 in params
|
|
22
|
+
* - Flattens result_type into params as "name (type): value"
|
|
23
|
+
* - Inverts _unconfirmed to confirmed
|
|
24
|
+
*/
|
|
25
|
+
export function formatEventData(raw) {
|
|
26
|
+
const data = raw.data ?? [];
|
|
27
|
+
const events = data.map((e) => {
|
|
28
|
+
const result = e.result ?? {};
|
|
29
|
+
const resultType = e.result_type ?? {};
|
|
30
|
+
// Build clean params: skip numeric index keys, convert hex addresses
|
|
31
|
+
const params = {};
|
|
32
|
+
for (const [key, value] of Object.entries(result)) {
|
|
33
|
+
if (/^\d+$/.test(key))
|
|
34
|
+
continue; // skip positional keys
|
|
35
|
+
const typ = resultType[key];
|
|
36
|
+
const displayValue = typ === "address" ? hexToBase58(value) : value;
|
|
37
|
+
params[typ ? `${key} (${typ})` : key] = displayValue;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
eventName: e.event_name,
|
|
41
|
+
signature: e.event,
|
|
42
|
+
transactionId: e.transaction_id,
|
|
43
|
+
blockNumber: e.block_number,
|
|
44
|
+
blockTimestamp: e.block_timestamp,
|
|
45
|
+
contractAddress: e.contract_address,
|
|
46
|
+
callerContractAddress: e.caller_contract_address,
|
|
47
|
+
confirmed: !e._unconfirmed,
|
|
48
|
+
params,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
events,
|
|
53
|
+
totalEvents: events.length,
|
|
54
|
+
...(raw.meta?.fingerprint ? { fingerprint: raw.meta.fingerprint } : {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get events emitted by a specific transaction
|
|
59
|
+
*/
|
|
60
|
+
export async function getEventsByTransactionId(transactionId, options = {}, network = "mainnet") {
|
|
61
|
+
const tronWeb = getTronWeb(network);
|
|
62
|
+
return tronWeb.event.getEventsByTransactionID(transactionId, {
|
|
63
|
+
only_confirmed: options.onlyConfirmed,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get events emitted by a specific contract address
|
|
68
|
+
*/
|
|
69
|
+
export async function getEventsByContractAddress(contractAddress, options = {}, network = "mainnet") {
|
|
70
|
+
const tronWeb = getTronWeb(network);
|
|
71
|
+
return tronWeb.event.getEventsByContractAddress(contractAddress, {
|
|
72
|
+
eventName: options.eventName,
|
|
73
|
+
limit: options.limit ?? 20,
|
|
74
|
+
fingerprint: options.fingerprint,
|
|
75
|
+
onlyConfirmed: options.onlyConfirmed,
|
|
76
|
+
orderBy: options.orderBy,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get events from a specific block number
|
|
81
|
+
*/
|
|
82
|
+
export async function getEventsByBlockNumber(blockNumber, options = {}, network = "mainnet") {
|
|
83
|
+
const tronWeb = getTronWeb(network);
|
|
84
|
+
return tronWeb.event.getEventsByBlockNumber(blockNumber, {
|
|
85
|
+
only_confirmed: options.onlyConfirmed,
|
|
86
|
+
limit: options.limit,
|
|
87
|
+
fingerprint: options.fingerprint,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get events from the latest block
|
|
92
|
+
*/
|
|
93
|
+
export async function getEventsOfLatestBlock(options = {}, network = "mainnet") {
|
|
94
|
+
const tronWeb = getTronWeb(network);
|
|
95
|
+
return tronWeb.event.getEventsOfLatestBlock({
|
|
96
|
+
only_confirmed: options.onlyConfirmed,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/core/services/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAuB/C;;;GAGG;AACH,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC/E,IAAI,CAAC;YACH,OAAO,eAAe,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,e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OAAO,CAAC,WAAW;KACjC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,UAAuC,EAAE,EACzC,OAAO,GAAG,SAAS;IAEnB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC;QAC1C,cAAc,EAAE,OAAO,CAAC,aAAa;KACtC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List all Super Representatives (witnesses)
|
|
3
|
+
* @param network Network name (mainnet, nile, shasta)
|
|
4
|
+
*/
|
|
5
|
+
export declare function listWitnesses(network?: string): Promise<any>;
|
|
6
|
+
/**
|
|
7
|
+
* Get paginated list of current Super Representatives
|
|
8
|
+
* Uses TronWeb listSuperRepresentatives with manual pagination since
|
|
9
|
+
* the raw paginated API is not available on all networks.
|
|
10
|
+
* @param offset Starting offset for pagination
|
|
11
|
+
* @param limit Number of results per page
|
|
12
|
+
* @param network Network name
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPaginatedWitnessList(offset?: number, limit?: number, network?: string): Promise<{
|
|
15
|
+
witnesses: any;
|
|
16
|
+
total: any;
|
|
17
|
+
offset: number;
|
|
18
|
+
limit: number;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Get the time (in seconds) until the next network maintenance / vote cycle
|
|
22
|
+
* @param network Network name
|
|
23
|
+
*/
|
|
24
|
+
export declare function getNextMaintenanceTime(network?: string): Promise<{
|
|
25
|
+
secondsUntilNextMaintenance: number;
|
|
26
|
+
nextMaintenanceTimestamp: number;
|
|
27
|
+
nextMaintenanceDate: string;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Get the current unclaimed voting reward for an address
|
|
31
|
+
* @param address The address to query reward for
|
|
32
|
+
* @param network Network name
|
|
33
|
+
*/
|
|
34
|
+
export declare function getReward(address: string, network?: string): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the brokerage ratio (SR dividend ratio) for a witness address
|
|
37
|
+
* @param witnessAddress The SR witness address
|
|
38
|
+
* @param network Network name
|
|
39
|
+
*/
|
|
40
|
+
export declare function getBrokerage(witnessAddress: string, network?: string): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Apply to become a Super Representative (witness)
|
|
43
|
+
* @param url The official website URL of the SR candidate
|
|
44
|
+
* @param network Network name
|
|
45
|
+
* @returns Transaction hash
|
|
46
|
+
*/
|
|
47
|
+
export declare function createWitness(url: string, network?: string): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Update SR node URL via raw API (TronWeb TransactionBuilder does not expose updateWitness)
|
|
50
|
+
* @param url The new official website URL
|
|
51
|
+
* @param network Network name
|
|
52
|
+
* @returns Transaction hash
|
|
53
|
+
*/
|
|
54
|
+
export declare function updateWitness(url: string, network?: string): Promise<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Vote for Super Representatives
|
|
57
|
+
* Requires the voter to have frozen TRX (Stake 2.0) to obtain TRON Power.
|
|
58
|
+
* @param votes Array of { address, voteCount } objects
|
|
59
|
+
* @param network Network name
|
|
60
|
+
* @returns Transaction hash
|
|
61
|
+
*/
|
|
62
|
+
export declare function voteWitness(votes: Array<{
|
|
63
|
+
address: string;
|
|
64
|
+
voteCount: number;
|
|
65
|
+
}>, network?: string): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Withdraw voting reward balance to the account
|
|
68
|
+
* @param network Network name
|
|
69
|
+
* @returns Transaction hash
|
|
70
|
+
*/
|
|
71
|
+
export declare function withdrawBalance(network?: string): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Update the SR brokerage ratio (dividend ratio for voters)
|
|
74
|
+
* @param brokerage Brokerage percentage (0-100). E.g. 20 means SR keeps 20%, voters get 80%.
|
|
75
|
+
* @param network Network name
|
|
76
|
+
* @returns Transaction hash
|
|
77
|
+
*/
|
|
78
|
+
export declare function updateBrokerage(brokerage: number, network?: string): Promise<string>;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { getTronWeb } from "./clients.js";
|
|
2
|
+
import { getOwnerAddress, buildSignBroadcast, signTransactionRaw } from "./agent-wallet.js";
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// WITNESS / SUPER REPRESENTATIVE READ OPERATIONS
|
|
5
|
+
// ============================================================================
|
|
6
|
+
/**
|
|
7
|
+
* List all Super Representatives (witnesses)
|
|
8
|
+
* @param network Network name (mainnet, nile, shasta)
|
|
9
|
+
*/
|
|
10
|
+
export async function listWitnesses(network = "mainnet") {
|
|
11
|
+
const tronWeb = getTronWeb(network);
|
|
12
|
+
try {
|
|
13
|
+
// TronWeb exposes this as listSuperRepresentatives
|
|
14
|
+
const witnesses = await tronWeb.trx.listSuperRepresentatives();
|
|
15
|
+
return witnesses;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw new Error(`Failed to list witnesses: ${error.message}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get paginated list of current Super Representatives
|
|
23
|
+
* Uses TronWeb listSuperRepresentatives with manual pagination since
|
|
24
|
+
* the raw paginated API is not available on all networks.
|
|
25
|
+
* @param offset Starting offset for pagination
|
|
26
|
+
* @param limit Number of results per page
|
|
27
|
+
* @param network Network name
|
|
28
|
+
*/
|
|
29
|
+
export async function getPaginatedWitnessList(offset = 0, limit = 20, network = "mainnet") {
|
|
30
|
+
const tronWeb = getTronWeb(network);
|
|
31
|
+
try {
|
|
32
|
+
const allWitnesses = await tronWeb.trx.listSuperRepresentatives();
|
|
33
|
+
const paged = allWitnesses.slice(offset, offset + limit);
|
|
34
|
+
return {
|
|
35
|
+
witnesses: paged,
|
|
36
|
+
total: allWitnesses.length,
|
|
37
|
+
offset,
|
|
38
|
+
limit,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new Error(`Failed to get paginated witness list: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the time (in seconds) until the next network maintenance / vote cycle
|
|
47
|
+
* @param network Network name
|
|
48
|
+
*/
|
|
49
|
+
export async function getNextMaintenanceTime(network = "mainnet") {
|
|
50
|
+
const tronWeb = getTronWeb(network);
|
|
51
|
+
try {
|
|
52
|
+
// timeUntilNextVoteCycle returns seconds until next maintenance
|
|
53
|
+
const secondsUntil = await tronWeb.trx.timeUntilNextVoteCycle();
|
|
54
|
+
const nextMaintenanceTimestamp = Date.now() + secondsUntil * 1000;
|
|
55
|
+
return {
|
|
56
|
+
secondsUntilNextMaintenance: secondsUntil,
|
|
57
|
+
nextMaintenanceTimestamp,
|
|
58
|
+
nextMaintenanceDate: new Date(nextMaintenanceTimestamp).toISOString(),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw new Error(`Failed to get next maintenance time: ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get the current unclaimed voting reward for an address
|
|
67
|
+
* @param address The address to query reward for
|
|
68
|
+
* @param network Network name
|
|
69
|
+
*/
|
|
70
|
+
export async function getReward(address, network = "mainnet") {
|
|
71
|
+
const tronWeb = getTronWeb(network);
|
|
72
|
+
try {
|
|
73
|
+
const reward = await tronWeb.trx.getReward(address);
|
|
74
|
+
return reward;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw new Error(`Failed to get reward: ${error.message}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the brokerage ratio (SR dividend ratio) for a witness address
|
|
82
|
+
* @param witnessAddress The SR witness address
|
|
83
|
+
* @param network Network name
|
|
84
|
+
*/
|
|
85
|
+
export async function getBrokerage(witnessAddress, network = "mainnet") {
|
|
86
|
+
const tronWeb = getTronWeb(network);
|
|
87
|
+
try {
|
|
88
|
+
const brokerage = await tronWeb.trx.getBrokerage(witnessAddress);
|
|
89
|
+
return brokerage;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Failed to get brokerage: ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// WITNESS / SUPER REPRESENTATIVE WRITE OPERATIONS
|
|
97
|
+
// ============================================================================
|
|
98
|
+
/**
|
|
99
|
+
* Apply to become a Super Representative (witness)
|
|
100
|
+
* @param url The official website URL of the SR candidate
|
|
101
|
+
* @param network Network name
|
|
102
|
+
* @returns Transaction hash
|
|
103
|
+
*/
|
|
104
|
+
export async function createWitness(url, network = "mainnet") {
|
|
105
|
+
const tronWeb = getTronWeb(network);
|
|
106
|
+
const ownerAddress = await getOwnerAddress();
|
|
107
|
+
try {
|
|
108
|
+
const transaction = await tronWeb.transactionBuilder.applyForSR(ownerAddress, url);
|
|
109
|
+
return await buildSignBroadcast(transaction, network);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
throw new Error(`Failed to create witness (apply for SR): ${error.message}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Update SR node URL via raw API (TronWeb TransactionBuilder does not expose updateWitness)
|
|
117
|
+
* @param url The new official website URL
|
|
118
|
+
* @param network Network name
|
|
119
|
+
* @returns Transaction hash
|
|
120
|
+
*/
|
|
121
|
+
export async function updateWitness(url, network = "mainnet") {
|
|
122
|
+
const tronWeb = getTronWeb(network);
|
|
123
|
+
const ownerAddress = await getOwnerAddress();
|
|
124
|
+
try {
|
|
125
|
+
const ownerHex = tronWeb.address.toHex(ownerAddress);
|
|
126
|
+
// Build the WitnessUpdateContract via raw API since TronWeb SDK doesn't wrap it
|
|
127
|
+
const transaction = await tronWeb.fullNode.request("wallet/updatewitness", {
|
|
128
|
+
owner_address: ownerHex,
|
|
129
|
+
update_url: Buffer.from(url).toString("hex"),
|
|
130
|
+
}, "post");
|
|
131
|
+
if (!transaction || transaction.Error) {
|
|
132
|
+
throw new Error(`Failed to build updateWitness transaction: ${transaction?.Error || "unknown error"}`);
|
|
133
|
+
}
|
|
134
|
+
// WitnessUpdateContract is not in TronWeb's txJsonToPb mapping, so tronWeb.trx.sign()
|
|
135
|
+
// fails with "getRawData" error. Use signTransactionRaw which bypasses txCheck:
|
|
136
|
+
// - agent-wallet mode: signs raw_data_hex directly
|
|
137
|
+
// - legacy mode: uses crypto.signTransaction
|
|
138
|
+
const signedTx = await signTransactionRaw(transaction, network);
|
|
139
|
+
const result = await tronWeb.trx.sendRawTransaction(signedTx);
|
|
140
|
+
if (result.result) {
|
|
141
|
+
return result.txid;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
throw new Error(`UpdateWitness failed: ${JSON.stringify(result)}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw new Error(`Failed to update witness: ${error.message}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Vote for Super Representatives
|
|
153
|
+
* Requires the voter to have frozen TRX (Stake 2.0) to obtain TRON Power.
|
|
154
|
+
* @param votes Array of { address, voteCount } objects
|
|
155
|
+
* @param network Network name
|
|
156
|
+
* @returns Transaction hash
|
|
157
|
+
*/
|
|
158
|
+
export async function voteWitness(votes, network = "mainnet") {
|
|
159
|
+
const tronWeb = getTronWeb(network);
|
|
160
|
+
const ownerAddress = await getOwnerAddress();
|
|
161
|
+
try {
|
|
162
|
+
// TronWeb vote() expects an object { srAddress: voteCount, ... }
|
|
163
|
+
const voteMap = {};
|
|
164
|
+
for (const v of votes) {
|
|
165
|
+
voteMap[v.address] = v.voteCount;
|
|
166
|
+
}
|
|
167
|
+
const transaction = await tronWeb.transactionBuilder.vote(voteMap, ownerAddress);
|
|
168
|
+
return await buildSignBroadcast(transaction, network);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
throw new Error(`Failed to vote for witness: ${error.message}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Withdraw voting reward balance to the account
|
|
176
|
+
* @param network Network name
|
|
177
|
+
* @returns Transaction hash
|
|
178
|
+
*/
|
|
179
|
+
export async function withdrawBalance(network = "mainnet") {
|
|
180
|
+
const tronWeb = getTronWeb(network);
|
|
181
|
+
const ownerAddress = await getOwnerAddress();
|
|
182
|
+
try {
|
|
183
|
+
const transaction = await tronWeb.transactionBuilder.withdrawBlockRewards(ownerAddress);
|
|
184
|
+
return await buildSignBroadcast(transaction, network);
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
throw new Error(`Failed to withdraw balance: ${error.message}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Update the SR brokerage ratio (dividend ratio for voters)
|
|
192
|
+
* @param brokerage Brokerage percentage (0-100). E.g. 20 means SR keeps 20%, voters get 80%.
|
|
193
|
+
* @param network Network name
|
|
194
|
+
* @returns Transaction hash
|
|
195
|
+
*/
|
|
196
|
+
export async function updateBrokerage(brokerage, network = "mainnet") {
|
|
197
|
+
const tronWeb = getTronWeb(network);
|
|
198
|
+
const ownerAddress = await getOwnerAddress();
|
|
199
|
+
try {
|
|
200
|
+
const transaction = await tronWeb.transactionBuilder.updateBrokerage(brokerage, ownerAddress);
|
|
201
|
+
return await buildSignBroadcast(transaction, network);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw new Error(`Failed to update brokerage: ${error.message}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=governance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../../src/core/services/governance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,e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|
|
5
|
+
export * from "./blocks.js";
|
|
6
|
+
export * from "./transactions.js";
|
|
7
|
+
export * from "./contracts.js";
|
|
8
|
+
export * from "./tokens.js";
|
|
9
|
+
export * from "./address.js";
|
|
10
|
+
export * from "./wallet.js";
|
|
11
|
+
export * from "./multicall-abi.js";
|
|
12
|
+
export * from "./staking.js";
|
|
13
|
+
export * from "./account-resource.js";
|
|
14
|
+
export * from "./query.js";
|
|
15
|
+
export * from "./broadcast.js";
|
|
16
|
+
export * from "./nodes.js";
|
|
17
|
+
export * from "./mempool.js";
|
|
18
|
+
export * from "./events.js";
|
|
19
|
+
export * from "./account.js";
|
|
20
|
+
export * from "./governance.js";
|
|
21
|
+
export * from "./proposals.js";
|
|
22
|
+
export * from "./trongrid-client.js";
|
|
23
|
+
export * from "./account-data.js";
|
|
24
|
+
export * from "./contract-data.js";
|
|
25
|
+
export * from "./utils.js";
|
|
26
|
+
export declare const helpers: Record<string, unknown> & {
|
|
27
|
+
formatJson: (data: unknown) => string;
|
|
28
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Export all services
|
|
2
|
+
export * from "./agent-wallet.js";
|
|
3
|
+
export * from "./clients.js";
|
|
4
|
+
export * from "./balance.js";
|
|
5
|
+
export * from "./transfer.js";
|
|
6
|
+
export * from "./blocks.js";
|
|
7
|
+
export * from "./transactions.js";
|
|
8
|
+
export * from "./contracts.js";
|
|
9
|
+
export * from "./tokens.js";
|
|
10
|
+
export * from "./address.js";
|
|
11
|
+
export * from "./wallet.js";
|
|
12
|
+
export * from "./multicall-abi.js";
|
|
13
|
+
export * from "./staking.js";
|
|
14
|
+
export * from "./account-resource.js";
|
|
15
|
+
export * from "./query.js";
|
|
16
|
+
export * from "./broadcast.js";
|
|
17
|
+
export * from "./nodes.js";
|
|
18
|
+
export * from "./mempool.js";
|
|
19
|
+
export * from "./events.js";
|
|
20
|
+
export * from "./account.js";
|
|
21
|
+
export * from "./governance.js";
|
|
22
|
+
export * from "./proposals.js";
|
|
23
|
+
export * from "./trongrid-client.js";
|
|
24
|
+
export * from "./account-data.js";
|
|
25
|
+
export * from "./contract-data.js";
|
|
26
|
+
export * from "./utils.js"; // Export utils as top level as well
|
|
27
|
+
// Add a helper object for easier access to everything
|
|
28
|
+
import * as agentWallet from "./agent-wallet.js";
|
|
29
|
+
import * as clients from "./clients.js";
|
|
30
|
+
import * as wallet from "./wallet.js";
|
|
31
|
+
import * as balance from "./balance.js";
|
|
32
|
+
import * as blocks from "./blocks.js";
|
|
33
|
+
import * as transactions from "./transactions.js";
|
|
34
|
+
import * as contracts from "./contracts.js";
|
|
35
|
+
import * as tokens from "./tokens.js";
|
|
36
|
+
import * as transfer from "./transfer.js";
|
|
37
|
+
import * as utils from "./utils.js";
|
|
38
|
+
import * as address from "./address.js";
|
|
39
|
+
import * as staking from "./staking.js";
|
|
40
|
+
import * as accountResource from "./account-resource.js";
|
|
41
|
+
import * as query from "./query.js";
|
|
42
|
+
import * as broadcast from "./broadcast.js";
|
|
43
|
+
import * as nodes from "./nodes.js";
|
|
44
|
+
import * as mempool from "./mempool.js";
|
|
45
|
+
import * as events from "./events.js";
|
|
46
|
+
import * as account from "./account.js";
|
|
47
|
+
import * as governance from "./governance.js";
|
|
48
|
+
import * as proposals from "./proposals.js";
|
|
49
|
+
import * as trongridClient from "./trongrid-client.js";
|
|
50
|
+
import * as accountData from "./account-data.js";
|
|
51
|
+
import * as contractData from "./contract-data.js";
|
|
52
|
+
// Re-export specific utils function as 'helpers' for backward compatibility with tools code
|
|
53
|
+
export const helpers = {
|
|
54
|
+
...agentWallet,
|
|
55
|
+
...clients,
|
|
56
|
+
...wallet,
|
|
57
|
+
...balance,
|
|
58
|
+
...blocks,
|
|
59
|
+
...transactions,
|
|
60
|
+
...contracts,
|
|
61
|
+
...tokens,
|
|
62
|
+
...transfer,
|
|
63
|
+
...address,
|
|
64
|
+
...staking,
|
|
65
|
+
...accountResource,
|
|
66
|
+
...query,
|
|
67
|
+
...broadcast,
|
|
68
|
+
...nodes,
|
|
69
|
+
...mempool,
|
|
70
|
+
...events,
|
|
71
|
+
...account,
|
|
72
|
+
...governance,
|
|
73
|
+
...proposals,
|
|
74
|
+
...trongridClient,
|
|
75
|
+
...accountData,
|
|
76
|
+
...contractData,
|
|
77
|
+
...utils,
|
|
78
|
+
// Specifically map formatJson from utils to helpers root as tools expect it there
|
|
79
|
+
formatJson: utils.utils.formatJson,
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/services/index.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC,CAAC,oCAAoC;AAEhE,sDAAsD;AACtD,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OA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AO;IACV,GAAG,MAAM;IACT,GAAG,OAAO;IACV,GAAG,UAAU;IACb,GAAG,SAAS;IACZ,GAAG,cAAc;IACjB,GAAG,WAAW;IACd,GAAG,YAAY;IACf,GAAG,KAAK;IACR,kFAAkF;IAClF,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU;CACnC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get list of transaction IDs in the pending pool
|
|
3
|
+
*/
|
|
4
|
+
export declare function getTransactionListFromPending(network?: string): Promise<string[]>;
|
|
5
|
+
/**
|
|
6
|
+
* Get a specific transaction from the pending pool by its ID
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTransactionFromPending(txId: string, network?: string): Promise<Record<string, unknown>>;
|
|
9
|
+
/**
|
|
10
|
+
* Get the number of transactions in the pending pool
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPendingSize(network?: string): Promise<number>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getTronWeb } from "./clients.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get list of transaction IDs in the pending pool
|
|
4
|
+
*/
|
|
5
|
+
export async function getTransactionListFromPending(network = "mainnet") {
|
|
6
|
+
const tronWeb = getTronWeb(network);
|
|
7
|
+
const result = await tronWeb.fullNode.request("/wallet/gettransactionlistfrompending", {}, "get");
|
|
8
|
+
if (result.Error) {
|
|
9
|
+
throw new Error(`TRON API error: ${result.Error}`);
|
|
10
|
+
}
|
|
11
|
+
return result.txId ?? [];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get a specific transaction from the pending pool by its ID
|
|
15
|
+
*/
|
|
16
|
+
export async function getTransactionFromPending(txId, network = "mainnet") {
|
|
17
|
+
const tronWeb = getTronWeb(network);
|
|
18
|
+
const result = await tronWeb.fullNode.request("/wallet/gettransactionfrompending", { value: txId }, "post");
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the number of transactions in the pending pool
|
|
23
|
+
*/
|
|
24
|
+
export async function getPendingSize(network = "mainnet") {
|
|
25
|
+
const tronWeb = getTronWeb(network);
|
|
26
|
+
const result = await tronWeb.fullNode.request("/wallet/getpendingsize", {}, "get");
|
|
27
|
+
if (result.Error) {
|
|
28
|
+
throw new Error(`TRON API error: ${result.Error}`);
|
|
29
|
+
}
|
|
30
|
+
return result.pendingTransactionSize ?? 0;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=mempool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mempool.js","sourceRoot":"","sources":["../../../src/core/services/mempool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,OAAO,GAAG,SAAS;IACrE,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAC3C,uCAAuC,EACvC,EAAE,EACF,KAAK,CACN,CAAC;IACF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,IAAY,EACZ,OAAO,GAAG,SAAS;IAEnB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAC3C,mCAAmC,EACnC,EAAE,KAAK,EAAE,IAAI,EAAE,EACf,MAAM,CACP,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM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