neozipkit 0.1.1 → 0.3.0
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/LICENSE +22 -0
- package/README.md +371 -200
- package/contracts/ABI.txt +889 -0
- package/contracts/Bytecode.txt +1 -0
- package/contracts/COMPILATION_NOTES.md +59 -0
- package/contracts/QUICK_DEPLOY.md +286 -0
- package/contracts/README.md +256 -0
- package/contracts/VERIFICATION.md +308 -0
- package/contracts/deploy-interactive.js +448 -0
- package/contracts/deployment-arbitrum-sepolia.json +12 -0
- package/contracts/deployment-arbitrum.json +12 -0
- package/contracts/deployment-eth-sepolia.json +12 -0
- package/contracts/hardhat.config.js +114 -0
- package/contracts/package.json +20 -0
- package/contracts/scripts/compile-and-extract.js +119 -0
- package/contracts/scripts/verify-contract.js +223 -0
- package/contracts/src/{NZIP-NFT-Private.sol → NZIP-NFT-v2.0.sol} +66 -151
- package/contracts/src/NZIP-NFT.sol +9 -15
- package/dist/{browser → blockchain/browser}/TokenVerifierBrowser.d.ts +11 -20
- package/dist/blockchain/browser/TokenVerifierBrowser.d.ts.map +1 -0
- package/dist/{browser → blockchain/browser}/TokenVerifierBrowser.js +106 -92
- package/dist/blockchain/browser/TokenVerifierBrowser.js.map +1 -0
- package/dist/blockchain/browser/WalletManagerBrowser.d.ts +98 -0
- package/dist/blockchain/browser/WalletManagerBrowser.d.ts.map +1 -0
- package/dist/blockchain/browser/WalletManagerBrowser.js +434 -0
- package/dist/blockchain/browser/WalletManagerBrowser.js.map +1 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts +58 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts.map +1 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.js +317 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.js.map +1 -0
- package/dist/blockchain/browser/index.d.ts +11 -0
- package/dist/blockchain/browser/index.d.ts.map +1 -0
- package/dist/blockchain/browser/index.js +16 -0
- package/dist/blockchain/browser/index.js.map +1 -0
- package/dist/{server/blockchain/WalletAnalyzer.d.ts → blockchain/core/WalletManager.d.ts} +69 -26
- package/dist/blockchain/core/WalletManager.d.ts.map +1 -0
- package/dist/{server/blockchain/WalletAnalyzer.js → blockchain/core/WalletManager.js} +172 -160
- package/dist/blockchain/core/WalletManager.js.map +1 -0
- package/dist/blockchain/core/ZipkitMinter.d.ts +141 -0
- package/dist/blockchain/core/ZipkitMinter.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitMinter.js +548 -0
- package/dist/blockchain/core/ZipkitMinter.js.map +1 -0
- package/dist/blockchain/core/ZipkitOTS.d.ts +126 -0
- package/dist/blockchain/core/ZipkitOTS.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitOTS.js +506 -0
- package/dist/blockchain/core/ZipkitOTS.js.map +1 -0
- package/dist/blockchain/core/ZipkitVerifier.d.ts +177 -0
- package/dist/blockchain/core/ZipkitVerifier.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitVerifier.js +632 -0
- package/dist/blockchain/core/ZipkitVerifier.js.map +1 -0
- package/dist/blockchain/core/contracts.d.ts +83 -0
- package/dist/blockchain/core/contracts.d.ts.map +1 -0
- package/dist/blockchain/core/contracts.js +341 -0
- package/dist/blockchain/core/contracts.js.map +1 -0
- package/dist/blockchain/core/index.d.ts +12 -0
- package/dist/blockchain/core/index.d.ts.map +1 -0
- package/dist/blockchain/core/index.js +59 -0
- package/dist/blockchain/core/index.js.map +1 -0
- package/dist/blockchain/index.d.ts +11 -0
- package/dist/blockchain/index.d.ts.map +1 -0
- package/dist/blockchain/index.js +34 -0
- package/dist/blockchain/index.js.map +1 -0
- package/dist/blockchain/node/WalletManagerNode.d.ts +47 -0
- package/dist/blockchain/node/WalletManagerNode.d.ts.map +1 -0
- package/dist/blockchain/node/WalletManagerNode.js +203 -0
- package/dist/blockchain/node/WalletManagerNode.js.map +1 -0
- package/dist/blockchain/node/index.d.ts +12 -0
- package/dist/blockchain/node/index.d.ts.map +1 -0
- package/dist/blockchain/node/index.js +24 -0
- package/dist/blockchain/node/index.js.map +1 -0
- package/dist/browser/ZipkitBrowser.d.ts +27 -0
- package/dist/browser/ZipkitBrowser.d.ts.map +1 -0
- package/dist/browser/{ZipKitBrowser.js → ZipkitBrowser.js} +96 -43
- package/dist/browser/ZipkitBrowser.js.map +1 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +42 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser-esm/index.d.ts +12 -0
- package/dist/browser-esm/index.js +59559 -0
- package/dist/browser-esm/index.js.map +7 -0
- package/dist/browser-umd/index.d.ts +12 -0
- package/dist/browser-umd/index.js +59576 -0
- package/dist/browser-umd/index.js.map +7 -0
- package/dist/browser-umd/index.min.js +63 -0
- package/dist/browser.d.ts +8 -17
- package/dist/browser.js +13 -29
- package/dist/core/ZipCompress.d.ts +99 -0
- package/dist/core/ZipCompress.d.ts.map +1 -0
- package/dist/core/ZipCompress.js +309 -0
- package/dist/core/ZipCompress.js.map +1 -0
- package/dist/core/ZipDecompress.d.ts +58 -0
- package/dist/core/ZipDecompress.d.ts.map +1 -0
- package/dist/core/ZipDecompress.js +172 -0
- package/dist/core/ZipDecompress.js.map +1 -0
- package/dist/{shared → core}/ZipEntry.d.ts +8 -1
- package/dist/core/ZipEntry.d.ts.map +1 -0
- package/dist/{shared → core}/ZipEntry.js +224 -81
- package/dist/core/ZipEntry.js.map +1 -0
- package/dist/core/Zipkit.d.ts +315 -0
- package/dist/core/Zipkit.d.ts.map +1 -0
- package/dist/core/Zipkit.js +647 -0
- package/dist/core/Zipkit.js.map +1 -0
- package/dist/core/components/HashCalculator.d.ts +138 -0
- package/dist/core/components/HashCalculator.d.ts.map +1 -0
- package/dist/core/components/HashCalculator.js +360 -0
- package/dist/core/components/HashCalculator.js.map +1 -0
- package/dist/core/components/Logger.d.ts +73 -0
- package/dist/core/components/Logger.d.ts.map +1 -0
- package/dist/core/components/Logger.js +156 -0
- package/dist/core/components/Logger.js.map +1 -0
- package/dist/core/components/ProgressTracker.d.ts +43 -0
- package/dist/core/components/ProgressTracker.d.ts.map +1 -0
- package/dist/core/components/ProgressTracker.js +112 -0
- package/dist/core/components/ProgressTracker.js.map +1 -0
- package/dist/{shared → core}/components/Support.d.ts +1 -0
- package/dist/core/components/Support.d.ts.map +1 -0
- package/dist/{shared → core}/components/Support.js +1 -0
- package/dist/core/components/Support.js.map +1 -0
- package/dist/{shared → core}/components/Util.d.ts +7 -2
- package/dist/core/components/Util.d.ts.map +1 -0
- package/dist/{shared → core}/components/Util.js +14 -34
- package/dist/core/components/Util.js.map +1 -0
- package/dist/{shared → core}/constants/Errors.d.ts +1 -2
- package/dist/core/constants/Errors.d.ts.map +1 -0
- package/dist/{shared → core}/constants/Errors.js +1 -3
- package/dist/core/constants/Errors.js.map +1 -0
- package/dist/{shared → core}/constants/Headers.d.ts +3 -0
- package/dist/core/constants/Headers.d.ts.map +1 -0
- package/dist/{shared → core}/constants/Headers.js +20 -17
- package/dist/core/constants/Headers.js.map +1 -0
- package/dist/core/encryption/Manager.d.ts +58 -0
- package/dist/core/encryption/Manager.d.ts.map +1 -0
- package/dist/core/encryption/Manager.js +121 -0
- package/dist/core/encryption/Manager.js.map +1 -0
- package/dist/core/encryption/ZipCrypto.d.ts +172 -0
- package/dist/core/encryption/ZipCrypto.d.ts.map +1 -0
- package/dist/core/encryption/ZipCrypto.js +554 -0
- package/dist/core/encryption/ZipCrypto.js.map +1 -0
- package/dist/core/encryption/index.d.ts +9 -0
- package/dist/core/encryption/index.d.ts.map +1 -0
- package/dist/core/encryption/index.js +17 -0
- package/dist/core/encryption/index.js.map +1 -0
- package/dist/core/encryption/types.d.ts +29 -0
- package/dist/core/encryption/types.d.ts.map +1 -0
- package/dist/core/encryption/types.js +12 -0
- package/dist/core/encryption/types.js.map +1 -0
- package/dist/core/index.d.ts +24 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +57 -0
- package/dist/core/index.js.map +1 -0
- package/dist/{shared → core}/version.d.ts +1 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +31 -0
- package/dist/core/version.js.map +1 -0
- package/dist/index.d.ts +8 -25
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -47
- package/dist/index.js.map +1 -0
- package/dist/node/ZipCompressNode.d.ts +123 -0
- package/dist/node/ZipCompressNode.d.ts.map +1 -0
- package/dist/node/ZipCompressNode.js +576 -0
- package/dist/node/ZipCompressNode.js.map +1 -0
- package/dist/node/ZipDecompressNode.d.ts +120 -0
- package/dist/node/ZipDecompressNode.d.ts.map +1 -0
- package/dist/node/ZipDecompressNode.js +461 -0
- package/dist/node/ZipDecompressNode.js.map +1 -0
- package/dist/node/ZipkitNode.d.ts +406 -0
- package/dist/node/ZipkitNode.d.ts.map +1 -0
- package/dist/node/ZipkitNode.js +1305 -0
- package/dist/node/ZipkitNode.js.map +1 -0
- package/dist/node/index.d.ts +26 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +65 -0
- package/dist/node/index.js.map +1 -0
- package/dist/types/index.d.ts +59 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +36 -1
- package/dist/types/index.js.map +1 -0
- package/examples/README.md +269 -0
- package/examples/blockchain-tokenize.ts +354 -0
- package/examples/create-zip.ts +172 -0
- package/examples/extract-zip.ts +158 -0
- package/examples/list-zip.ts +161 -0
- package/examples/test-files/data.json +116 -0
- package/examples/test-files/document.md +80 -0
- package/examples/test-files/document.txt +2 -0
- package/examples/test-files/file1.txt +48 -0
- package/examples/test-files/file2.txt +80 -0
- package/examples/tsconfig.json +44 -0
- package/examples/unzip-token.ts +6 -3
- package/examples/verify-tokenized-zip.ts +305 -0
- package/package.json +117 -23
- package/src/blockchain/README.md +222 -0
- package/src/{browser → blockchain/browser}/TokenVerifierBrowser.ts +125 -79
- package/src/blockchain/browser/WalletManagerBrowser.ts +486 -0
- package/src/blockchain/browser/ZipkitMinterBrowser.ts +400 -0
- package/src/blockchain/browser/index.ts +13 -0
- package/src/blockchain/core/WalletManager.ts +436 -0
- package/src/blockchain/core/ZipkitMinter.ts +716 -0
- package/src/blockchain/core/ZipkitOTS.ts +588 -0
- package/src/blockchain/core/ZipkitVerifier.ts +853 -0
- package/src/blockchain/core/contracts.ts +370 -0
- package/src/blockchain/core/index.ts +71 -0
- package/src/blockchain/index.ts +27 -0
- package/src/blockchain/node/WalletManagerNode.ts +171 -0
- package/src/blockchain/node/index.ts +40 -0
- package/src/browser/{ZipKitBrowser.ts → ZipkitBrowser.ts} +104 -41
- package/src/browser/index.esm.ts +37 -0
- package/src/browser/index.ts +25 -0
- package/src/core/ZipCompress.ts +398 -0
- package/src/core/ZipDecompress.ts +212 -0
- package/src/{shared → core}/ZipEntry.ts +239 -89
- package/src/core/Zipkit.ts +794 -0
- package/src/core/components/HashCalculator.ts +384 -0
- package/src/core/components/Logger.ts +180 -0
- package/src/core/components/ProgressTracker.ts +134 -0
- package/src/{shared → core}/components/Util.ts +12 -34
- package/src/{shared → core}/constants/Errors.ts +0 -4
- package/src/{shared → core}/constants/Headers.ts +19 -17
- package/src/core/encryption/Manager.ts +137 -0
- package/src/core/encryption/ZipCrypto.ts +650 -0
- package/src/core/encryption/index.ts +15 -0
- package/src/core/encryption/types.ts +33 -0
- package/src/core/index.ts +34 -0
- package/src/core/version.ts +33 -0
- package/src/index.ts +54 -32
- package/src/node/ZipCompressNode.ts +632 -0
- package/src/node/ZipDecompressNode.ts +508 -0
- package/src/node/ZipkitNode.ts +1559 -0
- package/src/node/index.ts +69 -0
- package/src/types/index.ts +131 -1
- package/src/types/opentimestamps.d.ts +1 -23
- package/contracts/Lock.sol +0 -34
- package/contracts/bytecode.txt +0 -1
- 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/ZipKitBrowser.d.ts +0 -18
- package/dist/browser/ZipKitStampBrowser.d.ts +0 -2
- package/dist/browser/ZipKitStampBrowser.js +0 -12
- package/dist/browser-index.d.ts +0 -21
- package/dist/browser-index.js +0 -58
- package/dist/server/blockchain/CertificateToken.d.ts +0 -48
- package/dist/server/blockchain/CertificateToken.js +0 -386
- 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/blockchain/types.d.ts +0 -69
- package/dist/server/blockchain/types.js +0 -51
- package/dist/server/platform/server/ZipKitServer.d.ts +0 -105
- package/dist/server/platform/server/ZipKitServer.js +0 -437
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +0 -91
- package/dist/server/platform/servercomponents/ZipKitOTS.js +0 -271
- package/dist/shared/ZipKit.d.ts +0 -249
- package/dist/shared/ZipKit.js +0 -789
- package/dist/shared/components/CertificateOTS.d.ts +0 -15
- package/dist/shared/components/CertificateOTS.js +0 -116
- package/dist/shared/components/FileSys.d.ts +0 -2
- package/dist/shared/components/FileSys.js +0 -113
- package/dist/shared/components/HashAccumulator.d.ts +0 -55
- package/dist/shared/components/HashAccumulator.js +0 -100
- package/dist/shared/components/ZipCrypto.d.ts +0 -3
- package/dist/shared/components/ZipCrypto.js +0 -78
- package/dist/shared/components/merkleTree.d.ts +0 -66
- package/dist/shared/components/merkleTree.js +0 -136
- package/dist/shared/types/index.d.ts +0 -21
- package/dist/shared/types/index.js +0 -3
- package/dist/shared/types.d.ts +0 -33
- package/dist/shared/types.js +0 -8
- package/dist/shared/version.js +0 -7
- package/src/browser/CertificateGeneratorBrowser.ts +0 -498
- package/src/browser/ZipKitStampBrowser.ts +0 -9
- package/src/browser-index.ts +0 -36
- package/src/server/blockchain/CertificateToken.ts +0 -444
- 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/constants.ts +0 -969
- 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/src/shared/ZipKit.ts +0 -899
- package/src/shared/components/CertificateOTS.ts +0 -132
- package/src/shared/components/FileSys.ts +0 -87
- package/src/shared/components/HashAccumulator.ts +0 -113
- package/src/shared/components/ZipCrypto.ts +0 -91
- package/src/shared/components/merkleTree.ts +0 -162
- package/src/shared/types/index.ts +0 -25
- package/src/shared/types/modules.d.ts +0 -22
- package/src/shared/types/opentimestamps.d.ts +0 -23
- package/src/shared/types.d.ts +0 -8
- package/src/shared/types.ts +0 -43
- package/src/shared/version.ts +0 -4
- /package/src/{shared → core}/components/Support.ts +0 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
## Blockchain Module APIs
|
|
2
|
+
|
|
3
|
+
This directory provides all blockchain-related functionality for NeoZipKit, including:
|
|
4
|
+
- OpenTimestamps utilities
|
|
5
|
+
- NFT contract interactions (verification, querying, minting)
|
|
6
|
+
- Wallet utilities and token processing
|
|
7
|
+
- Network constants and contract ABI
|
|
8
|
+
|
|
9
|
+
## 📁 Module Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
src/blockchain/
|
|
13
|
+
├── core/ # Core blockchain functionality
|
|
14
|
+
│ ├── WalletManager.ts # CoreWalletManager - platform-agnostic wallet operations
|
|
15
|
+
│ ├── ZipkitMinter.ts # Core minting functionality
|
|
16
|
+
│ ├── ZipkitVerifier.ts # Core verification functionality
|
|
17
|
+
│ ├── ZipkitOTS.ts # OpenTimestamps utilities
|
|
18
|
+
│ ├── contracts.ts # Contract ABI + network configs + addresses
|
|
19
|
+
│ ├── types.ts # Shared blockchain types
|
|
20
|
+
│ └── index.ts # Core exports
|
|
21
|
+
├── browser/ # Browser-specific implementations
|
|
22
|
+
│ ├── WalletManagerBrowser.ts # Browser wallet management
|
|
23
|
+
│ ├── ZipkitMinterBrowser.ts # Browser minting
|
|
24
|
+
│ ├── TokenVerifierBrowser.ts # Browser token verification
|
|
25
|
+
│ └── index.ts # Browser exports
|
|
26
|
+
├── server/ # Server-specific implementations
|
|
27
|
+
│ ├── WalletManagerServer.ts # Server wallet management with file system
|
|
28
|
+
│ ├── ZipkitMinterServer.ts # Server minting
|
|
29
|
+
│ ├── ZipkitVerifierServer.ts # Server verification
|
|
30
|
+
│ └── index.ts # Server exports
|
|
31
|
+
└── index.ts # Main module exports
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Package Entry
|
|
35
|
+
Import from the package root or from `src/blockchain` directly:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// Yes! You can import directly from the blockchain directory
|
|
39
|
+
import {
|
|
40
|
+
ZipkitMinter,
|
|
41
|
+
ZipkitVerifier,
|
|
42
|
+
CoreWalletManager,
|
|
43
|
+
WalletManagerServer,
|
|
44
|
+
WalletManagerBrowser,
|
|
45
|
+
WalletAnalyzer,
|
|
46
|
+
CONTRACT_CONFIGS,
|
|
47
|
+
NZIP_CONTRACT_ABI,
|
|
48
|
+
CURRENT_DEPLOYMENT
|
|
49
|
+
} from 'neozipkit/blockchain';
|
|
50
|
+
|
|
51
|
+
// Or from the main package (re-exports everything from blockchain)
|
|
52
|
+
import { ZipkitMinter, ZipkitVerifier, CoreWalletManager, WalletAnalyzer } from 'neozipkit';
|
|
53
|
+
|
|
54
|
+
// From source (monorepo/local development)
|
|
55
|
+
import { ZipkitMinter, ZipkitVerifier, CoreWalletManager, WalletAnalyzer } from '../src/blockchain';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Direct NFT APIs
|
|
59
|
+
|
|
60
|
+
Use the individual classes directly for minting and verification:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { ZipkitMinter, ZipkitVerifier, CoreWalletManager } from 'neozipkit/blockchain';
|
|
64
|
+
|
|
65
|
+
// Use classes directly
|
|
66
|
+
const walletManager = new CoreWalletManager();
|
|
67
|
+
const minter = new ZipkitMinter('archive.zip', 'abc123...', { walletPrivateKey: '0x...', network: 'base-sepolia' });
|
|
68
|
+
const verifier = new ZipkitVerifier({ debug: false });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### OpenTimestamps (ZipKitOTS.ts)
|
|
72
|
+
Bitcoin blockchain timestamping utilities for ZIP file integrity verification.
|
|
73
|
+
|
|
74
|
+
#### Core Functions
|
|
75
|
+
|
|
76
|
+
**Timestamp Creation & Verification:**
|
|
77
|
+
- `createTimestamp(hashDigest: string, options?: { debug?: boolean }): Promise<Buffer | null>`
|
|
78
|
+
- Creates an OpenTimestamps proof for a hash digest. Submits hash to OpenTimestamps servers for Bitcoin blockchain anchoring.
|
|
79
|
+
- `verifyOts(hashDigest: string | null, ots: ArrayBuffer | null, options?: { debug?: boolean }): Promise<TimestampResult | { error: string } | null>`
|
|
80
|
+
- Verifies an OpenTimestamps proof against a hash digest. Returns verification result, error object, or null if inputs invalid.
|
|
81
|
+
- `verifyOtsZip(zip: any): Promise<OtsVerifyResult>`
|
|
82
|
+
- Verifies OpenTimestamps proof within a ZIP file. Extracts merkle root and OTS proof, then verifies against Bitcoin blockchain.
|
|
83
|
+
|
|
84
|
+
**ZIP Integration:**
|
|
85
|
+
- `getOtsEntry(zip: any): any | null`
|
|
86
|
+
- Finds the OpenTimestamps entry in a ZIP file. Searches for TIMESTAMP_METADATA first, then TIMESTAMP_SUBMITTED.
|
|
87
|
+
- `getOtsBuffer(zip: any, otsEntry: any): Promise<Buffer | null>`
|
|
88
|
+
- Extracts OTS proof data from a ZIP entry.
|
|
89
|
+
- `getMerkleRootSafe(zip: any): string | null`
|
|
90
|
+
- Safely extracts merkle root from a ZIP file.
|
|
91
|
+
|
|
92
|
+
**Data Processing:**
|
|
93
|
+
- `deserializeOts(tsResult: TimestampResult, options?: { debug?: boolean }): Promise<string | null>`
|
|
94
|
+
- Deserializes OpenTimestamps verification result into JSON format. Extracts blockchain attestation data and transaction details.
|
|
95
|
+
- `parseVerifyResult(verifyResult: TimestampResult): Promise<TimestampInfo>`
|
|
96
|
+
- Parses timestamp verification result into readable information. Formats blockchain attestation data with human-readable messages and dates.
|
|
97
|
+
|
|
98
|
+
**Upgrade:**
|
|
99
|
+
- `upgradeOTS(zipFilePath: string, upgradedOts: Buffer): Promise<void>`
|
|
100
|
+
- Upgrades OpenTimestamps proof in an existing ZIP file. Replaces old timestamp metadata with upgraded OTS proof data.
|
|
101
|
+
- `createOtsMetadataEntry(zipKit: any, ots: Buffer | null): any | null`
|
|
102
|
+
- Creates a ZIP metadata entry containing OpenTimestamps proof. Creates a special ZIP entry marked as metadata that stores OTS proof data.
|
|
103
|
+
|
|
104
|
+
**Utility Functions:**
|
|
105
|
+
- `bufferToArrayBuffer(buf: Buffer): ArrayBuffer`
|
|
106
|
+
- Converts a Node.js Buffer to an ArrayBuffer.
|
|
107
|
+
|
|
108
|
+
#### Types & Interfaces
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
export interface TimestampResult {
|
|
112
|
+
merkleRoot: string | null;
|
|
113
|
+
ots: ArrayBuffer | null;
|
|
114
|
+
verified: boolean;
|
|
115
|
+
results: any | null;
|
|
116
|
+
error: string | null;
|
|
117
|
+
attestations: any | null;
|
|
118
|
+
upgradedOts: ArrayBuffer | null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface TimestampInfo {
|
|
122
|
+
message: string;
|
|
123
|
+
results: string[];
|
|
124
|
+
attestDate: Date | null;
|
|
125
|
+
attestHeight: number | null;
|
|
126
|
+
submittedUri: string | null;
|
|
127
|
+
otsUpgraded: boolean;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface OtsVerifyResult {
|
|
131
|
+
status: 'none' | 'valid' | 'pending' | 'error';
|
|
132
|
+
message?: string;
|
|
133
|
+
blockHeight?: number;
|
|
134
|
+
attestedAt?: Date;
|
|
135
|
+
upgraded?: boolean;
|
|
136
|
+
upgradedOts?: Buffer;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface DeserializeOtsResult {
|
|
140
|
+
attestStr: string | null;
|
|
141
|
+
needsUpdateMsg: string | null;
|
|
142
|
+
attestationValues: any[];
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Usage Example
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { createTimestamp, verifyOtsZip, upgradeOTS } from 'neozipkit/blockchain';
|
|
150
|
+
|
|
151
|
+
// Create timestamp for a file's hash
|
|
152
|
+
const otsProof = await createTimestamp(merkleRoot);
|
|
153
|
+
|
|
154
|
+
// Verify a loaded ZIP file
|
|
155
|
+
const result = await verifyOtsZip(zipInstance);
|
|
156
|
+
if (result.status === 'valid') {
|
|
157
|
+
console.log(`Verified! Block: ${result.blockHeight}`);
|
|
158
|
+
|
|
159
|
+
// Upgrade proof if available
|
|
160
|
+
if (result.upgradedOts) {
|
|
161
|
+
await upgradeOTS(zipPath, result.upgradedOts);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Contract Configuration (contracts.ts)
|
|
167
|
+
All contract-related constants and configurations in one place:
|
|
168
|
+
|
|
169
|
+
- `CONTRACT_CONFIGS`: Network configurations with contract addresses, RPC URLs, and explorer URLs
|
|
170
|
+
- `NZIP_CONTRACT_ABI`: Full ABI for the NZIP‑NFT contract
|
|
171
|
+
- `CURRENT_DEPLOYMENT`: Current default deployment (Base Sepolia)
|
|
172
|
+
- `DEFAULT_NETWORK`: Default network chain ID (84532)
|
|
173
|
+
- Helper functions: `getContractConfig()`, `getSupportedNetworks()`, `isNetworkSupported()`
|
|
174
|
+
|
|
175
|
+
**Supported Networks**:
|
|
176
|
+
- Base Sepolia (84532) - Primary testnet
|
|
177
|
+
- Base Mainnet (8453) - Production
|
|
178
|
+
|
|
179
|
+
### Token Verification (ZipKitVerifier.ts)
|
|
180
|
+
- High-level verification API for NZIP‑NFT contract and on-chain checks.
|
|
181
|
+
|
|
182
|
+
### Token Query
|
|
183
|
+
Token querying functionality is integrated into the core wallet and verification classes:
|
|
184
|
+
- `CoreWalletManager.queryWalletTokens()` - Query tokens for a wallet address
|
|
185
|
+
- `ZipkitVerifier.queryBlockchainForExistingToken()` - Query for existing tokens by merkle root
|
|
186
|
+
|
|
187
|
+
### Wallet Management
|
|
188
|
+
- `class CoreWalletManager`: Platform-agnostic wallet operations (core functionality)
|
|
189
|
+
- `class WalletManagerServer`: Server-specific wallet management with file system operations
|
|
190
|
+
- `class WalletManagerBrowser`: Browser-specific wallet management with provider connections
|
|
191
|
+
- `class WalletAnalyzer`: Analyze balances, scan NZIP tokens, ERC‑20s and NFTs.
|
|
192
|
+
- Types re‑exported: `TokenInfo`, `NZipTokenDetails`, `WalletBasicInfo`, `TokenScanResult`, `CommonTokenConfig`.
|
|
193
|
+
|
|
194
|
+
### NFT Minting (ZipkitMinter.ts)
|
|
195
|
+
- High‑level minting API for NZIP‑NFT contract.
|
|
196
|
+
- Core functionality in `core/ZipkitMinter.ts`
|
|
197
|
+
- Browser-specific implementation in `browser/ZipkitMinterBrowser.ts`
|
|
198
|
+
- Server-specific implementation in `server/ZipkitMinterServer.ts`
|
|
199
|
+
|
|
200
|
+
### NFT Verification (ZipkitVerifier.ts)
|
|
201
|
+
- High‑level verification API for NZIP‑NFT contract.
|
|
202
|
+
- Core functionality in `core/ZipkitVerifier.ts`
|
|
203
|
+
- Browser token verification in `browser/TokenVerifierBrowser.ts`
|
|
204
|
+
- Server-specific implementation in `server/ZipkitVerifierServer.ts`
|
|
205
|
+
|
|
206
|
+
- Helpers to format token and wallet data for display.
|
|
207
|
+
|
|
208
|
+
Re‑exports (index.ts):
|
|
209
|
+
Wallet formatting helpers have been removed. Use your app's UI layer for presentation formatting.
|
|
210
|
+
|
|
211
|
+
### ZIP Metadata Helpers
|
|
212
|
+
ZIP metadata functionality is integrated into the core ZIP handling classes:
|
|
213
|
+
- Token metadata validation and processing is handled by `ZipkitMinter` and `ZipkitVerifier`
|
|
214
|
+
- Metadata entries are managed through the core ZIP utilities
|
|
215
|
+
|
|
216
|
+
### Module Types (types.ts)
|
|
217
|
+
Exports shared types used across blockchain operations, including:
|
|
218
|
+
- `NZipTokenInfo`, `NZipTokenDetails`, `ZipFileInfo`, `WalletInfo`, `BlockchainVerification`, and others used by certificate/token helpers.
|
|
219
|
+
|
|
220
|
+
### Notes
|
|
221
|
+
- All OTS utilities suppress verbose logs by default. Pass `{ debug: true }` to see OpenTimestamps logs.
|
|
222
|
+
- Contract addresses vary per network; see `CONTRACT_CONFIGS` and keep them updated after deployments.
|
|
@@ -4,23 +4,12 @@
|
|
|
4
4
|
// Copyright (c) 2025 NeoWare, Inc. All rights reserved.
|
|
5
5
|
// ======================================
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import { ZipEntry } from '
|
|
9
|
-
import { TOKENIZED_METADATA } from '
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export interface NZipTokenInfo {
|
|
14
|
-
version: string;
|
|
15
|
-
tokenId: string;
|
|
16
|
-
contractAddress: string;
|
|
17
|
-
network: string;
|
|
18
|
-
networkChainId: number;
|
|
19
|
-
transactionHash: string;
|
|
20
|
-
merkleRoot: string;
|
|
21
|
-
fileName: string;
|
|
22
|
-
mintedAt: string;
|
|
23
|
-
}
|
|
7
|
+
import ZipkitBrowser from '../../browser/ZipkitBrowser';
|
|
8
|
+
import { ZipEntry } from '../../core';
|
|
9
|
+
import { TOKENIZED_METADATA } from '../../core/constants/Headers';
|
|
10
|
+
import { TokenMetadata } from '../../types';
|
|
11
|
+
import { NZIP_CONTRACT_ABI, getContractConfig } from '../core/contracts';
|
|
12
|
+
import { ethers } from 'ethers';
|
|
24
13
|
|
|
25
14
|
export interface TokenVerificationOptions {
|
|
26
15
|
skipHash?: boolean;
|
|
@@ -31,7 +20,7 @@ export interface TokenVerificationOptions {
|
|
|
31
20
|
|
|
32
21
|
export interface TokenVerificationResult {
|
|
33
22
|
isTokenized: boolean;
|
|
34
|
-
tokenMetadata:
|
|
23
|
+
tokenMetadata: TokenMetadata | null;
|
|
35
24
|
calculatedMerkleRoot: string | null;
|
|
36
25
|
blockchainMerkleRoot: string | null;
|
|
37
26
|
blockchainTimestamp?: number; // Actual blockchain timestamp from tokenizationTime
|
|
@@ -49,28 +38,6 @@ export interface BlockchainVerification {
|
|
|
49
38
|
blockNumber?: number;
|
|
50
39
|
}
|
|
51
40
|
|
|
52
|
-
// Network configuration for blockchain queries
|
|
53
|
-
const NETWORK_CONFIG: Record<string, any> = {
|
|
54
|
-
'Base Sepolia': {
|
|
55
|
-
chainId: 84532,
|
|
56
|
-
rpcUrls: [
|
|
57
|
-
'https://sepolia.base.org',
|
|
58
|
-
'https://base-sepolia.g.alchemy.com/v2/demo',
|
|
59
|
-
'https://base-sepolia-rpc.publicnode.com',
|
|
60
|
-
'https://base-sepolia.blockpi.network/v1/rpc/public'
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
'Base Mainnet': {
|
|
64
|
-
chainId: 8453,
|
|
65
|
-
rpcUrls: [
|
|
66
|
-
'https://mainnet.base.org',
|
|
67
|
-
'https://base-mainnet.g.alchemy.com/v2/demo',
|
|
68
|
-
'https://base-rpc.publicnode.com',
|
|
69
|
-
'https://base.blockpi.network/v1/rpc/public'
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
41
|
// Use the complete contract ABI from constants
|
|
75
42
|
const CONTRACT_ABI = NZIP_CONTRACT_ABI;
|
|
76
43
|
|
|
@@ -78,10 +45,10 @@ const CONTRACT_ABI = NZIP_CONTRACT_ABI;
|
|
|
78
45
|
* Browser-compatible token verification class
|
|
79
46
|
*/
|
|
80
47
|
export class TokenVerifierBrowser {
|
|
81
|
-
private
|
|
48
|
+
private zipkit: ZipkitBrowser;
|
|
82
49
|
|
|
83
|
-
constructor(
|
|
84
|
-
this.
|
|
50
|
+
constructor(zipkit: ZipkitBrowser) {
|
|
51
|
+
this.zipkit = zipkit;
|
|
85
52
|
}
|
|
86
53
|
|
|
87
54
|
/**
|
|
@@ -106,7 +73,7 @@ export class TokenVerifierBrowser {
|
|
|
106
73
|
|
|
107
74
|
try {
|
|
108
75
|
// Extract the token metadata
|
|
109
|
-
const tokenData = await this.
|
|
76
|
+
const tokenData = await this.zipkit.extractBlob(tokenEntry);
|
|
110
77
|
|
|
111
78
|
if (!tokenData) {
|
|
112
79
|
return {
|
|
@@ -164,9 +131,15 @@ export class TokenVerifierBrowser {
|
|
|
164
131
|
const blockchainData = await this.queryBlockchainData(tokenMetadata);
|
|
165
132
|
|
|
166
133
|
if (!blockchainData.merkleRoot) {
|
|
134
|
+
// Add owner information to tokenMetadata even if merkle root is not available
|
|
135
|
+
const enhancedTokenMetadata = {
|
|
136
|
+
...tokenMetadata,
|
|
137
|
+
owner: blockchainData.owner || undefined
|
|
138
|
+
};
|
|
139
|
+
|
|
167
140
|
return {
|
|
168
141
|
isTokenized: true,
|
|
169
|
-
tokenMetadata,
|
|
142
|
+
tokenMetadata: enhancedTokenMetadata,
|
|
170
143
|
calculatedMerkleRoot,
|
|
171
144
|
blockchainMerkleRoot: null,
|
|
172
145
|
blockchainTimestamp: blockchainData.timestamp ?? undefined,
|
|
@@ -175,16 +148,30 @@ export class TokenVerifierBrowser {
|
|
|
175
148
|
};
|
|
176
149
|
}
|
|
177
150
|
|
|
178
|
-
|
|
151
|
+
// Normalize both merkle roots for comparison (trim whitespace, lowercase)
|
|
152
|
+
const normalizedBlockchain = blockchainData.merkleRoot?.toLowerCase().trim() || '';
|
|
153
|
+
const normalizedCalculated = calculatedMerkleRoot?.toLowerCase().trim() || '';
|
|
154
|
+
const verificationPassed = normalizedBlockchain === normalizedCalculated;
|
|
155
|
+
|
|
156
|
+
// Log mismatch only (success is silent)
|
|
157
|
+
if (!verificationPassed) {
|
|
158
|
+
console.warn(`[TokenVerifier] ⚠️ Merkle root mismatch - Calculated: ${calculatedMerkleRoot}, Blockchain: ${blockchainData.merkleRoot}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Add owner information to tokenMetadata
|
|
162
|
+
const enhancedTokenMetadata = {
|
|
163
|
+
...tokenMetadata,
|
|
164
|
+
owner: blockchainData.owner || undefined
|
|
165
|
+
};
|
|
179
166
|
|
|
180
167
|
return {
|
|
181
168
|
isTokenized: true,
|
|
182
|
-
tokenMetadata,
|
|
169
|
+
tokenMetadata: enhancedTokenMetadata,
|
|
183
170
|
calculatedMerkleRoot,
|
|
184
171
|
blockchainMerkleRoot: blockchainData.merkleRoot,
|
|
185
172
|
blockchainTimestamp: blockchainData.timestamp ?? undefined,
|
|
186
173
|
verificationPassed,
|
|
187
|
-
errorMessage: verificationPassed ? undefined :
|
|
174
|
+
errorMessage: verificationPassed ? undefined : `Merkle root mismatch - Calculated: ${calculatedMerkleRoot}, Blockchain: ${blockchainData.merkleRoot}`
|
|
188
175
|
};
|
|
189
176
|
|
|
190
177
|
} catch (error) {
|
|
@@ -202,7 +189,7 @@ export class TokenVerifierBrowser {
|
|
|
202
189
|
/**
|
|
203
190
|
* Validates token metadata structure
|
|
204
191
|
*/
|
|
205
|
-
private validateTokenInfo(tokenMetadata: any): tokenMetadata is
|
|
192
|
+
private validateTokenInfo(tokenMetadata: any): tokenMetadata is TokenMetadata {
|
|
206
193
|
return tokenMetadata &&
|
|
207
194
|
typeof tokenMetadata.version === 'string' &&
|
|
208
195
|
typeof tokenMetadata.tokenId === 'string' &&
|
|
@@ -211,7 +198,6 @@ export class TokenVerifierBrowser {
|
|
|
211
198
|
typeof tokenMetadata.networkChainId === 'number' &&
|
|
212
199
|
typeof tokenMetadata.transactionHash === 'string' &&
|
|
213
200
|
typeof tokenMetadata.merkleRoot === 'string' &&
|
|
214
|
-
typeof tokenMetadata.fileName === 'string' &&
|
|
215
201
|
typeof tokenMetadata.mintedAt === 'string';
|
|
216
202
|
}
|
|
217
203
|
|
|
@@ -224,6 +210,7 @@ export class TokenVerifierBrowser {
|
|
|
224
210
|
const contentEntries = zipEntries.filter(entry => entry.filename !== TOKENIZED_METADATA);
|
|
225
211
|
|
|
226
212
|
if (contentEntries.length === 0) {
|
|
213
|
+
console.error(`[TokenVerifier] ❌ No content entries found after filtering`);
|
|
227
214
|
return null;
|
|
228
215
|
}
|
|
229
216
|
|
|
@@ -231,41 +218,96 @@ export class TokenVerifierBrowser {
|
|
|
231
218
|
for (const entry of contentEntries) {
|
|
232
219
|
if (!entry.sha256) {
|
|
233
220
|
// Extract the file to calculate its SHA-256 hash
|
|
234
|
-
await this.
|
|
221
|
+
await this.zipkit.extractBlob(entry);
|
|
235
222
|
}
|
|
236
223
|
}
|
|
237
224
|
|
|
238
225
|
// Calculate merkle root from content files
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
|
|
226
|
+
// getMerkleRoot() already excludes TOKENIZED_METADATA, TIMESTAMP_SUBMITTED, and TIMESTAMP_METADATA
|
|
227
|
+
const merkleRoot = await this.zipkit.getMerkleRoot?.() || null;
|
|
228
|
+
|
|
229
|
+
if (!merkleRoot) {
|
|
230
|
+
console.error(`[TokenVerifier] ❌ Failed to calculate merkle root`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return merkleRoot;
|
|
242
234
|
} catch (error) {
|
|
243
|
-
console.error(
|
|
235
|
+
console.error(`[TokenVerifier] ❌ Error calculating merkle root:`, error);
|
|
244
236
|
return null;
|
|
245
237
|
}
|
|
246
238
|
}
|
|
247
239
|
|
|
248
240
|
/**
|
|
249
|
-
* Queries the blockchain to get the actual merkle root and
|
|
241
|
+
* Queries the blockchain to get the actual merkle root, timestamp, and owner stored in the smart contract
|
|
250
242
|
*/
|
|
251
|
-
private async queryBlockchainData(tokenMetadata:
|
|
243
|
+
private async queryBlockchainData(tokenMetadata: TokenMetadata): Promise<{merkleRoot: string | null, timestamp: number | null, owner: string | null}> {
|
|
252
244
|
try {
|
|
253
|
-
//
|
|
254
|
-
|
|
245
|
+
// Get network configuration from contracts.ts (single source of truth)
|
|
246
|
+
if (!tokenMetadata.networkChainId) {
|
|
247
|
+
console.error(`[TokenVerifier] ❌ No chainId in token metadata`);
|
|
248
|
+
return { merkleRoot: null, timestamp: null, owner: null };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const networkConfig = getContractConfig(tokenMetadata.networkChainId);
|
|
255
252
|
|
|
256
|
-
const networkConfig = NETWORK_CONFIG[tokenMetadata.network];
|
|
257
253
|
if (!networkConfig) {
|
|
258
|
-
console.
|
|
259
|
-
return { merkleRoot: null, timestamp: null };
|
|
254
|
+
console.error(`[TokenVerifier] ❌ Could not resolve network configuration for chainId: ${tokenMetadata.networkChainId}`);
|
|
255
|
+
return { merkleRoot: null, timestamp: null, owner: null };
|
|
260
256
|
}
|
|
261
257
|
|
|
262
|
-
//
|
|
258
|
+
// Test RPC endpoints first to find working ones (same as server-side)
|
|
259
|
+
const workingRpcUrls: string[] = [];
|
|
260
|
+
|
|
263
261
|
for (const rpcUrl of networkConfig.rpcUrls) {
|
|
262
|
+
try {
|
|
263
|
+
const controller = new AbortController();
|
|
264
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
265
|
+
|
|
266
|
+
const testResponse = await fetch(rpcUrl, {
|
|
267
|
+
method: 'POST',
|
|
268
|
+
headers: { 'Content-Type': 'application/json' },
|
|
269
|
+
body: JSON.stringify({
|
|
270
|
+
jsonrpc: '2.0',
|
|
271
|
+
method: 'eth_chainId',
|
|
272
|
+
params: [],
|
|
273
|
+
id: 1
|
|
274
|
+
}),
|
|
275
|
+
signal: controller.signal
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
clearTimeout(timeoutId);
|
|
279
|
+
|
|
280
|
+
if (testResponse.ok) {
|
|
281
|
+
const contentType = testResponse.headers.get('content-type');
|
|
282
|
+
if (contentType && contentType.includes('application/json')) {
|
|
283
|
+
const testData = await testResponse.json() as { jsonrpc?: string; result?: string };
|
|
284
|
+
if (testData?.jsonrpc && testData?.result) {
|
|
285
|
+
const actualChainId = parseInt(testData.result, 16);
|
|
286
|
+
if (actualChainId === tokenMetadata.networkChainId) {
|
|
287
|
+
workingRpcUrls.push(rpcUrl);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
} catch (testError: any) {
|
|
293
|
+
// Silently skip failed endpoints
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (workingRpcUrls.length === 0) {
|
|
298
|
+
// Fallback to all endpoints if none tested successfully
|
|
299
|
+
workingRpcUrls.push(...networkConfig.rpcUrls);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Try multiple RPC endpoints (only working ones if available)
|
|
303
|
+
for (let i = 0; i < workingRpcUrls.length; i++) {
|
|
304
|
+
const rpcUrl = workingRpcUrls[i];
|
|
305
|
+
|
|
264
306
|
try {
|
|
265
307
|
const provider = new ethers.JsonRpcProvider(rpcUrl);
|
|
266
308
|
|
|
267
309
|
// Test connection with a timeout
|
|
268
|
-
|
|
310
|
+
await Promise.race([
|
|
269
311
|
provider.getBlockNumber(),
|
|
270
312
|
new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), 5000))
|
|
271
313
|
]);
|
|
@@ -276,23 +318,27 @@ export class TokenVerifierBrowser {
|
|
|
276
318
|
// Call getZipFileInfo to get the blockchain-stored data
|
|
277
319
|
const zipInfo = await contract.getZipFileInfo(tokenMetadata.tokenId);
|
|
278
320
|
|
|
321
|
+
// Get the token owner
|
|
322
|
+
const owner = await contract.ownerOf(tokenMetadata.tokenId);
|
|
323
|
+
|
|
279
324
|
return {
|
|
280
325
|
merkleRoot: zipInfo.merkleRootHash,
|
|
281
|
-
timestamp: Number(zipInfo.tokenizationTime)
|
|
326
|
+
timestamp: Number(zipInfo.tokenizationTime),
|
|
327
|
+
owner: owner
|
|
282
328
|
};
|
|
283
329
|
|
|
284
|
-
} catch (error) {
|
|
285
|
-
|
|
330
|
+
} catch (error: any) {
|
|
331
|
+
// Continue to next endpoint on error
|
|
286
332
|
continue;
|
|
287
333
|
}
|
|
288
334
|
}
|
|
289
335
|
|
|
290
|
-
console.
|
|
291
|
-
return { merkleRoot: null, timestamp: null };
|
|
336
|
+
console.error(`[TokenVerifier] ❌ All RPC endpoints failed for network: ${tokenMetadata.network}`);
|
|
337
|
+
return { merkleRoot: null, timestamp: null, owner: null };
|
|
292
338
|
|
|
293
|
-
} catch (error) {
|
|
294
|
-
console.error(
|
|
295
|
-
return { merkleRoot: null, timestamp: null };
|
|
339
|
+
} catch (error: any) {
|
|
340
|
+
console.error(`[TokenVerifier] ❌ Blockchain query error:`, error?.message || error);
|
|
341
|
+
return { merkleRoot: null, timestamp: null, owner: null };
|
|
296
342
|
}
|
|
297
343
|
}
|
|
298
344
|
|
|
@@ -311,15 +357,15 @@ export class TokenVerifierBrowser {
|
|
|
311
357
|
/**
|
|
312
358
|
* Creates a formatted summary of token information
|
|
313
359
|
*/
|
|
314
|
-
createTokenSummary(tokenMetadata:
|
|
360
|
+
createTokenSummary(tokenMetadata: TokenMetadata): string {
|
|
315
361
|
return `
|
|
316
362
|
🎫 NFT Token Information:
|
|
317
363
|
Token ID: ${tokenMetadata.tokenId}
|
|
318
364
|
Network: ${tokenMetadata.network}
|
|
319
365
|
Contract: ${tokenMetadata.contractAddress}
|
|
320
366
|
Transaction: ${tokenMetadata.transactionHash}
|
|
321
|
-
|
|
322
|
-
Minted: ${new Date(tokenMetadata.mintedAt).toLocaleString()}
|
|
367
|
+
Type: Tokenized Archive
|
|
368
|
+
Minted: ${tokenMetadata.mintedAt ? new Date(tokenMetadata.mintedAt).toLocaleString() : 'Unknown'}
|
|
323
369
|
`;
|
|
324
370
|
}
|
|
325
371
|
}
|
|
@@ -327,18 +373,18 @@ export class TokenVerifierBrowser {
|
|
|
327
373
|
/**
|
|
328
374
|
* Creates a new TokenVerifierBrowser instance
|
|
329
375
|
*/
|
|
330
|
-
export function createTokenVerifier(
|
|
331
|
-
return new TokenVerifierBrowser(
|
|
376
|
+
export function createTokenVerifier(zipkit: ZipkitBrowser): TokenVerifierBrowser {
|
|
377
|
+
return new TokenVerifierBrowser(zipkit);
|
|
332
378
|
}
|
|
333
379
|
|
|
334
380
|
/**
|
|
335
381
|
* Convenience function to check for tokenization
|
|
336
382
|
*/
|
|
337
383
|
export async function checkForTokenization(
|
|
338
|
-
|
|
384
|
+
zipkit: ZipkitBrowser,
|
|
339
385
|
zipEntries: ZipEntry[],
|
|
340
386
|
options: TokenVerificationOptions = {}
|
|
341
387
|
): Promise<TokenVerificationResult> {
|
|
342
|
-
const verifier = new TokenVerifierBrowser(
|
|
388
|
+
const verifier = new TokenVerifierBrowser(zipkit);
|
|
343
389
|
return verifier.checkForTokenization(zipEntries, options);
|
|
344
390
|
}
|