neozipkit 0.1.1 → 0.2.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.
- package/README.md +52 -105
- package/contracts/INTEGRATION.md +338 -0
- package/contracts/NETWORKS.md +156 -0
- package/contracts/README.md +152 -0
- package/{src/server/blockchain → contracts}/constants.ts +5 -22
- package/contracts/deploy-bytecode.mjs +94 -0
- package/dist/blockchain/ZipKitMinter.d.ts +106 -0
- package/dist/blockchain/ZipKitMinter.js +347 -0
- package/dist/blockchain/ZipKitNFT.d.ts +3 -0
- package/dist/blockchain/ZipKitNFT.js +7 -0
- package/dist/blockchain/ZipKitOTS.d.ts +135 -0
- package/dist/blockchain/ZipKitOTS.js +564 -0
- package/dist/blockchain/ZipKitVerifier.d.ts +69 -0
- package/dist/blockchain/ZipKitVerifier.js +289 -0
- package/dist/{server/blockchain/WalletAnalyzer.d.ts → blockchain/ZipKitWallet.d.ts} +31 -43
- package/dist/{server/blockchain/WalletAnalyzer.js → blockchain/ZipKitWallet.js} +193 -161
- package/dist/blockchain/contracts.d.ts +14 -0
- package/dist/blockchain/contracts.js +77 -0
- package/dist/blockchain/index.d.ts +7 -0
- package/dist/blockchain/index.js +50 -0
- package/dist/{server/blockchain → blockchain}/types.d.ts +12 -34
- package/dist/{server/blockchain → blockchain}/types.js +1 -22
- package/dist/browser-index.d.ts +0 -3
- package/dist/browser-index.js +4 -5
- package/dist/browser.d.ts +0 -3
- package/dist/browser.js +4 -5
- package/dist/index.d.ts +8 -15
- package/dist/index.js +12 -24
- package/dist/server/{platform/server/ZipKitServer.d.ts → ZipKitServer.d.ts} +4 -35
- package/dist/server/{platform/server/ZipKitServer.js → ZipKitServer.js} +55 -182
- package/dist/shared/ZipEntry.js +1 -1
- package/dist/shared/ZipKit.d.ts +0 -6
- package/dist/shared/ZipKit.js +1 -18
- package/dist/shared/types.js +2 -2
- package/dist/shared/version.d.ts +2 -4
- package/dist/shared/version.js +4 -5
- package/package.json +13 -3
- package/src/blockchain/README.md +229 -0
- package/src/blockchain/ZipKitMinter.ts +470 -0
- package/src/blockchain/ZipKitNFT.ts +12 -0
- package/src/blockchain/ZipKitOTS.ts +622 -0
- package/src/blockchain/ZipKitVerifier.ts +382 -0
- package/src/blockchain/ZipKitWallet.ts +338 -0
- package/src/blockchain/contracts.ts +88 -0
- package/src/blockchain/index.ts +61 -0
- package/src/blockchain/types.ts +91 -0
- package/src/browser/{TokenVerifierBrowser.ts → TokenVerifierBrowser.ts-remove} +1 -1
- package/src/browser-index.ts +3 -3
- package/src/index.ts +10 -17
- package/src/server/README.md +25 -0
- package/src/server/ZipKitServer.ts +305 -0
- package/src/shared/ZipEntry.ts +1 -1
- package/src/shared/ZipKit.ts +1 -19
- package/src/shared/types.ts +3 -3
- package/src/shared/version.ts +3 -4
- package/src/types/modules.d.ts +11 -1
- package/contracts/Lock.sol +0 -34
- package/contracts/compile-contract.js +0 -168
- package/contracts/deploy/deploy-both-contracts.js +0 -286
- package/contracts/deploy/deploy-enhanced-contract.js +0 -197
- package/contracts/deploy/deploy-private-contract.js +0 -190
- package/contracts/deploy/deploy-public-clean.js +0 -1063
- package/contracts/deploy/deploy-public-contract.js +0 -1107
- package/contracts/deployment.config.example.js +0 -25
- package/contracts/remix-compile.js +0 -222
- package/contracts/setup-deployment.js +0 -51
- package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +0 -260
- package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +0 -289
- package/dist/browser/CertificateGeneratorBrowser.d.ts +0 -75
- package/dist/browser/CertificateGeneratorBrowser.js +0 -433
- package/dist/browser/TokenVerifierBrowser.d.ts +0 -76
- package/dist/browser/TokenVerifierBrowser.js +0 -299
- package/dist/server/blockchain/NFTMinter.d.ts +0 -41
- package/dist/server/blockchain/NFTMinter.js +0 -323
- package/dist/server/blockchain/TokenQuerier.d.ts +0 -31
- package/dist/server/blockchain/TokenQuerier.js +0 -259
- package/dist/server/blockchain/TokenVerifier.d.ts +0 -20
- package/dist/server/blockchain/TokenVerifier.js +0 -395
- package/dist/server/blockchain/WalletFormatter.d.ts +0 -39
- package/dist/server/blockchain/WalletFormatter.js +0 -196
- package/dist/server/blockchain/WalletManager.d.ts +0 -46
- package/dist/server/blockchain/WalletManager.js +0 -294
- package/dist/server/blockchain/ZipMetadata.d.ts +0 -27
- package/dist/server/blockchain/ZipMetadata.js +0 -131
- package/dist/server/blockchain/ZipTokenProcessor.d.ts +0 -44
- package/dist/server/blockchain/ZipTokenProcessor.js +0 -204
- package/dist/server/blockchain/constants.d.ts +0 -102
- package/dist/server/blockchain/constants.js +0 -968
- package/dist/server/blockchain/index.d.ts +0 -9
- package/dist/server/blockchain/index.js +0 -44
- package/dist/server/blockchain/test-certificate.d.ts +0 -8
- package/dist/server/blockchain/test-certificate.js +0 -100
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +0 -91
- package/dist/server/platform/servercomponents/ZipKitOTS.js +0 -271
- package/examples/unzip-token.ts +0 -488
- package/examples/zip-token.ts +0 -604
- package/src/server/blockchain/NFTMinter.ts +0 -357
- package/src/server/blockchain/TokenQuerier.ts +0 -287
- package/src/server/blockchain/TokenVerifier.ts +0 -453
- package/src/server/blockchain/WalletAnalyzer.ts +0 -397
- package/src/server/blockchain/WalletFormatter.ts +0 -206
- package/src/server/blockchain/WalletManager.ts +0 -294
- package/src/server/blockchain/ZipMetadata.ts +0 -117
- package/src/server/blockchain/ZipTokenProcessor.ts +0 -234
- package/src/server/blockchain/index.ts +0 -42
- package/src/server/blockchain/test-certificate.ts +0 -137
- package/src/server/blockchain/types.ts +0 -134
- package/src/server/platform/server/ZipKitServer.ts +0 -459
- package/src/server/platform/servercomponents/ZipKitOTS.ts +0 -313
- package/src/server/platform/servercomponents/opentimestamps.d.ts +0 -23
- /package/contracts/{bytecode.txt → NZIP-NFT-bytecode.txt} +0 -0
- /package/dist/{server/blockchain → blockchain}/CertificateToken.d.ts +0 -0
- /package/dist/{server/blockchain → blockchain}/CertificateToken.js +0 -0
- /package/src/{server/blockchain → blockchain}/CertificateToken.ts +0 -0
- /package/src/browser/{CertificateGeneratorBrowser.ts → CertificateGeneratorBrowser.ts-remove} +0 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ZipKitVerifier - Handles NFT token verification for ZIP files
|
|
5
|
+
* Verifier API for NZIP-NFT smart contract.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { ethers } from 'ethers';
|
|
9
|
+
import { NZIP_CONTRACT_ABI, CONTRACT_CONFIGS } from './contracts';
|
|
10
|
+
import type { TokenMetadata } from './types';
|
|
11
|
+
|
|
12
|
+
// Network configurations
|
|
13
|
+
const NETWORK_CONFIGS = {
|
|
14
|
+
'base-sepolia': {
|
|
15
|
+
name: 'Base Sepolia',
|
|
16
|
+
rpcUrl: 'https://sepolia.base.org',
|
|
17
|
+
contractAddress: CONTRACT_CONFIGS[84532].address, // Use real contract address
|
|
18
|
+
explorerUrl: 'https://sepolia.basescan.org',
|
|
19
|
+
chainId: 84532
|
|
20
|
+
},
|
|
21
|
+
'base-mainnet': {
|
|
22
|
+
name: 'Base Mainnet',
|
|
23
|
+
rpcUrl: 'https://mainnet.base.org',
|
|
24
|
+
contractAddress: CONTRACT_CONFIGS[8453].address, // Use real contract address
|
|
25
|
+
explorerUrl: 'https://basescan.org',
|
|
26
|
+
chainId: 8453
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export interface VerificationOptions {
|
|
31
|
+
debug?: boolean;
|
|
32
|
+
skipHash?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface VerificationResult {
|
|
36
|
+
success: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
tokenMetadata?: TokenMetadata;
|
|
39
|
+
verificationDetails?: {
|
|
40
|
+
tokenId: string;
|
|
41
|
+
network: string;
|
|
42
|
+
contractAddress: string;
|
|
43
|
+
merkleRoot: string;
|
|
44
|
+
mintDate: string;
|
|
45
|
+
calculatedMerkleRoot?: string;
|
|
46
|
+
declaredMerkleRoot?: string;
|
|
47
|
+
merkleRootMatch?: boolean;
|
|
48
|
+
onChainValid?: boolean;
|
|
49
|
+
};
|
|
50
|
+
errorDetails?: {
|
|
51
|
+
errorType: 'METADATA_ERROR' | 'MERKLE_ERROR' | 'NETWORK_ERROR' | 'CONTRACT_ERROR';
|
|
52
|
+
networkName?: string;
|
|
53
|
+
rpcUrl?: string;
|
|
54
|
+
contractAddress?: string;
|
|
55
|
+
tokenId?: string;
|
|
56
|
+
merkleRoot?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Blockchain Token Verifier for ZIP files
|
|
62
|
+
*/
|
|
63
|
+
export class ZipKitVerifier {
|
|
64
|
+
private debug: boolean;
|
|
65
|
+
|
|
66
|
+
constructor(options: VerificationOptions = {}) {
|
|
67
|
+
this.debug = options.debug || false;
|
|
68
|
+
|
|
69
|
+
if (this.debug) {
|
|
70
|
+
console.log(`[DEBUG] ZipKitVerifier initialized`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Extract and validate token metadata from ZIP
|
|
76
|
+
*/
|
|
77
|
+
async extractTokenMetadata(tokenBuffer: Buffer): Promise<{ success: boolean; metadata?: TokenMetadata; error?: string }> {
|
|
78
|
+
try {
|
|
79
|
+
if (this.debug) {
|
|
80
|
+
console.log(`[DEBUG] Extracting token metadata from buffer (${tokenBuffer.length} bytes)`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const tokenData = JSON.parse(tokenBuffer.toString('utf8'));
|
|
84
|
+
|
|
85
|
+
// Validate required fields
|
|
86
|
+
const requiredFields = ['tokenId', 'contractAddress', 'network'];
|
|
87
|
+
for (const field of requiredFields) {
|
|
88
|
+
if (!tokenData[field]) {
|
|
89
|
+
if (this.debug) {
|
|
90
|
+
console.log(`[DEBUG] Missing required field: ${field}`);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
success: false,
|
|
94
|
+
error: `Missing required field: ${field}`
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.debug) {
|
|
100
|
+
console.log(`[DEBUG] Token metadata extracted successfully`);
|
|
101
|
+
console.log(`[DEBUG] Token ID: ${tokenData.tokenId}, Network: ${tokenData.network}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
success: true,
|
|
106
|
+
metadata: tokenData as TokenMetadata
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
} catch (error) {
|
|
110
|
+
const errorMessage = error instanceof Error ? error.message : 'Invalid JSON format';
|
|
111
|
+
|
|
112
|
+
if (this.debug) {
|
|
113
|
+
console.log(`[DEBUG] Failed to parse token metadata: ${errorMessage}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
error: `Invalid token metadata format: ${errorMessage}`
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Map network name to RPC configuration
|
|
125
|
+
*/
|
|
126
|
+
private getNetworkConfig(networkName: string): { success: boolean; config?: any; error?: string } {
|
|
127
|
+
const normalizedName = networkName.toLowerCase();
|
|
128
|
+
|
|
129
|
+
if (this.debug) {
|
|
130
|
+
console.log(`[DEBUG] Looking up network config for: ${normalizedName}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Map various network name variations to our configs
|
|
134
|
+
if (normalizedName.includes('sepolia')) {
|
|
135
|
+
return { success: true, config: NETWORK_CONFIGS['base-sepolia'] };
|
|
136
|
+
} else if (normalizedName.includes('base') && !normalizedName.includes('sepolia')) {
|
|
137
|
+
return { success: true, config: NETWORK_CONFIGS['base-mainnet'] };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (this.debug) {
|
|
141
|
+
console.log(`[DEBUG] Unsupported network: ${normalizedName}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
success: false,
|
|
146
|
+
error: `Unsupported network: ${networkName}`
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Perform merkle root comparison
|
|
152
|
+
*/
|
|
153
|
+
private compareMerkleRoots(calculated: string | null, declared: string | null): {
|
|
154
|
+
success: boolean;
|
|
155
|
+
match: boolean;
|
|
156
|
+
calculated?: string;
|
|
157
|
+
declared?: string;
|
|
158
|
+
error?: string;
|
|
159
|
+
} {
|
|
160
|
+
if (this.debug) {
|
|
161
|
+
console.log(`[DEBUG] Comparing merkle roots`);
|
|
162
|
+
console.log(`[DEBUG] Calculated: ${calculated || 'null'}`);
|
|
163
|
+
console.log(`[DEBUG] Declared: ${declared || 'null'}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!calculated) {
|
|
167
|
+
return {
|
|
168
|
+
success: false,
|
|
169
|
+
match: false,
|
|
170
|
+
error: 'Cannot calculate merkle root from archive contents'
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!declared) {
|
|
175
|
+
return {
|
|
176
|
+
success: false,
|
|
177
|
+
match: false,
|
|
178
|
+
calculated,
|
|
179
|
+
error: 'No merkle root found in token metadata'
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const match = calculated === declared;
|
|
184
|
+
|
|
185
|
+
if (this.debug) {
|
|
186
|
+
console.log(`[DEBUG] Merkle root match: ${match}`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
success: true,
|
|
191
|
+
match,
|
|
192
|
+
calculated,
|
|
193
|
+
declared
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Verify token against blockchain
|
|
199
|
+
*/
|
|
200
|
+
async verifyOnChain(
|
|
201
|
+
tokenId: string,
|
|
202
|
+
contractAddress: string,
|
|
203
|
+
networkConfig: any,
|
|
204
|
+
merkleRoot: string
|
|
205
|
+
): Promise<{ success: boolean; isValid?: boolean; error?: string }> {
|
|
206
|
+
try {
|
|
207
|
+
if (this.debug) {
|
|
208
|
+
console.log(`[DEBUG] Starting on-chain verification`);
|
|
209
|
+
console.log(`[DEBUG] Token ID: ${tokenId}, Contract: ${contractAddress}`);
|
|
210
|
+
console.log(`[DEBUG] Network: ${networkConfig.name}, RPC: ${networkConfig.rpcUrl}`);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const provider = new ethers.JsonRpcProvider(networkConfig.rpcUrl);
|
|
214
|
+
const contract = new ethers.Contract(contractAddress, NZIP_CONTRACT_ABI, provider);
|
|
215
|
+
|
|
216
|
+
if (this.debug) {
|
|
217
|
+
console.log(`[DEBUG] Calling contract.verifyZipFile(${tokenId}, ${merkleRoot.substring(0, 10)}...)`);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const isValid: boolean = await contract.verifyZipFile(tokenId, merkleRoot);
|
|
221
|
+
|
|
222
|
+
if (this.debug) {
|
|
223
|
+
console.log(`[DEBUG] On-chain verification result: ${isValid}`);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return { success: true, isValid };
|
|
227
|
+
|
|
228
|
+
} catch (error) {
|
|
229
|
+
const errorMessage = error instanceof Error ? error.message : 'Network error';
|
|
230
|
+
|
|
231
|
+
if (this.debug) {
|
|
232
|
+
console.log(`[DEBUG] On-chain verification failed: ${errorMessage}`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
success: false,
|
|
237
|
+
error: errorMessage
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Complete verification process
|
|
244
|
+
*/
|
|
245
|
+
async verifyToken(
|
|
246
|
+
tokenMetadata: TokenMetadata,
|
|
247
|
+
calculatedMerkleRoot: string | null,
|
|
248
|
+
options: VerificationOptions = {}
|
|
249
|
+
): Promise<VerificationResult> {
|
|
250
|
+
try {
|
|
251
|
+
if (this.debug) {
|
|
252
|
+
console.log(`[DEBUG] Starting complete token verification`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Get network configuration
|
|
256
|
+
const networkResult = this.getNetworkConfig(tokenMetadata.network);
|
|
257
|
+
if (!networkResult.success || !networkResult.config) {
|
|
258
|
+
return {
|
|
259
|
+
success: false,
|
|
260
|
+
message: networkResult.error || 'Unknown network error',
|
|
261
|
+
errorDetails: {
|
|
262
|
+
errorType: 'NETWORK_ERROR',
|
|
263
|
+
networkName: tokenMetadata.network
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const networkConfig = networkResult.config;
|
|
269
|
+
const declaredMerkleRoot = tokenMetadata.merkleRoot;
|
|
270
|
+
|
|
271
|
+
// Compare merkle roots if hash verification is not skipped
|
|
272
|
+
if (!options.skipHash) {
|
|
273
|
+
const merkleComparison = this.compareMerkleRoots(calculatedMerkleRoot, declaredMerkleRoot);
|
|
274
|
+
|
|
275
|
+
if (!merkleComparison.success) {
|
|
276
|
+
return {
|
|
277
|
+
success: false,
|
|
278
|
+
message: merkleComparison.error || 'Merkle root verification failed',
|
|
279
|
+
errorDetails: {
|
|
280
|
+
errorType: 'MERKLE_ERROR',
|
|
281
|
+
merkleRoot: declaredMerkleRoot || 'null'
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (!merkleComparison.match) {
|
|
287
|
+
return {
|
|
288
|
+
success: false,
|
|
289
|
+
message: 'Archive integrity verification FAILED - merkle root mismatch',
|
|
290
|
+
errorDetails: {
|
|
291
|
+
errorType: 'MERKLE_ERROR',
|
|
292
|
+
merkleRoot: `calculated: ${merkleComparison.calculated}, declared: ${merkleComparison.declared}`
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Perform on-chain verification
|
|
299
|
+
const merkleToVerify = calculatedMerkleRoot;
|
|
300
|
+
if (!merkleToVerify) {
|
|
301
|
+
return {
|
|
302
|
+
success: false,
|
|
303
|
+
message: 'No merkle root available for verification',
|
|
304
|
+
errorDetails: {
|
|
305
|
+
errorType: 'MERKLE_ERROR'
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const onChainResult = await this.verifyOnChain(
|
|
311
|
+
tokenMetadata.tokenId,
|
|
312
|
+
tokenMetadata.contractAddress,
|
|
313
|
+
networkConfig,
|
|
314
|
+
merkleToVerify
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
if (!onChainResult.success) {
|
|
318
|
+
return {
|
|
319
|
+
success: false,
|
|
320
|
+
message: `Blockchain verification failed: ${onChainResult.error}`,
|
|
321
|
+
errorDetails: {
|
|
322
|
+
errorType: 'CONTRACT_ERROR',
|
|
323
|
+
networkName: tokenMetadata.network,
|
|
324
|
+
rpcUrl: networkConfig.rpcUrl,
|
|
325
|
+
contractAddress: tokenMetadata.contractAddress,
|
|
326
|
+
tokenId: tokenMetadata.tokenId
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (!onChainResult.isValid) {
|
|
332
|
+
return {
|
|
333
|
+
success: false,
|
|
334
|
+
message: 'Blockchain verification FAILED - token or merkle root invalid',
|
|
335
|
+
errorDetails: {
|
|
336
|
+
errorType: 'CONTRACT_ERROR',
|
|
337
|
+
tokenId: tokenMetadata.tokenId,
|
|
338
|
+
contractAddress: tokenMetadata.contractAddress,
|
|
339
|
+
merkleRoot: merkleToVerify
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Success - create verification details
|
|
345
|
+
const mintDate = tokenMetadata.mintDate ||
|
|
346
|
+
(tokenMetadata.creationTimestamp ? new Date(tokenMetadata.creationTimestamp * 1000).toLocaleString() : '') ||
|
|
347
|
+
'8/01/2025 at 1:00:00 PM'; // fallback
|
|
348
|
+
|
|
349
|
+
return {
|
|
350
|
+
success: true,
|
|
351
|
+
message: 'Archive integrity VERIFIED against blockchain records',
|
|
352
|
+
tokenMetadata,
|
|
353
|
+
verificationDetails: {
|
|
354
|
+
tokenId: tokenMetadata.tokenId,
|
|
355
|
+
network: tokenMetadata.network,
|
|
356
|
+
contractAddress: tokenMetadata.contractAddress,
|
|
357
|
+
merkleRoot: merkleToVerify,
|
|
358
|
+
mintDate,
|
|
359
|
+
calculatedMerkleRoot: calculatedMerkleRoot || undefined,
|
|
360
|
+
declaredMerkleRoot: declaredMerkleRoot || undefined,
|
|
361
|
+
merkleRootMatch: !options.skipHash ? calculatedMerkleRoot === declaredMerkleRoot : undefined,
|
|
362
|
+
onChainValid: true
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
} catch (error) {
|
|
367
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown verification error';
|
|
368
|
+
|
|
369
|
+
if (this.debug) {
|
|
370
|
+
console.log(`[DEBUG] Verification process failed: ${errorMessage}`);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return {
|
|
374
|
+
success: false,
|
|
375
|
+
message: `Tokenization verification failed: ${errorMessage}`,
|
|
376
|
+
errorDetails: {
|
|
377
|
+
errorType: 'METADATA_ERROR'
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|