pwc-sdk-wallet 0.8.0 → 0.8.2

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
@@ -1503,6 +1503,90 @@ npm install pwc-wallet-sdk react-native-webview
1503
1503
 
1504
1504
  **Note:** This is a peer dependency. Mobile developers need to install it to use the DApp Browser features.
1505
1505
 
1506
+ ### React Native Polyfills (Required for TRON Support)
1507
+
1508
+ The SDK uses `tronweb` for TRON blockchain support, which requires Node.js polyfills in React Native. You **must** set up polyfills before using the SDK in a React Native app.
1509
+
1510
+ #### Option 1: Automatic Polyfills (Recommended)
1511
+
1512
+ The SDK automatically applies polyfills when using TRON features, but you still need to install the required packages:
1513
+
1514
+ ```bash
1515
+ npm install buffer process react-native-get-random-values
1516
+ ```
1517
+
1518
+ Then, at the **very top** of your app's entry file (e.g., `index.js` or `App.js`), import the polyfills:
1519
+
1520
+ ```typescript
1521
+ // At the VERY TOP of index.js or App.js - before any other imports
1522
+ import 'react-native-get-random-values';
1523
+ import { Buffer } from 'buffer';
1524
+ import process from 'process';
1525
+
1526
+ // Make them available globally
1527
+ global.Buffer = Buffer;
1528
+ global.process = process;
1529
+ ```
1530
+
1531
+ #### Option 2: Manual Setup
1532
+
1533
+ If you prefer more control, you can manually set up polyfills:
1534
+
1535
+ 1. Install dependencies:
1536
+ ```bash
1537
+ npm install buffer process react-native-get-random-values
1538
+ ```
1539
+
1540
+ 2. Create a polyfill file (e.g., `polyfills.js`):
1541
+ ```typescript
1542
+ import 'react-native-get-random-values';
1543
+ import { Buffer } from 'buffer';
1544
+ import process from 'process';
1545
+
1546
+ global.Buffer = Buffer;
1547
+ global.process = process;
1548
+ ```
1549
+
1550
+ 3. Import it at the top of your entry file:
1551
+ ```typescript
1552
+ import './polyfills';
1553
+ // ... rest of your imports
1554
+ ```
1555
+
1556
+ #### Troubleshooting
1557
+
1558
+ If you encounter errors like:
1559
+ - `RCTFatal` or `TronWebProto.Vote.serializeBinaryToWriter`
1560
+ - `Buffer is not defined`
1561
+ - `process is not defined`
1562
+ - `crypto.getRandomValues is not a function`
1563
+
1564
+ Make sure:
1565
+ 1. ✅ `react-native-get-random-values` is imported **first** (before any crypto operations)
1566
+ 2. ✅ `buffer` and `process` are installed and set as globals
1567
+ 3. ✅ Polyfills are imported **before** importing the SDK
1568
+ 4. ✅ You've restarted your Metro bundler after installing dependencies
1569
+
1570
+ #### Metro Config (Optional but Recommended)
1571
+
1572
+ For better compatibility, you can configure Metro to handle Node.js modules. Create or update `metro.config.js`:
1573
+
1574
+ ```javascript
1575
+ const { getDefaultConfig } = require('metro-config');
1576
+
1577
+ module.exports = (async () => {
1578
+ const {
1579
+ resolver: { sourceExts, assetExts },
1580
+ } = await getDefaultConfig();
1581
+
1582
+ return {
1583
+ resolver: {
1584
+ sourceExts: [...sourceExts, 'cjs'],
1585
+ },
1586
+ };
1587
+ })();
1588
+ ```
1589
+
1506
1590
  ## Quick Start
1507
1591
 
1508
1592
  ### 1. Basic Wallet Creation
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' | 'Tron';
7
+ type: 'HD' | 'Simple' | 'Solana';
8
8
  name: string;
9
9
  }
10
10
  export interface TransactionResponse {
@@ -51,7 +51,7 @@ 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, 'solana' for Solana, or 'tron' for TRON). Defaults to 'evm'
54
+ * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana). 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
  */
