pwc-sdk-wallet 0.7.8 → 0.7.9

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/README.md CHANGED
@@ -31,6 +31,7 @@ A comprehensive, secure, and user-friendly wallet SDK for React Native applicati
31
31
  - [Account Management](#account-management)
32
32
  - [Add New HD Account](#add-new-hd-account)
33
33
  - [Add New Solana Account](#add-new-solana-account)
34
+ - [Add New TRON Account](#add-new-tron-account)
34
35
  - [Import Account](#import-account)
35
36
  - [Get Accounts](#get-accounts)
36
37
  - [Balance & Token Functions](#balance--token-functions)
@@ -45,6 +46,9 @@ A comprehensive, secure, and user-friendly wallet SDK for React Native applicati
45
46
  - [Send Native Token](#send-native-token)
46
47
  - [Send Token](#send-token)
47
48
  - [Send SPL Token (Solana)](#send-spl-token-solana)
49
+ - [Send TRX (TRON)](#send-trx-tron)
50
+ - [Send TRC-20 Token (TRON)](#send-trc-20-token-tron)
51
+ - [Popular TRON TRC-20 Tokens](#popular-tron-trc-20-tokens)
48
52
  - [Export Mnemonic](#export-mnemonic)
49
53
 
50
54
  ### 🔄 Multi-Transfer Operations
@@ -1469,7 +1473,7 @@ console.log('ERC-1155 transfer gas:', erc1155TransferGas.toString());
1469
1473
 
1470
1474
  - 🔐 **Secure HD Wallet Management**: BIP-44 compliant hierarchical deterministic wallets
1471
1475
  - 🎯 **Vanity Address Generation**: Generate wallets with custom address prefixes
1472
- - 🔗 **Multi-Chain Support**: Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, and Solana
1476
+ - 🔗 **Multi-Chain Support**: Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, Solana, and TRON
1473
1477
  - 🚀 **Multi-Transfer Operations**: Batch send tokens to multiple recipients
1474
1478
  - 🔧 **Custom Chain Support**: Add custom chains and override built-in configurations
1475
1479
  - 📱 **React Native Optimized**: Designed specifically for mobile applications
@@ -1536,6 +1540,13 @@ const { vault, encryptedVault } = await Vault.createFromMnemonic(
1536
1540
  'solana'
1537
1541
  );
1538
1542
 
1543
+ // For TRON
1544
+ const { vault, encryptedVault } = await Vault.createFromMnemonic(
1545
+ existingMnemonic,
1546
+ 'your-secure-password',
1547
+ 'tron'
1548
+ );
1549
+
1539
1550
  // Get wallet accounts
1540
1551
  const accounts = vault.getAccounts();
1541
1552
  console.log('Imported wallet addresses:', accounts.map(acc => acc.address));
@@ -1788,6 +1799,13 @@ const newSolanaAccount = vault.addSolanaAccount();
1788
1799
  console.log('New Solana account:', newSolanaAccount.address);
1789
1800
  ```
1790
1801
 
1802
+ #### Add New TRON Account
1803
+ ```typescript
1804
+ // Add a new TRON account
1805
+ const newTronAccount = vault.addNewTronAccount();
1806
+ console.log('New TRON account:', newTronAccount.address);
1807
+ ```
1808
+
1791
1809
  #### Import Account
1792
1810
  ```typescript
1793
1811
  // Import an existing account with private key
@@ -1917,6 +1935,96 @@ const USDC_DEVNET = '4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU';
1917
1935
  const USDT_DEVNET = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB';
1918
1936
  ```
1919
1937
 
1938
+ #### Send TRX (TRON)
1939
+ ```typescript
1940
+ // Send native TRX
1941
+ const tx = await vault.sendTRX(from, to, '1.5');
1942
+ console.log('Transaction hash:', tx.hash);
1943
+
1944
+ // Get TRX balance
1945
+ const balance = await vault.getTRXBalance(address);
1946
+ console.log('TRX Balance:', TronChainService.sunToTrx(balance.toString()));
1947
+ ```
1948
+
1949
+ #### Send TRC-20 Token (TRON)
1950
+ ```typescript
1951
+ // Send USDT on TRON
1952
+ const usdtTx = await vault.sendTRC20Token(
1953
+ 'TYourAddress...',
1954
+ 'TRecipient...',
1955
+ '100', // 100 USDT
1956
+ 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' // USDT contract address
1957
+ );
1958
+
1959
+ // Send USDC on TRON
1960
+ const usdcTx = await vault.sendTRC20Token(
1961
+ 'TYourAddress...',
1962
+ 'TRecipient...',
1963
+ '50', // 50 USDC
1964
+ 'TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8' // USDC contract address
1965
+ );
1966
+
1967
+ // Get TRC-20 token balance
1968
+ const usdtBalance = await vault.getTRC20TokenBalance(
1969
+ 'TYourAddress...',
1970
+ 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'
1971
+ );
1972
+ console.log('USDT Balance:', usdtBalance.toString());
1973
+
1974
+ // Get TRC-20 token information
1975
+ const tokenInfo = await vault.getTRC20TokenInfo(
1976
+ 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'
1977
+ );
1978
+ console.log('Token:', tokenInfo.name, '(', tokenInfo.symbol, ')');
1979
+ console.log('Decimals:', tokenInfo.decimals);
1980
+
1981
+ // Estimate TRX transfer fee
1982
+ const trxFee = await vault.estimateTRXTransferFee(
1983
+ 'TYourAddress...',
1984
+ 'TRecipient...',
1985
+ '1.5'
1986
+ );
1987
+ console.log('Estimated TRX fee:', TronChainService.sunToTrx(trxFee.toString()), 'TRX');
1988
+
1989
+ // Estimate TRC-20 transfer fee
1990
+ const tokenFee = await vault.estimateTRC20TransferFee(
1991
+ 'TYourAddress...',
1992
+ 'TRecipient...',
1993
+ '100',
1994
+ 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'
1995
+ );
1996
+ console.log('Estimated token fee:', TronChainService.sunToTrx(tokenFee.toString()), 'TRX');
1997
+ ```
1998
+
1999
+ #### Popular TRON TRC-20 Tokens
2000
+
2001
+ **Mainnet Token Addresses:**
2002
+ ```typescript
2003
+ // USDT (Tether USD)
2004
+ const USDT_TRC20 = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';
2005
+
2006
+ // USDC (USD Coin)
2007
+ const USDC_TRC20 = 'TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8';
2008
+
2009
+ // USDD (Decentralized USD)
2010
+ const USDD_TRC20 = 'TPYmHEhy5n8TCEfYGqW2rPxsghSfzghPDn';
2011
+
2012
+ // JST (JUST)
2013
+ const JST_TRC20 = 'TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9';
2014
+
2015
+ // WIN (WINkLink)
2016
+ const WIN_TRC20 = 'TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7';
2017
+ ```
2018
+
2019
+ **Shasta Testnet Token Addresses (for testing):**
2020
+ ```typescript
2021
+ // USDT Shasta
2022
+ const USDT_SHASTA = 'TG3XXyExBkPp9nzdajDZsozEu1kkaAzc3X';
2023
+
2024
+ // USDC Shasta
2025
+ const USDC_SHASTA = 'TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBZ';
2026
+ ```
2027
+
1920
2028
  #### Export Mnemonic
1921
2029
  ```typescript
1922
2030
  // Export the mnemonic phrase (requires password)
package/dist/Vault.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Recipient, MultiTransferResult } from './types/multiTransfer';
4
4
  import { NFTDetailExtended, NFTBalance, NFTOptions } from './types/nft';
5
5
  export interface Account {
6
6
  address: string;
7
- type: 'HD' | 'Simple' | 'Solana';
7
+ type: 'HD' | 'Simple' | 'Solana' | 'Tron';
8
8
  name: string;
9
9
  }
10
10
  export interface TransactionResponse {
@@ -51,11 +51,11 @@ export declare class Vault {
51
51
  /**
52
52
  * Creates a new Vault with a fresh mnemonic.
53
53
  * @param password - The password used to encrypt the vault data
54
- * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains or 'solana' for Solana). Defaults to 'evm'
54
+ * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana, or 'tron' for TRON). Defaults to 'evm'
55
55
  * @returns Promise resolving to an object containing the created vault instance and its encrypted data
56
56
  * @throws Error if mnemonic generation or keyring initialization fails
57
57
  */
58
- static createNew(password: string, chainType?: 'evm' | 'solana', config?: VaultConfig): Promise<{
58
+ static createNew(password: string, chainType?: 'evm' | 'solana' | 'tron', config?: VaultConfig): Promise<{
59
59
  vault: Vault;
60
60
  encryptedVault: EncryptedData;
61
61
  }>;
@@ -63,11 +63,11 @@ export declare class Vault {
63
63
  * Creates a new Vault from an existing mnemonic phrase.
64
64
  * @param mnemonic - The existing mnemonic phrase (12, 15, 18, 21, or 24 words)
65
65
  * @param password - The password used to encrypt the vault data
66
- * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains or 'solana' for Solana). Defaults to 'evm'
66
+ * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana, or 'tron' for TRON). Defaults to 'evm'
67
67
  * @returns Promise resolving to an object containing the created vault instance and its encrypted data
68
68
  * @throws Error if mnemonic is invalid or keyring initialization fails
69
69
  */
70
- static createFromMnemonic(mnemonic: string, password: string, chainType?: 'evm' | 'solana', config?: VaultConfig): Promise<{
70
+ static createFromMnemonic(mnemonic: string, password: string, chainType?: 'evm' | 'solana' | 'tron', config?: VaultConfig): Promise<{
71
71
  vault: Vault;
72
72
  encryptedVault: EncryptedData;
73
73
  }>;
@@ -91,6 +91,12 @@ export declare class Vault {
91
91
  * @throws Error if no Solana keyring is available in the vault
92
92
  */
93
93
  addNewSolanaAccount(): Promise<Account>;
94
+ /**
95
+ * Adds a new TRON account derived from the TRON keyring.
96
+ * @returns Promise resolving to the newly created TRON account information
97
+ * @throws Error if no TRON keyring is available in the vault
98
+ */
99
+ addNewTronAccount(): Promise<Account>;
94
100
  /**
95
101
  * Imports an account from a private key and adds it to the vault.
96
102
  * @param privateKey - The private key to import (hex string without '0x' prefix for EVM, base58 for Solana)
@@ -580,4 +586,82 @@ export declare class Vault {
580
586
  * ```
581
587
  */
582
588
  sendNativeToken(fromAddress: string, to: string, amount: string, chainId: ChainId): Promise<TransactionResponse>;
589
+ /**
590
+ * Sends TRX (native TRON token) to another address.
591
+ * @param fromAddress - The sender's TRON address
592
+ * @param to - The recipient's TRON address
593
+ * @param amount - The amount of TRX to send as a string (e.g., "1.5")
594
+ * @returns Promise resolving to the transaction response with hash and details
595
+ * @throws Error if the transaction fails or recipient address is invalid
596
+ *
597
+ * @example
598
+ * ```typescript
599
+ * // Send 1.5 TRX
600
+ * const tx = await vault.sendTRX(from, to, '1.5');
601
+ * console.log('Transaction hash:', tx.hash);
602
+ * ```
603
+ */
604
+ sendTRX(fromAddress: string, to: string, amount: string): Promise<TransactionResponse>;
605
+ /**
606
+ * Sends TRC-20 tokens on TRON blockchain.
607
+ * @param fromAddress - The sender's TRON address
608
+ * @param to - The recipient's TRON address
609
+ * @param amount - The amount of tokens to send as a string
610
+ * @param tokenAddress - The TRC-20 token contract address
611
+ * @returns Promise resolving to the transaction response with hash and details
612
+ * @throws Error if insufficient balance, invalid addresses, or transaction fails
613
+ *
614
+ * @example
615
+ * ```typescript
616
+ * // Send USDT on TRON
617
+ * const tx = await vault.sendTRC20Token(
618
+ * 'TYourAddress...',
619
+ * 'TRecipient...',
620
+ * '100', // 100 USDT
621
+ * 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' // USDT contract address
622
+ * );
623
+ * ```
624
+ */
625
+ sendTRC20Token(fromAddress: string, to: string, amount: string, tokenAddress: string): Promise<TransactionResponse>;
626
+ /**
627
+ * Gets TRX balance for a specific address on TRON.
628
+ * @param address - The TRON address to check balance for
629
+ * @returns Promise resolving to the TRX balance as a bigint in SUN
630
+ * @throws Error if the balance query fails
631
+ */
632
+ getTRXBalance(address: string): Promise<bigint>;
633
+ /**
634
+ * Gets TRC-20 token balance for a specific address on TRON.
635
+ * @param address - The TRON address to check balance for
636
+ * @param tokenAddress - The TRC-20 token contract address
637
+ * @returns Promise resolving to the token balance as a bigint
638
+ * @throws Error if the balance query fails
639
+ */
640
+ getTRC20TokenBalance(address: string, tokenAddress: string): Promise<bigint>;
641
+ /**
642
+ * Gets TRC-20 token information.
643
+ * @param tokenAddress - The TRC-20 token contract address
644
+ * @returns Promise resolving to the token information
645
+ * @throws Error if the token query fails
646
+ */
647
+ getTRC20TokenInfo(tokenAddress: string): Promise<Token>;
648
+ /**
649
+ * Estimates the transaction fee for a TRX transfer.
650
+ * @param fromAddress - The sender's TRON address
651
+ * @param to - The recipient's TRON address
652
+ * @param amount - The amount of TRX to send
653
+ * @returns Promise resolving to the estimated fee in SUN
654
+ * @throws Error if the estimation fails
655
+ */
656
+ estimateTRXTransferFee(fromAddress: string, to: string, amount: string): Promise<bigint>;
657
+ /**
658
+ * Estimates the transaction fee for a TRC-20 token transfer.
659
+ * @param fromAddress - The sender's TRON address
660
+ * @param to - The recipient's TRON address
661
+ * @param amount - The amount of tokens to send
662
+ * @param tokenAddress - The TRC-20 token contract address
663
+ * @returns Promise resolving to the estimated fee in SUN
664
+ * @throws Error if the estimation fails
665
+ */
666
+ estimateTRC20TransferFee(fromAddress: string, to: string, amount: string, tokenAddress: string): Promise<bigint>;
583
667
  }
package/dist/Vault.js CHANGED
@@ -4,8 +4,10 @@ exports.Vault = void 0;
4
4
  const HDKeyring_1 = require("./keyrings/HDKeyring");
5
5
  const SimpleKeyring_1 = require("./keyrings/SimpleKeyring");
6
6
  const SolanaKeyring_1 = require("./keyrings/SolanaKeyring");
7
+ const TronKeyring_1 = require("./keyrings/TronKeyring");
7
8
  const ChainService_1 = require("./chain/ChainService");
8
9
  const SolanaChainService_1 = require("./chain/SolanaChainService");
10
+ const TronChainService_1 = require("./chain/TronChainService");
9
11
  const EncryptionService_1 = require("./crypto/EncryptionService");
10
12
  const chains_1 = require("./config/chains");
11
13
  const constants_1 = require("./config/constants");
@@ -43,7 +45,7 @@ class Vault {
43
45
  /**
44
46
  * Creates a new Vault with a fresh mnemonic.
45
47
  * @param password - The password used to encrypt the vault data
46
- * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains or 'solana' for Solana). Defaults to 'evm'
48
+ * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana, or 'tron' for TRON). Defaults to 'evm'
47
49
  * @returns Promise resolving to an object containing the created vault instance and its encrypted data
48
50
  * @throws Error if mnemonic generation or keyring initialization fails
49
51
  */
@@ -56,6 +58,13 @@ class Vault {
56
58
  const encryptedVault = await vault.encrypt(password);
57
59
  return { vault, encryptedVault };
58
60
  }
61
+ else if (chainType === 'tron') {
62
+ const tronKeyring = new TronKeyring_1.TronKeyring(mnemonic);
63
+ const vault = new Vault([tronKeyring], config);
64
+ vault.chainId = 'tron'; // Set TRON chain ID
65
+ const encryptedVault = await vault.encrypt(password);
66
+ return { vault, encryptedVault };
67
+ }
59
68
  else {
60
69
  const hdKeyring = new HDKeyring_1.HDKeyring(mnemonic);
61
70
  await hdKeyring.initialize();
@@ -69,7 +78,7 @@ class Vault {
69
78
  * Creates a new Vault from an existing mnemonic phrase.
70
79
  * @param mnemonic - The existing mnemonic phrase (12, 15, 18, 21, or 24 words)
71
80
  * @param password - The password used to encrypt the vault data
72
- * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains or 'solana' for Solana). Defaults to 'evm'
81
+ * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana, or 'tron' for TRON). Defaults to 'evm'
73
82
  * @returns Promise resolving to an object containing the created vault instance and its encrypted data
74
83
  * @throws Error if mnemonic is invalid or keyring initialization fails
75
84
  */
@@ -81,6 +90,13 @@ class Vault {
81
90
  const encryptedVault = await vault.encrypt(password);
82
91
  return { vault, encryptedVault };
83
92
  }
93
+ else if (chainType === 'tron') {
94
+ const tronKeyring = new TronKeyring_1.TronKeyring(mnemonic);
95
+ const vault = new Vault([tronKeyring], config);
96
+ vault.chainId = 'tron'; // Set TRON chain ID
97
+ const encryptedVault = await vault.encrypt(password);
98
+ return { vault, encryptedVault };
99
+ }
84
100
  else {
85
101
  const hdKeyring = new HDKeyring_1.HDKeyring(mnemonic);
86
102
  await hdKeyring.initialize();
@@ -171,6 +187,23 @@ class Vault {
171
187
  name: `Solana ${solanaKeyring.accounts.length}`
172
188
  };
173
189
  }
190
+ /**
191
+ * Adds a new TRON account derived from the TRON keyring.
192
+ * @returns Promise resolving to the newly created TRON account information
193
+ * @throws Error if no TRON keyring is available in the vault
194
+ */
195
+ async addNewTronAccount() {
196
+ const tronKeyring = this.keyrings.find(k => k instanceof TronKeyring_1.TronKeyring);
197
+ if (!tronKeyring) {
198
+ throw new Error('No TRON keyring available to create new accounts.');
199
+ }
200
+ const newAddress = await tronKeyring.addNewAccount();
201
+ return {
202
+ address: newAddress,
203
+ type: 'Tron',
204
+ name: `Tron ${tronKeyring.getAllAccounts().length}`
205
+ };
206
+ }
174
207
  /**
175
208
  * Imports an account from a private key and adds it to the vault.
176
209
  * @param privateKey - The private key to import (hex string without '0x' prefix for EVM, base58 for Solana)
@@ -204,6 +237,7 @@ class Vault {
204
237
  let hdAccountCount = 1;
205
238
  let importedAccountCount = 1;
206
239
  let solanaAccountCount = 1;
240
+ let tronAccountCount = 1;
207
241
  for (const keyring of this.keyrings) {
208
242
  if (keyring instanceof HDKeyring_1.HDKeyring) {
209
243
  for (const address of keyring.accounts) {
@@ -230,6 +264,15 @@ class Vault {
230
264
  });
231
265
  }
232
266
  }
267
+ else if (keyring instanceof TronKeyring_1.TronKeyring) {
268
+ for (const address of keyring.getAllAccounts()) {
269
+ accounts.push({
270
+ address,
271
+ type: 'Tron',
272
+ name: `Tron ${tronAccountCount++}`,
273
+ });
274
+ }
275
+ }
233
276
  }
234
277
  return accounts;
235
278
  }
@@ -1300,6 +1343,16 @@ class Vault {
1300
1343
  blockNumber: result.blockNumber || undefined
1301
1344
  };
1302
1345
  }
1346
+ else if (chainInfo.type === 'tron') {
1347
+ const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1348
+ const result = await chainService.sendTransaction(to, amount);
1349
+ return {
1350
+ hash: result.hash,
1351
+ from: result.from,
1352
+ to: result.to,
1353
+ blockNumber: result.blockNumber || undefined
1354
+ };
1355
+ }
1303
1356
  else {
1304
1357
  const chainService = new ChainService_1.ChainService(privateKey, chainInfo);
1305
1358
  // Create transaction request for native token transfer
@@ -1316,6 +1369,161 @@ class Vault {
1316
1369
  };
1317
1370
  }
1318
1371
  }
1372
+ // --- TRON Operations ---
1373
+ /**
1374
+ * Sends TRX (native TRON token) to another address.
1375
+ * @param fromAddress - The sender's TRON address
1376
+ * @param to - The recipient's TRON address
1377
+ * @param amount - The amount of TRX to send as a string (e.g., "1.5")
1378
+ * @returns Promise resolving to the transaction response with hash and details
1379
+ * @throws Error if the transaction fails or recipient address is invalid
1380
+ *
1381
+ * @example
1382
+ * ```typescript
1383
+ * // Send 1.5 TRX
1384
+ * const tx = await vault.sendTRX(from, to, '1.5');
1385
+ * console.log('Transaction hash:', tx.hash);
1386
+ * ```
1387
+ */
1388
+ async sendTRX(fromAddress, to, amount) {
1389
+ const chainInfo = (0, chains_1.getChainConfig)('tron');
1390
+ if (chainInfo.type !== 'tron') {
1391
+ throw new Error('TRON chain configuration not found');
1392
+ }
1393
+ const privateKey = await this.getPrivateKeyFor(fromAddress);
1394
+ const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1395
+ const result = await chainService.sendTransaction(to, amount);
1396
+ return {
1397
+ hash: result.hash,
1398
+ from: result.from,
1399
+ to: result.to,
1400
+ blockNumber: result.blockNumber
1401
+ };
1402
+ }
1403
+ /**
1404
+ * Sends TRC-20 tokens on TRON blockchain.
1405
+ * @param fromAddress - The sender's TRON address
1406
+ * @param to - The recipient's TRON address
1407
+ * @param amount - The amount of tokens to send as a string
1408
+ * @param tokenAddress - The TRC-20 token contract address
1409
+ * @returns Promise resolving to the transaction response with hash and details
1410
+ * @throws Error if insufficient balance, invalid addresses, or transaction fails
1411
+ *
1412
+ * @example
1413
+ * ```typescript
1414
+ * // Send USDT on TRON
1415
+ * const tx = await vault.sendTRC20Token(
1416
+ * 'TYourAddress...',
1417
+ * 'TRecipient...',
1418
+ * '100', // 100 USDT
1419
+ * 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' // USDT contract address
1420
+ * );
1421
+ * ```
1422
+ */
1423
+ async sendTRC20Token(fromAddress, to, amount, tokenAddress) {
1424
+ const chainInfo = (0, chains_1.getChainConfig)('tron');
1425
+ if (chainInfo.type !== 'tron') {
1426
+ throw new Error('TRON chain configuration not found');
1427
+ }
1428
+ const privateKey = await this.getPrivateKeyFor(fromAddress);
1429
+ const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1430
+ const result = await chainService.sendToken(to, amount, tokenAddress);
1431
+ return {
1432
+ hash: result.hash,
1433
+ from: result.from,
1434
+ to: result.to,
1435
+ blockNumber: result.blockNumber
1436
+ };
1437
+ }
1438
+ /**
1439
+ * Gets TRX balance for a specific address on TRON.
1440
+ * @param address - The TRON address to check balance for
1441
+ * @returns Promise resolving to the TRX balance as a bigint in SUN
1442
+ * @throws Error if the balance query fails
1443
+ */
1444
+ async getTRXBalance(address) {
1445
+ const chainInfo = (0, chains_1.getChainConfig)('tron');
1446
+ if (chainInfo.type !== 'tron') {
1447
+ throw new Error('TRON chain configuration not found');
1448
+ }
1449
+ const privateKey = await this.getPrivateKeyFor(address);
1450
+ const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1451
+ return await chainService.getNativeBalance();
1452
+ }
1453
+ /**
1454
+ * Gets TRC-20 token balance for a specific address on TRON.
1455
+ * @param address - The TRON address to check balance for
1456
+ * @param tokenAddress - The TRC-20 token contract address
1457
+ * @returns Promise resolving to the token balance as a bigint
1458
+ * @throws Error if the balance query fails
1459
+ */
1460
+ async getTRC20TokenBalance(address, tokenAddress) {
1461
+ const chainInfo = (0, chains_1.getChainConfig)('tron');
1462
+ if (chainInfo.type !== 'tron') {
1463
+ throw new Error('TRON chain configuration not found');
1464
+ }
1465
+ const privateKey = await this.getPrivateKeyFor(address);
1466
+ const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1467
+ return await chainService.getTokenBalance(tokenAddress);
1468
+ }
1469
+ /**
1470
+ * Gets TRC-20 token information.
1471
+ * @param tokenAddress - The TRC-20 token contract address
1472
+ * @returns Promise resolving to the token information
1473
+ * @throws Error if the token query fails
1474
+ */
1475
+ async getTRC20TokenInfo(tokenAddress) {
1476
+ const chainInfo = (0, chains_1.getChainConfig)('tron');
1477
+ if (chainInfo.type !== 'tron') {
1478
+ throw new Error('TRON chain configuration not found');
1479
+ }
1480
+ // Use a dummy private key for read-only operations
1481
+ const dummyPrivateKey = '0000000000000000000000000000000000000000000000000000000000000001';
1482
+ const chainService = new TronChainService_1.TronChainService(dummyPrivateKey, chainInfo);
1483
+ const tokenInfo = await chainService.getTokenInfo(tokenAddress);
1484
+ return {
1485
+ address: tokenInfo.address,
1486
+ name: tokenInfo.name,
1487
+ symbol: tokenInfo.symbol,
1488
+ decimals: tokenInfo.decimals,
1489
+ totalSupply: tokenInfo.totalSupply
1490
+ };
1491
+ }
1492
+ /**
1493
+ * Estimates the transaction fee for a TRX transfer.
1494
+ * @param fromAddress - The sender's TRON address
1495
+ * @param to - The recipient's TRON address
1496
+ * @param amount - The amount of TRX to send
1497
+ * @returns Promise resolving to the estimated fee in SUN
1498
+ * @throws Error if the estimation fails
1499
+ */
1500
+ async estimateTRXTransferFee(fromAddress, to, amount) {
1501
+ const chainInfo = (0, chains_1.getChainConfig)('tron');
1502
+ if (chainInfo.type !== 'tron') {
1503
+ throw new Error('TRON chain configuration not found');
1504
+ }
1505
+ const privateKey = await this.getPrivateKeyFor(fromAddress);
1506
+ const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1507
+ return await chainService.estimateTransactionFee(to, amount);
1508
+ }
1509
+ /**
1510
+ * Estimates the transaction fee for a TRC-20 token transfer.
1511
+ * @param fromAddress - The sender's TRON address
1512
+ * @param to - The recipient's TRON address
1513
+ * @param amount - The amount of tokens to send
1514
+ * @param tokenAddress - The TRC-20 token contract address
1515
+ * @returns Promise resolving to the estimated fee in SUN
1516
+ * @throws Error if the estimation fails
1517
+ */
1518
+ async estimateTRC20TransferFee(fromAddress, to, amount, tokenAddress) {
1519
+ const chainInfo = (0, chains_1.getChainConfig)('tron');
1520
+ if (chainInfo.type !== 'tron') {
1521
+ throw new Error('TRON chain configuration not found');
1522
+ }
1523
+ const privateKey = await this.getPrivateKeyFor(fromAddress);
1524
+ const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1525
+ return await chainService.estimateTokenTransferFee(to, amount, tokenAddress);
1526
+ }
1319
1527
  }
1320
1528
  exports.Vault = Vault;
1321
1529
  // Rate limiting for export attempts