pwc-sdk-wallet 0.8.3 → 0.8.4

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/dist/Vault.js CHANGED
@@ -1000,6 +1000,7 @@ class Vault {
1000
1000
  const chainService = new ChainService_1.ChainService(privateKey, chainInfo);
1001
1001
  const tx = {
1002
1002
  to: to,
1003
+ // @ts-expect-error - ethers v6 parseEther compatibility
1003
1004
  value: ethers_1.ethers.parseEther(amount)
1004
1005
  };
1005
1006
  return chainService.estimateGas(tx);
@@ -1041,6 +1042,7 @@ class Vault {
1041
1042
  const chainService = new ChainService_1.ChainService(privateKey, chainInfo);
1042
1043
  // Get token info to parse amount correctly
1043
1044
  const tokenInfo = await chainService.getTokenInfo(tokenAddress);
1045
+ // @ts-expect-error - ethers v6 parseUnits compatibility
1044
1046
  const parsedAmount = ethers_1.ethers.parseUnits(amount, tokenInfo.decimals);
1045
1047
  // Create contract instance for gas estimation
1046
1048
  const contract = new ethers_1.ethers.Contract(tokenAddress, [
@@ -1365,6 +1367,7 @@ class Vault {
1365
1367
  // Create transaction request for native token transfer
1366
1368
  const txRequest = {
1367
1369
  to: to,
1370
+ // @ts-expect-error - ethers v6 parseEther compatibility
1368
1371
  value: ethers_1.ethers.parseEther(amount)
1369
1372
  };
1370
1373
  const result = await chainService.sendTransaction(txRequest);
@@ -28,6 +28,7 @@ class ChainService {
28
28
  if (chainConfig.type !== 'evm') {
29
29
  throw new Error('ChainService only supports EVM chains');
30
30
  }
31
+ // @ts-expect-error - ethers v6 JsonRpcProvider compatibility
31
32
  const provider = new ethers_1.ethers.JsonRpcProvider(chainConfig.rpcUrl);
32
33
  this.wallet = new ethers_1.ethers.Wallet(privateKey, provider);
33
34
  }
@@ -48,7 +49,8 @@ class ChainService {
48
49
  if (!this.wallet.provider) {
49
50
  throw new Error('Provider not set for wallet.');
50
51
  }
51
- return this.wallet.provider.getBalance(this.wallet.address);
52
+ const balance = await this.wallet.provider.getBalance(this.wallet.address);
53
+ return typeof balance === 'bigint' ? balance : BigInt(balance.toString());
52
54
  }
53
55
  /**
54
56
  * Gets the balance of a specific ERC-20 token for the wallet.
@@ -91,7 +93,8 @@ class ChainService {
91
93
  if (!this.wallet.provider) {
92
94
  throw new Error('Provider not set for wallet.');
93
95
  }
94
- return this.wallet.provider.estimateGas(transaction);
96
+ const gas = await this.wallet.provider.estimateGas(transaction);
97
+ return typeof gas === 'bigint' ? gas : BigInt(gas.toString());
95
98
  }
96
99
  /**
97
100
  * Sends a transaction to the blockchain.
@@ -116,6 +119,7 @@ class ChainService {
116
119
  }
117
120
  const contract = new ethers_1.ethers.Contract(tokenAddress, ERC20_ABI, this.wallet);
118
121
  const tokenInfo = await this.getTokenInfo(tokenAddress);
122
+ // @ts-expect-error - ethers v6 parseUnits compatibility
119
123
  const parsedAmount = ethers_1.ethers.parseUnits(amount, tokenInfo.decimals);
120
124
  // The contract instance is connected to the wallet, which will sign and send the transaction.
121
125
  return contract.transfer(to, parsedAmount);
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConnectionModal = void 0;
7
+ // @ts-nocheck - React Native peer dependency
7
8
  const react_1 = __importDefault(require("react"));
8
9
  const react_native_1 = require("react-native");
9
10
  const ConnectionModal = ({ visible, dAppInfo, onApprove, onReject, }) => {
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DAppBrowser = void 0;
37
+ // @ts-nocheck - React Native peer dependency
37
38
  const react_1 = __importStar(require("react"));
38
39
  const react_native_1 = require("react-native");
39
40
  // Note: react-native-webview is a peer dependency
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TransactionModal = void 0;
7
+ // @ts-nocheck - React Native peer dependency
7
8
  const react_1 = __importDefault(require("react"));
8
9
  const react_native_1 = require("react-native");
9
10
  const TransactionModal = ({ visible, transaction, onApprove, onReject, }) => {
@@ -163,6 +163,7 @@ exports.SUPPORTED_CHAINS = {
163
163
  * @returns An ethers.js JsonRpcProvider instance for the specified chain
164
164
  * @throws Error if the chain is not supported or is not an EVM chain
165
165
  */
166
+ // @ts-expect-error - ethers v6 JsonRpcProvider compatibility
166
167
  const getProvider = (chainId) => {
167
168
  const chainInfo = exports.SUPPORTED_CHAINS[chainId];
168
169
  if (!chainInfo) {
@@ -171,6 +172,7 @@ const getProvider = (chainId) => {
171
172
  if (chainInfo.type !== 'evm') {
172
173
  throw new Error(`Chain ${chainId} is not an EVM chain`);
173
174
  }
175
+ // @ts-expect-error - ethers v6 JsonRpcProvider compatibility
174
176
  return new ethers_1.ethers.JsonRpcProvider(chainInfo.rpcUrl);
175
177
  };
176
178
  exports.getProvider = getProvider;
@@ -101,7 +101,10 @@ class SolanaKeyring {
101
101
  if (!Number.isInteger(index) || index < 0) {
102
102
  throw new Error(SolanaKeyring.ERROR_INVALID_INDEX);
103
103
  }
104
- const path = `${chains_1.DERIVATION_PATHS.SOLANA.slice(0, -1)}${index}'`;
104
+ // Solana derivation path: m/44'/501'/0'/{index}'
105
+ // Need to replace the last segment (0') with the account index
106
+ const basePath = chains_1.DERIVATION_PATHS.SOLANA; // "m/44'/501'/0'/0'"
107
+ const path = basePath.replace(/\/\d+'$/, `/${index}'`);
105
108
  const derivedSeed = (0, ed25519_hd_key_1.derivePath)(path, seed.toString('hex')).key;
106
109
  return web3_js_1.Keypair.fromSeed(derivedSeed);
107
110
  }
@@ -32,6 +32,7 @@ class BatchProcessor {
32
32
  // EVM native token transfer
33
33
  txResult = await chainService.sendTransaction({
34
34
  to: recipient.address,
35
+ // @ts-expect-error - ethers v6 parseEther compatibility
35
36
  value: ethers_1.ethers.parseEther(recipient.amount)
36
37
  });
37
38
  }
@@ -164,6 +164,7 @@ class MultiTransferService {
164
164
  const useChainId = chainId || this.chainId;
165
165
  if (isNative) {
166
166
  balance = await (0, TokenUtils_1.getNativeBalance)(address, useChainId);
167
+ // @ts-expect-error - ethers v6 parseEther compatibility
167
168
  amountWei = ethers_1.ethers.parseEther(amount);
168
169
  }
169
170
  else if (tokenAddress) {
@@ -171,13 +172,16 @@ class MultiTransferService {
171
172
  // For token transfers, we need to get token decimals to parse amount correctly
172
173
  // For now, we'll use a default of 18 decimals (most common)
173
174
  // In a real implementation, you'd get this from the token contract
175
+ // @ts-expect-error - ethers v6 parseUnits compatibility
174
176
  amountWei = ethers_1.ethers.parseUnits(amount, 18);
175
177
  }
176
178
  else {
177
179
  throw new Error('Token address required for token balance check');
178
180
  }
179
181
  if (balance < amountWei) {
182
+ // @ts-expect-error - ethers v6 formatEther/formatUnits compatibility
180
183
  const balanceEth = isNative ? ethers_1.ethers.formatEther(balance) : ethers_1.ethers.formatUnits(balance, 18);
184
+ // @ts-expect-error - ethers v6 formatEther/formatUnits compatibility
181
185
  const amountEth = isNative ? ethers_1.ethers.formatEther(amountWei) : ethers_1.ethers.formatUnits(amountWei, 18);
182
186
  throw new Error(`Insufficient balance. Available: ${balanceEth}, Required: ${amountEth}`);
183
187
  }
@@ -202,6 +206,7 @@ class MultiTransferService {
202
206
  // Estimate native token transfer
203
207
  const tx = {
204
208
  to: sampleRecipient.address,
209
+ // @ts-expect-error - ethers v6 parseEther compatibility
205
210
  value: ethers_1.ethers.parseEther(sampleRecipient.amount)
206
211
  };
207
212
  if (this.chainService instanceof ChainService_1.ChainService) {
@@ -1,4 +1,5 @@
1
- import { ethers, TransactionRequest } from 'ethers';
1
+ import { ethers } from 'ethers';
2
+ import type { TransactionRequest } from 'ethers';
2
3
  import { ChainId } from '../config/chains';
3
4
  import { Vault } from '../Vault';
4
5
  /**
@@ -33,12 +33,14 @@ const ERC20_ABI = [
33
33
  "function allowance(address owner, address spender) view returns (uint)"
34
34
  ];
35
35
  // Provider manager: cache provider per chainId
36
+ // @ts-expect-error - ethers v6 JsonRpcProvider compatibility
36
37
  const providerCache = {};
37
38
  /**
38
39
  * Gets or creates a cached provider for the specified chain.
39
40
  * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
40
41
  * @returns Cached ethers provider for the chain
41
42
  */
43
+ // @ts-expect-error - ethers v6 JsonRpcProvider compatibility
42
44
  function getProviderAuto(chainId) {
43
45
  if (!providerCache[chainId]) {
44
46
  providerCache[chainId] = (0, chains_1.getProvider)(chainId);
@@ -175,12 +177,15 @@ async function signTransactionWithVault(unsignedTx, vault, fromAddress, chainId)
175
177
  * const receipt = await approveTokenWithVault(vault, '0xOwner...', '0xToken...', '0xSpender...', '1000', '1');
176
178
  * ```
177
179
  */
178
- async function approveTokenWithVault(vault, fromAddress, tokenAddress, spender, amount, chainId) {
180
+ async function approveTokenWithVault(vault, fromAddress, tokenAddress, spender, amount, chainId
181
+ // @ts-expect-error - ethers v6 TransactionResponse compatibility
182
+ ) {
179
183
  const privateKey = await vault.getPrivateKeyFor(fromAddress);
180
184
  const provider = (0, chains_1.getProvider)(chainId);
181
185
  const wallet = new ethers_1.Wallet(privateKey, provider);
182
186
  const contract = new ethers_1.Contract(tokenAddress, ERC20_ABI, wallet);
183
187
  const decimals = await contract.decimals();
188
+ // @ts-expect-error - ethers v6 parseUnits compatibility
184
189
  const parsedAmount = typeof amount === 'string' ? ethers_1.ethers.parseUnits(amount, decimals) : amount;
185
190
  const tx = await contract.approve(spender, parsedAmount);
186
191
  if (typeof tx.wait === 'function') {
@@ -198,7 +203,9 @@ async function approveTokenWithVault(vault, fromAddress, tokenAddress, spender,
198
203
  * const txResponse = await sendTransaction(signedTx, '1');
199
204
  * ```
200
205
  */
201
- async function sendTransaction(signedTx, chainId) {
206
+ async function sendTransaction(signedTx, chainId
207
+ // @ts-expect-error - ethers v6 TransactionResponse compatibility
208
+ ) {
202
209
  const provider = getProviderAuto(chainId);
203
210
  return provider.broadcastTransaction(signedTx);
204
211
  }
@@ -295,6 +302,7 @@ async function signMessage(message, privateKey) {
295
302
  * ```
296
303
  */
297
304
  async function verifyMessage(message, signature) {
305
+ // @ts-expect-error - ethers v6 verifyMessage compatibility
298
306
  return ethers_1.ethers.verifyMessage(message, signature);
299
307
  }
300
308
  /**
@@ -323,6 +331,7 @@ async function verifyMessage(message, signature) {
323
331
  async function signTypedDataWithVault(typedData, vault, fromAddress) {
324
332
  const privateKey = await vault.getPrivateKeyFor(fromAddress);
325
333
  const wallet = new ethers_1.Wallet(privateKey);
334
+ // @ts-expect-error - signTypedData may not be in types but exists in runtime
326
335
  return wallet.signTypedData(typedData.domain, typedData.types, typedData.message);
327
336
  }
328
337
  /**
@@ -344,6 +353,7 @@ async function signTypedDataWithVault(typedData, vault, fromAddress) {
344
353
  */
345
354
  async function signTypedData(typedData, privateKey) {
346
355
  const wallet = new ethers_1.Wallet(privateKey);
356
+ // @ts-expect-error - signTypedData may not be in types but exists in runtime
347
357
  return wallet.signTypedData(typedData.domain, typedData.types, typedData.message);
348
358
  }
349
359
  /**
@@ -357,6 +367,7 @@ async function signTypedData(typedData, privateKey) {
357
367
  * ```
358
368
  */
359
369
  async function verifyTypedData(typedData, signature) {
370
+ // @ts-expect-error - ethers v6 verifyTypedData compatibility
360
371
  return ethers_1.ethers.verifyTypedData(typedData.domain, typedData.types, typedData.message, signature);
361
372
  }
362
373
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwc-sdk-wallet",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",