@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,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get full account information from the TRON network
|
|
3
|
+
* @param address Account address (Base58 or Hex)
|
|
4
|
+
* @param network Network name
|
|
5
|
+
* @returns Full account object including balance, resources, permissions, etc.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getAccount(address: string, network?: string): Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Get account balance at a specific block
|
|
10
|
+
* TronWeb does not wrap this API, so we call the fullNode HTTP endpoint directly.
|
|
11
|
+
* @param address Account address
|
|
12
|
+
* @param blockHash Block hash
|
|
13
|
+
* @param blockNumber Block number
|
|
14
|
+
* @param network Network name
|
|
15
|
+
*/
|
|
16
|
+
export declare function getAccountBalance(address: string, blockHash: string, blockNumber: number, network?: string): Promise<{
|
|
17
|
+
balance?: number;
|
|
18
|
+
block_identifier?: any;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Generate a new account.
|
|
22
|
+
* Unified interface that returns a new keypair (ephemeral).
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateAccount(): Promise<{
|
|
25
|
+
address: {
|
|
26
|
+
base58: string;
|
|
27
|
+
};
|
|
28
|
+
privateKey: string;
|
|
29
|
+
message: string;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Validate a TRON address
|
|
33
|
+
* @param address Address to validate
|
|
34
|
+
* @returns Validation result with format information
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateAddress(address: string): {
|
|
37
|
+
isValid: boolean;
|
|
38
|
+
address: string;
|
|
39
|
+
format: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Get bandwidth information for an account
|
|
43
|
+
* @param address Account address
|
|
44
|
+
* @param network Network name
|
|
45
|
+
* @returns Bandwidth (net) value
|
|
46
|
+
*/
|
|
47
|
+
export declare function getAccountNet(address: string, network?: string): Promise<{
|
|
48
|
+
address: string;
|
|
49
|
+
bandwidth: number;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Get account resource information (energy, bandwidth, etc.)
|
|
53
|
+
* @param address Account address
|
|
54
|
+
* @param network Network name
|
|
55
|
+
* @returns Account resources including energy limit, bandwidth, frozen balance, etc.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getAccountResource(address: string, network?: string): Promise<any>;
|
|
58
|
+
/**
|
|
59
|
+
* Get delegated resource details between two accounts (Stake 2.0)
|
|
60
|
+
* @param fromAddress Delegator address
|
|
61
|
+
* @param toAddress Recipient address
|
|
62
|
+
* @param network Network name
|
|
63
|
+
*/
|
|
64
|
+
export declare function getDelegatedResource(fromAddress: string, toAddress: string, network?: string): Promise<{
|
|
65
|
+
delegatedResource: {
|
|
66
|
+
from: string;
|
|
67
|
+
to: string;
|
|
68
|
+
frozen_balance_for_bandwidth: number;
|
|
69
|
+
frozen_balance_for_energy: number;
|
|
70
|
+
expire_time_for_bandwidth: number;
|
|
71
|
+
expire_time_for_energy: number;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Get the delegation index for an account (who delegated to whom)
|
|
76
|
+
* @param address Account address
|
|
77
|
+
* @param network Network name
|
|
78
|
+
* @returns Delegation index with fromAccounts and toAccounts lists
|
|
79
|
+
*/
|
|
80
|
+
export declare function getDelegatedResourceIndex(address: string, network?: string): Promise<{
|
|
81
|
+
account: string;
|
|
82
|
+
fromAccounts: string[];
|
|
83
|
+
toAccounts: string[];
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Activate a new account on the TRON network (costs bandwidth from the creator)
|
|
87
|
+
* @param newAddress Address to activate
|
|
88
|
+
* @param network Network name
|
|
89
|
+
* @returns Transaction hash
|
|
90
|
+
*/
|
|
91
|
+
export declare function createAccount(newAddress: string, network?: string): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Update account name (can only be set once)
|
|
94
|
+
* @param accountName New account name
|
|
95
|
+
* @param network Network name
|
|
96
|
+
* @returns Transaction hash
|
|
97
|
+
*/
|
|
98
|
+
export declare function updateAccount(accountName: string, network?: string): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Update account permissions (multi-signature configuration)
|
|
101
|
+
* @param ownerPermission Owner permission configuration
|
|
102
|
+
* @param activePermissions Active permission(s) configuration
|
|
103
|
+
* @param witnessPermission Optional witness permission (for Super Representatives)
|
|
104
|
+
* @param network Network name
|
|
105
|
+
* @returns Transaction hash
|
|
106
|
+
*/
|
|
107
|
+
export declare function updateAccountPermissions(ownerPermission: {
|
|
108
|
+
type: number;
|
|
109
|
+
permission_name: string;
|
|
110
|
+
threshold: number;
|
|
111
|
+
keys: {
|
|
112
|
+
address: string;
|
|
113
|
+
weight: number;
|
|
114
|
+
}[];
|
|
115
|
+
}, activePermissions: {
|
|
116
|
+
type: number;
|
|
117
|
+
permission_name: string;
|
|
118
|
+
threshold: number;
|
|
119
|
+
operations: string;
|
|
120
|
+
keys: {
|
|
121
|
+
address: string;
|
|
122
|
+
weight: number;
|
|
123
|
+
}[];
|
|
124
|
+
} | {
|
|
125
|
+
type: number;
|
|
126
|
+
permission_name: string;
|
|
127
|
+
threshold: number;
|
|
128
|
+
operations: string;
|
|
129
|
+
keys: {
|
|
130
|
+
address: string;
|
|
131
|
+
weight: number;
|
|
132
|
+
}[];
|
|
133
|
+
}[], witnessPermission: {
|
|
134
|
+
type: number;
|
|
135
|
+
permission_name: string;
|
|
136
|
+
threshold: number;
|
|
137
|
+
keys: {
|
|
138
|
+
address: string;
|
|
139
|
+
weight: number;
|
|
140
|
+
}[];
|
|
141
|
+
} | null | undefined, network?: string): Promise<string>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { TronWeb } from "tronweb";
|
|
2
|
+
import { getTronWeb } from "./clients.js";
|
|
3
|
+
import { getOwnerAddress, buildSignBroadcast, generateAccountKeypair as generateAccountService, } from "./agent-wallet.js";
|
|
4
|
+
/**
|
|
5
|
+
* Get full account information from the TRON network
|
|
6
|
+
* @param address Account address (Base58 or Hex)
|
|
7
|
+
* @param network Network name
|
|
8
|
+
* @returns Full account object including balance, resources, permissions, etc.
|
|
9
|
+
*/
|
|
10
|
+
export async function getAccount(address, network = "mainnet") {
|
|
11
|
+
const tronWeb = getTronWeb(network);
|
|
12
|
+
try {
|
|
13
|
+
const account = await tronWeb.trx.getAccount(address);
|
|
14
|
+
return account;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
throw new Error(`Failed to get account: ${error.message}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get account balance at a specific block
|
|
22
|
+
* TronWeb does not wrap this API, so we call the fullNode HTTP endpoint directly.
|
|
23
|
+
* @param address Account address
|
|
24
|
+
* @param blockHash Block hash
|
|
25
|
+
* @param blockNumber Block number
|
|
26
|
+
* @param network Network name
|
|
27
|
+
*/
|
|
28
|
+
export async function getAccountBalance(address, blockHash, blockNumber, network = "mainnet") {
|
|
29
|
+
const tronWeb = getTronWeb(network);
|
|
30
|
+
try {
|
|
31
|
+
const result = await tronWeb.fullNode.request("/wallet/getaccountbalance", {
|
|
32
|
+
account_identifier: { address },
|
|
33
|
+
block_identifier: { hash: blockHash, number: blockNumber },
|
|
34
|
+
visible: true,
|
|
35
|
+
}, "post");
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw new Error(`Failed to get account balance: ${error.message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generate a new account.
|
|
44
|
+
* Unified interface that returns a new keypair (ephemeral).
|
|
45
|
+
*/
|
|
46
|
+
export async function generateAccount() {
|
|
47
|
+
try {
|
|
48
|
+
const result = await generateAccountService();
|
|
49
|
+
return {
|
|
50
|
+
address: { base58: result.address },
|
|
51
|
+
privateKey: result.privateKey,
|
|
52
|
+
message: result.message,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new Error(`Failed to generate account: ${error.message}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Validate a TRON address
|
|
61
|
+
* @param address Address to validate
|
|
62
|
+
* @returns Validation result with format information
|
|
63
|
+
*/
|
|
64
|
+
export function validateAddress(address) {
|
|
65
|
+
const isValid = TronWeb.isAddress(address);
|
|
66
|
+
const isBase58 = typeof address === "string" && address.startsWith("T") && address.length === 34;
|
|
67
|
+
const isHex = typeof address === "string" && (address.startsWith("41") || address.startsWith("0x"));
|
|
68
|
+
return {
|
|
69
|
+
isValid,
|
|
70
|
+
address,
|
|
71
|
+
format: isBase58 ? "base58" : isHex ? "hex" : "unknown",
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get bandwidth information for an account
|
|
76
|
+
* @param address Account address
|
|
77
|
+
* @param network Network name
|
|
78
|
+
* @returns Bandwidth (net) value
|
|
79
|
+
*/
|
|
80
|
+
export async function getAccountNet(address, network = "mainnet") {
|
|
81
|
+
const tronWeb = getTronWeb(network);
|
|
82
|
+
try {
|
|
83
|
+
const bandwidth = await tronWeb.trx.getBandwidth(address);
|
|
84
|
+
return { address, bandwidth };
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new Error(`Failed to get account net: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get account resource information (energy, bandwidth, etc.)
|
|
92
|
+
* @param address Account address
|
|
93
|
+
* @param network Network name
|
|
94
|
+
* @returns Account resources including energy limit, bandwidth, frozen balance, etc.
|
|
95
|
+
*/
|
|
96
|
+
export async function getAccountResource(address, network = "mainnet") {
|
|
97
|
+
const tronWeb = getTronWeb(network);
|
|
98
|
+
try {
|
|
99
|
+
const resources = await tronWeb.trx.getAccountResources(address);
|
|
100
|
+
return resources;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw new Error(`Failed to get account resource: ${error.message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get delegated resource details between two accounts (Stake 2.0)
|
|
108
|
+
* @param fromAddress Delegator address
|
|
109
|
+
* @param toAddress Recipient address
|
|
110
|
+
* @param network Network name
|
|
111
|
+
*/
|
|
112
|
+
export async function getDelegatedResource(fromAddress, toAddress, network = "mainnet") {
|
|
113
|
+
const tronWeb = getTronWeb(network);
|
|
114
|
+
try {
|
|
115
|
+
const result = await tronWeb.trx.getDelegatedResourceV2(fromAddress, toAddress);
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw new Error(`Failed to get delegated resource: ${error.message}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get the delegation index for an account (who delegated to whom)
|
|
124
|
+
* @param address Account address
|
|
125
|
+
* @param network Network name
|
|
126
|
+
* @returns Delegation index with fromAccounts and toAccounts lists
|
|
127
|
+
*/
|
|
128
|
+
export async function getDelegatedResourceIndex(address, network = "mainnet") {
|
|
129
|
+
const tronWeb = getTronWeb(network);
|
|
130
|
+
try {
|
|
131
|
+
const result = await tronWeb.trx.getDelegatedResourceAccountIndexV2(address);
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
throw new Error(`Failed to get delegated resource index: ${error.message}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Activate a new account on the TRON network (costs bandwidth from the creator)
|
|
140
|
+
* @param newAddress Address to activate
|
|
141
|
+
* @param network Network name
|
|
142
|
+
* @returns Transaction hash
|
|
143
|
+
*/
|
|
144
|
+
export async function createAccount(newAddress, network = "mainnet") {
|
|
145
|
+
const tronWeb = getTronWeb(network);
|
|
146
|
+
const ownerAddress = await getOwnerAddress();
|
|
147
|
+
try {
|
|
148
|
+
const transaction = await tronWeb.transactionBuilder.createAccount(newAddress, ownerAddress);
|
|
149
|
+
return await buildSignBroadcast(transaction, network);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
throw new Error(`Failed to create account: ${error.message}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Update account name (can only be set once)
|
|
157
|
+
* @param accountName New account name
|
|
158
|
+
* @param network Network name
|
|
159
|
+
* @returns Transaction hash
|
|
160
|
+
*/
|
|
161
|
+
export async function updateAccount(accountName, network = "mainnet") {
|
|
162
|
+
const tronWeb = getTronWeb(network);
|
|
163
|
+
const ownerAddress = await getOwnerAddress();
|
|
164
|
+
try {
|
|
165
|
+
const transaction = await tronWeb.transactionBuilder.updateAccount(accountName, ownerAddress);
|
|
166
|
+
return await buildSignBroadcast(transaction, network);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
throw new Error(`Failed to update account: ${error.message}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Update account permissions (multi-signature configuration)
|
|
174
|
+
* @param ownerPermission Owner permission configuration
|
|
175
|
+
* @param activePermissions Active permission(s) configuration
|
|
176
|
+
* @param witnessPermission Optional witness permission (for Super Representatives)
|
|
177
|
+
* @param network Network name
|
|
178
|
+
* @returns Transaction hash
|
|
179
|
+
*/
|
|
180
|
+
export async function updateAccountPermissions(ownerPermission, activePermissions, witnessPermission, network = "mainnet") {
|
|
181
|
+
const tronWeb = getTronWeb(network);
|
|
182
|
+
const ownerAddress = await getOwnerAddress();
|
|
183
|
+
try {
|
|
184
|
+
const transaction = await tronWeb.transactionBuilder.updateAccountPermissions(ownerAddress, ownerPermission, witnessPermission, activePermissions);
|
|
185
|
+
return await buildSignBroadcast(transaction, network);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
throw new Error(`Failed to update account permissions: ${error.message}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/core/services/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,sBAAsB,IAAI,sBAAsB,GACjD,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe,EAAE,OAAO,GAAG,SAAS;IACnE,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,SAAiB,EACjB,WAAmB,EACnB,OAAO,GAAG,SAAS;IAEnB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAC3C,2BAA2B,EAC3B;YACE,kBAAkB,EAAE,EAAE,OAAO,EAAE;YAC/B,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE;YAC1D,OAAO,EAAE,IAAI;SACd,EACD,MAAM,CACP,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAU,EAA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C,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,eAKC,EACD,iBAcO,EACP,iBAQa,EACb,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,wBAAwB,CAC3E,YAAY,EACZ,eAAsB,EACtB,iBAAwB,EACxB,iBAAwB,CACzB,CAAC;QACF,OAAO,MAAM,kBAAkB,CAAC,WAAkB,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service for handling address conversions (Hex <-> Base58)
|
|
3
|
+
*/
|
|
4
|
+
export declare function toHexAddress(address: string): string;
|
|
5
|
+
export declare function toBase58Address(address: string): string;
|
|
6
|
+
export declare function isBase58(address: string): boolean;
|
|
7
|
+
export declare function isHex(address: string): boolean;
|
|
8
|
+
export declare const resolveAddress: (nameOrAddress: string, _network?: string) => Promise<string>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TronWeb } from "tronweb";
|
|
2
|
+
/**
|
|
3
|
+
* Service for handling address conversions (Hex <-> Base58)
|
|
4
|
+
*/
|
|
5
|
+
export function toHexAddress(address) {
|
|
6
|
+
if (address.startsWith("T")) {
|
|
7
|
+
return TronWeb.address.toHex(address);
|
|
8
|
+
}
|
|
9
|
+
return address;
|
|
10
|
+
}
|
|
11
|
+
export function toBase58Address(address) {
|
|
12
|
+
if (address.startsWith("41")) {
|
|
13
|
+
return TronWeb.address.fromHex(address);
|
|
14
|
+
}
|
|
15
|
+
if (address.startsWith("0x")) {
|
|
16
|
+
// TronWeb expects 41 prefix for hex addresses usually, but 0x might be passed from EVM habits
|
|
17
|
+
// 0x prefix usually needs to be replaced with 41 if it's a valid Tron address in hex
|
|
18
|
+
// However, TronWeb.address.fromHex handles 0x prefix by assuming it's an ETH address and converting?
|
|
19
|
+
// Let's rely on TronWeb's robust handling
|
|
20
|
+
return TronWeb.address.fromHex(address);
|
|
21
|
+
}
|
|
22
|
+
return address;
|
|
23
|
+
}
|
|
24
|
+
export function isBase58(address) {
|
|
25
|
+
return address.startsWith("T") && TronWeb.isAddress(address);
|
|
26
|
+
}
|
|
27
|
+
export function isHex(address) {
|
|
28
|
+
// Base58 addresses start with T, Hex addresses don't (0-9, a-f)
|
|
29
|
+
if (address.startsWith("T"))
|
|
30
|
+
return false;
|
|
31
|
+
let cleanAddress = address;
|
|
32
|
+
if (address.startsWith("0x")) {
|
|
33
|
+
cleanAddress = address.substring(2);
|
|
34
|
+
}
|
|
35
|
+
// If it's a 20-byte hex (40 chars), prefix with 41 to verify as a Tron address
|
|
36
|
+
// TronWeb.address.fromHex handles this auto-prefixing, so isHex should validate it too
|
|
37
|
+
if (cleanAddress.length === 40) {
|
|
38
|
+
cleanAddress = "41" + cleanAddress;
|
|
39
|
+
}
|
|
40
|
+
return TronWeb.isAddress(cleanAddress);
|
|
41
|
+
}
|
|
42
|
+
// Re-export utility for convenience
|
|
43
|
+
export const resolveAddress = async (nameOrAddress, _network) => {
|
|
44
|
+
// Tron doesn't have ENS exactly like ETH.
|
|
45
|
+
// If it's a valid address, return it.
|
|
46
|
+
if (TronWeb.isAddress(nameOrAddress)) {
|
|
47
|
+
return nameOrAddress;
|
|
48
|
+
}
|
|
49
|
+
// Future: Implement Tron NS resolution if needed
|
|
50
|
+
throw new Error(`Invalid address or unsupported name service: ${nameOrAddress}`);
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/core/services/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;GAEG;AAEH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,8FAA8F;QAC9F,qFAAqF;QACrF,qGAAqG;QACrG,0CAA0C;QAC1C,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,OAAe;IACnC,gEAAgE;IAChE,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAE1C,IAAI,YAAY,GAAG,OAAO,CAAC;IAC3B,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,+EAA+E;IAC/E,uFAAuF;IACvF,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC/B,YAAY,GAAG,IAAI,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,OAAO,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC;AAED,oCAAoC;AACpC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,aAAqB,EAAE,QAAiB,EAAmB,EAAE;IAChG,0CAA0C;IAC1C,sCAAsC;IACtC,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;QACrC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,iDAAiD;IACjD,MAAM,IAAI,KAAK,CAAC,gDAAgD,aAAa,EAAE,CAAC,CAAC;AACnF,CAAC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-wallet integration layer for mcp-server-tron.
|
|
3
|
+
*
|
|
4
|
+
* Provides a unified signing interface via agent-wallet SDK.
|
|
5
|
+
*/
|
|
6
|
+
import { type Wallet } from "@missionsquad/agent-wallet";
|
|
7
|
+
/**
|
|
8
|
+
* Get the currently active agent-wallet.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getActiveWallet(): Promise<Wallet>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the address of the active wallet.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getOwnerAddress(): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Switch the active wallet at runtime when the provider supports multi-wallet selection.
|
|
17
|
+
*/
|
|
18
|
+
export declare function selectWallet(walletId: string): Promise<{
|
|
19
|
+
id: string;
|
|
20
|
+
address: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* List all available wallets.
|
|
24
|
+
*/
|
|
25
|
+
export declare function listAgentWallets(): Promise<Array<{
|
|
26
|
+
id: string;
|
|
27
|
+
type: string;
|
|
28
|
+
address: string;
|
|
29
|
+
}>>;
|
|
30
|
+
/**
|
|
31
|
+
* Get the currently active wallet ID.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getActiveWalletId(): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Sign an unsigned transaction.
|
|
36
|
+
*/
|
|
37
|
+
export declare function signTransaction(unsignedTx: Record<string, unknown>): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* Sign using raw crypto.
|
|
40
|
+
*/
|
|
41
|
+
export declare function signTransactionRaw(unsignedTx: Record<string, unknown>, _network?: string): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* Sign an unsigned transaction and broadcast it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildSignBroadcast(unsignedTx: Record<string, unknown>, network?: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Sign a message using the active wallet.
|
|
48
|
+
*/
|
|
49
|
+
export declare function signMessageWithWallet(message: string): Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Sign typed data (EIP-712) using the active wallet.
|
|
52
|
+
*/
|
|
53
|
+
export declare function signTypedDataWithWallet(domain: object, types: object, value: object): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Unified account generation.
|
|
56
|
+
* Generates a keypair and returns it directly. It is NOT stored in agent-wallet.
|
|
57
|
+
*/
|
|
58
|
+
export declare function generateAccountKeypair(): Promise<{
|
|
59
|
+
address: string;
|
|
60
|
+
privateKey: string;
|
|
61
|
+
message: string;
|
|
62
|
+
}>;
|