@deserialize/multi-vm-wallet 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/.claude/settings.local.json +7 -1
  2. package/BUILD_OPTIMIZATION_PLAN.md +640 -0
  3. package/BUILD_RESULTS.md +282 -0
  4. package/BUN_MIGRATION.md +415 -0
  5. package/CHANGELOG_SECURITY.md +573 -0
  6. package/IMPLEMENTATION_SUMMARY.md +494 -0
  7. package/SECURITY_AUDIT.md +1124 -0
  8. package/bun.lock +553 -0
  9. package/dist/IChainWallet.js +0 -5
  10. package/dist/bip32Old.js +0 -885
  11. package/dist/bip32Small.js +0 -79
  12. package/dist/bipTest.js +0 -362
  13. package/dist/constant.js +0 -17
  14. package/dist/english.js +0 -1
  15. package/dist/evm/aa-service/index.d.ts +0 -5
  16. package/dist/evm/aa-service/index.js +0 -14
  17. package/dist/evm/aa-service/lib/account-adapter.d.ts +0 -22
  18. package/dist/evm/aa-service/lib/account-adapter.js +0 -24
  19. package/dist/evm/aa-service/lib/kernel-account.d.ts +0 -30
  20. package/dist/evm/aa-service/lib/kernel-account.js +2 -67
  21. package/dist/evm/aa-service/lib/kernel-modules.d.ts +0 -177
  22. package/dist/evm/aa-service/lib/kernel-modules.js +4 -202
  23. package/dist/evm/aa-service/lib/session-keys.d.ts +0 -118
  24. package/dist/evm/aa-service/lib/session-keys.js +7 -151
  25. package/dist/evm/aa-service/lib/type.d.ts +0 -55
  26. package/dist/evm/aa-service/lib/type.js +0 -10
  27. package/dist/evm/aa-service/services/account-abstraction.d.ts +0 -426
  28. package/dist/evm/aa-service/services/account-abstraction.js +0 -461
  29. package/dist/evm/aa-service/services/bundler.d.ts +0 -6
  30. package/dist/evm/aa-service/services/bundler.js +0 -54
  31. package/dist/evm/evm.d.ts +9 -51
  32. package/dist/evm/evm.js +338 -76
  33. package/dist/evm/index.js +0 -3
  34. package/dist/evm/script.js +3 -17
  35. package/dist/evm/smartWallet.d.ts +0 -173
  36. package/dist/evm/smartWallet.js +0 -206
  37. package/dist/evm/smartWallet.types.d.ts +0 -6
  38. package/dist/evm/smartWallet.types.js +0 -8
  39. package/dist/evm/transaction.utils.d.ts +0 -242
  40. package/dist/evm/transaction.utils.js +4 -320
  41. package/dist/evm/transactionParsing.d.ts +0 -11
  42. package/dist/evm/transactionParsing.js +28 -147
  43. package/dist/evm/utils.d.ts +0 -46
  44. package/dist/evm/utils.js +1 -57
  45. package/dist/helpers/index.d.ts +0 -4
  46. package/dist/helpers/index.js +8 -44
  47. package/dist/helpers/routeScan.js +0 -1
  48. package/dist/index.js +0 -1
  49. package/dist/old.js +0 -884
  50. package/dist/price.js +0 -1
  51. package/dist/price.types.js +0 -2
  52. package/dist/rate-limiter.d.ts +28 -0
  53. package/dist/rate-limiter.js +95 -0
  54. package/dist/retry-logic.d.ts +14 -0
  55. package/dist/retry-logic.js +120 -0
  56. package/dist/savings/index.js +0 -1
  57. package/dist/savings/saving-manager.d.ts +10 -11
  58. package/dist/savings/saving-manager.js +79 -22
  59. package/dist/savings/savings-operations.d.ts +39 -0
  60. package/dist/savings/savings-operations.js +141 -0
  61. package/dist/savings/smart-savings.d.ts +0 -63
  62. package/dist/savings/smart-savings.js +0 -78
  63. package/dist/savings/types.d.ts +0 -69
  64. package/dist/savings/types.js +0 -7
  65. package/dist/savings/validation.d.ts +9 -0
  66. package/dist/savings/validation.js +85 -0
  67. package/dist/svm/constant.js +0 -1
  68. package/dist/svm/index.js +0 -1
  69. package/dist/svm/svm.d.ts +11 -1
  70. package/dist/svm/svm.js +267 -27
  71. package/dist/svm/transactionParsing.d.ts +0 -7
  72. package/dist/svm/transactionParsing.js +3 -41
  73. package/dist/svm/transactionSender.js +0 -9
  74. package/dist/svm/utils.d.ts +0 -12
  75. package/dist/svm/utils.js +9 -60
  76. package/dist/test.d.ts +0 -4
  77. package/dist/test.js +6 -98
  78. package/dist/transaction-utils.d.ts +38 -0
  79. package/dist/transaction-utils.js +168 -0
  80. package/dist/types.d.ts +36 -0
  81. package/dist/types.js +0 -1
  82. package/dist/utils.js +0 -1
  83. package/dist/vm-validation.d.ts +11 -0
  84. package/dist/vm-validation.js +151 -0
  85. package/dist/vm.d.ts +12 -2
  86. package/dist/vm.js +61 -16
  87. package/dist/walletBip32.js +15 -70
  88. package/package.json +9 -4
  89. package/test-discovery.ts +235 -0
  90. package/test-pocket-discovery.ts +84 -0
  91. package/tsconfig.json +18 -11
  92. package/tsconfig.prod.json +10 -0
  93. package/utils/evm/evm.ts +554 -8
  94. package/utils/rate-limiter.ts +179 -0
  95. package/utils/retry-logic.ts +271 -0
  96. package/utils/savings/EXAMPLES.md +883 -0
  97. package/utils/savings/SECURITY.md +731 -0
  98. package/utils/savings/saving-manager.ts +526 -16
  99. package/utils/savings/savings-operations.ts +509 -0
  100. package/utils/savings/validation.ts +187 -0
  101. package/utils/svm/svm.ts +476 -5
  102. package/utils/test.ts +2 -2
  103. package/utils/transaction-utils.ts +394 -0
  104. package/utils/types.ts +100 -0
  105. package/utils/vm-validation.ts +280 -0
  106. package/utils/vm.ts +197 -10
  107. package/utils/walletBip32.ts +39 -3
  108. package/dist/IChainWallet.js.map +0 -1
  109. package/dist/bip32.d.ts +0 -9
  110. package/dist/bip32.js +0 -172
  111. package/dist/bip32.js.map +0 -1
  112. package/dist/bip32Old.js.map +0 -1
  113. package/dist/bip32Small.js.map +0 -1
  114. package/dist/bipTest.js.map +0 -1
  115. package/dist/constant.js.map +0 -1
  116. package/dist/english.js.map +0 -1
  117. package/dist/evm/SMART_WALLET_EXAMPLES.d.ts +0 -20
  118. package/dist/evm/SMART_WALLET_EXAMPLES.js +0 -451
  119. package/dist/evm/SMART_WALLET_EXAMPLES.js.map +0 -1
  120. package/dist/evm/aa-service/index.js.map +0 -1
  121. package/dist/evm/aa-service/lib/account-adapter.js.map +0 -1
  122. package/dist/evm/aa-service/lib/kernel-account.js.map +0 -1
  123. package/dist/evm/aa-service/lib/kernel-modules.js.map +0 -1
  124. package/dist/evm/aa-service/lib/session-keys.js.map +0 -1
  125. package/dist/evm/aa-service/lib/type.js.map +0 -1
  126. package/dist/evm/aa-service/services/account-abstraction.js.map +0 -1
  127. package/dist/evm/aa-service/services/bundler.js.map +0 -1
  128. package/dist/evm/evm.js.map +0 -1
  129. package/dist/evm/index.js.map +0 -1
  130. package/dist/evm/script.js.map +0 -1
  131. package/dist/evm/smartWallet.js.map +0 -1
  132. package/dist/evm/smartWallet.types.js.map +0 -1
  133. package/dist/evm/transaction.utils.js.map +0 -1
  134. package/dist/evm/transactionParsing.js.map +0 -1
  135. package/dist/evm/utils.js.map +0 -1
  136. package/dist/helpers/index.js.map +0 -1
  137. package/dist/helpers/routeScan.js.map +0 -1
  138. package/dist/index.js.map +0 -1
  139. package/dist/old.js.map +0 -1
  140. package/dist/price.js.map +0 -1
  141. package/dist/price.types.js.map +0 -1
  142. package/dist/privacy/artifact-manager.d.ts +0 -117
  143. package/dist/privacy/artifact-manager.js +0 -251
  144. package/dist/privacy/artifact-manager.js.map +0 -1
  145. package/dist/privacy/broadcaster-client.d.ts +0 -166
  146. package/dist/privacy/broadcaster-client.js +0 -261
  147. package/dist/privacy/broadcaster-client.js.map +0 -1
  148. package/dist/privacy/index.d.ts +0 -34
  149. package/dist/privacy/index.js +0 -56
  150. package/dist/privacy/index.js.map +0 -1
  151. package/dist/privacy/network-config.d.ts +0 -57
  152. package/dist/privacy/network-config.js +0 -118
  153. package/dist/privacy/network-config.js.map +0 -1
  154. package/dist/privacy/poi-helper.d.ts +0 -161
  155. package/dist/privacy/poi-helper.js +0 -249
  156. package/dist/privacy/poi-helper.js.map +0 -1
  157. package/dist/privacy/railgun-engine.d.ts +0 -135
  158. package/dist/privacy/railgun-engine.js +0 -205
  159. package/dist/privacy/railgun-engine.js.map +0 -1
  160. package/dist/privacy/railgun-privacy-wallet.d.ts +0 -288
  161. package/dist/privacy/railgun-privacy-wallet.js +0 -539
  162. package/dist/privacy/railgun-privacy-wallet.js.map +0 -1
  163. package/dist/privacy/types.d.ts +0 -229
  164. package/dist/privacy/types.js +0 -26
  165. package/dist/privacy/types.js.map +0 -1
  166. package/dist/savings/index.js.map +0 -1
  167. package/dist/savings/saving-actions.d.ts +0 -0
  168. package/dist/savings/saving-actions.js +0 -78
  169. package/dist/savings/saving-actions.js.map +0 -1
  170. package/dist/savings/saving-manager.js.map +0 -1
  171. package/dist/savings/savings-manager.d.ts +0 -126
  172. package/dist/savings/savings-manager.js +0 -234
  173. package/dist/savings/savings-manager.js.map +0 -1
  174. package/dist/savings/smart-savings.js.map +0 -1
  175. package/dist/savings/types.js.map +0 -1
  176. package/dist/svm/constant.js.map +0 -1
  177. package/dist/svm/index.js.map +0 -1
  178. package/dist/svm/svm.js.map +0 -1
  179. package/dist/svm/transactionParsing.js.map +0 -1
  180. package/dist/svm/transactionSender.js.map +0 -1
  181. package/dist/svm/utils.js.map +0 -1
  182. package/dist/test.js.map +0 -1
  183. package/dist/types.js.map +0 -1
  184. package/dist/utils.js.map +0 -1
  185. package/dist/vm.js.map +0 -1
  186. package/dist/walletBip32.js.map +0 -1