@@ -63,7 +63,7 @@ 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, 'solana' for Solana, or 'tron' for TRON). Defaults to 'evm'
66
+ * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana). 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
  */
@@ -92,7 +92,7 @@ export declare class Vault {
92
92
  */
93
93
  addNewSolanaAccount(): Promise<Account>;
94
94
  /**
95
- * Adds a new TRON account derived from the TRON keyring.
95
+ * Adds a new TRON account derived from the TRON keyring. (TEMPORARILY DISABLED)
96
96
  * @returns Promise resolving to the newly created TRON account information
97
97
  * @throws Error if no TRON keyring is available in the vault
98
98
  */
@@ -595,7 +595,7 @@ export declare class Vault {
595
595
  */
596
596
  sendNativeToken(fromAddress: string, to: string, amount: string, chainId: ChainId): Promise<TransactionResponse>;
597
597
  /**
598
- * Sends TRX (native TRON token) to another address.
598
+ * Sends TRX (native TRON token) to another address. (TEMPORARILY DISABLED)
599
599
  * @param fromAddress - The sender's TRON address
600
600
  * @param to - The recipient's TRON address
601
601
  * @param amount - The amount of TRX to send as a string (e.g., "1.5")
package/dist/Vault.js CHANGED
@@ -4,10 +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
+ // import { TronKeyring } from './keyrings/TronKeyring'; // TEMPORARILY DISABLED - tronweb compatibility issues
8
8
  const ChainService_1 = require("./chain/ChainService");
9
9
  const SolanaChainService_1 = require("./chain/SolanaChainService");
10
- const TronChainService_1 = require("./chain/TronChainService");
10
+ // import { TronChainService } from './chain/TronChainService'; // TEMPORARILY DISABLED - tronweb compatibility issues
11
11
  const EncryptionService_1 = require("./crypto/EncryptionService");
12
12
  const chains_1 = require("./config/chains");
13
13
  const constants_1 = require("./config/constants");
@@ -45,7 +45,7 @@ class Vault {
45
45
  /**
46
46
  * Creates a new Vault with a fresh mnemonic.
47
47
  * @param password - The password used to encrypt the vault data
48
- * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana, or 'tron' for TRON). Defaults to 'evm'
48
+ * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana). Defaults to 'evm'
49
49
  * @returns Promise resolving to an object containing the created vault instance and its encrypted data
50
50
  * @throws Error if mnemonic generation or keyring initialization fails
51
51
  */
@@ -59,11 +59,7 @@ class Vault {
59
59
  return { vault, encryptedVault };
60
60
  }
61
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 };
62
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
67
63
  }
68
64
  else {
69
65
  const hdKeyring = new HDKeyring_1.HDKeyring(mnemonic);
@@ -78,7 +74,7 @@ class Vault {
78
74
  * Creates a new Vault from an existing mnemonic phrase.
79
75
  * @param mnemonic - The existing mnemonic phrase (12, 15, 18, 21, or 24 words)
80
76
  * @param password - The password used to encrypt the vault data
81
- * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana, or 'tron' for TRON). Defaults to 'evm'
77
+ * @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains, 'solana' for Solana). Defaults to 'evm'
82
78
  * @returns Promise resolving to an object containing the created vault instance and its encrypted data
83
79
  * @throws Error if mnemonic is invalid or keyring initialization fails
84
80
  */
@@ -91,11 +87,7 @@ class Vault {
91
87
  return { vault, encryptedVault };
92
88
  }
93
89
  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 };
90
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
99
91
  }
100
92
  else {
101
93
  const hdKeyring = new HDKeyring_1.HDKeyring(mnemonic);
@@ -133,10 +125,10 @@ class Vault {
133
125
  }
134
126
  else if (sKeyring.type === 'Solana') {
135
127
  keyrings.push(await SolanaKeyring_1.SolanaKeyring.deserialize(sKeyring));
136
- }
128
+ } /* TEMPORARILY DISABLED - tronweb compatibility issues
137
129
  else if (sKeyring.type === 'Tron') {
138
- keyrings.push(await TronKeyring_1.TronKeyring.deserialize(sKeyring));
139
- }
130
+ keyrings.push(await TronKeyring.deserialize(sKeyring));
131
+ } */
140
132
  else {
141
133
  throw new Error(`Unknown keyring type: ${sKeyring.type}`);
142
134
  }
