pwc-sdk-wallet 0.7.7 → 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 +300 -7
- package/dist/Vault.d.ts +180 -6
- package/dist/Vault.js +426 -5
- package/dist/chain/SolanaChainService.d.ts +68 -4
- package/dist/chain/SolanaChainService.js +166 -34
- package/dist/chain/TronChainService.d.ts +130 -0
- package/dist/chain/TronChainService.js +292 -0
- package/dist/config/chains.d.ts +28 -4
- package/dist/config/chains.js +16 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -2
- package/dist/keyrings/TronKeyring.d.ts +88 -0
- package/dist/keyrings/TronKeyring.js +228 -0
- package/dist/services/BatchProcessor.js +5 -1
- package/dist/services/nft/NFTService.d.ts +29 -2
- package/dist/services/nft/NFTService.js +249 -24
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -31,20 +31,30 @@ 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)
|
|
37
38
|
- [Get Native Balance](#get-native-balance)
|
|
38
39
|
- [Get Token Balance](#get-token-balance)
|
|
39
40
|
- [Get Token Info](#get-token-info)
|
|
41
|
+
- [Get SPL Token Balance (Solana)](#get-spl-token-balance)
|
|
42
|
+
- [Get SPL Token Info (Solana)](#get-spl-token-info)
|
|
43
|
+
- [Estimate SPL Token Transfer Fee](#estimate-spl-token-transfer-fee)
|
|
44
|
+
- [Popular Solana SPL Tokens](#popular-solana-spl-tokens)
|
|
40
45
|
- [Transaction Functions](#transaction-functions)
|
|
41
46
|
- [Send Native Token](#send-native-token)
|
|
42
47
|
- [Send Token](#send-token)
|
|
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)
|
|
43
52
|
- [Export Mnemonic](#export-mnemonic)
|
|
44
53
|
|
|
45
54
|
### 🔄 Multi-Transfer Operations
|
|
46
55
|
- [Batch Send Native Tokens](#batch-send-native-tokens)
|
|
47
56
|
- [Batch Send ERC-20 Tokens](#batch-send-erc-20-tokens)
|
|
57
|
+
- [Multi-Transfer (Batch Send) - Simple Usage](#multi-transfer-batch-send---simple-usage)
|
|
48
58
|
|
|
49
59
|
### 📱 QR Code Functionality
|
|
50
60
|
- [Generate Address QR](#generate-address-qr)
|
|
@@ -76,6 +86,9 @@ A comprehensive, secure, and user-friendly wallet SDK for React Native applicati
|
|
|
76
86
|
- [React Native NFT Component Example](#react-native-nft-component-example)
|
|
77
87
|
- [Get Owned NFTs](#get-owned-nfts)
|
|
78
88
|
- [Transfer NFT](#transfer-nft)
|
|
89
|
+
- [Transfer Solana NFT](#transfer-solana-nft)
|
|
90
|
+
- [Get Solana NFT Balance](#get-solana-nft-balance)
|
|
91
|
+
- [Get Solana NFT Details](#get-solana-nft-details)
|
|
79
92
|
- [Estimate NFT Transfer Gas](#estimate-nft-transfer-gas)
|
|
80
93
|
|
|
81
94
|
### ⛽ Advanced Features
|
|
@@ -122,7 +135,26 @@ A comprehensive, secure, and user-friendly wallet SDK for React Native applicati
|
|
|
122
135
|
### 🛠️ Development
|
|
123
136
|
- [Contributing](#contributing)
|
|
124
137
|
|
|
138
|
+
### 🔥 New API: Simple chainId-based usage
|
|
139
|
+
- [Simple chainId-based usage](#new-api-simple-chainid-based-usage)
|
|
140
|
+
|
|
141
|
+
### 📱 QR Code Functionality
|
|
142
|
+
- [Generate Address QR](#generate-address-qr)
|
|
143
|
+
- [Generate Mnemonic QR](#generate-mnemonic-qr)
|
|
144
|
+
- [Generate Transaction QR](#generate-transaction-qr)
|
|
145
|
+
- [Import Wallet from QR](#import-wallet-from-qr)
|
|
146
|
+
- [Process Transaction from QR](#process-transaction-from-qr)
|
|
147
|
+
- [Validate QR Code](#validate-qr-code)
|
|
148
|
+
- [Generate EIP-681 Compatible Address QR](#generate-eip-681-compatible-address-qr-for-metamask-binance-trust-wallet)
|
|
149
|
+
|
|
125
150
|
### 🛠️ Advanced Transaction Utilities
|
|
151
|
+
- [Build Generic Transaction](#build-generic-transaction)
|
|
152
|
+
- [Sign Transaction (Vault)](#sign-transaction-recommended---using-vault)
|
|
153
|
+
- [Sign Transaction (Private Key)](#sign-transaction-deprecated---using-private-key)
|
|
154
|
+
- [Send Raw Transaction](#send-raw-transaction)
|
|
155
|
+
- [Approve Token (Vault)](#approve-token-recommended---using-vault)
|
|
156
|
+
- [Approve Token (Private Key)](#approve-token-deprecated---using-private-key)
|
|
157
|
+
- [Track Transaction Status](#track-transaction-status)
|
|
126
158
|
|
|
127
159
|
### Build Generic Transaction
|
|
128
160
|
Builds an unsigned transaction for any contract method.
|
|
@@ -975,7 +1007,7 @@ The PWC Wallet SDK with direct provider injection provides **universal dApp comp
|
|
|
975
1007
|
|
|
976
1008
|
#### ✅ **One Setup, Universal Access:**
|
|
977
1009
|
```typescript
|
|
978
|
-
// Mobile
|
|
1010
|
+
// Mobile developers only need to setup once
|
|
979
1011
|
<DAppBrowser
|
|
980
1012
|
vault={vault}
|
|
981
1013
|
initialUrl="https://pancakeswap.finance/"
|
|
@@ -1194,7 +1226,7 @@ Transfers an NFT (ERC-721) from one address to another.
|
|
|
1194
1226
|
- `tokenId` - Token ID to transfer (string)
|
|
1195
1227
|
|
|
1196
1228
|
```typescript
|
|
1197
|
-
//
|
|
1229
|
+
// Send ERC-721 NFT from this wallet to another wallet
|
|
1198
1230
|
const tx = await vault.transferNFT(
|
|
1199
1231
|
'0xSenderAddress',
|
|
1200
1232
|
'0xRecipientAddress',
|
|
@@ -1204,7 +1236,88 @@ const tx = await vault.transferNFT(
|
|
|
1204
1236
|
console.log('NFT transfer tx hash:', tx.hash);
|
|
1205
1237
|
```
|
|
1206
1238
|
|
|
1207
|
-
> **Note:**
|
|
1239
|
+
> **Note:** Currently supports EVM chains (Ethereum, BSC, etc.) and Solana NFTs. Solana NFT transfers are now fully supported!
|
|
1240
|
+
|
|
1241
|
+
#### Transfer Solana NFT
|
|
1242
|
+
Transfers a Solana NFT from one address to another using the dedicated Solana NFT method.
|
|
1243
|
+
|
|
1244
|
+
**Parameters:**
|
|
1245
|
+
- `fromAddress` - Sender's address
|
|
1246
|
+
- `toAddress` - Recipient's address
|
|
1247
|
+
- `mintAddress` - The NFT mint address
|
|
1248
|
+
- `commitment` - Optional commitment level (default: 'confirmed')
|
|
1249
|
+
|
|
1250
|
+
```typescript
|
|
1251
|
+
// Transfer a Solana NFT
|
|
1252
|
+
const tx = await vault.transferSolanaNFT(
|
|
1253
|
+
'0xYourAddress...',
|
|
1254
|
+
'0xRecipient...',
|
|
1255
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // NFT mint address
|
|
1256
|
+
);
|
|
1257
|
+
console.log('Solana NFT transfer hash:', tx.hash);
|
|
1258
|
+
|
|
1259
|
+
// With custom commitment level
|
|
1260
|
+
const txFast = await vault.transferSolanaNFT(
|
|
1261
|
+
'0xYourAddress...',
|
|
1262
|
+
'0xRecipient...',
|
|
1263
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
1264
|
+
'processed' // Fastest confirmation
|
|
1265
|
+
);
|
|
1266
|
+
```
|
|
1267
|
+
|
|
1268
|
+
#### Get Solana NFT Balance
|
|
1269
|
+
Gets Solana NFT balance for a specific address.
|
|
1270
|
+
|
|
1271
|
+
**Parameters:**
|
|
1272
|
+
- `address` - Wallet address to check balance for
|
|
1273
|
+
- `mintAddress` - The NFT mint address
|
|
1274
|
+
- `commitment` - Optional commitment level (default: 'confirmed')
|
|
1275
|
+
|
|
1276
|
+
```typescript
|
|
1277
|
+
// Check if you own a specific Solana NFT
|
|
1278
|
+
const balance = await vault.getSolanaNFTBalance(
|
|
1279
|
+
'0xYourAddress...',
|
|
1280
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1281
|
+
);
|
|
1282
|
+
|
|
1283
|
+
if (balance.count > 0) {
|
|
1284
|
+
console.log('You own this NFT!');
|
|
1285
|
+
} else {
|
|
1286
|
+
console.log('You do not own this NFT');
|
|
1287
|
+
}
|
|
1288
|
+
```
|
|
1289
|
+
|
|
1290
|
+
#### Get Solana NFT Details
|
|
1291
|
+
Gets detailed Solana NFT information with metadata.
|
|
1292
|
+
|
|
1293
|
+
**Parameters:**
|
|
1294
|
+
- `mintAddress` - The NFT mint address
|
|
1295
|
+
- `options` - Query options for additional data
|
|
1296
|
+
- `commitment` - Optional commitment level (default: 'confirmed')
|
|
1297
|
+
|
|
1298
|
+
```typescript
|
|
1299
|
+
// Get basic Solana NFT information
|
|
1300
|
+
const nftDetail = await vault.getSolanaNFTDetail(
|
|
1301
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1302
|
+
);
|
|
1303
|
+
console.log('NFT Name:', nftDetail.name);
|
|
1304
|
+
console.log('Owner:', nftDetail.owner);
|
|
1305
|
+
console.log('Token Type:', nftDetail.tokenType); // 'SPL-NFT'
|
|
1306
|
+
|
|
1307
|
+
// Get extended information with metadata
|
|
1308
|
+
const nftDetailExtended = await vault.getSolanaNFTDetail(
|
|
1309
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
1310
|
+
{
|
|
1311
|
+
includeMetadata: true,
|
|
1312
|
+
includeHistory: true,
|
|
1313
|
+
includeCollection: true
|
|
1314
|
+
}
|
|
1315
|
+
);
|
|
1316
|
+
console.log('Description:', nftDetailExtended.description);
|
|
1317
|
+
console.log('Image URL:', nftDetailExtended.image);
|
|
1318
|
+
console.log('Attributes:', nftDetailExtended.attributes);
|
|
1319
|
+
console.log('Transaction History:', nftDetailExtended.transactionHistory);
|
|
1320
|
+
```
|
|
1208
1321
|
|
|
1209
1322
|
---
|
|
1210
1323
|
|
|
@@ -1360,7 +1473,7 @@ console.log('ERC-1155 transfer gas:', erc1155TransferGas.toString());
|
|
|
1360
1473
|
|
|
1361
1474
|
- 🔐 **Secure HD Wallet Management**: BIP-44 compliant hierarchical deterministic wallets
|
|
1362
1475
|
- 🎯 **Vanity Address Generation**: Generate wallets with custom address prefixes
|
|
1363
|
-
- 🔗 **Multi-Chain Support**: Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, and
|
|
1476
|
+
- 🔗 **Multi-Chain Support**: Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, Solana, and TRON
|
|
1364
1477
|
- 🚀 **Multi-Transfer Operations**: Batch send tokens to multiple recipients
|
|
1365
1478
|
- 🔧 **Custom Chain Support**: Add custom chains and override built-in configurations
|
|
1366
1479
|
- 📱 **React Native Optimized**: Designed specifically for mobile applications
|
|
@@ -1427,6 +1540,13 @@ const { vault, encryptedVault } = await Vault.createFromMnemonic(
|
|
|
1427
1540
|
'solana'
|
|
1428
1541
|
);
|
|
1429
1542
|
|
|
1543
|
+
// For TRON
|
|
1544
|
+
const { vault, encryptedVault } = await Vault.createFromMnemonic(
|
|
1545
|
+
existingMnemonic,
|
|
1546
|
+
'your-secure-password',
|
|
1547
|
+
'tron'
|
|
1548
|
+
);
|
|
1549
|
+
|
|
1430
1550
|
// Get wallet accounts
|
|
1431
1551
|
const accounts = vault.getAccounts();
|
|
1432
1552
|
console.log('Imported wallet addresses:', accounts.map(acc => acc.address));
|
|
@@ -1679,6 +1799,13 @@ const newSolanaAccount = vault.addSolanaAccount();
|
|
|
1679
1799
|
console.log('New Solana account:', newSolanaAccount.address);
|
|
1680
1800
|
```
|
|
1681
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
|
+
|
|
1682
1809
|
#### Import Account
|
|
1683
1810
|
```typescript
|
|
1684
1811
|
// Import an existing account with private key
|
|
@@ -1727,9 +1854,175 @@ console.log('Transaction hash:', tx.hash);
|
|
|
1727
1854
|
|
|
1728
1855
|
#### Send Token
|
|
1729
1856
|
```typescript
|
|
1730
|
-
// Send ERC-20 tokens
|
|
1857
|
+
// Send ERC-20 tokens on EVM chains
|
|
1731
1858
|
const tx = await vault.sendToken(from, to, amount, tokenAddress, '1');
|
|
1732
1859
|
console.log('Transaction hash:', tx.hash);
|
|
1860
|
+
|
|
1861
|
+
// Send SPL tokens on Solana
|
|
1862
|
+
const solanaTx = await vault.sendSPLToken(
|
|
1863
|
+
from,
|
|
1864
|
+
to,
|
|
1865
|
+
amount,
|
|
1866
|
+
tokenAddress // SPL token mint address
|
|
1867
|
+
);
|
|
1868
|
+
console.log('Solana transaction hash:', solanaTx.hash);
|
|
1869
|
+
```
|
|
1870
|
+
|
|
1871
|
+
#### Send SPL Token (Solana)
|
|
1872
|
+
```typescript
|
|
1873
|
+
// Send USDC on Solana
|
|
1874
|
+
const usdcTx = await vault.sendSPLToken(
|
|
1875
|
+
'0xYourAddress...',
|
|
1876
|
+
'0xRecipient...',
|
|
1877
|
+
'100', // 100 USDC
|
|
1878
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC mint address
|
|
1879
|
+
);
|
|
1880
|
+
|
|
1881
|
+
// Send USDT on Solana
|
|
1882
|
+
const usdtTx = await vault.sendSPLToken(
|
|
1883
|
+
'0xYourAddress...',
|
|
1884
|
+
'0xRecipient...',
|
|
1885
|
+
'50', // 50 USDT
|
|
1886
|
+
'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB' // USDT mint address
|
|
1887
|
+
);
|
|
1888
|
+
|
|
1889
|
+
// Get SPL token balance
|
|
1890
|
+
const usdcBalance = await vault.getSPLTokenBalance(
|
|
1891
|
+
'0xYourAddress...',
|
|
1892
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1893
|
+
);
|
|
1894
|
+
console.log('USDC Balance:', usdcBalance.toString());
|
|
1895
|
+
|
|
1896
|
+
// Get SPL token information
|
|
1897
|
+
const tokenInfo = await vault.getSPLTokenInfo(
|
|
1898
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1899
|
+
);
|
|
1900
|
+
console.log('Token:', tokenInfo.name, '(', tokenInfo.symbol, ')');
|
|
1901
|
+
console.log('Decimals:', tokenInfo.decimals);
|
|
1902
|
+
|
|
1903
|
+
// Estimate SPL token transfer fee
|
|
1904
|
+
const transferFee = await vault.estimateSPLTokenTransferFee(
|
|
1905
|
+
'0xYourAddress...',
|
|
1906
|
+
'0xRecipient...',
|
|
1907
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1908
|
+
);
|
|
1909
|
+
console.log('Estimated fee:', transferFee.toString(), 'lamports');
|
|
1910
|
+
```
|
|
1911
|
+
|
|
1912
|
+
#### Popular Solana SPL Tokens
|
|
1913
|
+
|
|
1914
|
+
**Mainnet Token Addresses:**
|
|
1915
|
+
```typescript
|
|
1916
|
+
// USDC (USD Coin)
|
|
1917
|
+
const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
|
|
1918
|
+
|
|
1919
|
+
// USDT (Tether)
|
|
1920
|
+
const USDT_MINT = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB';
|
|
1921
|
+
|
|
1922
|
+
// BONK (Bonk)
|
|
1923
|
+
const BONK_MINT = 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263';
|
|
1924
|
+
|
|
1925
|
+
// JUP (Jupiter)
|
|
1926
|
+
const JUP_MINT = 'JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN';
|
|
1927
|
+
```
|
|
1928
|
+
|
|
1929
|
+
**Devnet Token Addresses (for testing):**
|
|
1930
|
+
```typescript
|
|
1931
|
+
// USDC Devnet
|
|
1932
|
+
const USDC_DEVNET = '4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU';
|
|
1933
|
+
|
|
1934
|
+
// USDT Devnet
|
|
1935
|
+
const USDT_DEVNET = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB';
|
|
1936
|
+
```
|
|
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';
|
|
1733
2026
|
```
|
|
1734
2027
|
|
|
1735
2028
|
#### Export Mnemonic
|
|
@@ -1745,7 +2038,7 @@ console.log('Mnemonic:', mnemonic);
|
|
|
1745
2038
|
```typescript
|
|
1746
2039
|
import { MultiTransferService } from 'pwc-wallet-sdk';
|
|
1747
2040
|
|
|
1748
|
-
const multiTransferService = new MultiTransferService(vault, chainService, '1'); // '1'
|
|
2041
|
+
const multiTransferService = new MultiTransferService(vault, chainService, '1'); // '1' is chainId for Ethereum mainnet
|
|
1749
2042
|
const recipients = [
|
|
1750
2043
|
{ address: '0x1111...', amount: '0.01' },
|
|
1751
2044
|
{ address: '0x2222...', amount: '0.02' },
|
|
@@ -2148,7 +2441,7 @@ const balance = await getTokenBalance('0xToken...', '0x123...', '1');
|
|
|
2148
2441
|
### Example: MultiTransfer
|
|
2149
2442
|
```ts
|
|
2150
2443
|
import { MultiTransferService } from 'pwc-wallet-sdk';
|
|
2151
|
-
const service = new MultiTransferService(vault, chainService, '1'); //
|
|
2444
|
+
const service = new MultiTransferService(vault, chainService, '1'); // pass chainId explicitly
|
|
2152
2445
|
await service.transferNativeTokens('0x123...', [{ address: '0xabc...', amount: '0.1' }], '1');
|
|
2153
2446
|
```
|
|
2154
2447
|
|
package/dist/Vault.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type EncryptedData } from './crypto/EncryptionService';
|
|
2
2
|
import { type ChainId } from './config/chains';
|
|
3
3
|
import { Recipient, MultiTransferResult } from './types/multiTransfer';
|
|
4
|
-
import { NFTDetailExtended, NFTOptions } from './types/nft';
|
|
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 '
|
|
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 '
|
|
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)
|
|
@@ -150,6 +156,96 @@ export declare class Vault {
|
|
|
150
156
|
* @throws Error if insufficient balance, invalid addresses, or transaction fails
|
|
151
157
|
*/
|
|
152
158
|
sendToken(fromAddress: string, to: string, amount: string, tokenAddress: string, chainId: ChainId): Promise<TransactionResponse>;
|
|
159
|
+
/**
|
|
160
|
+
* Sends SPL tokens on Solana blockchain with enhanced validation and error handling.
|
|
161
|
+
* This method is specifically designed for Solana SPL token transfers.
|
|
162
|
+
* @param fromAddress - The sender's account address
|
|
163
|
+
* @param to - The recipient's address
|
|
164
|
+
* @param amount - The amount of tokens to send as a string
|
|
165
|
+
* @param tokenAddress - The SPL token mint address
|
|
166
|
+
* @param commitment - Optional commitment level for the transaction (default: 'confirmed')
|
|
167
|
+
* @returns Promise resolving to the transaction response with hash and details
|
|
168
|
+
* @throws Error if insufficient balance, invalid addresses, or transaction fails
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* // Send USDC on Solana
|
|
173
|
+
* const tx = await vault.sendSPLToken(
|
|
174
|
+
* '0xYourAddress...',
|
|
175
|
+
* '0xRecipient...',
|
|
176
|
+
* '100', // 100 USDC
|
|
177
|
+
* 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC mint address
|
|
178
|
+
* );
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
sendSPLToken(fromAddress: string, to: string, amount: string, tokenAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<TransactionResponse>;
|
|
182
|
+
/**
|
|
183
|
+
* Gets SPL token balance for a specific address on Solana.
|
|
184
|
+
* @param address - The account address to check balance for
|
|
185
|
+
* @param tokenAddress - The SPL token mint address
|
|
186
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
187
|
+
* @returns Promise resolving to the token balance as a bigint
|
|
188
|
+
* @throws Error if the balance query fails
|
|
189
|
+
*/
|
|
190
|
+
getSPLTokenBalance(address: string, tokenAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<bigint>;
|
|
191
|
+
/**
|
|
192
|
+
* Gets SPL token information on Solana.
|
|
193
|
+
* @param tokenAddress - The SPL token mint address
|
|
194
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
195
|
+
* @returns Promise resolving to token metadata
|
|
196
|
+
* @throws Error if the token info query fails
|
|
197
|
+
*/
|
|
198
|
+
getSPLTokenInfo(tokenAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<Token>;
|
|
199
|
+
/**
|
|
200
|
+
* Estimates the transaction fee for SPL token transfers on Solana.
|
|
201
|
+
* @param fromAddress - The sender's account address
|
|
202
|
+
* @param to - The recipient's address
|
|
203
|
+
* @param tokenAddress - The SPL token mint address
|
|
204
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
205
|
+
* @returns Promise resolving to the estimated fee as a bigint in lamports
|
|
206
|
+
* @throws Error if the fee estimation fails
|
|
207
|
+
*/
|
|
208
|
+
estimateSPLTokenTransferFee(fromAddress: string, to: string, tokenAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<bigint>;
|
|
209
|
+
/**
|
|
210
|
+
* Transfers a Solana NFT from one address to another.
|
|
211
|
+
* This method is specifically designed for Solana NFT transfers.
|
|
212
|
+
* @param fromAddress - The sender's account address
|
|
213
|
+
* @param toAddress - The recipient's address
|
|
214
|
+
* @param mintAddress - The NFT mint address
|
|
215
|
+
* @param commitment - Optional commitment level for the transaction (default: 'confirmed')
|
|
216
|
+
* @returns Promise resolving to the transaction response with hash and details
|
|
217
|
+
* @throws Error if insufficient balance, invalid addresses, or transaction fails
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* // Transfer a Solana NFT
|
|
222
|
+
* const tx = await vault.transferSolanaNFT(
|
|
223
|
+
* '0xYourAddress...',
|
|
224
|
+
* '0xRecipient...',
|
|
225
|
+
* 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // NFT mint address
|
|
226
|
+
* );
|
|
227
|
+
* console.log('NFT transfer hash:', tx.hash);
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
transferSolanaNFT(fromAddress: string, toAddress: string, mintAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<TransactionResponse>;
|
|
231
|
+
/**
|
|
232
|
+
* Gets Solana NFT balance for a specific address.
|
|
233
|
+
* @param address - Wallet address to check balance for
|
|
234
|
+
* @param mintAddress - The NFT mint address
|
|
235
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
236
|
+
* @returns Promise resolving to the NFT balance
|
|
237
|
+
* @throws Error if the balance query fails
|
|
238
|
+
*/
|
|
239
|
+
getSolanaNFTBalance(address: string, mintAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<NFTBalance>;
|
|
240
|
+
/**
|
|
241
|
+
* Gets detailed Solana NFT information with metadata.
|
|
242
|
+
* @param mintAddress - The NFT mint address
|
|
243
|
+
* @param options - Query options for additional data
|
|
244
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
245
|
+
* @returns Promise resolving to extended NFT detail
|
|
246
|
+
* @throws Error if the NFT query fails
|
|
247
|
+
*/
|
|
248
|
+
getSolanaNFTDetail(mintAddress: string, options?: NFTOptions, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<NFTDetailExtended>;
|
|
153
249
|
/**
|
|
154
250
|
* Generates a vanity HD wallet with a specific address prefix.
|
|
155
251
|
* Uses default configuration from VANITY_WALLET_CONFIG for optimal settings.
|
|
@@ -490,4 +586,82 @@ export declare class Vault {
|
|
|
490
586
|
* ```
|
|
491
587
|
*/
|
|
492
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>;
|
|
493
667
|
}
|