package/dist/evm/utils.js CHANGED
@@ -27,7 +27,6 @@ const KYBER_SUPPORTED_CHAINS = {
27
27
  exports.DESERIALIZED_SUPPORTED_CHAINS = {
28
28
  '16661': '0gMainnet',
29
29
  };
30
- // ERC-20 ABI
31
30
  exports.ERC20_ABI = [
32
31
  {
33
32
  name: 'balanceOf',
@@ -135,7 +134,7 @@ function viemReceiptToEthersReceipt(receipt) {
135
134
  removed: false,
136
135
  })),
137
136
  blockNumber: Number(receipt.blockNumber),
138
- confirmations: 0, // ethers usually fills this lazily
137
+ confirmations: 0,
139
138
  cumulativeGasUsed: receipt.cumulativeGasUsed,
140
139
  effectiveGasPrice: receipt.effectiveGasPrice,
141
140
  status: receipt.status === 'success' ? 1 : 0,
@@ -199,9 +198,6 @@ const getTokenBalance = async (tokenAddress, walletAddress, client) => {
199
198
  };
200
199
  };
201
200
  exports.getTokenBalance = getTokenBalance;
202
- /**
203
- * Sign, send, and confirm any EVM transaction
204
- */
205
201
  const signSendAndConfirm = async (walletClient, publicClient, params, confirmations = 1) => {
206
202
  if (walletClient.account === undefined) {
207
203
  throw new Error("wallet Client is not Initialized with an Account");
@@ -233,17 +229,11 @@ const signSendAndConfirm = async (walletClient, publicClient, params, confirmati
233
229
  };
234
230
  };
235
231
  exports.signSendAndConfirm = signSendAndConfirm;
236
- /**
237
- * Send native token (ETH, BNB, MATIC, etc.)
238
- */
239
232
  const sendNativeToken = async (walletClient, publicClient, to, amount, confirmations = 1) => {
240
233
  const value = typeof amount === 'string' ? (0, viem_1.parseEther)(amount) : amount;
241
234
  return (0, exports.signSendAndConfirm)(walletClient, publicClient, { to, value }, confirmations);
242
235
  };
243
236
  exports.sendNativeToken = sendNativeToken;
244
- /**
245
- * Send ERC-20 token
246
- */
247
237
  const sendERC20Token = async (walletClient, publicClient, tokenAddress, to, amount, confirmations = 1) => {
248
238
  const data = (0, viem_1.encodeFunctionData)({
249
239
  abi: exports.ERC20_ABI,
@@ -253,9 +243,6 @@ const sendERC20Token = async (walletClient, publicClient, tokenAddress, to, amou
253
243
  return (0, exports.signSendAndConfirm)(walletClient, publicClient, { to: tokenAddress, data }, confirmations);
254
244
  };
255
245
  exports.sendERC20Token = sendERC20Token;
256
- /**
257
- * Get current gas prices (both legacy and EIP-1559)
258
- */
259
246
  const getGasPrices = async (client) => {
260
247
  const fees = await client.estimateFeesPerGas();
261
248
  return {
@@ -265,9 +252,6 @@ const getGasPrices = async (client) => {
265
252
  };
266
253
  };
267
254
  exports.getGasPrices = getGasPrices;
268
- /**
269
- * Estimate gas for a transaction
270
- */
271
255
  const estimateGas = async (client, params) => {
272
256
  return client.estimateGas(params);
273
257
  };
@@ -293,17 +277,11 @@ const checkAllowance = async (client, tokenAddress, owner, spender) => {
293
277
  };
294
278
  };
295
279
  exports.checkAllowance = checkAllowance;
296
- /**
297
- * Check if allowance is sufficient for a transaction
298
- */
299
280
  const isAllowanceSufficient = async (publicClient, tokenAddress, owner, spender, requiredAmount) => {
300
281
  const { allowance } = await (0, exports.checkAllowance)(publicClient, tokenAddress, owner, spender);
301
282
  return allowance >= BigInt(requiredAmount);
302
283
  };
303
284
  exports.isAllowanceSufficient = isAllowanceSufficient;
304
- /**
305
- * Approve ERC-20 token spending
306
- */
307
285
  const approveToken = async (walletClient, publicClient, tokenAddress, spender, amount, confirmations = 1) => {
308
286
  const data = (0, viem_1.encodeFunctionData)({
309
287
  abi: exports.ERC20_ABI,
@@ -314,16 +292,10 @@ const approveToken = async (walletClient, publicClient, tokenAddress, spender, a
314
292
  };
315
293
  exports.approveToken = approveToken;
316
294
  const MAX_UINT256 = 2n ** 256n - 1n;
317
- /**
318
- * Approve unlimited token spending (MaxUint256)
319
- */
320
295
  const approveTokenUnlimited = async (walletClient, publicClient, tokenAddress, spender, gas, confirmations = 1) => {
321
296
  return (0, exports.approveToken)(walletClient, publicClient, tokenAddress, spender, MAX_UINT256, confirmations);
322
297
  };
323
298
  exports.approveTokenUnlimited = approveTokenUnlimited;
324
- /**
325
- * Check allowance and approve if necessary
326
- */
327
299
  const checkAndApprove = async (walletClient, publicClient, tokenAddress, spender, requiredAmount, approvalAmount, gas, confirmations = 1) => {
328
300
  const owner = walletClient.account.address;
329
301
  const allowance = await publicClient.readContract({
@@ -347,17 +319,10 @@ const checkAndApprove = async (walletClient, publicClient, tokenAddress, spender
347
319
  };
348
320
  };
349
321
  exports.checkAndApprove = checkAndApprove;
350
- /**
351
- * Reset token allowance to zero (security best practice before setting new allowance)
352
- */
353
322
  const resetAllowance = async (walletClient, publicClient, tokenAddress, spender, gas, confirmations = 1) => {
354
323
  return (0, exports.approveToken)(walletClient, publicClient, tokenAddress, spender, 0n, confirmations);
355
324
  };
356
325
  exports.resetAllowance = resetAllowance;
357
- /**
358
- * Safe approve: Reset to zero first, then approve the desired amount
359
- * (Some tokens like USDT require this)
360
- */
361
326
  const safeApprove = async (walletClient, publicClient, tokenAddress, spender, amount, gas, confirmations = 1) => {
362
327
  const resetResult = await (0, exports.resetAllowance)(walletClient, publicClient, tokenAddress, spender, gas, confirmations);
363
328
  if (!resetResult.success) {
@@ -394,17 +359,11 @@ function toPrecisionWithoutTrailingZeros(n, precision) {
394
359
  .toPrecision(precision)
395
360
  .replace(/(\.[0-9]*[1-9])0*|(\.0*)/u, '$1');
396
361
  }
397
- /**
398
- * @param {number|string|BigNumber} value
399
- * @param {number=} decimals
400
- * @returns {BigNumber}
401
- */
402
362
  function calcTokenAmount(value, decimals) {
403
363
  const divisor = new bignumber_js_1.default(10).pow(decimals ?? 0);
404
364
  return new bignumber_js_1.default(String(value)).div(divisor);
405
365
  }
406
366
  const transformEVMNFTToUnified = (nft) => {
407
- // Extract image URL from various sources
408
367
  const imageUrl = nft.image?.cachedUrl ||
409
368
  nft.image?.thumbnailUrl ||
410
369
  nft.image?.pngUrl ||
@@ -412,7 +371,6 @@ const transformEVMNFTToUnified = (nft) => {
412
371
  nft.openSeaMetadata?.imageUrl ||
413
372
  nft.raw?.metadata?.image ||
414
373
  undefined;
415
- // Extract attributes
416
374
  const attributes = nft.raw?.metadata?.attributes?.map(attr => ({
417
375
  trait_type: attr.trait_type,
418
376
  value: attr.value,
@@ -448,10 +406,8 @@ const discoverNFTs = async (wallet, chain) => {
448
406
  try {
449
407
  const response = await helpers_1.HelperAPI.getUserNFTs(wallet, chain.vmType ?? "EVM", chain.chainId);
450
408
  console.log('discoverNFTs: Successfully fetched', response.data.length, 'NFTs');
451
- // Filter out spam NFTs if desired (optional)
452
409
  const evmNfts = response.data.filter((nft) => !nft.contract.isSpam);
453
410
  console.log('discoverNFTs: After spam filtering:', evmNfts.length, 'NFTs');
454
- // Transform to unified NFT format
455
411
  const nfts = evmNfts.map(exports.transformEVMNFTToUnified);
456
412
  return nfts;
457
413
  }
@@ -469,7 +425,6 @@ const discoverAllNFTs = async (wallet, chain) => {
469
425
  try {
470
426
  const response = await helpers_1.HelperAPI.getUserNFTs(wallet, chain.vmType ?? "EVM", chain.chainId);
471
427
  console.log('discoverAllNFTs: Successfully fetched', response.data.length, 'NFTs (including spam)');
472
- // Transform to unified NFT format
473
428
  const nfts = response.data.map(exports.transformEVMNFTToUnified);
474
429
  return nfts;
475
430
  }
@@ -480,30 +435,20 @@ const discoverAllNFTs = async (wallet, chain) => {
480
435
  }
481
436
  };
482
437
  exports.discoverAllNFTs = discoverAllNFTs;
483
- /**
484
- * Get NFT collection details for a specific collection
485
- * @param wallet - User's wallet address
486
- * @param collectionAddress - The NFT collection contract address
487
- * @param chain - Chain configuration
488
- * @returns NFTCollection object with collection details and user's NFTs in that collection
489
- */
490
438
  const getNFTCollection = async (wallet, collectionAddress, chain) => {
491
439
  console.log('getNFTCollection: Starting collection fetch');
492
440
  console.log('Wallet:', wallet);
493
441
  console.log('Collection Address:', collectionAddress);
494
442
  console.log('Chain:', chain.name, 'ChainId:', chain.chainId);
495
443
  try {
496
- // Fetch all NFTs for the user
497
444
  const allNfts = await (0, exports.discoverAllNFTs)(wallet, chain);
498
445
  console.log('getNFTCollection: Fetched', allNfts.length, 'total NFTs');
499
- // Filter NFTs by collection address (case-insensitive comparison)
500
446
  const collectionNfts = allNfts.filter(nft => nft.collection.address.toLowerCase() === collectionAddress.toLowerCase());
501
447
  console.log('getNFTCollection: Found', collectionNfts.length, 'NFTs in collection');
502
448
  if (collectionNfts.length === 0) {
503
449
  console.log('getNFTCollection: No NFTs found in this collection');
504
450
  return null;
505
451
  }
506
- // Extract collection metadata from the first NFT
507
452
  const firstNft = collectionNfts[0];
508
453
  const rawEvmNft = firstNft.raw?.evm;
509
454
  const collection = {
@@ -538,4 +483,3 @@ const getNFTCollection = async (wallet, collectionAddress, chain) => {
538
483
  }
539
484
  };
540
485
  exports.getNFTCollection = getNFTCollection;
541
- //# sourceMappingURL=utils.js.map
@@ -1,10 +1,6 @@
1
1
  export * from './routeScan';
2
2
  import { vmTypes, EVMNFTResponse } from "../types";
3
3
  export declare class HelperAPI {
4
- /**
5
- * Get network name from chainId for RouteScan API
6
- * Defaults to 'mainnet' for most chains
7
- */
8
4
  private static getNetworkFromChainId;
9
5
  static getPrice(tokenOrNativeSymbol: string, chainId: number, vm: vmTypes): Promise<any>;
10
6
  static getUserToken(wallet: string, vm: vmTypes, chainId: number): Promise<any>;
@@ -19,13 +19,8 @@ __exportStar(require("./routeScan"), exports);
19
19
  const routeScan_1 = require("./routeScan");
20
20
  const BASE_URL = "https://helper.decane.app";
21
21
  class HelperAPI {
22
- /**
23
- * Get network name from chainId for RouteScan API
24
- * Defaults to 'mainnet' for most chains
25
- */
26
22
  static getNetworkFromChainId(chainId) {
27
- // Map common testnet chain IDs to 'testnet'
28
- const testnets = [11155111, 80001, 5, 97, 421614, 84532]; // Sepolia, Mumbai, Goerli, BSC Testnet, Arbitrum Sepolia, Base Sepolia
23
+ const testnets = [11155111, 80001, 5, 97, 421614, 84532];
29
24
  if (testnets.includes(chainId)) {
30
25
  return 'testnet';
31
26
  }
@@ -37,20 +32,11 @@ class HelperAPI {
37
32
  return data;
38
33
  }
39
34
  static async getUserToken(wallet, vm, chainId) {
40
- // Only try RouteScan for EVM chains
41
35
  if (vm === 'EVM') {
42
36
  try {
43
37
  const network = this.getNetworkFromChainId(chainId);
44
- const routeScanData = await routeScan_1.RouteScanAPI.getTokenTransfers(network, chainId, wallet, undefined, // contractaddress
45
- 0, // startblock
46
- 99999999, // endblock
47
- 1, // page
48
- 100, // offset - get more results
49
- 'desc' // sort by newest first
50
- );
51
- // If RouteScan succeeds and has valid data, transform to expected format
38
+ const routeScanData = await routeScan_1.RouteScanAPI.getTokenTransfers(network, chainId, wallet, undefined, 0, 99999999, 1, 100, 'desc');
52
39
  if (routeScanData && routeScanData.status === '1' && routeScanData.result) {
53
- // Group token transfers by contract address to get unique tokens
54
40
  const tokenMap = new Map();
55
41
  for (const transfer of routeScanData.result) {
56
42
  const address = transfer.contractAddress.toLowerCase();
@@ -60,12 +46,11 @@ class HelperAPI {
60
46
  name: transfer.tokenName,
61
47
  symbol: transfer.tokenSymbol,
62
48
  decimals: parseInt(transfer.tokenDecimal) || 0,
63
- balance: '0', // RouteScan doesn't provide current balance
49
+ balance: '0',
64
50
  logo: undefined
65
51
  });
66
52
  }
67
53
  }
68
- // Transform to expected format with 'data' field
69
54
  return {
70
55
  data: Array.from(tokenMap.values())
71
56
  };
@@ -75,42 +60,32 @@ class HelperAPI {
75
60
  console.warn('RouteScan API failed, falling back to helper.decane.app:', error);
76
61
  }
77
62
  }
78
- // Fallback to original API
79
63
  const res = await fetch("" + BASE_URL + `/${vm}/tokens/discover?wallet=${wallet}&chainId=${chainId}`);
80
64
  const data = await res.json();
81
65
  return data;
82
66
  }
83
67
  static async getUserNFTs(wallet, vm, chainId) {
84
- // Only try RouteScan for EVM chains
85
68
  if (vm === 'EVM') {
86
69
  try {
87
70
  const network = this.getNetworkFromChainId(chainId);
88
- const routeScanData = await routeScan_1.RouteScanAPI.getNftTransfers(network, chainId, wallet, undefined, // contractaddress
89
- 0, // startblock
90
- 99999999, // endblock
91
- 1, // page
92
- 100, // offset
93
- 'desc' // sort by newest first
94
- );
95
- // If RouteScan succeeds and has valid data, transform to EVMNFTResponse format
71
+ const routeScanData = await routeScan_1.RouteScanAPI.getNftTransfers(network, chainId, wallet, undefined, 0, 99999999, 1, 100, 'desc');
96
72
  if (routeScanData && routeScanData.status === '1' && routeScanData.result) {
97
- // Map RouteScan NFT transfers to EVMNFTResponse format
98
73
  const nfts = routeScanData.result.map(nftTx => ({
99
74
  contract: {
100
75
  address: nftTx.contractAddress,
101
76
  name: nftTx.tokenName,
102
77
  symbol: nftTx.tokenSymbol,
103
78
  totalSupply: '0',
104
- tokenType: 'ERC721', // Default, RouteScan doesn't specify
79
+ tokenType: 'ERC721',
105
80
  contractDeployer: '',
106
81
  deployedBlockNumber: parseInt(nftTx.blockNumber) || 0,
107
82
  isSpam: false
108
83
  },
109
84
  tokenId: nftTx.tokenID,
110
- tokenType: 'ERC721', // Default
85
+ tokenType: 'ERC721',
111
86
  name: nftTx.tokenName,
112
87
  description: '',
113
- balance: '1', // Default for NFTs
88
+ balance: '1',
114
89
  timeLastUpdated: nftTx.timeStamp,
115
90
  acquiredAt: nftTx.timeStamp
116
91
  }));
@@ -123,24 +98,15 @@ class HelperAPI {
123
98
  console.warn('RouteScan API failed, falling back to helper.decane.app:', error);
124
99
  }
125
100
  }
126
- // Fallback to original API
127
101
  const res = await fetch("" + BASE_URL + `/${vm}/nfts/discover?wallet=${wallet}&chainId=${chainId}`);
128
102
  const data = await res.json();
129
103
  return data;
130
104
  }
131
105
  static async getTransactionHistory(wallet, vm, chainId, limit = 20) {
132
- // Only try RouteScan for EVM chains
133
106
  if (vm === 'EVM') {
134
107
  try {
135
108
  const network = this.getNetworkFromChainId(chainId);
136
- const routeScanData = await routeScan_1.RouteScanAPI.getTxList(network, chainId, wallet, 0, // startblock
137
- 99999999, // endblock
138
- 1, // page
139
- limit, // offset (number of results)
140
- 'desc' // sort by newest first
141
- );
142
- // If RouteScan succeeds and has valid data, transform it to expected format
143
- // Return RouteScan response as-is - consumer will handle the transformation
109
+ const routeScanData = await routeScan_1.RouteScanAPI.getTxList(network, chainId, wallet, 0, 99999999, 1, limit, 'desc');
144
110
  if (routeScanData && routeScanData.status === '1' && routeScanData.result) {
145
111
  return routeScanData;
146
112
  }
@@ -149,11 +115,9 @@ class HelperAPI {
149
115
  console.warn('RouteScan API failed, falling back to helper.decane.app:', error);
150
116
  }
151
117
  }
152
- // Fallback to original API
153
118
  const res = await fetch("" + BASE_URL + `/${vm}/transactions/history?wallet=${wallet}&chainId=${chainId}&limit=${limit}`);
154
119
  const data = await res.json();
155
120
  return data;
156
121
  }
157
122
  }
158
123
  exports.HelperAPI = HelperAPI;
159
- //# sourceMappingURL=index.js.map
@@ -111,4 +111,3 @@ class RouteScanAPI {
111
111
  }
112
112
  }
113
113
  exports.RouteScanAPI = RouteScanAPI;
114
- //# sourceMappingURL=routeScan.js.map
package/dist/index.js CHANGED
@@ -24,4 +24,3 @@ __exportStar(require("bs58"), exports);
24
24
  __exportStar(require("@solana/web3.js"), exports);
25
25
  __exportStar(require("./price"), exports);
26
26
  __exportStar(require("./utils"), exports);
27
- //# sourceMappingURL=index.js.map