neozipkit 0.1.1

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 (135) hide show
  1. package/README.md +400 -0
  2. package/contracts/Lock.sol +34 -0
  3. package/contracts/bytecode.txt +1 -0
  4. package/contracts/compile-contract.js +168 -0
  5. package/contracts/deploy/deploy-both-contracts.js +286 -0
  6. package/contracts/deploy/deploy-enhanced-contract.js +197 -0
  7. package/contracts/deploy/deploy-private-contract.js +190 -0
  8. package/contracts/deploy/deploy-public-clean.js +1063 -0
  9. package/contracts/deploy/deploy-public-contract.js +1107 -0
  10. package/contracts/deployment.config.example.js +25 -0
  11. package/contracts/remix-compile.js +222 -0
  12. package/contracts/setup-deployment.js +51 -0
  13. package/contracts/src/NZIP-NFT-Private.sol +350 -0
  14. package/contracts/src/NZIP-NFT.sol +265 -0
  15. package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +260 -0
  16. package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +289 -0
  17. package/dist/browser/CertificateGeneratorBrowser.d.ts +75 -0
  18. package/dist/browser/CertificateGeneratorBrowser.js +433 -0
  19. package/dist/browser/TokenVerifierBrowser.d.ts +76 -0
  20. package/dist/browser/TokenVerifierBrowser.js +299 -0
  21. package/dist/browser/ZipKitBrowser.d.ts +18 -0
  22. package/dist/browser/ZipKitBrowser.js +250 -0
  23. package/dist/browser/ZipKitStampBrowser.d.ts +2 -0
  24. package/dist/browser/ZipKitStampBrowser.js +12 -0
  25. package/dist/browser-index.d.ts +21 -0
  26. package/dist/browser-index.js +58 -0
  27. package/dist/browser.d.ts +21 -0
  28. package/dist/browser.js +58 -0
  29. package/dist/index.d.ts +29 -0
  30. package/dist/index.js +76 -0
  31. package/dist/server/blockchain/CertificateToken.d.ts +48 -0
  32. package/dist/server/blockchain/CertificateToken.js +386 -0
  33. package/dist/server/blockchain/NFTMinter.d.ts +41 -0
  34. package/dist/server/blockchain/NFTMinter.js +323 -0
  35. package/dist/server/blockchain/TokenQuerier.d.ts +31 -0
  36. package/dist/server/blockchain/TokenQuerier.js +259 -0
  37. package/dist/server/blockchain/TokenVerifier.d.ts +20 -0
  38. package/dist/server/blockchain/TokenVerifier.js +395 -0
  39. package/dist/server/blockchain/WalletAnalyzer.d.ts +81 -0
  40. package/dist/server/blockchain/WalletAnalyzer.js +356 -0
  41. package/dist/server/blockchain/WalletFormatter.d.ts +39 -0
  42. package/dist/server/blockchain/WalletFormatter.js +196 -0
  43. package/dist/server/blockchain/WalletManager.d.ts +46 -0
  44. package/dist/server/blockchain/WalletManager.js +294 -0
  45. package/dist/server/blockchain/ZipMetadata.d.ts +27 -0
  46. package/dist/server/blockchain/ZipMetadata.js +131 -0
  47. package/dist/server/blockchain/ZipTokenProcessor.d.ts +44 -0
  48. package/dist/server/blockchain/ZipTokenProcessor.js +204 -0
  49. package/dist/server/blockchain/constants.d.ts +102 -0
  50. package/dist/server/blockchain/constants.js +968 -0
  51. package/dist/server/blockchain/index.d.ts +9 -0
  52. package/dist/server/blockchain/index.js +44 -0
  53. package/dist/server/blockchain/test-certificate.d.ts +8 -0
  54. package/dist/server/blockchain/test-certificate.js +100 -0
  55. package/dist/server/blockchain/types.d.ts +69 -0
  56. package/dist/server/blockchain/types.js +51 -0
  57. package/dist/server/platform/server/ZipKitServer.d.ts +105 -0
  58. package/dist/server/platform/server/ZipKitServer.js +437 -0
  59. package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +91 -0
  60. package/dist/server/platform/servercomponents/ZipKitOTS.js +271 -0
  61. package/dist/shared/ZipEntry.d.ts +131 -0
  62. package/dist/shared/ZipEntry.js +686 -0
  63. package/dist/shared/ZipKit.d.ts +249 -0
  64. package/dist/shared/ZipKit.js +789 -0
  65. package/dist/shared/components/CertificateOTS.d.ts +15 -0
  66. package/dist/shared/components/CertificateOTS.js +116 -0
  67. package/dist/shared/components/FileSys.d.ts +2 -0
  68. package/dist/shared/components/FileSys.js +113 -0
  69. package/dist/shared/components/HashAccumulator.d.ts +55 -0
  70. package/dist/shared/components/HashAccumulator.js +100 -0
  71. package/dist/shared/components/Support.d.ts +63 -0
  72. package/dist/shared/components/Support.js +70 -0
  73. package/dist/shared/components/Util.d.ts +21 -0
  74. package/dist/shared/components/Util.js +115 -0
  75. package/dist/shared/components/ZipCrypto.d.ts +3 -0
  76. package/dist/shared/components/ZipCrypto.js +78 -0
  77. package/dist/shared/components/merkleTree.d.ts +66 -0
  78. package/dist/shared/components/merkleTree.js +136 -0
  79. package/dist/shared/constants/Errors.d.ts +53 -0
  80. package/dist/shared/constants/Errors.js +69 -0
  81. package/dist/shared/constants/Headers.d.ts +167 -0
  82. package/dist/shared/constants/Headers.js +191 -0
  83. package/dist/shared/types/index.d.ts +21 -0
  84. package/dist/shared/types/index.js +3 -0
  85. package/dist/shared/types.d.ts +33 -0
  86. package/dist/shared/types.js +8 -0
  87. package/dist/shared/version.d.ts +4 -0
  88. package/dist/shared/version.js +7 -0
  89. package/dist/types/index.d.ts +21 -0
  90. package/dist/types/index.js +3 -0
  91. package/examples/unzip-token.ts +488 -0
  92. package/examples/zip-token.ts +604 -0
  93. package/package.json +117 -0
  94. package/src/browser/CertificateGeneratorBrowser.ts +498 -0
  95. package/src/browser/TokenVerifierBrowser.ts +344 -0
  96. package/src/browser/ZipKitBrowser.ts +242 -0
  97. package/src/browser/ZipKitStampBrowser.ts +9 -0
  98. package/src/browser-index.ts +36 -0
  99. package/src/index.ts +48 -0
  100. package/src/server/blockchain/CertificateToken.ts +444 -0
  101. package/src/server/blockchain/NFTMinter.ts +357 -0
  102. package/src/server/blockchain/TokenQuerier.ts +287 -0
  103. package/src/server/blockchain/TokenVerifier.ts +453 -0
  104. package/src/server/blockchain/WalletAnalyzer.ts +397 -0
  105. package/src/server/blockchain/WalletFormatter.ts +206 -0
  106. package/src/server/blockchain/WalletManager.ts +294 -0
  107. package/src/server/blockchain/ZipMetadata.ts +117 -0
  108. package/src/server/blockchain/ZipTokenProcessor.ts +234 -0
  109. package/src/server/blockchain/constants.ts +969 -0
  110. package/src/server/blockchain/index.ts +42 -0
  111. package/src/server/blockchain/test-certificate.ts +137 -0
  112. package/src/server/blockchain/types.ts +134 -0
  113. package/src/server/platform/server/ZipKitServer.ts +459 -0
  114. package/src/server/platform/servercomponents/ZipKitOTS.ts +313 -0
  115. package/src/server/platform/servercomponents/opentimestamps.d.ts +23 -0
  116. package/src/shared/ZipEntry.ts +767 -0
  117. package/src/shared/ZipKit.ts +899 -0
  118. package/src/shared/components/CertificateOTS.ts +132 -0
  119. package/src/shared/components/FileSys.ts +87 -0
  120. package/src/shared/components/HashAccumulator.ts +113 -0
  121. package/src/shared/components/Support.ts +77 -0
  122. package/src/shared/components/Util.ts +113 -0
  123. package/src/shared/components/ZipCrypto.ts +91 -0
  124. package/src/shared/components/merkleTree.ts +162 -0
  125. package/src/shared/constants/Errors.ts +82 -0
  126. package/src/shared/constants/Headers.ts +203 -0
  127. package/src/shared/types/index.ts +25 -0
  128. package/src/shared/types/modules.d.ts +22 -0
  129. package/src/shared/types/opentimestamps.d.ts +23 -0
  130. package/src/shared/types.d.ts +8 -0
  131. package/src/shared/types.ts +43 -0
  132. package/src/shared/version.ts +4 -0
  133. package/src/types/index.ts +25 -0
  134. package/src/types/modules.d.ts +22 -0
  135. package/src/types/opentimestamps.d.ts +23 -0
