@deserialize/multi-vm-wallet 1.2.29 → 1.2.41

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/utils/test.ts CHANGED
@@ -8,12 +8,15 @@ import { Connection, PublicKey, Keypair } from "@solana/web3.js";
8
8
  import { SVMChainWallet, SVMVM, } from "./svm";
9
9
  import { VM } from "./vm";
10
10
  import { ChainWalletConfig } from "./types";
11
- import { EVMChainWallet } from "./evm";
11
+ import { discoverNFTs, EVMChainWallet } from "./evm";
12
12
  import { } from "./svm/transactionParsing";
13
13
  import { getEVMTransactionHistory } from "./evm/transactionParsing";
14
14
  import { createPublicClient, http, PublicClient } from "viem";
15
15
  import { base, baseGoerli } from "viem/chains";
16
- import { getTokenInfo } from "./svm/utils";
16
+ import { discoverTokens, fetchWalletNfts, getTokenInfo } from "./svm/utils";
17
+ import { JsonRpcProvider } from "ethers";
18
+
19
+ import { } from "@solana/spl-token-metadata"
17
20
  // const mnemonic = GenerateNewMnemonic()
18
21
 
19
22
 
@@ -22,8 +25,8 @@ import { getTokenInfo } from "./svm/utils";
22
25
  // const seed = VM.mnemonicToSeed(mnemonic)
23
26
  const pKey = "4QxETeX9pndiF1XNghUiDTnZnHq3cfjmuPLBJysrgocsLq1yb8w96aPWALa8ZnRZWmDU4wM8Tg8d1ZRVVByj7uXE"
24
27
 
25
- export const testUserKeyPair = Keypair.fromSecretKey(base58.decode(pKey));
26
- const x = testUserKeyPair instanceof Keypair;
28
+ const testUserKeyPair = Keypair.fromSecretKey(base58.decode(pKey));
29
+ // const x = testUserKeyPair instanceof Keypair;
27
30
  const evePrivateKey = "0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
28
31
  const evmPrivateKey2 = "0x0123456789012345678901234567890123456789012345678901234567890123"
29
32
  const ogPrivKey = "d2d3f7117aa9a4c6e5d4affedd8a5ea624ffd82b2a1de81509e5913709b1ea72"
