@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.
- package/dist/constant.js +18 -3
- package/dist/constant.js.map +1 -1
- package/dist/evm/transaction.utils.d.ts +362 -0
- package/dist/evm/transaction.utils.js +669 -0
- package/dist/evm/transaction.utils.js.map +1 -0
- package/dist/evm/transactionParsing.d.ts +1 -3633
- package/dist/evm/transactionParsing.js +0 -27
- package/dist/evm/transactionParsing.js.map +1 -1
- package/dist/evm/utils.d.ts +8 -0
- package/dist/evm/utils.js +20 -0
- package/dist/evm/utils.js.map +1 -1
- package/package.json +1 -1
- package/utils/constant.ts +18 -3
- package/utils/evm/transaction.utils.ts +824 -0
- package/utils/evm/transactionParsing.ts +0 -26
- package/utils/evm/utils.ts +18 -0
|
@@ -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
|
-
*/
|
package/utils/evm/utils.ts
CHANGED
|
@@ -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
|
|