@deserialize/multi-vm-wallet 1.2.11 → 1.2.21

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 (47) hide show
  1. package/dist/IChainWallet.d.ts +5 -1
  2. package/dist/IChainWallet.js.map +1 -1
  3. package/dist/constant.d.ts +16 -0
  4. package/dist/constant.js +19 -3
  5. package/dist/constant.js.map +1 -1
  6. package/dist/evm/evm.d.ts +6 -1
  7. package/dist/evm/evm.js +36 -45
  8. package/dist/evm/evm.js.map +1 -1
  9. package/dist/evm/transactionParsing.d.ts +3687 -0
  10. package/dist/evm/transactionParsing.js +441 -0
  11. package/dist/evm/transactionParsing.js.map +1 -0
  12. package/dist/evm/utils.d.ts +2 -9
  13. package/dist/evm/utils.js +17 -16
  14. package/dist/evm/utils.js.map +1 -1
  15. package/dist/helpers/index.d.ts +4 -0
  16. package/dist/helpers/index.js +13 -0
  17. package/dist/helpers/index.js.map +1 -0
  18. package/dist/svm/constant.d.ts +15 -0
  19. package/dist/svm/constant.js +25 -0
  20. package/dist/svm/constant.js.map +1 -0
  21. package/dist/svm/svm.d.ts +5 -2
  22. package/dist/svm/svm.js +10 -0
  23. package/dist/svm/svm.js.map +1 -1
  24. package/dist/svm/transactionParsing.d.ts +28 -0
  25. package/dist/svm/transactionParsing.js +207 -0
  26. package/dist/svm/transactionParsing.js.map +1 -0
  27. package/dist/svm/utils.d.ts +3 -2
  28. package/dist/svm/utils.js +45 -4
  29. package/dist/svm/utils.js.map +1 -1
  30. package/dist/test.d.ts +1 -1
  31. package/dist/test.js +47 -9
  32. package/dist/test.js.map +1 -1
  33. package/dist/types.d.ts +5 -1
  34. package/dist/types.js.map +1 -1
  35. package/package.json +4 -2
  36. package/utils/IChainWallet.ts +6 -2
  37. package/utils/constant.ts +22 -4
  38. package/utils/evm/evm.ts +53 -48
  39. package/utils/evm/transactionParsing.ts +639 -0
  40. package/utils/evm/utils.ts +26 -25
  41. package/utils/helpers/index.ts +11 -0
  42. package/utils/svm/constant.ts +29 -0
  43. package/utils/svm/svm.ts +14 -2
  44. package/utils/svm/transactionParsing.ts +294 -0
  45. package/utils/svm/utils.ts +60 -13
  46. package/utils/test.ts +56 -6
  47. package/utils/types.ts +6 -1
package/utils/test.ts CHANGED
@@ -3,11 +3,16 @@ import { generateKey } from "crypto";
3
3
 
4
4
  import base58 from "bs58";
5
5
  import { NATIVE_MINT } from "@solana/spl-token";
6
+ import { Connection, PublicKey, Keypair } from "@solana/web3.js";
6
7
  // import { GenerateNewMnemonic } from "./bip32";
7
- import { SVMChainWallet, SVMVM } from "./svm";
8
+ import { SVMChainWallet, SVMVM, } from "./svm";
8
9
  import { VM } from "./vm";
9
10
  import { ChainWalletConfig } from "./types";
10
- import { Keypair } from ".";
11
+ import { EVMChainWallet } from "./evm";
12
+ import { } from "./svm/transactionParsing";
13
+ import { getEVMTransactionHistory } from "./evm/transactionParsing";
14
+ import { createPublicClient, http, PublicClient } from "viem";
15
+ import { base, baseGoerli } from "viem/chains";
11
16
  // const mnemonic = GenerateNewMnemonic()
12
17
 
13
18
 
@@ -18,6 +23,9 @@ const pKey = "4QxETeX9pndiF1XNghUiDTnZnHq3cfjmuPLBJysrgocsLq1yb8w96aPWALa8ZnRZWm
18
23
 
19
24
  export const testUserKeyPair = Keypair.fromSecretKey(base58.decode(pKey));
20
25
  const x = testUserKeyPair instanceof Keypair;
26
+ const evePrivateKey = "0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
27
+ const evmPrivateKey2 = "0x0123456789012345678901234567890123456789012345678901234567890123"
28
+
21
29
  // const vm = new SVMVM(seed)
22
30
 
23
31
 
