@deserialize/multi-vm-wallet 1.2.2 → 1.2.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.
Files changed (42) hide show
  1. package/dist/IChainWallet.d.ts +6 -1
  2. package/dist/IChainWallet.js.map +1 -1
  3. package/dist/constant.js +32 -18
  4. package/dist/constant.js.map +1 -1
  5. package/dist/evm/evm.d.ts +5 -1
  6. package/dist/evm/evm.js +11 -2
  7. package/dist/evm/evm.js.map +1 -1
  8. package/dist/evm/transaction.utils.d.ts +362 -0
  9. package/dist/evm/transaction.utils.js +669 -0
  10. package/dist/evm/transaction.utils.js.map +1 -0
  11. package/dist/evm/transactionParsing.d.ts +1 -3633
  12. package/dist/evm/transactionParsing.js +0 -27
  13. package/dist/evm/transactionParsing.js.map +1 -1
  14. package/dist/evm/utils.d.ts +13 -1
  15. package/dist/evm/utils.js +101 -2
  16. package/dist/evm/utils.js.map +1 -1
  17. package/dist/helpers/index.d.ts +2 -1
  18. package/dist/helpers/index.js +5 -0
  19. package/dist/helpers/index.js.map +1 -1
  20. package/dist/svm/svm.d.ts +14 -4
  21. package/dist/svm/svm.js +25 -7
  22. package/dist/svm/svm.js.map +1 -1
  23. package/dist/svm/utils.d.ts +9 -3
  24. package/dist/svm/utils.js +94 -12
  25. package/dist/svm/utils.js.map +1 -1
  26. package/dist/test.d.ts +4 -0
  27. package/dist/test.js +38 -18
  28. package/dist/test.js.map +1 -1
  29. package/dist/types.d.ts +110 -0
  30. package/dist/types.js.map +1 -1
  31. package/package.json +5 -2
  32. package/utils/IChainWallet.ts +6 -3
  33. package/utils/constant.ts +34 -18
  34. package/utils/evm/evm.ts +17 -4
  35. package/utils/evm/transaction.utils.ts +824 -0
  36. package/utils/evm/transactionParsing.ts +0 -26
  37. package/utils/evm/utils.ts +110 -3
  38. package/utils/helpers/index.ts +7 -1
  39. package/utils/svm/svm.ts +40 -9
  40. package/utils/svm/utils.ts +131 -16
  41. package/utils/test.ts +48 -18
  42. package/utils/types.ts +140 -0
package/utils/evm/evm.ts CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  import { EVMDeriveChildPrivateKey } from "../walletBip32";
8
8
  import { ChainWallet } from "../IChainWallet";
9
- import { Balance, ChainWalletConfig, NFTInfo, UserTokenBalance, TokenInfo, TransactionResult } from "../types";
9
+ import { Balance, ChainWalletConfig, NFTInfo, UserTokenBalance, TokenInfo, TransactionResult, NFT } from "../types";
10
10
  import { VM } from "../vm";
11
11
  import { ethers, JsonRpcProvider, Wallet, formatUnits } from "ethers";
12
12
  import BN from "bn.js";
@@ -30,7 +30,8 @@ import {
30
30
  executeContractMethod,
31
31
  getTokenInfo,
32
32
  DESERIALIZED_SUPPORTED_CHAINS,
33
- discoverTokens
33
+ discoverTokens,
34
+ discoverNFTs
34
35
  } from "./utils";
35
36
  import { EVMTransactionHistoryItem, getEVMTransactionHistory } from "./transactionParsing";
36
37
  import { createPublicClient, Hex, http, PublicClient } from "viem";
@@ -79,6 +80,7 @@ export class EVMVM extends VM<string, string, JsonRpcProvider> {
79
80
  }
80
81
 
81
82
  getTokenInfo = getTokenInfo
83
+ static getTokenInfo = getTokenInfo
82
84
  generatePrivateKey(index: number, seed?: string, mnemonic?: string, derivationPath = this.derivationPath) {
83
85
  let _seed: string
84
86
 
@@ -114,12 +116,14 @@ export class EVMVM extends VM<string, string, JsonRpcProvider> {
114
116
 
115
117
  export class EVMChainWallet extends ChainWallet<string, string, JsonRpcProvider> {
116
118
  client: PublicClient
119
+ wallet: Wallet
117
120
  constructor(config: ChainWalletConfig, privateKey: string, index: number) {
118
121
  super(config, privateKey, index);
119
- const wallet = new Wallet(privateKey);
122
+ this.connection = new JsonRpcProvider(config.rpcUrl)
123
+ const wallet = new Wallet(privateKey, this.connection);
124
+ this.wallet = wallet
120
125
  this.address = wallet.address;
121
126
  this.privateKey = privateKey;
122
- this.connection = new JsonRpcProvider(config.rpcUrl)
123
127
 
124
128
  //client for viem
125
129
  this.client = createPublicClient(
@@ -172,11 +176,20 @@ export class EVMChainWallet extends ChainWallet<string, string, JsonRpcProvider>
172
176
  return await EVMVM.getTokenBalance(this.address, tokenAddress, this.connection!)
173
177
  }
174
178
 
179
+ async getTokenInfo(tokenAddress: string) {
180
+ return await EVMVM.getTokenInfo(tokenAddress, this.connection!)
181
+ }
182
+
175
183
  async discoverToken(): Promise<UserTokenBalance<string>[]> {
176
184
  // Implement token discovery logic here
177
185
  return await discoverTokens(this.address, this.config)
178
186
  }
179
187
 
188
+ async discoverNFT(): Promise<NFT[]> {
189
+ // Implement NFT discovery logic here
190
+ return await discoverNFTs(this.address, this.config)
191
+ }
192
+
180
193
  async transferNative(to: string, amount: number): Promise<TransactionResult> {
181
194
  // Implement native transfer logic here
182
195
  const wallet = this.getWallet()