@@ -0,0 +1,356 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.WalletAnalyzer = void 0;
37
+ const ethers_1 = require("ethers");
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ // Contract ABI for NZIP tokens
41
+ const NZIP_CONTRACT_ABI = [
42
+ "function getZipFileInfo(uint256 tokenId) view returns (tuple(string fileName, string merkleRootHash, uint256 creationTimestamp, string ipfsHash, uint256 tokenizationTime, address creator))",
43
+ "function ownerOf(uint256 tokenId) view returns (address)",
44
+ "function name() view returns (string)",
45
+ "function symbol() view returns (string)",
46
+ "function totalSupply() view returns (uint256)",
47
+ "function getTokensByMerkleRoot(string merkleRootHash) view returns (uint256[])",
48
+ "event ZipFileTokenized(uint256 indexed tokenId, address indexed creator, string fileName, string merkleRootHash, uint256 creationTimestamp, string ipfsHash)"
49
+ ];
50
+ // ERC-20 token ABI for checking other tokens
51
+ const ERC20_ABI = [
52
+ "function balanceOf(address owner) view returns (uint256)",
53
+ "function name() view returns (string)",
54
+ "function symbol() view returns (string)",
55
+ "function decimals() view returns (uint8)"
56
+ ];
57
+ // ERC-721 NFT ABI
58
+ const ERC721_ABI = [
59
+ "function balanceOf(address owner) view returns (uint256)",
60
+ "function name() view returns (string)",
61
+ "function symbol() view returns (string)",
62
+ "function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)"
63
+ ];
64
+ class WalletAnalyzer {
65
+ constructor(provider) {
66
+ this.provider = provider;
67
+ }
68
+ /**
69
+ * Get basic wallet information (balance, transaction count, etc.)
70
+ */
71
+ async getWalletBasics(address) {
72
+ try {
73
+ // Get ETH balance
74
+ const balance = await this.provider.getBalance(address);
75
+ const ethBalance = ethers_1.ethers.formatEther(balance);
76
+ // Get transaction count (nonce)
77
+ const txCount = await this.provider.getTransactionCount(address);
78
+ // Get network info
79
+ const network = await this.provider.getNetwork();
80
+ // Get latest block
81
+ const latestBlock = await this.provider.getBlockNumber();
82
+ return {
83
+ ethBalance,
84
+ transactionCount: txCount,
85
+ networkName: network.name,
86
+ chainId: network.chainId,
87
+ latestBlock
88
+ };
89
+ }
90
+ catch (error) {
91
+ throw new Error(`Failed to get wallet basics: ${error}`);
92
+ }
93
+ }
94
+ /**
95
+ * Scan for NZIP tokens owned by an address using multiple methods
96
+ */
97
+ async scanForNZipTokens(contractAddress, ownerAddress) {
98
+ const contract = new ethers_1.ethers.Contract(contractAddress, NZIP_CONTRACT_ABI, this.provider);
99
+ let foundTokens = [];
100
+ let searchMethod = 'none';
101
+ // Method 1: Try events with recent blocks only
102
+ try {
103
+ const latestBlock = await this.provider.getBlockNumber();
104
+ const startBlock = Math.max(0, latestBlock - 50000);
105
+ const filter = contract.filters.ZipFileTokenized(null, ownerAddress);
106
+ const events = await contract.queryFilter(filter, startBlock, 'latest');
107
+ for (const event of events) {
108
+ if ('args' in event && event.args && event.args.tokenId) {
109
+ const tokenId = Number(event.args.tokenId);
110
+ if (!foundTokens.includes(tokenId)) {
111
+ foundTokens.push(tokenId);
112
+ }
113
+ }
114
+ }
115
+ if (foundTokens.length > 0) {
116
+ searchMethod = 'recent-events';
117
+ return { foundTokens, searchMethod };
118
+ }
119
+ }
120
+ catch (eventError) {
121
+ // Continue to next method
122
+ }
123
+ // Method 2: Direct token ID checking (brute force for small supply)
124
+ try {
125
+ const totalSupply = await contract.totalSupply();
126
+ const maxCheck = Math.min(Number(totalSupply), 50); // Limit to 50 tokens max
127
+ for (let tokenId = 0; tokenId < maxCheck; tokenId++) {
128
+ try {
129
+ const owner = await contract.ownerOf(tokenId);
130
+ if (owner.toLowerCase() === ownerAddress.toLowerCase()) {
131
+ foundTokens.push(tokenId);
132
+ }
133
+ }
134
+ catch (ownerError) {
135
+ // Token doesn't exist or other error, skip
136
+ }
137
+ }
138
+ if (foundTokens.length > 0) {
139
+ searchMethod = 'iteration';
140
+ return { foundTokens, searchMethod };
141
+ }
142
+ }
143
+ catch (iterationError) {
144
+ // Continue to next method
145
+ }
146
+ // Method 3: Check specific token IDs that commonly exist
147
+ const commonTokenIds = Array.from({ length: 20 }, (_, i) => i); // 0-19
148
+ for (const tokenId of commonTokenIds) {
149
+ try {
150
+ const owner = await contract.ownerOf(tokenId);
151
+ if (owner.toLowerCase() === ownerAddress.toLowerCase()) {
152
+ foundTokens.push(tokenId);
153
+ }
154
+ }
155
+ catch (ownerError) {
156
+ // Token doesn't exist, skip
157
+ }
158
+ }
159
+ if (foundTokens.length > 0) {
160
+ searchMethod = 'common-ids';
161
+ }
162
+ return { foundTokens, searchMethod };
163
+ }
164
+ /**
165
+ * Get detailed information about NZIP tokens
166
+ */
167
+ async getNZipTokenDetails(contractAddress, tokenIds) {
168
+ const contract = new ethers_1.ethers.Contract(contractAddress, NZIP_CONTRACT_ABI, this.provider);
169
+ const tokenDetails = [];
170
+ for (const tokenId of tokenIds) {
171
+ try {
172
+ const zipInfo = await contract.getZipFileInfo(tokenId);
173
+ tokenDetails.push({
174
+ tokenId: tokenId.toString(),
175
+ merkleRootHash: zipInfo.merkleRootHash,
176
+ fileName: zipInfo.fileName,
177
+ timestamp: Number(zipInfo.creationTimestamp),
178
+ creator: zipInfo.creator,
179
+ creationTimestamp: Number(zipInfo.creationTimestamp),
180
+ tokenizationTime: Number(zipInfo.tokenizationTime),
181
+ ipfsHash: zipInfo.ipfsHash || undefined
182
+ });
183
+ }
184
+ catch (error) {
185
+ console.error(`Error fetching details for token ${tokenId}:`, error);
186
+ }
187
+ }
188
+ return tokenDetails;
189
+ }
190
+ /**
191
+ * Get contract information (name, symbol, total supply)
192
+ */
193
+ async getContractInfo(contractAddress) {
194
+ try {
195
+ const contract = new ethers_1.ethers.Contract(contractAddress, NZIP_CONTRACT_ABI, this.provider);
196
+ const [name, symbol, totalSupply] = await Promise.all([
197
+ contract.name(),
198
+ contract.symbol(),
199
+ contract.totalSupply()
200
+ ]);
201
+ return {
202
+ name,
203
+ symbol,
204
+ totalSupply: totalSupply.toString()
205
+ };
206
+ }
207
+ catch (error) {
208
+ return null;
209
+ }
210
+ }
211
+ /**
212
+ * Check ERC-20 token balances for common tokens
213
+ */
214
+ async checkERC20Tokens(ownerAddress, tokenConfigs) {
215
+ const foundTokens = [];
216
+ for (const tokenConfig of tokenConfigs.filter(t => t.type === 'ERC20')) {
217
+ try {
218
+ const contract = new ethers_1.ethers.Contract(tokenConfig.address, ERC20_ABI, this.provider);
219
+ const balance = await contract.balanceOf(ownerAddress);
220
+ if (balance > 0) {
221
+ let name, symbol, decimals;
222
+ try {
223
+ [name, symbol, decimals] = await Promise.all([
224
+ contract.name(),
225
+ contract.symbol(),
226
+ contract.decimals()
227
+ ]);
228
+ }
229
+ catch (metadataError) {
230
+ // Use fallback info if contract calls fail
231
+ name = tokenConfig.name;
232
+ symbol = tokenConfig.symbol;
233
+ decimals = 18; // Default decimals
234
+ }
235
+ const formattedBalance = ethers_1.ethers.formatUnits(balance, decimals);
236
+ foundTokens.push({
237
+ address: tokenConfig.address,
238
+ name,
239
+ symbol,
240
+ balance: formattedBalance,
241
+ decimals,
242
+ type: 'ERC20'
243
+ });
244
+ }
245
+ }
246
+ catch (error) {
247
+ // Token might not exist or might not be ERC20, continue silently
248
+ }
249
+ }
250
+ return foundTokens;
251
+ }
252
+ /**
253
+ * Check NFT collection balances
254
+ */
255
+ async checkNFTCollections(ownerAddress, nftConfigs) {
256
+ const foundNFTs = [];
257
+ for (const nftConfig of nftConfigs) {
258
+ try {
259
+ const contract = new ethers_1.ethers.Contract(nftConfig.address, ERC721_ABI, this.provider);
260
+ const balance = await contract.balanceOf(ownerAddress);
261
+ if (balance > 0) {
262
+ let name, symbol;
263
+ try {
264
+ [name, symbol] = await Promise.all([
265
+ contract.name(),
266
+ contract.symbol()
267
+ ]);
268
+ }
269
+ catch (metadataError) {
270
+ name = nftConfig.name;
271
+ symbol = nftConfig.symbol;
272
+ }
273
+ // Try to get token IDs if balance is small
274
+ let tokenIds = [];
275
+ if (Number(balance) <= 5) {
276
+ try {
277
+ for (let i = 0; i < Number(balance); i++) {
278
+ const tokenId = await contract.tokenOfOwnerByIndex(ownerAddress, i);
279
+ tokenIds.push(tokenId.toString());
280
+ }
281
+ }
282
+ catch (enumError) {
283
+ // Unable to enumerate, that's okay
284
+ }
285
+ }
286
+ foundNFTs.push({
287
+ address: nftConfig.address,
288
+ name,
289
+ symbol,
290
+ balance: balance.toString(),
291
+ type: 'ERC721'
292
+ });
293
+ }
294
+ }
295
+ catch (error) {
296
+ // Contract might not exist or might not be ERC-721, continue silently
297
+ }
298
+ }
299
+ return foundNFTs;
300
+ }
301
+ /**
302
+ * Detect NZIP contract from deployment file
303
+ */
304
+ static detectNZipContract() {
305
+ const deploymentPath = path.join(process.cwd(), 'zipfile-nft-deployment.json');
306
+ if (fs.existsSync(deploymentPath)) {
307
+ try {
308
+ const deploymentInfo = JSON.parse(fs.readFileSync(deploymentPath, 'utf8'));
309
+ if (deploymentInfo.address) {
310
+ return deploymentInfo.address;
311
+ }
312
+ }
313
+ catch (error) {
314
+ // Could not read deployment file
315
+ }
316
+ }
317
+ return undefined;
318
+ }
319
+ /**
320
+ * Get common token configurations for a network
321
+ */
322
+ static getCommonTokens(network) {
323
+ const commonTokens = {
324
+ 'base-sepolia': [
325
+ { address: '0x036CbD53842c5426634e7929541eC2318f3dCF7e', name: 'USD Coin', symbol: 'USDC', type: 'ERC20' },
326
+ { address: '0x4200000000000000000000000000000000000006', name: 'Wrapped Ether', symbol: 'WETH', type: 'ERC20' },
327
+ { address: '0xE4aB69C077896252FAFBD49EFD26B5D171A32410', name: 'Coinbase Wrapped Staked ETH', symbol: 'cbETH', type: 'ERC20' },
328
+ ],
329
+ 'base': [
330
+ { address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', name: 'USD Coin', symbol: 'USDC', type: 'ERC20' },
331
+ { address: '0x4200000000000000000000000000000000000006', name: 'Wrapped Ether', symbol: 'WETH', type: 'ERC20' },
332
+ { address: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb', name: 'Dai Stablecoin', symbol: 'DAI', type: 'ERC20' },
333
+ { address: '0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22', name: 'Coinbase Wrapped Staked ETH', symbol: 'cbETH', type: 'ERC20' },
334
+ { address: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', name: 'USD Base Coin', symbol: 'USDbC', type: 'ERC20' },
335
+ ]
336
+ };
337
+ return commonTokens[network] || [];
338
+ }
339
+ /**
340
+ * Get common NFT configurations for a network
341
+ */
342
+ static getCommonNFTs(network) {
343
+ const commonNFTs = {
344
+ 'base-sepolia': [
345
+ // Add known testnet NFTs here when they become available
346
+ ],
347
+ 'base': [
348
+ // Base mainnet NFTs - these are examples, real addresses would be different
349
+ { address: '0x1234567890123456789012345678901234567890', name: 'Base Punks', symbol: 'BPUNK', type: 'ERC721' },
350
+ { address: '0x0987654321098765432109876543210987654321', name: 'Base Bears', symbol: 'BBEAR', type: 'ERC721' },
351
+ ]
352
+ };
353
+ return commonNFTs[network] || [];
354
+ }
355
+ }
356
+ exports.WalletAnalyzer = WalletAnalyzer;
@@ -0,0 +1,39 @@
1
+ import { WalletBasicInfo, NZipTokenDetails, TokenInfo, TokenScanResult } from './WalletAnalyzer';
2
+ export declare class WalletFormatter {
3
+ /**
4
+ * Display basic wallet information
5
+ */
6
+ static displayWalletBasics(walletInfo: WalletBasicInfo): void;
7
+ /**
8
+ * Display contract information
9
+ */
10
+ static displayContractInfo(contractInfo: {
11
+ name: string;
12
+ symbol: string;
13
+ totalSupply: string;
14
+ } | null, isLegacy?: boolean): void;
15
+ /**
16
+ * Display token scan progress
17
+ */
18
+ static displayTokenScanProgress(scanResult: TokenScanResult): void;
19
+ /**
20
+ * Display detailed NZIP token information
21
+ */
22
+ static displayNZipTokenDetails(tokenDetails: NZipTokenDetails[], scanResult: TokenScanResult, contractAddress: string): void;
23
+ /**
24
+ * Display ERC-20 token information
25
+ */
26
+ static displayERC20Tokens(tokens: TokenInfo[]): void;
27
+ /**
28
+ * Display NFT collection information
29
+ */
30
+ static displayNFTCollections(nfts: TokenInfo[]): void;
31
+ /**
32
+ * Display token scan summary
33
+ */
34
+ static displayTokenScanSummary(erc20Count: number, totalScanned: number): void;
35
+ /**
36
+ * Display error messages for contract connection issues
37
+ */
38
+ static displayContractError(error: any, contractAddress: string): void;
39
+ }
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletFormatter = void 0;
4
+ class WalletFormatter {
5
+ /**
6
+ * Display basic wallet information
7
+ */
8
+ static displayWalletBasics(walletInfo) {
9
+ console.log('\nšŸ’° Basic Wallet Information');
10
+ console.log('─'.repeat(50));
11
+ console.log(`ETH Balance: ${walletInfo.ethBalance} ETH`);
12
+ console.log(`Transaction Count: ${walletInfo.transactionCount}`);
13
+ console.log(`Network Name: ${walletInfo.networkName}`);
14
+ console.log(`Chain ID: ${walletInfo.chainId}`);
15
+ console.log(`Latest Block: ${walletInfo.latestBlock}`);
16
+ }
17
+ /**
18
+ * Display contract information
19
+ */
20
+ static displayContractInfo(contractInfo, isLegacy = false) {
21
+ if (contractInfo) {
22
+ console.log(`Contract Name: ${contractInfo.name}`);
23
+ console.log(`Contract Symbol: ${contractInfo.symbol}`);
24
+ console.log(`Total Supply: ${contractInfo.totalSupply}`);
25
+ }
26
+ else {
27
+ console.log('Contract Info: Unable to fetch');
28
+ }
29
+ }
30
+ /**
31
+ * Display token scan progress
32
+ */
33
+ static displayTokenScanProgress(scanResult) {
34
+ console.log('Searching for tokens owned by this address...');
35
+ if (scanResult.searchMethod === 'recent-events') {
36
+ console.log(' šŸ” Trying recent events (last 50k blocks)...');
37
+ console.log(` āœ… Found ${scanResult.foundTokens.length} tokens from recent events`);
38
+ }
39
+ else if (scanResult.searchMethod === 'iteration') {
40
+ console.log(' šŸ” Trying recent events (last 50k blocks)...');
41
+ console.log(' āŒ Recent events failed, trying alternative methods...');
42
+ console.log(' šŸ” Checking token ownership by iteration...');
43
+ console.log(` āœ… Found ${scanResult.foundTokens.length} tokens by iteration`);
44
+ }
45
+ else if (scanResult.searchMethod === 'common-ids') {
46
+ console.log(' šŸ” Trying recent events (last 50k blocks)...');
47
+ console.log(' āŒ Recent events failed, trying alternative methods...');
48
+ console.log(' šŸ” Checking token ownership by iteration...');
49
+ console.log(' āš ļø No tokens found by iteration, checking common IDs...');
50
+ console.log(' šŸ” Checking common token IDs (0-19)...');
51
+ console.log(` āœ… Found ${scanResult.foundTokens.length} tokens from common IDs`);
52
+ }
53
+ else {
54
+ console.log(' šŸ” Trying recent events (last 50k blocks)...');
55
+ console.log(' āŒ Recent events failed, trying alternative methods...');
56
+ console.log(' šŸ” Checking token ownership by iteration...');
57
+ console.log(' āš ļø No tokens found by iteration, checking common IDs...');
58
+ console.log(' šŸ” Checking common token IDs (0-19)...');
59
+ }
60
+ }
61
+ /**
62
+ * Display detailed NZIP token information
63
+ */
64
+ static displayNZipTokenDetails(tokenDetails, scanResult, contractAddress) {
65
+ if (tokenDetails.length > 0) {
66
+ console.log(`\nāœ… Found ${tokenDetails.length} NZIP token(s) using ${scanResult.searchMethod}:`);
67
+ console.log('šŸ“‹ Your NZIP Token Details:');
68
+ console.log('═'.repeat(80));
69
+ for (const token of tokenDetails.sort((a, b) => parseInt(a.tokenId) - parseInt(b.tokenId))) {
70
+ console.log(`\nšŸŽÆ Token ID ${token.tokenId}:`);
71
+ console.log(` File Name: ${token.fileName}`);
72
+ console.log(` Merkle Root: ${token.merkleRootHash}`);
73
+ // Convert timestamps to dates
74
+ const creationDate = new Date(token.creationTimestamp * 1000);
75
+ const tokenizationDate = new Date(token.tokenizationTime * 1000);
76
+ // Format dates in a more readable format
77
+ const formatOptions = {
78
+ year: 'numeric',
79
+ month: 'short',
80
+ day: '2-digit',
81
+ hour: '2-digit',
82
+ minute: '2-digit',
83
+ second: '2-digit',
84
+ timeZoneName: 'short'
85
+ };
86
+ console.log(` Created: ${creationDate.toLocaleDateString('en-US', formatOptions)}`);
87
+ console.log(` Tokenized: ${tokenizationDate.toLocaleDateString('en-US', formatOptions)}`);
88
+ // Show time difference between creation and tokenization
89
+ const timeDiffSeconds = token.tokenizationTime - token.creationTimestamp;
90
+ if (timeDiffSeconds > 0) {
91
+ if (timeDiffSeconds < 60) {
92
+ console.log(` Tokenization Delay: ${timeDiffSeconds} seconds`);
93
+ }
94
+ else if (timeDiffSeconds < 3600) {
95
+ console.log(` Tokenization Delay: ${Math.round(timeDiffSeconds / 60)} minutes`);
96
+ }
97
+ else {
98
+ console.log(` Tokenization Delay: ${Math.round(timeDiffSeconds / 3600)} hours`);
99
+ }
100
+ }
101
+ if (token.ipfsHash && token.ipfsHash !== '') {
102
+ console.log(` IPFS Hash: ${token.ipfsHash}`);
103
+ }
104
+ console.log(` Creator: ${token.creator}`);
105
+ // Calculate age since creation (using current time)
106
+ const now = Date.now();
107
+ const ageMs = now - (token.creationTimestamp * 1000);
108
+ const ageDays = Math.floor(ageMs / (1000 * 60 * 60 * 24));
109
+ const ageHours = Math.floor((ageMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
110
+ const ageMinutes = Math.floor((ageMs % (1000 * 60 * 60)) / (1000 * 60));
111
+ if (ageDays > 0) {
112
+ console.log(` Age: ${ageDays} days, ${ageHours} hours`);
113
+ }
114
+ else if (ageHours > 0) {
115
+ console.log(` Age: ${ageHours} hours, ${ageMinutes} minutes`);
116
+ }
117
+ else {
118
+ console.log(` Age: ${ageMinutes} minutes`);
119
+ }
120
+ }
121
+ }
122
+ else {
123
+ console.log('\nāŒ No NZIP tokens found for this address');
124
+ console.log('\nšŸ’” This could mean:');
125
+ console.log(' • You don\'t own any NZIP tokens on this network');
126
+ console.log(' • The tokens are on a different contract or network');
127
+ console.log(' • There are temporary RPC connectivity issues');
128
+ console.log('\nšŸ”§ Try these troubleshooting steps:');
129
+ console.log(' • Verify you\'re on the correct network (--network flag)');
130
+ console.log(' • Check if you have tokens on a different contract (--contract flag)');
131
+ console.log(' • Try again in a few minutes if RPC is experiencing issues');
132
+ console.log(` • Verify the contract address: ${contractAddress}`);
133
+ }
134
+ }
135
+ /**
136
+ * Display ERC-20 token information
137
+ */
138
+ static displayERC20Tokens(tokens) {
139
+ if (tokens.length > 0) {
140
+ console.log(`\nšŸ’° ERC-20 Token Balances:`);
141
+ for (const token of tokens) {
142
+ console.log(`\n šŸ’Ž ${token.symbol} (${token.name}):`);
143
+ console.log(` Contract: ${token.address}`);
144
+ console.log(` Balance: ${token.balance} ${token.symbol}`);
145
+ console.log(` Decimals: ${token.decimals}`);
146
+ // Add USD value estimation for major stablecoins
147
+ if (['USDC', 'USDT', 'DAI', 'USDbC'].includes(token.symbol)) {
148
+ console.log(` Est. USD Value: ~$${token.balance}`);
149
+ }
150
+ }
151
+ }
152
+ }
153
+ /**
154
+ * Display NFT collection information
155
+ */
156
+ static displayNFTCollections(nfts) {
157
+ console.log(`\nšŸ–¼ļø Other NFT Collections:`);
158
+ if (nfts.length > 0) {
159
+ for (const nft of nfts) {
160
+ console.log(`\n šŸ–¼ļø ${nft.symbol} (${nft.name}):`);
161
+ console.log(` Contract: ${nft.address}`);
162
+ console.log(` NFTs Owned: ${nft.balance}`);
163
+ }
164
+ }
165
+ else {
166
+ console.log(` No other NFT collections found`);
167
+ }
168
+ }
169
+ /**
170
+ * Display token scan summary
171
+ */
172
+ static displayTokenScanSummary(erc20Count, totalScanned) {
173
+ console.log(`\nšŸ“Š Token Scan Summary:`);
174
+ console.log(` ERC-20 Tokens Found: ${erc20Count}`);
175
+ console.log(` Total Tokens Scanned: ${totalScanned}`);
176
+ if (erc20Count === 0) {
177
+ console.log(`\nšŸ’” No tokens found. This could mean:`);
178
+ console.log(` • This is a new wallet with no token activity`);
179
+ console.log(` • Tokens are on a different network`);
180
+ console.log(` • You have tokens not in our common token list`);
181
+ console.log(` • There are temporary RPC connectivity issues`);
182
+ }
183
+ }
184
+ /**
185
+ * Display error messages for contract connection issues
186
+ */
187
+ static displayContractError(error, contractAddress) {
188
+ console.error('āŒ Error connecting to NZIP contract:', error);
189
+ console.log('\nšŸ”§ Troubleshooting suggestions:');
190
+ console.log(' • Check if the contract address is correct');
191
+ console.log(' • Verify you\'re on the right network');
192
+ console.log(' • Try again later if RPC is experiencing issues');
193
+ console.log(' • Use --contract flag to specify a different contract address');
194
+ }
195
+ }
196
+ exports.WalletFormatter = WalletFormatter;
@@ -0,0 +1,46 @@
1
+ import { ethers } from 'ethers';
2
+ import { WalletSetupResult, MintingOptions } from './types';
3
+ export declare class WalletManager {
4
+ private wallet;
5
+ private provider;
6
+ /**
7
+ * Prompts the user for input
8
+ */
9
+ private promptUser;
10
+ /**
11
+ * Looks for existing wallet files in the current directory and wallet subdirectory
12
+ */
13
+ private findExistingWallets;
14
+ /**
15
+ * Loads wallet information from a file
16
+ */
17
+ private loadWalletFromFile;
18
+ /**
19
+ * Sets up a Base wallet for token operations
20
+ */
21
+ setupWallet(options: MintingOptions): Promise<WalletSetupResult>;
22
+ /**
23
+ * Creates a new wallet and saves it to file
24
+ */
25
+ private createNewWallet;
26
+ /**
27
+ * Connects to the specified blockchain network
28
+ */
29
+ private connectToNetwork;
30
+ /**
31
+ * Gets the current wallet instance
32
+ */
33
+ getWallet(): ethers.Wallet | null;
34
+ /**
35
+ * Gets the current provider instance
36
+ */
37
+ getProvider(): ethers.JsonRpcProvider | null;
38
+ /**
39
+ * Checks if wallet is connected and ready for transactions
40
+ */
41
+ isReady(): boolean;
42
+ /**
43
+ * Checks if provider is connected
44
+ */
45
+ isOnline(): boolean;
46
+ }