@deserialize/multi-vm-wallet 1.2.21 → 1.2.22

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.
@@ -610,30 +610,4 @@ async function parseTransferLogs(
610
610
  return { tokens, nfts };
611
611
  }
612
612
 
613
- /**
614
- * Helper function to create a client
615
- */
616
- export function createEVMClient(rpcUrl: string) {
617
- return createPublicClient({
618
- transport: http(rpcUrl),
619
- });
620
- }
621
-
622
- // Example usage:
623
- /*
624
- import { mainnet } from 'viem/chains';
625
-
626
- const client = createPublicClient({
627
- chain: mainnet,
628
- transport: http('https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY'),
629
- });
630
-
631
- const history = await getEVMTransactionHistoryWithAPI(
632
- client,
633
- '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb' as Address,
634
- 'https://api.etherscan.io/api',
635
- 'YOUR_ETHERSCAN_API_KEY'
636
- );
637
613
 
638
- console.log(history);
639
- */
@@ -654,6 +654,24 @@ export const discoverTokens = async (wallet: string, chain: ChainWalletConfig):
654
654
  return formatBalances
655
655
  }
656
656
 
657
+ export function calcGasTotal(gasLimit = '0', gasPrice = '0') {
658
+ return new BN(gasLimit, 16).mul(new BN(gasPrice, 16)).toString();
659
+ }
660
+ export function toPrecisionWithoutTrailingZeros(n: number, precision: number) {
661
+ return new BigNumber(n)
662
+ .toPrecision(precision)
663
+ .replace(/(\.[0-9]*[1-9])0*|(\.0*)/u, '$1');
664
+ }
665
+
666
+ /**
667
+ * @param {number|string|BigNumber} value
668
+ * @param {number=} decimals
669
+ * @returns {BigNumber}
670
+ */
671
+ export function calcTokenAmount(value: number | string | BigNumber, decimals?: number): BigNumber {
672
+ const divisor = new BigNumber(10).pow(decimals ?? 0);
673
+ return new BigNumber(String(value)).div(divisor);
674
+ }
657
675
  //swaps
658
676
 
659
677