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