@@ -150,10 +142,10 @@ class Vault {
150
142
  // Set chain ID based on keyring type
151
143
  if (keyrings.some(k => k instanceof SolanaKeyring_1.SolanaKeyring)) {
152
144
  vault.chainId = 'solana';
153
- }
154
- else if (keyrings.some(k => k instanceof TronKeyring_1.TronKeyring)) {
145
+ } /* TEMPORARILY DISABLED - tronweb compatibility issues
146
+ else if (keyrings.some(k => k instanceof TronKeyring)) {
155
147
  vault.chainId = 'tron';
156
- }
148
+ } */
157
149
  else {
158
150
  vault.chainId = '1'; // Default to Ethereum mainnet
159
151
  }
@@ -196,21 +188,12 @@ class Vault {
196
188
  };
197
189
  }
198
190
  /**
199
- * Adds a new TRON account derived from the TRON keyring.
191
+ * Adds a new TRON account derived from the TRON keyring. (TEMPORARILY DISABLED)
200
192
  * @returns Promise resolving to the newly created TRON account information
201
193
  * @throws Error if no TRON keyring is available in the vault
202
194
  */
203
195
  async addNewTronAccount() {
204
- const tronKeyring = this.keyrings.find(k => k instanceof TronKeyring_1.TronKeyring);
205
- if (!tronKeyring) {
206
- throw new Error('No TRON keyring available to create new accounts.');
207
- }
208
- const newAddress = await tronKeyring.addNewAccount();
209
- return {
210
- address: newAddress,
211
- type: 'Tron',
212
- name: `Tron ${tronKeyring.getAllAccounts().length}`
213
- };
196
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
214
197
  }
215
198
  /**
216
199
  * Imports an account from a private key and adds it to the vault.
@@ -271,8 +254,8 @@ class Vault {
271
254
  name: `Solana ${solanaAccountCount++}`,
272
255
  });
273
256
  }
274
- }
275
- else if (keyring instanceof TronKeyring_1.TronKeyring) {
257
+ } /* TEMPORARILY DISABLED - tronweb compatibility issues
258
+ else if (keyring instanceof TronKeyring) {
276
259
  for (const address of keyring.getAllAccounts()) {
277
260
  accounts.push({
278
261
  address,
@@ -281,6 +264,7 @@ class Vault {
281
264
  });
282
265
  }
283
266
  }
267
+ */
284
268
  }
285
269
  return accounts;
286
270
  }
@@ -401,11 +385,10 @@ class Vault {
401
385
  if (chainInfo.type === 'solana') {
402
386
  const chainService = new SolanaChainService_1.SolanaChainService(privateKey, chainInfo);
403
387
  return chainService.getNativeBalance();
404
- }
388
+ } /* TEMPORARILY DISABLED - tronweb compatibility issues
405
389
  else if (chainInfo.type === 'tron') {
406
- const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
407
- return chainService.getNativeBalance();
408
- }
390
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
391
+ } */
409
392
  else {
410
393
  const chainService = new ChainService_1.ChainService(privateKey, chainInfo);
411
394
  return chainService.getNativeBalance();
@@ -1373,17 +1356,10 @@ class Vault {
1373
1356
  to: result.to,
1374
1357
  blockNumber: result.blockNumber || undefined
1375
1358
  };
1376
- }
1359
+ } /* TEMPORARILY DISABLED - tronweb compatibility issues
1377
1360
  else if (chainInfo.type === 'tron') {
1378
- const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1379
- const result = await chainService.sendTransaction(to, amount);
1380
- return {
1381
- hash: result.hash,
1382
- from: result.from,
1383
- to: result.to,
1384
- blockNumber: result.blockNumber || undefined
1385
- };
1386
- }
1361
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
1362
+ } */
1387
1363
  else {
1388
1364
  const chainService = new ChainService_1.ChainService(privateKey, chainInfo);
1389
1365
  // Create transaction request for native token transfer
@@ -1400,9 +1376,10 @@ class Vault {
1400
1376
  };
1401
1377
  }
