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,42 @@
1
+ // Export all types
2
+ export * from './types';
3
+
4
+ // Export wallet management
5
+ export { WalletManager } from './WalletManager';
6
+
7
+ // Export NFT minting
8
+ export { NFTMinter } from './NFTMinter';
9
+
10
+ // Export main processor
11
+ export { ZipTokenProcessor } from './ZipTokenProcessor';
12
+
13
+ // Export ZIP metadata utilities
14
+ export { ZipMetadata } from './ZipMetadata';
15
+
16
+ // Export token verification utilities
17
+ export {
18
+ checkForTokenization,
19
+ TokenVerificationOptions,
20
+ TokenVerificationResult
21
+ } from './TokenVerifier';
22
+
23
+ // Export token querying utilities
24
+ export {
25
+ queryBlockchainForExistingToken,
26
+ queryWalletTokens,
27
+ ExistingTokenInfo,
28
+ TokenQueryOptions
29
+ } from './TokenQuerier';
30
+
31
+ // Export wallet analysis utilities
32
+ export {
33
+ WalletAnalyzer,
34
+ TokenInfo,
35
+ NZipTokenDetails,
36
+ WalletBasicInfo,
37
+ TokenScanResult,
38
+ CommonTokenConfig
39
+ } from './WalletAnalyzer';
40
+
41
+ // Export wallet formatting utilities
42
+ export { WalletFormatter } from './WalletFormatter';
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Test/Demo script for CertificateToken functionality
5
+ *
6
+ * This demonstrates how to generate certificates for tokenized ZIP files
7
+ * independently of the neozipkit integration.
8
+ */
9
+
10
+ import {
11
+ createTokenCertificate,
12
+ saveCertificate,
13
+ TokenInfo,
14
+ BlockchainVerification,
15
+ WalletInfo,
16
+ ZipFileInfo
17
+ } from './CertificateToken';
18
+ import { CURRENT_DEPLOYMENT } from './constants';
19
+
20
+ // Example token information
21
+ const sampleTokenInfo: TokenInfo = {
22
+ tokenId: "10",
23
+ contractAddress: CURRENT_DEPLOYMENT.address, // NZIP NFT Contract v2.0
24
+ network: "Base Sepolia",
25
+ transactionHash: "0x403331e67051b70c92af413ad9424e70f4e4cacb5512a2f6e6af46a6cb198340",
26
+ wallet: "0x1234567890123456789012345678901234567890",
27
+ timestamp: Math.floor(Date.now() / 1000),
28
+ note: "Test tokenized ZIP file for demonstration"
29
+ };
30
+
31
+ // Example blockchain verification results
32
+ const sampleVerification: BlockchainVerification = {
33
+ merkleRootMatches: true,
34
+ blockchainMerkleRoot: "abc123def456789012345678901234567890123456789012345678901234567890",
35
+ calculatedMerkleRoot: "abc123def456789012345678901234567890123456789012345678901234567890",
36
+ verificationStatus: 'PASSED',
37
+ verificationTime: Math.floor(Date.now() / 1000),
38
+ blockNumber: 12345678
39
+ };
40
+
41
+ // Example wallet information
42
+ const sampleWalletInfo: WalletInfo = {
43
+ address: "0x1234567890123456789012345678901234567890",
44
+ network: "Base Sepolia",
45
+ balance: "1.234 ETH",
46
+ ensName: "demo.eth"
47
+ };
48
+
49
+ // Example file information
50
+ const sampleFiles: ZipFileInfo[] = [
51
+ {
52
+ filename: "README.md",
53
+ size: 1024,
54
+ date: "2025-01-10 12:00:00 UTC",
55
+ hash: "a1b2c3d4e5f6789012345678901234567890123456789012345678901234567890"
56
+ },
57
+ {
58
+ filename: "document.pdf",
59
+ size: 2048576,
60
+ date: "2025-01-10 11:30:00 UTC",
61
+ hash: "b2c3d4e5f6a7890123456789012345678901234567890123456789012345678901"
62
+ },
63
+ {
64
+ filename: "image.jpg",
65
+ size: 512000,
66
+ date: "2025-01-10 10:15:00 UTC",
67
+ hash: "c3d4e5f6a7b8901234567890123456789012345678901234567890123456789012"
68
+ }
69
+ ];
70
+
71
+ function testCertificateGeneration() {
72
+ console.log('🧪 Testing Certificate Generation...');
73
+ console.log('=====================================');
74
+
75
+ try {
76
+ // Test with full information
77
+ console.log('1. Generating certificate with full information...');
78
+ const fullCertificate = createTokenCertificate(
79
+ sampleTokenInfo,
80
+ 'test-archive.zip',
81
+ sampleVerification,
82
+ sampleWalletInfo,
83
+ sampleFiles
84
+ );
85
+
86
+ const fullCertPath = saveCertificate('test-archive.zip', fullCertificate, './certificates');
87
+ console.log(`āœ… Full certificate saved: ${fullCertPath}`);
88
+
89
+ // Test with minimal information
90
+ console.log('\n2. Generating certificate with minimal information...');
91
+ const minimalVerification: BlockchainVerification = {
92
+ merkleRootMatches: false,
93
+ blockchainMerkleRoot: "different123456789012345678901234567890123456789012345678901234567890",
94
+ calculatedMerkleRoot: "calculated123456789012345678901234567890123456789012345678901234567890",
95
+ verificationStatus: 'FAILED'
96
+ };
97
+
98
+ const minimalCertificate = createTokenCertificate(
99
+ sampleTokenInfo,
100
+ 'minimal-archive.zip',
101
+ minimalVerification
102
+ );
103
+
104
+ const minimalCertPath = saveCertificate('minimal-archive.zip', minimalCertificate, './blockchain/output');
105
+ console.log(`āœ… Minimal certificate saved: ${minimalCertPath}`);
106
+
107
+ // Test with unavailable verification
108
+ console.log('\n3. Generating certificate with unavailable verification...');
109
+ const unavailableVerification: BlockchainVerification = {
110
+ merkleRootMatches: false,
111
+ blockchainMerkleRoot: "N/A",
112
+ calculatedMerkleRoot: "calculated123456789012345678901234567890123456789012345678901234567890",
113
+ verificationStatus: 'UNAVAILABLE'
114
+ };
115
+
116
+ const unavailableCertificate = createTokenCertificate(
117
+ sampleTokenInfo,
118
+ 'unavailable-archive.zip',
119
+ unavailableVerification,
120
+ sampleWalletInfo
121
+ );
122
+
123
+ const unavailableCertPath = saveCertificate('unavailable-archive.zip', unavailableCertificate, './blockchain/output');
124
+ console.log(`āœ… Unavailable verification certificate saved: ${unavailableCertPath}`);
125
+
126
+ console.log('\nšŸŽ‰ All certificate tests completed successfully!');
127
+ console.log('Check the ./blockchain/output directory for generated certificates.');
128
+
129
+ } catch (error) {
130
+ console.error('āŒ Error during certificate generation:', error);
131
+ }
132
+ }
133
+
134
+ // Run the test
135
+ if (require.main === module) {
136
+ testCertificateGeneration();
137
+ }
@@ -0,0 +1,134 @@
1
+ import { ethers } from 'ethers';
2
+ import { TOKENIZED_METADATA } from '../../shared/constants/Headers';
3
+
4
+ // NFT Metadata types
5
+ export interface NFTAttribute {
6
+ trait_type: string;
7
+ value: string;
8
+ }
9
+
10
+ export interface NFTMetadata {
11
+ name: string;
12
+ description: string;
13
+ image: string;
14
+ attributes: NFTAttribute[];
15
+ }
16
+
17
+ // Wallet and network types
18
+ export interface WalletInfo {
19
+ address: string;
20
+ privateKey: string;
21
+ mnemonic: string;
22
+ }
23
+
24
+ export interface NetworkConfig {
25
+ name: string;
26
+ rpcUrl: string;
27
+ chainId: number;
28
+ explorerUrl: string;
29
+ }
30
+
31
+ export interface WalletSetupResult {
32
+ wallet: ethers.Wallet | null;
33
+ provider: ethers.JsonRpcProvider | null;
34
+ success: boolean;
35
+ message?: string;
36
+ }
37
+
38
+ // Contract interaction types
39
+ export interface ContractInfo {
40
+ address: string;
41
+ abi: any[];
42
+ network: string;
43
+ deployer: string;
44
+ deploymentTime: string;
45
+ }
46
+
47
+ export interface MintingResult {
48
+ success: boolean;
49
+ message: string;
50
+ tokenId?: string;
51
+ txHash?: string;
52
+ creationTimestamp?: number;
53
+ }
54
+
55
+ // ZIP and minting specific types
56
+ export interface ZipTokenData {
57
+ zipFile: string;
58
+ merkleRoot: string;
59
+ fileName: string;
60
+ timestamp: string;
61
+ }
62
+
63
+ export interface MintingOptions {
64
+ wallet?: string;
65
+ network: string;
66
+ mintToken: boolean;
67
+ }
68
+
69
+ // Token information stored in ZIP file
70
+ export interface NZipTokenInfo {
71
+ version: string;
72
+ tokenId: string;
73
+ contractAddress: string;
74
+ network: string;
75
+ networkChainId: number;
76
+ transactionHash: string;
77
+ merkleRoot: string;
78
+ fileName: string;
79
+ mintedAt: string;
80
+ creationTimestamp?: number; // Unix timestamp when the token was created
81
+ blockNumber?: number;
82
+ ipfsHash?: string;
83
+ }
84
+
85
+ // Network configuration
86
+ export const NETWORKS: Record<string, NetworkConfig> = {
87
+ 'base': {
88
+ name: 'Base Mainnet',
89
+ rpcUrl: 'https://mainnet.base.org',
90
+ chainId: 8453,
91
+ explorerUrl: 'https://basescan.org'
92
+ },
93
+ 'base-sepolia': {
94
+ name: 'Base Sepolia',
95
+ rpcUrl: 'https://sepolia.base.org',
96
+ chainId: 84532,
97
+ explorerUrl: 'https://sepolia.basescan.org'
98
+ },
99
+ 'base-goerli': {
100
+ name: 'Base Goerli',
101
+ rpcUrl: 'https://goerli.base.org',
102
+ chainId: 84531,
103
+ explorerUrl: 'https://goerli.basescan.org'
104
+ },
105
+ 'localhost': {
106
+ name: 'Localhost',
107
+ rpcUrl: 'http://localhost:8545',
108
+ chainId: 31337,
109
+ explorerUrl: 'http://localhost:8545'
110
+ }
111
+ };
112
+
113
+ // Token metadata constants - use TOKENIZED_METADATA from constants/Headers
114
+
115
+ // NFT Metadata template
116
+ export const NFT_METADATA_TEMPLATE: NFTMetadata = {
117
+ name: "NeoZip Archive Token",
118
+ description: "This NFT represents ownership of a timestamped and verified ZIP archive on Base",
119
+ image: "", // Will be set to IPFS hash of thumbnail
120
+ attributes: [
121
+ {
122
+ trait_type: "Archive Hash",
123
+ value: "" // Will be set to the Merkle root hash of the archive
124
+ },
125
+ {
126
+ trait_type: "Creation Date",
127
+ value: "" // Will be set to timestamp
128
+ },
129
+ {
130
+ trait_type: "Blockchain",
131
+ value: "Base" // Specify Base as the blockchain
132
+ }
133
+ ]
134
+ };