@@ -39,7 +42,7 @@ const ogPrivKey = "d2d3f7117aa9a4c6e5d4affedd8a5ea624ffd82b2a1de81509e5913709b1e
39
42
  const chainConfig: ChainWalletConfig = {
40
43
  chainId: 123456789,
41
44
  name: "Solana",
42
- rpcUrl: "https://solana-mainnet.g.alchemy.com/v2/vB5mKztdJeFdz9RkW99Qf",
45
+ rpcUrl: "https://solana-mainnet.g.alchemy.com/v2/lhoyb3hc9ccT9NA_y2cfA",
43
46
  explorerUrl: "https://explorer.solana.com",
44
47
  nativeToken: { name: "Solana", symbol: "SOL", decimals: 9 },
45
48
  confirmationNo: 1,
@@ -49,7 +52,7 @@ const chainConfig: ChainWalletConfig = {
49
52
  const evmChainConfig: ChainWalletConfig = {
50
53
  chainId: 8453,
51
54
  name: "Ethereum",
52
- rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/vB5mKztdJeFdz9RkW99Qf",
55
+ rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/lhoyb3hc9ccT9NA_y2cfA",
53
56
  explorerUrl: "https://explorer.ethereum.com",
54
57
  nativeToken: { name: "Ethereum", symbol: "ETH", decimals: 18 },
55
58
  confirmationNo: 1,
@@ -93,6 +96,10 @@ console.log('address: ', wallet.address);
93
96
  const RPC_URL = chainConfig.rpcUrl;
94
97
  const connection = new Connection(RPC_URL);
95
98
 
99
+ // const evmConnection = new JsonRpcProvider(evmChainConfig.rpcUrl, {
100
+ // chainId: evmChainConfig.chainId
101
+ // });
102
+
96
103
  /**
97
104
  * Fetches and logs the token metadata for a given mint address.
98
105
  * @param mintAddress - The mint address of the token.
@@ -125,4 +132,26 @@ const connection = new Connection(RPC_URL);
125
132
  // console.error("Error fetching EVM transaction history:", error);
126
133
  // });
127
134
 
135
+ // discoverNFTs("0x498581ff718922c3f8e6a244956af099b2652b2b", evmChainConfig).then(nfts => {
136
+ // console.log("Discovered NFTs:", nfts);
137
+ // }).catch(error => {
138
+ // console.error("Error discovering NFTs:", error);
139
+ // });
140
+
141
+ // fetchWalletNfts(new PublicKey("LebronkTYWjc5J1gtqntdMcbhBXgwRgYcCxMA8JMA17"), connection).then(nfts => {
142
+ // console.log("Discovered NFTs:", nfts);
143
+ // }).catch(error => {
144
+ // console.error("Error discovering NFTs:", error);
145
+ // });
146
+
147
+ // discoverTokens(new PublicKey("8AXoqNjEVyhhe43ckDEsYiphWxTBH2oWXkKLZAbCNWLL"), connection).then(tokens => {
148
+ // console.log("Discovered Tokens:", tokens);
149
+ // }).catch(error => {
150
+ // console.error("Error discovering Tokens:", error);
151
+ // });
152
+
128
153
 
154
+ // //IIFE
155
+ // (async () => {
156
+ // //GET TOKEN LOGO using @solana/spl-token-metadata
157
+ // })();
package/utils/types.ts CHANGED
@@ -24,6 +24,15 @@ export interface TokenInfo {
24
24
  name: string;
25
25
  symbol: string;
26
26
  decimals: number;
27
+ logoUrl?: string;
28
+ description?: string;
29
+ website?: string;
30
+ social?: {
31
+ twitter?: string;
32
+ discord?: string;
33
+ telegram?: string;
34
+ [key: string]: string | undefined;
35
+ };
27
36
  }
28
37
 
29
38
  export interface UserTokenBalance<AddressType> extends TokenInfo {
@@ -39,6 +48,146 @@ export interface NFTInfo {
39
48
  image?: string;
40
49
  }
41
50
 
51
+ // Unified NFT interface for both EVM and SVM chains
52
+ export interface NFT {
53
+ // Unique identifier
54
+ id: string; // For Solana: mint address, For EVM: contractAddress:tokenId
55
+
56
+ // Basic metadata
57
+ name: string;
58
+ symbol?: string;
59
+ description: string;
60
+ image?: string;
61
+ uri: string; // Metadata URI
62
+
63
+ // Collection/Contract info
64
+ collection: {
65
+ address: string;
66
+ name: string;
67
+ verified?: boolean;
68
+ };
69
+
70
+ // Chain-specific data
71
+ chainType: 'SVM' | 'EVM';
72
+
73
+ // Ownership
74
+ balance?: string; // Quantity owned (useful for ERC1155)
75
+
76
+ // Optional metadata
77
+ attributes?: Array<{
78
+ trait_type: string;
79
+ value: string | number;
80
+ display_type?: string;
81
+ }>;
82
+
83
+ // Creators/Royalties (mainly for Solana)
84
+ creators?: Array<{
85
+ address: string;
86
+ verified: boolean;
87
+ share: number;
88
+ }>;
89
+
90
+ // Additional metadata
91
+ sellerFeeBasisPoints?: number; // Royalty percentage
92
+ tokenStandard?: string; // e.g., "ERC721", "ERC1155", "NonFungible", etc.
93
+
94
+ // Spam detection (mainly for EVM)
95
+ isSpam?: boolean;
96
+
97
+ // Raw chain-specific data for advanced use cases
98
+ raw?: {
99
+ svm?: SolanaNFT;
100
+ evm?: EVMNFT;
101
+ };
102
+ }
103
+
104
+ export interface SolanaNFT {
105
+ mint: string;
106
+ name: string;
107
+ symbol: string;
108
+ uri: string;
109
+ updateAuthority: string;
110
+ sellerFeeBasisPoints: number;
111
+ creators?: Array<{
112
+ address: string;
113
+ verified: boolean;
114
+ share: number;
115
+ }>;
116
+ }
117
+
118
+ export interface EVMNFTContract {
119
+ address: string;
120
+ name: string;
121
+ symbol: string;
122
+ totalSupply: string;
123
+ tokenType: string;
124
+ contractDeployer: string;
125
+ deployedBlockNumber: number;
126
+ isSpam: boolean;
127
+ spamClassifications?: string[];
128
+ }
129
+
130
+ export interface EVMNFTOpenSeaMetadata {
131
+ collectionName: string;
132
+ collectionSlug: string;
133
+ floorPrice?: number;
134
+ safelistRequestStatus: string;
135
+ imageUrl?: string;
136
+ lastIngestedAt: string;
137
+ }
138
+
139
+ export interface EVMNFTImage {
140
+ cachedUrl?: string;
141
+ thumbnailUrl?: string;
142
+ pngUrl?: string;
143
+ contentType?: string;
144
+ size?: number;
145
+ originalUrl?: string;
146
+ }
147
+
148
+ export interface EVMNFTAttribute {
149
+ trait_type: string;
150
+ value: string | number;
151
+ display_type?: string;
152
+ }
153
+
154
+ export interface EVMNFTRawMetadata {
155
+ tokenUri?: string;
156
+ metadata?: {
157
+ name?: string;
158
+ description?: string;
159
+ image?: string;
160
+ attributes?: EVMNFTAttribute[];
161
+ [key: string]: any;
162
+ };
163
+ }
164
+
165
+ export interface EVMNFTMint {
166
+ mintAddress?: string;
167
+ blockNumber?: number;
168
+ timestamp?: string;
169
+ transactionHash?: string;
170
+ }
171
+
172
+ export interface EVMNFT {
173
+ contract: EVMNFTContract;
174
+ openSeaMetadata?: EVMNFTOpenSeaMetadata;
175
+ tokenId: string;
176
+ tokenType: string;
177
+ name: string;
178
+ description: string;
179
+ balance: string;
180
+ image?: EVMNFTImage;
181
+ raw?: EVMNFTRawMetadata;
182
+ mint?: EVMNFTMint;
183
+ timeLastUpdated: string;
184
+ acquiredAt?: string;
185
+ }
186
+
187
+ export interface EVMNFTResponse {
188
+ data: EVMNFT[];
189
+ }
190
+
42
191
  export interface TransactionResult {
43
192
  hash: string;
44
193
  success: boolean;