1402
1378
  }
1403
- // --- TRON Operations ---
1379
+ // --- TRON Operations --- (TEMPORARILY DISABLED - tronweb compatibility issues)
1380
+ // All TRON-related methods are temporarily disabled due to tronweb compatibility issues with React Native
1404
1381
  /**
1405
- * Sends TRX (native TRON token) to another address.
1382
+ * Sends TRX (native TRON token) to another address. (TEMPORARILY DISABLED)
1406
1383
  * @param fromAddress - The sender's TRON address
1407
1384
  * @param to - The recipient's TRON address
1408
1385
  * @param amount - The amount of TRX to send as a string (e.g., "1.5")
@@ -1417,19 +1394,7 @@ class Vault {
1417
1394
  * ```
1418
1395
  */
1419
1396
  async sendTRX(fromAddress, to, amount) {
1420
- const chainInfo = (0, chains_1.getChainConfig)('tron');
1421
- if (chainInfo.type !== 'tron') {
1422
- throw new Error('TRON chain configuration not found');
1423
- }
1424
- const privateKey = await this.getPrivateKeyFor(fromAddress);
1425
- const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1426
- const result = await chainService.sendTransaction(to, amount);
1427
- return {
1428
- hash: result.hash,
1429
- from: result.from,
1430
- to: result.to,
1431
- blockNumber: result.blockNumber
1432
- };
1397
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
1433
1398
  }
1434
1399
  /**
1435
1400
  * Sends TRC-20 tokens on TRON blockchain.
@@ -1452,19 +1417,7 @@ class Vault {
1452
1417
  * ```
1453
1418
  */
1454
1419
  async sendTRC20Token(fromAddress, to, amount, tokenAddress) {
1455
- const chainInfo = (0, chains_1.getChainConfig)('tron');
1456
- if (chainInfo.type !== 'tron') {
1457
- throw new Error('TRON chain configuration not found');
1458
- }
1459
- const privateKey = await this.getPrivateKeyFor(fromAddress);
1460
- const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1461
- const result = await chainService.sendToken(to, amount, tokenAddress);
1462
- return {
1463
- hash: result.hash,
1464
- from: result.from,
1465
- to: result.to,
1466
- blockNumber: result.blockNumber
1467
- };
1420
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
1468
1421
  }
1469
1422
  /**
1470
1423
  * Gets TRX balance for a specific address on TRON.
@@ -1473,13 +1426,7 @@ class Vault {
1473
1426
  * @throws Error if the balance query fails
1474
1427
  */
1475
1428
  async getTRXBalance(address) {
1476
- const chainInfo = (0, chains_1.getChainConfig)('tron');
1477
- if (chainInfo.type !== 'tron') {
1478
- throw new Error('TRON chain configuration not found');
1479
- }
1480
- const privateKey = await this.getPrivateKeyFor(address);
1481
- const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1482
- return await chainService.getNativeBalance();
1429
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
1483
1430
  }
1484
1431
  /**
1485
1432
  * Gets TRC-20 token balance for a specific address on TRON.
@@ -1489,13 +1436,7 @@ class Vault {
1489
1436
  * @throws Error if the balance query fails
1490
1437
  */
1491
1438
  async getTRC20TokenBalance(address, tokenAddress) {
1492
- const chainInfo = (0, chains_1.getChainConfig)('tron');
1493
- if (chainInfo.type !== 'tron') {
1494
- throw new Error('TRON chain configuration not found');
1495
- }
1496
- const privateKey = await this.getPrivateKeyFor(address);
1497
- const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1498
- return await chainService.getTokenBalance(tokenAddress);
1439
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
1499
1440
  }
1500
1441
  /**
1501
1442
  * Gets TRC-20 token information.
@@ -1504,21 +1445,7 @@ class Vault {
1504
1445
  * @throws Error if the token query fails
1505
1446
  */