@@ -27,7 +35,7 @@ const x = testUserKeyPair instanceof Keypair;
27
35
  // const key = vm.generatePrivateKey(0)
28
36
  // console.log('key: ', key.privateKey.publicKey);
29
37
  const chainConfig: ChainWalletConfig = {
30
- chainId: "solana-mainnet",
38
+ chainId: 123456789,
31
39
  name: "Solana",
32
40
  rpcUrl: "https://solana-mainnet.g.alchemy.com/v2/vB5mKztdJeFdz9RkW99Qf",
33
41
  explorerUrl: "https://explorer.solana.com",
@@ -37,7 +45,7 @@ const chainConfig: ChainWalletConfig = {
37
45
  }
38
46
 
39
47
  const evmChainConfig: ChainWalletConfig = {
40
- chainId: "evm-mainnet",
48
+ chainId: 8453,
41
49
  name: "Ethereum",
42
50
  rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/vB5mKztdJeFdz9RkW99Qf",
43
51
  explorerUrl: "https://explorer.ethereum.com",
@@ -46,10 +54,13 @@ const evmChainConfig: ChainWalletConfig = {
46
54
  }
47
55
 
48
56
 
49
- const wallet = new SVMChainWallet(chainConfig, testUserKeyPair, 0)
57
+ // const wallet = new SVMChainWallet(chainConfig, testUserKeyPair, 0)
58
+ const wallet = new EVMChainWallet(evmChainConfig, evmPrivateKey2, 0)
50
59
  // console.log('wallet: ', wallet);
51
60
 
52
- wallet.getNativeBalance().then(e => console.log('native balance: ', e))
61
+ // wallet.discoverToken().then(e => console.log('discovered tokens: ', e))
62
+ // wallet.getNativeBalance().then(e => console.log('native balance: ', e))
63
+ console.log('address: ', wallet.address);
53
64
  // const toBuy = new PublicKey("9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump")
54
65
  // wallet.swap({
55
66
  // name: NATIVE_MINT.toBase58(),
@@ -63,3 +74,42 @@ wallet.getNativeBalance().then(e => console.log('native balance: ', e))
63
74
  // wal.getNativeBalance().then(e => console.log(e))
64
75
 
65
76
 
77
+
78
+
79
+
80
+
81
+ const RPC_URL = chainConfig.rpcUrl;
82
+ const connection = new Connection(RPC_URL);
83
+
84
+ /**
85
+ * Fetches and logs the token metadata for a given mint address.
86
+ * @param mintAddress - The mint address of the token.
87
+ */
88
+
89
+ // get transaction history
90
+ // getTransactionHistory(
91
+ // connection,
92
+ // wallet.address,
93
+ // {
94
+ // limit: 2,
95
+ // before: "5RKG5zKJdz9PqWSav1J358hm1GtfnV1QnYcrw3sRpY7aCgT7f4HTKnp4c9pXrJRujcHHisu3Z6jdtbzq5aTRbikq"
96
+ // }
97
+ // ).then((history: any) => {
98
+ // console.log("Transaction History:", history);
99
+ // }).catch((error: any) => {
100
+ // console.error("Error fetching transaction history:", error);
101
+ // });
102
+ const client = createPublicClient({
103
+ chain: base,
104
+ transport: http(base.rpcUrls.default.http[0]),
105
+ })
106
+
107
+ getEVMTransactionHistory(client as PublicClient, "0x9C82CE0e125F61AdE50BC0c19638F6Ba93d71D5e", {
108
+ startBlock: BigInt(37427020)
109
+ // before: "0xabc..."
110
+ }).then((history: any) => {
111
+ console.log("EVM Transaction History:", history);
112
+ }).catch((error: any) => {
113
+ console.error("Error fetching EVM transaction history:", error);
114
+ });
115
+
package/utils/types.ts CHANGED
@@ -3,7 +3,7 @@ import { EVMVM } from "./evm";
3
3
  import { SVMVM } from "./svm";
4
4
 
5
5
  export interface ChainWalletConfig {
6
- chainId: string | number;
6
+ chainId: number;
7
7
  name: string;
8
8
  rpcUrl: string;
9
9
  explorerUrl: string;
@@ -26,6 +26,11 @@ export interface TokenInfo {
26
26
  decimals: number;
27
27
  }
28
28
 
29
+ export interface UserTokenBalance<AddressType> extends TokenInfo {
30
+ balance: number;
31
+ owner: AddressType;
32
+ }
33
+
29
34
  export interface NFTInfo {
30
35
  tokenId: string;
31
36
  contractAddress: string;