1506
1447
  async getTRC20TokenInfo(tokenAddress) {
1507
- const chainInfo = (0, chains_1.getChainConfig)('tron');
1508
- if (chainInfo.type !== 'tron') {
1509
- throw new Error('TRON chain configuration not found');
1510
- }
1511
- // Use a dummy private key for read-only operations
1512
- const dummyPrivateKey = '0000000000000000000000000000000000000000000000000000000000000001';
1513
- const chainService = new TronChainService_1.TronChainService(dummyPrivateKey, chainInfo);
1514
- const tokenInfo = await chainService.getTokenInfo(tokenAddress);
1515
- return {
1516
- address: tokenInfo.address,
1517
- name: tokenInfo.name,
1518
- symbol: tokenInfo.symbol,
1519
- decimals: tokenInfo.decimals,
1520
- totalSupply: tokenInfo.totalSupply
1521
- };
1448
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
1522
1449
  }
1523
1450
  /**
1524
1451
  * Estimates the transaction fee for a TRX transfer.
@@ -1529,13 +1456,7 @@ class Vault {
1529
1456
  * @throws Error if the estimation fails
1530
1457
  */
1531
1458
  async estimateTRXTransferFee(fromAddress, to, amount) {
1532
- const chainInfo = (0, chains_1.getChainConfig)('tron');
1533
- if (chainInfo.type !== 'tron') {
1534
- throw new Error('TRON chain configuration not found');
1535
- }
1536
- const privateKey = await this.getPrivateKeyFor(fromAddress);
1537
- const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1538
- return await chainService.estimateTransactionFee(to, amount);
1459
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
1539
1460
  }
1540
1461
  /**
1541
1462
  * Estimates the transaction fee for a TRC-20 token transfer.
@@ -1547,13 +1468,7 @@ class Vault {
1547
1468
  * @throws Error if the estimation fails
1548
1469
  */
1549
1470
  async estimateTRC20TransferFee(fromAddress, to, amount, tokenAddress) {
1550
- const chainInfo = (0, chains_1.getChainConfig)('tron');
1551
- if (chainInfo.type !== 'tron') {
1552
- throw new Error('TRON chain configuration not found');
1553
- }
1554
- const privateKey = await this.getPrivateKeyFor(fromAddress);
1555
- const chainService = new TronChainService_1.TronChainService(privateKey, chainInfo);
1556
- return await chainService.estimateTokenTransferFee(to, amount, tokenAddress);
1471
+ throw new Error('TRON support is temporarily disabled due to tronweb compatibility issues with React Native.');
1557
1472
  }
1558
1473
  }
1559
1474
  exports.Vault = Vault;
package/dist/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export type { Account } from './Vault';
3
3
  export type { ChainId, ChainConfig } from './config/chains';
4
4
  export type { EncryptedData } from './crypto/EncryptionService';
5
5
  export type { Token } from './chain/ChainService';
6
- export type { TronTransactionResponse, TronToken } from './chain/TronChainService';
7
6
  export type { Recipient, MultiTransferOptions, MultiTransferResult, BatchResult, ValidationResult } from './types/multiTransfer';
8
7
  export type { QRCodeData, WalletImportData, TransactionData } from './services/QRCodeService';
9
8
  export { SUPPORTED_CHAINS, DERIVATION_PATHS, registerCustomChain, overrideChain, overrideChains, getChainConfig, setupChainConfigs, getAllAvailableChains, clearCustomChains, clearOverrides, clearOverride, getCustomChains, getOverrides, setGlobalRPCConfig, setGlobalExplorerConfig, clearGlobalConfigs } from './config/chains';
@@ -13,10 +12,8 @@ export { getEnvironmentConfig, validateEnvironmentConfig, getEnvVar, getEnvVarNu
13
12
  export { HDKeyring } from './keyrings/HDKeyring';
14
13
  export { SimpleKeyring } from './keyrings/SimpleKeyring';
15
14
  export { SolanaKeyring } from './keyrings/SolanaKeyring';
16
- export { TronKeyring } from './keyrings/TronKeyring';
17
15
  export { ChainService } from './chain/ChainService';
18
16
  export { SolanaChainService } from './chain/SolanaChainService';
19
- export { TronChainService } from './chain/TronChainService';
20
17
  export { EncryptionService } from './crypto/EncryptionService';
21
18
  export { MultiTransferService } from './services/MultiTransferService';
22
19
  export { BatchProcessor } from './services/BatchProcessor';
package/dist/index.js CHANGED
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.TransactionHandler = exports.MessageBridgeService = exports.BrowserProviderService = exports.QRCodeService = exports.BatchProcessor = exports.MultiTransferService = exports.EncryptionService = exports.TronChainService = exports.SolanaChainService = exports.ChainService = exports.TronKeyring = exports.SolanaKeyring = exports.SimpleKeyring = exports.HDKeyring = exports.getEnvVarBoolean = exports.getEnvVarBigInt = exports.getEnvVarNumber = exports.getEnvVar = exports.validateEnvironmentConfig = exports.getEnvironmentConfig = exports.VALIDATION_CONFIG = exports.CACHE_CONFIG = exports.NETWORK_CONFIG = exports.SECURITY_CONFIG = exports.VANITY_WALLET_CONFIG = exports.clearGlobalGasConfigs = exports.getGasConfig = exports.setGlobalNetworkGasConfig = exports.setGlobalGasConfig = exports.calculateOptimalGasPrice = exports.getNetworkGasConfig = exports.NETWORK_GAS_CONFIG = exports.GAS_CONFIG = exports.clearGlobalConfigs = exports.setGlobalExplorerConfig = exports.setGlobalRPCConfig = exports.getOverrides = exports.getCustomChains = exports.clearOverride = exports.clearOverrides = exports.clearCustomChains = exports.getAllAvailableChains = exports.setupChainConfigs = exports.getChainConfig = exports.overrideChains = exports.overrideChain = exports.registerCustomChain = exports.DERIVATION_PATHS = exports.SUPPORTED_CHAINS = exports.Vault = void 0;
19
- exports.usePWCWallet = exports.ConnectionModal = exports.TransactionModal = exports.DAppBrowser = void 0;
18
+ exports.TransactionModal = exports.DAppBrowser = exports.TransactionHandler = exports.MessageBridgeService = exports.BrowserProviderService = exports.QRCodeService = exports.BatchProcessor = exports.MultiTransferService = exports.EncryptionService = exports.SolanaChainService = exports.ChainService = exports.SolanaKeyring = exports.SimpleKeyring = exports.HDKeyring = exports.getEnvVarBoolean = exports.getEnvVarBigInt = exports.getEnvVarNumber = exports.getEnvVar = exports.validateEnvironmentConfig = exports.getEnvironmentConfig = exports.VALIDATION_CONFIG = exports.CACHE_CONFIG = exports.NETWORK_CONFIG = exports.SECURITY_CONFIG = exports.VANITY_WALLET_CONFIG = exports.clearGlobalGasConfigs = exports.getGasConfig = exports.setGlobalNetworkGasConfig = exports.setGlobalGasConfig = exports.calculateOptimalGasPrice = exports.getNetworkGasConfig = exports.NETWORK_GAS_CONFIG = exports.GAS_CONFIG = exports.clearGlobalConfigs = exports.setGlobalExplorerConfig = exports.setGlobalRPCConfig = exports.getOverrides = exports.getCustomChains = exports.clearOverride = exports.clearOverrides = exports.clearCustomChains = exports.getAllAvailableChains = exports.setupChainConfigs = exports.getChainConfig = exports.overrideChains = exports.overrideChain = exports.registerCustomChain = exports.DERIVATION_PATHS = exports.SUPPORTED_CHAINS = exports.Vault = void 0;
19
+ exports.usePWCWallet = exports.ConnectionModal = void 0;
20
20
  // The primary `Vault` class is the main entry point for interacting with the SDK.
21
21
  var Vault_1 = require("./Vault");
22
22
  Object.defineProperty(exports, "Vault", { enumerable: true, get: function () { return Vault_1.Vault; } });
@@ -73,15 +73,13 @@ var SimpleKeyring_1 = require("./keyrings/SimpleKeyring");
73
73
  Object.defineProperty(exports, "SimpleKeyring", { enumerable: true, get: function () { return SimpleKeyring_1.SimpleKeyring; } });
74
74
  var SolanaKeyring_1 = require("./keyrings/SolanaKeyring");
75
75
  Object.defineProperty(exports, "SolanaKeyring", { enumerable: true, get: function () { return SolanaKeyring_1.SolanaKeyring; } });
76
- var TronKeyring_1 = require("./keyrings/TronKeyring");
77
- Object.defineProperty(exports, "TronKeyring", { enumerable: true, get: function () { return TronKeyring_1.TronKeyring; } });
76
+ // export { TronKeyring } from './keyrings/TronKeyring'; // TEMPORARILY DISABLED
78
77
  // Chain services
79
78
  var ChainService_1 = require("./chain/ChainService");
80
79
  Object.defineProperty(exports, "ChainService", { enumerable: true, get: function () { return ChainService_1.ChainService; } });
81
80
  var SolanaChainService_1 = require("./chain/SolanaChainService");
82
81
  Object.defineProperty(exports, "SolanaChainService", { enumerable: true, get: function () { return SolanaChainService_1.SolanaChainService; } });
83
- var TronChainService_1 = require("./chain/TronChainService");
84
- Object.defineProperty(exports, "TronChainService", { enumerable: true, get: function () { return TronChainService_1.TronChainService; } });
82
+ // export { TronChainService } from './chain/TronChainService'; // TEMPORARILY DISABLED
85
83
  // `EncryptionService` provides access to the underlying encryption/decryption methods.
86
84
  var EncryptionService_1 = require("./crypto/EncryptionService");
87
85
  Object.defineProperty(exports, "EncryptionService", { enumerable: true, get: function () { return EncryptionService_1.EncryptionService; } });
@@ -156,5 +156,5 @@ class HDKeyring {
156
156
  }
157
157
  }
158
158
  exports.HDKeyring = HDKeyring;
159
- // Cache để tránh tạo lại seed
159
+ // Cache to avoid recreating seed
160
160
  HDKeyring.seedCache = new Map();
@@ -137,7 +137,7 @@ class SolanaKeyring {
137
137
  if (data.type !== 'Solana' || !data.mnemonic) {
138
138
  throw new Error('Invalid data for SolanaKeyring deserialization.');
139
139
  }
140
- // Chỉ khôi phục mnemonic, không khôi phục lại accounts
140
+ // Only restore mnemonic, do not restore accounts
141
141
  return new SolanaKeyring(data.mnemonic);
142
142
  }
143
143
  /**
@@ -0,0 +1,34 @@
1
+ /**
2
+ * React Native Polyfills
3
+ *
4
+ * This file provides necessary polyfills for Node.js APIs that are required
5
+ * by dependencies like tronweb (which uses Protocol Buffers).
6
+ *
7
+ * IMPORTANT: This file must be imported at the very beginning of your app entry point
8
+ * (e.g., index.js or App.js) BEFORE any other imports that use these polyfills.
9
+ *
10
+ * Usage in React Native app:
11
+ * ```typescript
12
+ * // At the very top of index.js or App.js
13
+ * import 'pwc-sdk-wallet/dist/polyfills/react-native';
14
+ *
15
+ * // Then import other modules
16
+ * import { Vault } from 'pwc-sdk-wallet';
17
+ * ```
18
+ *
19
+ * Alternatively, you can install the required polyfills in your app:
20
+ * ```bash
21
+ * npm install buffer process react-native-get-random-values
22
+ * ```
23
+ *
24
+ * And import them at the top of your entry file:
25
+ * ```typescript
26
+ * import 'react-native-get-random-values';
27
+ * import { Buffer } from 'buffer';
28
+ * import process from 'process';
29
+ *
30
+ * global.Buffer = Buffer;
31
+ * global.process = process;
32
+ * ```
33
+ */
34
+ export {};
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ /**
3
+ * React Native Polyfills
4
+ *
5
+ * This file provides necessary polyfills for Node.js APIs that are required
6
+ * by dependencies like tronweb (which uses Protocol Buffers).
7
+ *
8
+ * IMPORTANT: This file must be imported at the very beginning of your app entry point
9
+ * (e.g., index.js or App.js) BEFORE any other imports that use these polyfills.
10
+ *
11
+ * Usage in React Native app:
12
+ * ```typescript
13
+ * // At the very top of index.js or App.js
14
+ * import 'pwc-sdk-wallet/dist/polyfills/react-native';
15
+ *
16
+ * // Then import other modules
17
+ * import { Vault } from 'pwc-sdk-wallet';
18
+ * ```
19
+ *
20
+ * Alternatively, you can install the required polyfills in your app:
21
+ * ```bash
22
+ * npm install buffer process react-native-get-random-values
23
+ * ```
24
+ *
25
+ * And import them at the top of your entry file:
26
+ * ```typescript
27
+ * import 'react-native-get-random-values';
28
+ * import { Buffer } from 'buffer';
29
+ * import process from 'process';
30
+ *
31
+ * global.Buffer = Buffer;
32
+ * global.process = process;
33
+ * ```
34
+ */
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const isReactNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative' ||
37
+ (typeof window !== 'undefined' && window?.ReactNativeWebView !== undefined);
38
+ // Only apply polyfills in React Native environment
39
+ if (isReactNative || typeof window === 'undefined') {
40
+ // Polyfill Buffer
41
+ if (typeof global.Buffer === 'undefined') {
42
+ try {
43
+ global.Buffer = require('buffer').Buffer;
44
+ }
45
+ catch (e) {
46
+ console.warn('Failed to load buffer polyfill:', e);
47
+ }
48
+ }
49
+ // Polyfill process
50
+ if (typeof global.process === 'undefined') {
51
+ try {
52
+ global.process = require('process');
53
+ }
54
+ catch (e) {
55
+ // Fallback minimal process object
56
+ global.process = {
57
+ env: {},
58
+ version: '',
59
+ versions: {},
60
+ platform: 'react-native',
61
+ nextTick: (fn) => setTimeout(() => fn(), 0),
62
+ browser: true,
63
+ };
64
+ }
65
+ }
66
+ // Ensure process.env exists
67
+ if (!global.process.env) {
68
+ global.process.env = {};
69
+ }
70
+ // Polyfill crypto.getRandomValues (required by react-native-get-random-values)
71
+ // This should be imported by the app, but we ensure it's available
72
+ if (typeof global.crypto === 'undefined' || !global.crypto.getRandomValues) {
73
+ try {
74
+ // Try to use react-native-get-random-values if available
75
+ require('react-native-get-random-values');
76
+ }
77
+ catch (e) {
78
+ // Fallback implementation
79
+ if (typeof global.crypto === 'undefined') {
80
+ global.crypto = {};
81
+ }
82
+ if (!global.crypto.getRandomValues) {
83
+ global.crypto.getRandomValues = function (arr) {
84
+ if (arr) {
85
+ const view = new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
86
+ for (let i = 0; i < view.length; i++) {
87
+ view[i] = Math.floor(Math.random() * 256);
88
+ }
89
+ }
90
+ return arr;
91
+ };
92
+ }
93
+ }
94
+ }
95
+ // Polyfill TextEncoder/TextDecoder if not available
96
+ if (typeof global.TextEncoder === 'undefined') {
97
+ try {
98
+ const { TextEncoder, TextDecoder } = require('util');
99
+ global.TextEncoder = TextEncoder;
100
+ global.TextDecoder = TextDecoder;
101
+ }
102
+ catch (e) {
103
+ // Use polyfill if util is not available
104
+ try {
105
+ const { TextEncoder: TE, TextDecoder: TD } = require('text-encoding');
106
+ global.TextEncoder = TE;
107
+ global.TextDecoder = TD;
108
+ }
109
+ catch (e2) {
110
+ console.warn('TextEncoder/TextDecoder polyfills not available');
111
+ }
112
+ }
113
+ }
114
+ // Ensure global is available
115
+ if (typeof global === 'undefined' && typeof window !== 'undefined') {
116
+ window.global = window;
117
+ }
118
+ }