neozipkit 0.2.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.
Files changed (301) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +410 -186
  3. package/contracts/ABI.txt +889 -0
  4. package/contracts/Bytecode.txt +1 -0
  5. package/contracts/COMPILATION_NOTES.md +59 -0
  6. package/contracts/QUICK_DEPLOY.md +286 -0
  7. package/contracts/README.md +235 -131
  8. package/contracts/VERIFICATION.md +308 -0
  9. package/contracts/deploy-interactive.js +448 -0
  10. package/contracts/deployment-arbitrum-sepolia.json +12 -0
  11. package/contracts/deployment-arbitrum.json +12 -0
  12. package/contracts/deployment-eth-sepolia.json +12 -0
  13. package/contracts/hardhat.config.js +114 -0
  14. package/contracts/package.json +20 -0
  15. package/contracts/scripts/compile-and-extract.js +119 -0
  16. package/contracts/scripts/verify-contract.js +223 -0
  17. package/contracts/src/{NZIP-NFT-Private.sol → NZIP-NFT-v2.0.sol} +66 -151
  18. package/contracts/src/NZIP-NFT.sol +9 -15
  19. package/dist/blockchain/browser/TokenVerifierBrowser.d.ts +67 -0
  20. package/dist/blockchain/browser/TokenVerifierBrowser.d.ts.map +1 -0
  21. package/dist/blockchain/browser/TokenVerifierBrowser.js +313 -0
  22. package/dist/blockchain/browser/TokenVerifierBrowser.js.map +1 -0
  23. package/dist/blockchain/browser/WalletManagerBrowser.d.ts +98 -0
  24. package/dist/blockchain/browser/WalletManagerBrowser.d.ts.map +1 -0
  25. package/dist/blockchain/browser/WalletManagerBrowser.js +434 -0
  26. package/dist/blockchain/browser/WalletManagerBrowser.js.map +1 -0
  27. package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts +58 -0
  28. package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts.map +1 -0
  29. package/dist/blockchain/browser/ZipkitMinterBrowser.js +317 -0
  30. package/dist/blockchain/browser/ZipkitMinterBrowser.js.map +1 -0
  31. package/dist/blockchain/browser/index.d.ts +11 -0
  32. package/dist/blockchain/browser/index.d.ts.map +1 -0
  33. package/dist/blockchain/browser/index.js +16 -0
  34. package/dist/blockchain/browser/index.js.map +1 -0
  35. package/dist/blockchain/core/WalletManager.d.ts +124 -0
  36. package/dist/blockchain/core/WalletManager.d.ts.map +1 -0
  37. package/dist/blockchain/{ZipKitWallet.js → core/WalletManager.js} +157 -177
  38. package/dist/blockchain/core/WalletManager.js.map +1 -0
  39. package/dist/blockchain/{ZipKitMinter.d.ts → core/ZipkitMinter.d.ts} +46 -11
  40. package/dist/blockchain/core/ZipkitMinter.d.ts.map +1 -0
  41. package/dist/blockchain/core/ZipkitMinter.js +548 -0
  42. package/dist/blockchain/core/ZipkitMinter.js.map +1 -0
  43. package/dist/blockchain/{ZipKitOTS.d.ts → core/ZipkitOTS.d.ts} +6 -15
  44. package/dist/blockchain/core/ZipkitOTS.d.ts.map +1 -0
  45. package/dist/blockchain/{ZipKitOTS.js → core/ZipkitOTS.js} +26 -84
  46. package/dist/blockchain/core/ZipkitOTS.js.map +1 -0
  47. package/dist/blockchain/core/ZipkitVerifier.d.ts +177 -0
  48. package/dist/blockchain/core/ZipkitVerifier.d.ts.map +1 -0
  49. package/dist/blockchain/core/ZipkitVerifier.js +632 -0
  50. package/dist/blockchain/core/ZipkitVerifier.js.map +1 -0
  51. package/dist/blockchain/core/contracts.d.ts +83 -0
  52. package/dist/blockchain/core/contracts.d.ts.map +1 -0
  53. package/dist/blockchain/core/contracts.js +341 -0
  54. package/dist/blockchain/core/contracts.js.map +1 -0
  55. package/dist/blockchain/core/index.d.ts +12 -0
  56. package/dist/blockchain/core/index.d.ts.map +1 -0
  57. package/dist/blockchain/core/index.js +59 -0
  58. package/dist/blockchain/core/index.js.map +1 -0
  59. package/dist/blockchain/index.d.ts +11 -7
  60. package/dist/blockchain/index.d.ts.map +1 -0
  61. package/dist/blockchain/index.js +18 -34
  62. package/dist/blockchain/index.js.map +1 -0
  63. package/dist/blockchain/node/WalletManagerNode.d.ts +47 -0
  64. package/dist/blockchain/node/WalletManagerNode.d.ts.map +1 -0
  65. package/dist/blockchain/node/WalletManagerNode.js +203 -0
  66. package/dist/blockchain/node/WalletManagerNode.js.map +1 -0
  67. package/dist/blockchain/node/index.d.ts +12 -0
  68. package/dist/blockchain/node/index.d.ts.map +1 -0
  69. package/dist/blockchain/node/index.js +24 -0
  70. package/dist/blockchain/node/index.js.map +1 -0
  71. package/dist/browser/ZipkitBrowser.d.ts +27 -0
  72. package/dist/browser/ZipkitBrowser.d.ts.map +1 -0
  73. package/dist/browser/{ZipKitBrowser.js → ZipkitBrowser.js} +96 -43
  74. package/dist/browser/ZipkitBrowser.js.map +1 -0
  75. package/dist/browser/index.d.ts +12 -0
  76. package/dist/browser/index.d.ts.map +1 -0
  77. package/dist/browser/index.js +42 -0
  78. package/dist/browser/index.js.map +1 -0
  79. package/dist/browser-esm/index.d.ts +12 -0
  80. package/dist/browser-esm/index.js +59559 -0
  81. package/dist/browser-esm/index.js.map +7 -0
  82. package/dist/browser-umd/index.d.ts +12 -0
  83. package/dist/browser-umd/index.js +59576 -0
  84. package/dist/browser-umd/index.js.map +7 -0
  85. package/dist/browser-umd/index.min.js +63 -0
  86. package/dist/browser.d.ts +8 -14
  87. package/dist/browser.js +13 -28
  88. package/dist/core/ZipCompress.d.ts +99 -0
  89. package/dist/core/ZipCompress.d.ts.map +1 -0
  90. package/dist/core/ZipCompress.js +309 -0
  91. package/dist/core/ZipCompress.js.map +1 -0
  92. package/dist/core/ZipDecompress.d.ts +58 -0
  93. package/dist/core/ZipDecompress.d.ts.map +1 -0
  94. package/dist/core/ZipDecompress.js +172 -0
  95. package/dist/core/ZipDecompress.js.map +1 -0
  96. package/dist/{shared → core}/ZipEntry.d.ts +8 -1
  97. package/dist/core/ZipEntry.d.ts.map +1 -0
  98. package/dist/{shared → core}/ZipEntry.js +225 -82
  99. package/dist/core/ZipEntry.js.map +1 -0
  100. package/dist/core/Zipkit.d.ts +315 -0
  101. package/dist/core/Zipkit.d.ts.map +1 -0
  102. package/dist/core/Zipkit.js +647 -0
  103. package/dist/core/Zipkit.js.map +1 -0
  104. package/dist/core/components/HashCalculator.d.ts +138 -0
  105. package/dist/core/components/HashCalculator.d.ts.map +1 -0
  106. package/dist/core/components/HashCalculator.js +360 -0
  107. package/dist/core/components/HashCalculator.js.map +1 -0
  108. package/dist/core/components/Logger.d.ts +73 -0
  109. package/dist/core/components/Logger.d.ts.map +1 -0
  110. package/dist/core/components/Logger.js +156 -0
  111. package/dist/core/components/Logger.js.map +1 -0
  112. package/dist/core/components/ProgressTracker.d.ts +43 -0
  113. package/dist/core/components/ProgressTracker.d.ts.map +1 -0
  114. package/dist/core/components/ProgressTracker.js +112 -0
  115. package/dist/core/components/ProgressTracker.js.map +1 -0
  116. package/dist/{shared → core}/components/Support.d.ts +1 -0
  117. package/dist/core/components/Support.d.ts.map +1 -0
  118. package/dist/{shared → core}/components/Support.js +1 -0
  119. package/dist/core/components/Support.js.map +1 -0
  120. package/dist/{shared → core}/components/Util.d.ts +7 -2
  121. package/dist/core/components/Util.d.ts.map +1 -0
  122. package/dist/{shared → core}/components/Util.js +14 -34
  123. package/dist/core/components/Util.js.map +1 -0
  124. package/dist/{shared → core}/constants/Errors.d.ts +1 -2
  125. package/dist/core/constants/Errors.d.ts.map +1 -0
  126. package/dist/{shared → core}/constants/Errors.js +1 -3
  127. package/dist/core/constants/Errors.js.map +1 -0
  128. package/dist/{shared → core}/constants/Headers.d.ts +3 -0
  129. package/dist/core/constants/Headers.d.ts.map +1 -0
  130. package/dist/{shared → core}/constants/Headers.js +20 -17
  131. package/dist/core/constants/Headers.js.map +1 -0
  132. package/dist/core/encryption/Manager.d.ts +58 -0
  133. package/dist/core/encryption/Manager.d.ts.map +1 -0
  134. package/dist/core/encryption/Manager.js +121 -0
  135. package/dist/core/encryption/Manager.js.map +1 -0
  136. package/dist/core/encryption/ZipCrypto.d.ts +172 -0
  137. package/dist/core/encryption/ZipCrypto.d.ts.map +1 -0
  138. package/dist/core/encryption/ZipCrypto.js +554 -0
  139. package/dist/core/encryption/ZipCrypto.js.map +1 -0
  140. package/dist/core/encryption/index.d.ts +9 -0
  141. package/dist/core/encryption/index.d.ts.map +1 -0
  142. package/dist/core/encryption/index.js +17 -0
  143. package/dist/core/encryption/index.js.map +1 -0
  144. package/dist/core/encryption/types.d.ts +29 -0
  145. package/dist/core/encryption/types.d.ts.map +1 -0
  146. package/dist/core/encryption/types.js +12 -0
  147. package/dist/core/encryption/types.js.map +1 -0
  148. package/dist/core/index.d.ts +24 -0
  149. package/dist/core/index.d.ts.map +1 -0
  150. package/dist/core/index.js +57 -0
  151. package/dist/core/index.js.map +1 -0
  152. package/dist/core/version.d.ts +5 -0
  153. package/dist/core/version.d.ts.map +1 -0
  154. package/dist/core/version.js +31 -0
  155. package/dist/core/version.js.map +1 -0
  156. package/dist/index.d.ts +8 -18
  157. package/dist/index.d.ts.map +1 -0
  158. package/dist/index.js +29 -35
  159. package/dist/index.js.map +1 -0
  160. package/dist/node/ZipCompressNode.d.ts +123 -0
  161. package/dist/node/ZipCompressNode.d.ts.map +1 -0
  162. package/dist/node/ZipCompressNode.js +576 -0
  163. package/dist/node/ZipCompressNode.js.map +1 -0
  164. package/dist/node/ZipDecompressNode.d.ts +120 -0
  165. package/dist/node/ZipDecompressNode.d.ts.map +1 -0
  166. package/dist/node/ZipDecompressNode.js +461 -0
  167. package/dist/node/ZipDecompressNode.js.map +1 -0
  168. package/dist/node/ZipkitNode.d.ts +406 -0
  169. package/dist/node/ZipkitNode.d.ts.map +1 -0
  170. package/dist/node/ZipkitNode.js +1305 -0
  171. package/dist/node/ZipkitNode.js.map +1 -0
  172. package/dist/node/index.d.ts +26 -0
  173. package/dist/node/index.d.ts.map +1 -0
  174. package/dist/node/index.js +65 -0
  175. package/dist/node/index.js.map +1 -0
  176. package/dist/types/index.d.ts +59 -0
  177. package/dist/types/index.d.ts.map +1 -0
  178. package/dist/types/index.js +36 -1
  179. package/dist/types/index.js.map +1 -0
  180. package/examples/README.md +269 -0
  181. package/examples/blockchain-tokenize.ts +354 -0
  182. package/examples/create-zip.ts +172 -0
  183. package/examples/extract-zip.ts +158 -0
  184. package/examples/list-zip.ts +161 -0
  185. package/examples/test-files/data.json +116 -0
  186. package/examples/test-files/document.md +80 -0
  187. package/examples/test-files/document.txt +2 -0
  188. package/examples/test-files/file1.txt +48 -0
  189. package/examples/test-files/file2.txt +80 -0
  190. package/examples/tsconfig.json +44 -0
  191. package/examples/unzip-token.ts +491 -0
  192. package/examples/verify-tokenized-zip.ts +305 -0
  193. package/examples/zip-token.ts +604 -0
  194. package/package.json +108 -24
  195. package/src/blockchain/README.md +59 -66
  196. package/src/{browser/TokenVerifierBrowser.ts-remove → blockchain/browser/TokenVerifierBrowser.ts} +125 -79
  197. package/src/blockchain/browser/WalletManagerBrowser.ts +486 -0
  198. package/src/blockchain/browser/ZipkitMinterBrowser.ts +400 -0
  199. package/src/blockchain/browser/index.ts +13 -0
  200. package/src/blockchain/{ZipKitWallet.ts → core/WalletManager.ts} +241 -143
  201. package/src/blockchain/core/ZipkitMinter.ts +716 -0
  202. package/src/blockchain/{ZipKitOTS.ts → core/ZipkitOTS.ts} +28 -62
  203. package/src/blockchain/core/ZipkitVerifier.ts +853 -0
  204. package/src/blockchain/core/contracts.ts +370 -0
  205. package/src/blockchain/core/index.ts +71 -0
  206. package/src/blockchain/index.ts +21 -55
  207. package/src/blockchain/node/WalletManagerNode.ts +171 -0
  208. package/src/blockchain/node/index.ts +40 -0
  209. package/src/browser/{ZipKitBrowser.ts → ZipkitBrowser.ts} +104 -41
  210. package/src/browser/index.esm.ts +37 -0
  211. package/src/browser/index.ts +25 -0
  212. package/src/core/ZipCompress.ts +398 -0
  213. package/src/core/ZipDecompress.ts +212 -0
  214. package/src/{shared → core}/ZipEntry.ts +240 -90
  215. package/src/core/Zipkit.ts +794 -0
  216. package/src/core/components/HashCalculator.ts +384 -0
  217. package/src/core/components/Logger.ts +180 -0
  218. package/src/core/components/ProgressTracker.ts +134 -0
  219. package/src/{shared → core}/components/Util.ts +12 -34
  220. package/src/{shared → core}/constants/Errors.ts +0 -4
  221. package/src/{shared → core}/constants/Headers.ts +19 -17
  222. package/src/core/encryption/Manager.ts +137 -0
  223. package/src/core/encryption/ZipCrypto.ts +650 -0
  224. package/src/core/encryption/index.ts +15 -0
  225. package/src/core/encryption/types.ts +33 -0
  226. package/src/core/index.ts +34 -0
  227. package/src/core/version.ts +33 -0
  228. package/src/index.ts +54 -25
  229. package/src/node/ZipCompressNode.ts +632 -0
  230. package/src/node/ZipDecompressNode.ts +508 -0
  231. package/src/node/ZipkitNode.ts +1559 -0
  232. package/src/node/index.ts +69 -0
  233. package/src/types/index.ts +131 -1
  234. package/src/types/modules.d.ts +1 -11
  235. package/src/types/opentimestamps.d.ts +1 -23
  236. package/contracts/INTEGRATION.md +0 -338
  237. package/contracts/NETWORKS.md +0 -156
  238. package/contracts/NZIP-NFT-bytecode.txt +0 -1
  239. package/contracts/constants.ts +0 -952
  240. package/contracts/deploy-bytecode.mjs +0 -94
  241. package/dist/blockchain/CertificateToken.d.ts +0 -48
  242. package/dist/blockchain/CertificateToken.js +0 -386
  243. package/dist/blockchain/ZipKitMinter.js +0 -347
  244. package/dist/blockchain/ZipKitNFT.d.ts +0 -3
  245. package/dist/blockchain/ZipKitNFT.js +0 -7
  246. package/dist/blockchain/ZipKitVerifier.d.ts +0 -69
  247. package/dist/blockchain/ZipKitVerifier.js +0 -289
  248. package/dist/blockchain/ZipKitWallet.d.ts +0 -69
  249. package/dist/blockchain/contracts.d.ts +0 -14
  250. package/dist/blockchain/contracts.js +0 -77
  251. package/dist/blockchain/types.d.ts +0 -47
  252. package/dist/blockchain/types.js +0 -30
  253. package/dist/browser/ZipKitBrowser.d.ts +0 -18
  254. package/dist/browser/ZipKitStampBrowser.d.ts +0 -2
  255. package/dist/browser/ZipKitStampBrowser.js +0 -12
  256. package/dist/browser-index.d.ts +0 -18
  257. package/dist/browser-index.js +0 -57
  258. package/dist/server/ZipKitServer.d.ts +0 -74
  259. package/dist/server/ZipKitServer.js +0 -310
  260. package/dist/shared/ZipKit.d.ts +0 -243
  261. package/dist/shared/ZipKit.js +0 -772
  262. package/dist/shared/components/CertificateOTS.d.ts +0 -15
  263. package/dist/shared/components/CertificateOTS.js +0 -116
  264. package/dist/shared/components/FileSys.d.ts +0 -2
  265. package/dist/shared/components/FileSys.js +0 -113
  266. package/dist/shared/components/HashAccumulator.d.ts +0 -55
  267. package/dist/shared/components/HashAccumulator.js +0 -100
  268. package/dist/shared/components/ZipCrypto.d.ts +0 -3
  269. package/dist/shared/components/ZipCrypto.js +0 -78
  270. package/dist/shared/components/merkleTree.d.ts +0 -66
  271. package/dist/shared/components/merkleTree.js +0 -136
  272. package/dist/shared/types/index.d.ts +0 -21
  273. package/dist/shared/types/index.js +0 -3
  274. package/dist/shared/types.d.ts +0 -33
  275. package/dist/shared/types.js +0 -8
  276. package/dist/shared/version.d.ts +0 -2
  277. package/dist/shared/version.js +0 -6
  278. package/src/blockchain/CertificateToken.ts +0 -444
  279. package/src/blockchain/ZipKitMinter.ts +0 -470
  280. package/src/blockchain/ZipKitNFT.ts +0 -12
  281. package/src/blockchain/ZipKitVerifier.ts +0 -382
  282. package/src/blockchain/contracts.ts +0 -88
  283. package/src/blockchain/types.ts +0 -91
  284. package/src/browser/CertificateGeneratorBrowser.ts-remove +0 -498
  285. package/src/browser/ZipKitStampBrowser.ts +0 -9
  286. package/src/browser-index.ts +0 -36
  287. package/src/server/README.md +0 -25
  288. package/src/server/ZipKitServer.ts +0 -305
  289. package/src/shared/ZipKit.ts +0 -881
  290. package/src/shared/components/CertificateOTS.ts +0 -132
  291. package/src/shared/components/FileSys.ts +0 -87
  292. package/src/shared/components/HashAccumulator.ts +0 -113
  293. package/src/shared/components/ZipCrypto.ts +0 -91
  294. package/src/shared/components/merkleTree.ts +0 -162
  295. package/src/shared/types/index.ts +0 -25
  296. package/src/shared/types/modules.d.ts +0 -22
  297. package/src/shared/types/opentimestamps.d.ts +0 -23
  298. package/src/shared/types.d.ts +0 -8
  299. package/src/shared/types.ts +0 -43
  300. package/src/shared/version.ts +0 -3
  301. /package/src/{shared → core}/components/Support.ts +0 -0
@@ -0,0 +1,370 @@
1
+ // Contract addresses and configurations for different networks
2
+
3
+ export interface ContractConfig {
4
+ address: string
5
+ network: string
6
+ chainId: number
7
+ explorerUrl: string
8
+ rpcUrls: string[]
9
+ nameAliases?: string[] // Alternative network name formats (e.g., ["base-sepolia", "base sepolia"])
10
+ }
11
+
12
+ // NZIP NFT Contract configurations by network
13
+ export const CONTRACT_CONFIGS: Record<number, ContractConfig> = {
14
+ // Base Sepolia (Primary testnet)
15
+ 84532: {
16
+ // address: '0xFD76a5d420704F34d84b0767961835c43D7b30a8', // Production contract v2.0
17
+ address: '0xdAe9D83d7AC62197fAE7704abc66b13DA28D3143', // Production contract v2.10
18
+ network: 'Base Sepolia',
19
+ chainId: 84532,
20
+ explorerUrl: 'https://sepolia.basescan.org',
21
+ rpcUrls: [
22
+ 'https://sepolia.base.org',
23
+ 'https://base-sepolia-rpc.publicnode.com',
24
+ 'https://base-sepolia.gateway.tenderly.co'
25
+ ],
26
+ nameAliases: ['base-sepolia', 'base sepolia', 'basesepolia', 'base-sepolia-testnet']
27
+ },
28
+
29
+ // Base Mainnet (Production)
30
+ 8453: {
31
+ // address: '0x2716c4609fD97DaEdF429BC4B4Ec2faa81e2cC60', // Production contract v2.0
32
+ address: '0xd871Fba59F85108aF29299786DD8243B38dD9686', // Production contract v2.10
33
+ network: 'Base Mainnet',
34
+ chainId: 8453,
35
+ explorerUrl: 'https://basescan.org',
36
+ rpcUrls: [
37
+ 'https://mainnet.base.org',
38
+ 'https://base.drpc.org',
39
+ 'https://base.gateway.tenderly.co'
40
+ ],
41
+ nameAliases: ['base-mainnet', 'base mainnet', 'basemainnet', 'base']
42
+ },
43
+
44
+ // Ethereum Sepolia (Testnet)
45
+ // WARNING: Sepolia testnet has been experiencing instability since the Pectra upgrade (March 2025)
46
+ // Network issues include transaction processing failures and RPC timeouts
47
+ // Consider using Base Sepolia (84532) for more reliable testing
48
+ 11155111: {
49
+ address: '0x2716c4609fD97DaEdF429BC4B4Ec2faa81e2cC60', // Production contract v2.10
50
+ network: 'Sepolia Testnet',
51
+ chainId: 11155111,
52
+ explorerUrl: 'https://sepolia.etherscan.io',
53
+ rpcUrls: [
54
+ // Official Sepolia RPC endpoints (most reliable)
55
+ 'https://rpc.sepolia.ethpandaops.io',
56
+
57
+ // Popular public RPC providers
58
+ 'https://eth-sepolia.public.blastapi.io',
59
+ 'https://ethereum-sepolia-rpc.publicnode.com',
60
+ 'https://sepolia.drpc.org',
61
+ 'https://1rpc.io/sepolia',
62
+ ],
63
+ nameAliases: ['sepolia-testnet', 'sepolia testnet', 'sepoliatestnet', 'sepolia', 'ethereum-sepolia', 'ethereum sepolia']
64
+ },
65
+
66
+ // Arbitrum Sepolia (Testnet)
67
+ 421614: {
68
+ address: '0x2716c4609fD97DaEdF429BC4B4Ec2faa81e2cC60', // Production contract v2.10
69
+ network: 'Arbitrum Sepolia',
70
+ chainId: 421614,
71
+ explorerUrl: 'https://sepolia.arbiscan.io',
72
+ rpcUrls: [
73
+ 'https://sepolia-rollup.arbitrum.io/rpc',
74
+ 'https://arbitrum-sepolia-rpc.publicnode.com'
75
+ ],
76
+ nameAliases: ['arbitrum-sepolia', 'arbitrum sepolia', 'arbitrumsepolia', 'arbitrum-sepolia-testnet']
77
+ },
78
+
79
+ // Arbitrum One (Production)
80
+ // Note: Same contract address as Arbitrum Sepolia due to deterministic deployment
81
+ // (same deployer address + same nonce = same contract address on both networks)
82
+ 42161: {
83
+ address: '0x2716c4609fD97DaEdF429BC4B4Ec2faa81e2cC60', // Production contract v2.10
84
+ network: 'Arbitrum One',
85
+ chainId: 42161,
86
+ explorerUrl: 'https://arbiscan.io',
87
+ rpcUrls: [
88
+ 'https://arb1.arbitrum.io/rpc',
89
+ 'https://arbitrum.llamarpc.com',
90
+ 'https://arbitrum.publicnode.com'
91
+ ],
92
+ nameAliases: ['arbitrum-one', 'arbitrum one', 'arbitrumone', 'arbitrum', 'arbitrum-mainnet', 'arbitrum mainnet']
93
+ },
94
+
95
+ // Ethereum Mainnet (Production) - disabled until NZIP is deployed
96
+ // 1: {
97
+ // address: '0x0000000000000000000000000000000000000000',
98
+ // network: 'Ethereum Mainnet',
99
+ // chainId: 1,
100
+ // explorerUrl: 'https://etherscan.io',
101
+ // rpcUrls: []
102
+ // }
103
+ }
104
+
105
+ // Contract ABI (ethers.js human-readable format)
106
+ export const NZIP_CONTRACT_ABI = [
107
+ "function publicMintZipFile(string memory merkleRootHash, uint256 creationTimestamp, string memory ipfsHash, string memory metadataURI) public returns (uint256)",
108
+ "function totalSupply() external view returns (uint256)",
109
+ "function getTokensByMerkleRoot(string memory merkleRoot) external view returns (uint256[])",
110
+ "function getTokensByOwner(address owner) external view returns (uint256[])",
111
+ "function getZipFileInfo(uint256 tokenId) external view returns (tuple(string merkleRootHash, string ipfsHash, address creator, uint256 creationTimestamp, uint256 tokenizationTime, uint256 blockNumber))",
112
+ "function ownerOf(uint256 tokenId) external view returns (address)",
113
+ "function balanceOf(address owner) external view returns (uint256)",
114
+ "function isZipFileTokenized(string memory merkleRootHash, uint256 creationTimestamp) external view returns (bool exists, uint256 tokenId)",
115
+ "function verifyZipFile(uint256 tokenId, string memory providedMerkleRoot) external view returns (bool isValid)",
116
+ "function getVersion() external pure returns (string memory)",
117
+ "event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)",
118
+ "event ZipFileTokenized(uint256 indexed tokenId, address indexed creator, string merkleRootHash, uint256 creationTimestamp, string ipfsHash, uint256 tokenizationTime, uint256 blockNumber)"
119
+ ]
120
+
121
+ // Contract ABI (Web3.js JSON format)
122
+ export const NZIP_CONTRACT_ABI_WEB3 = [
123
+ {
124
+ inputs: [
125
+ { name: "merkleRootHash", type: "string" },
126
+ { name: "creationTimestamp", type: "uint256" },
127
+ { name: "ipfsHash", type: "string" },
128
+ { name: "metadataURI", type: "string" }
129
+ ],
130
+ name: "publicMintZipFile",
131
+ outputs: [{ name: "", type: "uint256" }],
132
+ stateMutability: "nonpayable",
133
+ type: "function"
134
+ },
135
+ {
136
+ inputs: [],
137
+ name: "totalSupply",
138
+ outputs: [{ name: "", type: "uint256" }],
139
+ stateMutability: "view",
140
+ type: "function"
141
+ },
142
+ {
143
+ inputs: [{ name: "merkleRoot", type: "string" }],
144
+ name: "getTokensByMerkleRoot",
145
+ outputs: [{ name: "", type: "uint256[]" }],
146
+ stateMutability: "view",
147
+ type: "function"
148
+ },
149
+ {
150
+ inputs: [{ name: "tokenId", type: "uint256" }],
151
+ name: "getZipFileInfo",
152
+ outputs: [
153
+ {
154
+ components: [
155
+ { name: "merkleRootHash", type: "string" },
156
+ { name: "ipfsHash", type: "string" },
157
+ { name: "creator", type: "address" },
158
+ { name: "creationTimestamp", type: "uint256" },
159
+ { name: "tokenizationTime", type: "uint256" },
160
+ { name: "blockNumber", type: "uint256" }
161
+ ],
162
+ name: "",
163
+ type: "tuple"
164
+ }
165
+ ],
166
+ stateMutability: "view",
167
+ type: "function"
168
+ },
169
+ {
170
+ inputs: [{ name: "tokenId", type: "uint256" }],
171
+ name: "ownerOf",
172
+ outputs: [{ name: "", type: "address" }],
173
+ stateMutability: "view",
174
+ type: "function"
175
+ },
176
+ {
177
+ inputs: [{ name: "owner", type: "address" }],
178
+ name: "balanceOf",
179
+ outputs: [{ name: "", type: "uint256" }],
180
+ stateMutability: "view",
181
+ type: "function"
182
+ },
183
+ {
184
+ inputs: [
185
+ { name: "merkleRootHash", type: "string" },
186
+ { name: "creationTimestamp", type: "uint256" }
187
+ ],
188
+ name: "isZipFileTokenized",
189
+ outputs: [
190
+ { name: "exists", type: "bool" },
191
+ { name: "tokenId", type: "uint256" }
192
+ ],
193
+ stateMutability: "view",
194
+ type: "function"
195
+ },
196
+ {
197
+ inputs: [
198
+ { name: "tokenId", type: "uint256" },
199
+ { name: "providedMerkleRoot", type: "string" }
200
+ ],
201
+ name: "verifyZipFile",
202
+ outputs: [{ name: "isValid", type: "bool" }],
203
+ stateMutability: "view",
204
+ type: "function"
205
+ },
206
+ {
207
+ inputs: [],
208
+ name: "getVersion",
209
+ outputs: [{ name: "", type: "string" }],
210
+ stateMutability: "pure",
211
+ type: "function"
212
+ },
213
+ {
214
+ anonymous: false,
215
+ inputs: [
216
+ { indexed: true, name: "from", type: "address" },
217
+ { indexed: true, name: "to", type: "address" },
218
+ { indexed: true, name: "tokenId", type: "uint256" }
219
+ ],
220
+ name: "Transfer",
221
+ type: "event"
222
+ },
223
+ {
224
+ anonymous: false,
225
+ inputs: [
226
+ { indexed: true, name: "tokenId", type: "uint256" },
227
+ { indexed: true, name: "creator", type: "address" },
228
+ { indexed: false, name: "merkleRootHash", type: "string" },
229
+ { indexed: false, name: "creationTimestamp", type: "uint256" },
230
+ { indexed: false, name: "ipfsHash", type: "string" },
231
+ { indexed: false, name: "tokenizationTime", type: "uint256" },
232
+ { indexed: false, name: "blockNumber", type: "uint256" }
233
+ ],
234
+ name: "ZipFileTokenized",
235
+ type: "event"
236
+ }
237
+ ]
238
+
239
+ // Default configuration (Base Sepolia for development)
240
+ export const DEFAULT_NETWORK = 84532
241
+ export const CURRENT_DEPLOYMENT = CONTRACT_CONFIGS[DEFAULT_NETWORK]
242
+
243
+ // Helper functions
244
+ export const getContractConfig = (chainId: number): ContractConfig => {
245
+ return CONTRACT_CONFIGS[chainId] || CURRENT_DEPLOYMENT
246
+ }
247
+
248
+ export const getSupportedNetworks = (): number[] => {
249
+ return Object.keys(CONTRACT_CONFIGS).map(Number)
250
+ }
251
+
252
+ export const isNetworkSupported = (chainId: number): boolean => {
253
+ return chainId in CONTRACT_CONFIGS
254
+ }
255
+
256
+ /**
257
+ * Normalize network name for matching (lowercase, trim, replace spaces with hyphens)
258
+ */
259
+ export function normalizeNetworkName(networkName: string): string {
260
+ return networkName.toLowerCase().trim().replace(/\s+/g, '-').replace(/_/g, '-')
261
+ }
262
+
263
+ /**
264
+ * Get chain ID by network name (supports aliases)
265
+ * Returns chain ID if found, null otherwise
266
+ */
267
+ export function getChainIdByName(networkName: string): number | null {
268
+ const normalized = normalizeNetworkName(networkName)
269
+
270
+ // Search through all configs
271
+ for (const [chainIdStr, config] of Object.entries(CONTRACT_CONFIGS)) {
272
+ const chainId = Number(chainIdStr)
273
+
274
+ // Check primary network name
275
+ if (normalizeNetworkName(config.network) === normalized) {
276
+ return chainId
277
+ }
278
+
279
+ // Check name aliases
280
+ if (config.nameAliases) {
281
+ for (const alias of config.nameAliases) {
282
+ if (normalizeNetworkName(alias) === normalized) {
283
+ return chainId
284
+ }
285
+ }
286
+ }
287
+ }
288
+
289
+ return null
290
+ }
291
+
292
+ /**
293
+ * Get network configuration by network name (supports aliases)
294
+ * Returns ContractConfig if found, null otherwise
295
+ */
296
+ export function getNetworkByName(networkName: string): ContractConfig | null {
297
+ const chainId = getChainIdByName(networkName)
298
+ if (chainId === null) {
299
+ return null
300
+ }
301
+ return getContractConfig(chainId)
302
+ }
303
+
304
+ /**
305
+ * Get all supported network name aliases
306
+ * Returns array of all supported network names (primary + aliases)
307
+ */
308
+ export function getSupportedNetworkNames(): string[] {
309
+ const names: string[] = []
310
+
311
+ for (const config of Object.values(CONTRACT_CONFIGS)) {
312
+ // Add primary network name
313
+ names.push(config.network)
314
+
315
+ // Add aliases
316
+ if (config.nameAliases) {
317
+ names.push(...config.nameAliases)
318
+ }
319
+ }
320
+
321
+ return names
322
+ }
323
+
324
+ /**
325
+ * Fuzzy match network name (for backward compatibility)
326
+ * Handles partial matches like "sepolia" matching "Base Sepolia" or "Arbitrum Sepolia"
327
+ * Returns best match or null
328
+ */
329
+ export function fuzzyMatchNetworkName(networkName: string): ContractConfig | null {
330
+ const normalized = normalizeNetworkName(networkName)
331
+
332
+ // First try exact match
333
+ const exactMatch = getNetworkByName(networkName)
334
+ if (exactMatch) {
335
+ return exactMatch
336
+ }
337
+
338
+ // Try partial matching
339
+ const matches: Array<{ config: ContractConfig; score: number }> = []
340
+
341
+ for (const config of Object.values(CONTRACT_CONFIGS)) {
342
+ const configNormalized = normalizeNetworkName(config.network)
343
+ let score = 0
344
+
345
+ // Check if normalized input is contained in config name or vice versa
346
+ if (configNormalized.includes(normalized) || normalized.includes(configNormalized)) {
347
+ score = Math.max(configNormalized.length, normalized.length) / Math.min(configNormalized.length, normalized.length)
348
+ matches.push({ config, score })
349
+ }
350
+
351
+ // Check aliases
352
+ if (config.nameAliases) {
353
+ for (const alias of config.nameAliases) {
354
+ const aliasNormalized = normalizeNetworkName(alias)
355
+ if (aliasNormalized.includes(normalized) || normalized.includes(aliasNormalized)) {
356
+ score = Math.max(aliasNormalized.length, normalized.length) / Math.min(aliasNormalized.length, normalized.length)
357
+ matches.push({ config, score })
358
+ }
359
+ }
360
+ }
361
+ }
362
+
363
+ // Return best match (highest score)
364
+ if (matches.length > 0) {
365
+ matches.sort((a, b) => b.score - a.score)
366
+ return matches[0].config
367
+ }
368
+
369
+ return null
370
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Core Blockchain Module Exports
3
+ * Platform-agnostic blockchain functionality for ZIP file tokenization
4
+ */
5
+
6
+ // Export all types from consolidated types location
7
+ export * from '../../types';
8
+
9
+ export {
10
+ ZipkitMinter,
11
+ MintingOptions,
12
+ MintingResult,
13
+ DuplicateCheckResult,
14
+ WalletInfo,
15
+ validatePrivateKey
16
+ } from './ZipkitMinter';
17
+
18
+ export {
19
+ ZipkitVerifier,
20
+ VerificationOptions,
21
+ VerificationResult
22
+ } from './ZipkitVerifier';
23
+
24
+ export { TokenMetadata } from '../../types';
25
+
26
+ // Export core wallet functionality
27
+ export {
28
+ CoreWalletManager,
29
+ WalletAnalyzer,
30
+ CommonTokenConfig,
31
+ TokenInfo,
32
+ WalletBasicInfo,
33
+ TokenScanResult,
34
+ NZipTokenDetails
35
+ } from './WalletManager';
36
+
37
+ export {
38
+ NZIP_CONTRACT_ABI,
39
+ NZIP_CONTRACT_ABI_WEB3,
40
+ CONTRACT_CONFIGS,
41
+ CURRENT_DEPLOYMENT,
42
+ DEFAULT_NETWORK,
43
+ getContractConfig,
44
+ getSupportedNetworks,
45
+ isNetworkSupported,
46
+ getChainIdByName,
47
+ getSupportedNetworkNames,
48
+ getNetworkByName,
49
+ normalizeNetworkName,
50
+ ContractConfig
51
+ } from './contracts';
52
+
53
+ // Export OpenTimestamps utilities
54
+ export {
55
+ createTimestamp,
56
+ deserializeOts,
57
+ parseVerifyResult,
58
+ upgradeOTS,
59
+ createOtsMetadataEntry,
60
+ bufferToArrayBuffer,
61
+ getOtsEntry,
62
+ getOtsBuffer,
63
+ getMerkleRootSafe,
64
+ verifyOts,
65
+ verifyOtsZip,
66
+ // Export interfaces
67
+ TimestampResult,
68
+ TimestampInfo,
69
+ DeserializeOtsResult,
70
+ OtsVerifyResult
71
+ } from './ZipkitOTS';
@@ -1,61 +1,27 @@
1
- // Export all types
2
- export * from './types';
1
+ /**
2
+ * Blockchain Module Exports
3
+ * Unified blockchain functionality for ZIP file tokenization
4
+ */
3
5
 
4
- export {
5
- ZipKitMinter,
6
- MintingOptions,
7
- MintingResult,
8
- DuplicateCheckResult,
9
- TokenInfo,
10
- WalletInfo,
11
- validatePrivateKey
12
- } from './ZipKitMinter';
6
+ // Export core blockchain functionality (platform-agnostic)
7
+ export * from './core';
13
8
 
14
- export {
15
- ZipKitVerifier,
16
- VerificationOptions,
17
- VerificationResult
18
- } from './ZipKitVerifier';
19
-
20
- export { TokenMetadata } from './types';
9
+ // Export browser-specific blockchain functionality
10
+ export * from './browser';
21
11
 
12
+ // Export Node.js-specific blockchain functionality (only WalletManagerNode is Node-specific)
22
13
  export {
23
- NZIP_CONTRACT_ABI,
24
- CONTRACT_CONFIGS,
25
- CURRENT_DEPLOYMENT,
26
- DEFAULT_NETWORK,
27
- getContractConfig,
28
- getSupportedNetworks,
29
- isNetworkSupported
30
- } from './contracts';
14
+ WalletManagerNode,
15
+ ZipkitWallet
16
+ } from './node';
31
17
 
32
- // Export wallet management and analysis (combined under ZipKitWallet)
33
- export {
34
- ZipKitWallet,
35
- WalletAnalyzer,
36
- NZipTokenDetails,
37
- WalletBasicInfo,
38
- TokenScanResult,
39
- CommonTokenConfig
40
- } from './ZipKitWallet';
18
+ // Export enhanced verification types from core (now available in core)
19
+ export type {
20
+ EnhancedVerificationResult,
21
+ BatchVerificationResult,
22
+ VerificationJob
23
+ } from './core/ZipkitVerifier';
41
24
 
42
- // Export OpenTimestamps utilities
43
- export {
44
- createTimestamp,
45
- deserializeOts,
46
- parseVerifyResult,
47
- createCertificateOts,
48
- upgradeOTS,
49
- createOtsMetadataEntry,
50
- bufferToArrayBuffer,
51
- getOtsEntry,
52
- getOtsBuffer,
53
- getMerkleRootSafe,
54
- verifyOts,
55
- verifyOtsZip,
56
- // Export interfaces
57
- TimestampResult,
58
- TimestampInfo,
59
- DeserializeOtsResult,
60
- OtsVerifyResult
61
- } from './ZipKitOTS';
25
+ // Export Logger utility for console control (from core module)
26
+ export { Logger, configureLoggerFromEnvironment } from '../core';
27
+ export type { LogLevel, LoggerConfig } from '../core';
@@ -0,0 +1,171 @@
1
+ /**
2
+ * WalletManagerNode - Node.js-specific wallet functionality with file system operations
3
+ * Extends CoreWalletManager with file-based wallet management
4
+ */
5
+
6
+ import * as fs from 'fs';
7
+ import * as path from 'path';
8
+ import { ethers } from 'ethers';
9
+ import { CoreWalletManager } from '../core/WalletManager';
10
+ import { WalletSetupResult, WalletInfo, MintingOptions } from '../../types';
11
+ import { Logger } from '../../core/components/Logger';
12
+
13
+ /**
14
+ * Node.js-specific wallet manager with file system operations
15
+ */
16
+ export class WalletManagerNode extends CoreWalletManager {
17
+ constructor() {
18
+ super();
19
+ }
20
+
21
+ /**
22
+ * Setup wallet with file system support
23
+ */
24
+ async setupWalletWithOptions(options: MintingOptions): Promise<WalletSetupResult> {
25
+ try {
26
+ let privateKey: string;
27
+
28
+ if ((options as any).wallet) {
29
+ const val = (options as any).wallet as string;
30
+ if (fs.existsSync(val)) {
31
+ const loaded = this.loadWalletFromFile(val);
32
+ if (!loaded) throw new Error(`Could not load valid private key from ${val}`);
33
+ privateKey = loaded;
34
+ } else {
35
+ privateKey = val;
36
+ }
37
+ } else {
38
+ const existing = this.findExistingWallets();
39
+ if (existing.length > 0) {
40
+ const selected = existing[0];
41
+ const relativePath = path.relative(process.cwd(), selected);
42
+ Logger.log(`Using existing wallet: ${relativePath}`);
43
+ const loaded = this.loadWalletFromFile(selected);
44
+ if (!loaded) throw new Error(`Could not load valid private key from ${selected}`);
45
+ privateKey = loaded;
46
+ } else {
47
+ Logger.log('No existing wallet found. Creating new wallet...');
48
+ privateKey = await this.createNewWallet();
49
+ }
50
+ }
51
+
52
+ return await super.setupWallet(privateKey, options.network, (options as any).mintToken === true);
53
+ } catch (error) {
54
+ Logger.error('Error setting up wallet:', error);
55
+ return {
56
+ wallet: null,
57
+ provider: null,
58
+ success: false,
59
+ message: `Wallet setup failed: ${error instanceof Error ? error.message : String(error)}`
60
+ };
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Find existing wallet files
66
+ */
67
+ private findExistingWallets(): string[] {
68
+ const walletFiles: string[] = [];
69
+ const currentDir = process.cwd();
70
+ const walletDir = path.join(currentDir, 'wallet');
71
+ const walletFileNames = ['neozip-wallet.json'];
72
+
73
+ for (const fileName of walletFileNames) {
74
+ const filePath = path.join(currentDir, fileName);
75
+ if (fs.existsSync(filePath)) walletFiles.push(filePath);
76
+ }
77
+
78
+ if (fs.existsSync(walletDir)) {
79
+ for (const fileName of walletFileNames) {
80
+ const filePath = path.join(walletDir, fileName);
81
+ if (fs.existsSync(filePath)) walletFiles.push(filePath);
82
+ }
83
+ }
84
+
85
+ return walletFiles;
86
+ }
87
+
88
+ /**
89
+ * Load wallet from file
90
+ *
91
+ * SECURITY WARNING: This method reads private keys from disk.
92
+ * - Only use for development/testing
93
+ * - Wallet files are automatically excluded from git via .gitignore
94
+ * - Wallet files are excluded from NPM packages via .npmignore
95
+ * - Use secure key management (HSMs, KMS) for production
96
+ */
97
+ private loadWalletFromFile(filePath: string): string | null {
98
+ try {
99
+ const content = fs.readFileSync(filePath, 'utf8').trim();
100
+ try {
101
+ const walletData = JSON.parse(content);
102
+ if (walletData.privateKey) {
103
+ Logger.log(`Found wallet file: ${filePath}`);
104
+ Logger.log(`Wallet address: ${walletData.address}`);
105
+ return walletData.privateKey;
106
+ }
107
+ } catch {
108
+ if (content.startsWith('0x') && content.length === 66) {
109
+ Logger.log(`Found private key file: ${filePath}`);
110
+ return content;
111
+ }
112
+ }
113
+ return null;
114
+ } catch (error) {
115
+ Logger.warn(`Could not read wallet file ${filePath}:`, error);
116
+ return null;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Create a new wallet and save to file
122
+ *
123
+ * SECURITY WARNING: This method saves private keys to disk.
124
+ * - Only use for development/testing
125
+ * - Never commit wallet files to version control
126
+ * - Use secure key management for production
127
+ * - Wallet files are automatically excluded via .gitignore and .npmignore
128
+ * - Protect file system permissions on wallet files
129
+ */
130
+ private async createNewWallet(): Promise<string> {
131
+ Logger.log('Creating a new wallet...');
132
+ const newWallet = ethers.Wallet.createRandom();
133
+ const walletInfo: WalletInfo = {
134
+ address: newWallet.address,
135
+ privateKey: newWallet.privateKey,
136
+ mnemonic: newWallet.mnemonic?.phrase || ""
137
+ };
138
+
139
+ const walletDir = path.join(process.cwd(), 'wallet');
140
+ if (!fs.existsSync(walletDir)) fs.mkdirSync(walletDir, { recursive: true });
141
+
142
+ const walletFilePath = path.join(walletDir, 'neozip-wallet.json');
143
+ fs.writeFileSync(walletFilePath, JSON.stringify(walletInfo, null, 2));
144
+
145
+ Logger.log(`New wallet created and saved to ${walletFilePath}`);
146
+ Logger.log(`Wallet address: ${newWallet.address}`);
147
+ Logger.log(`IMPORTANT: Please fund this wallet with testnet ETH to use for minting NFTs!`);
148
+ Logger.log(`SECURITY: Wallet file is automatically excluded from git (.gitignore) and NPM packages (.npmignore)`);
149
+ Logger.log(`SECURITY: Never commit wallet files to version control`);
150
+ Logger.log(`SECURITY: Use secure key management (HSMs, KMS) for production applications`);
151
+
152
+ return newWallet.privateKey;
153
+ }
154
+
155
+ /**
156
+ * Detect NZIP contract from deployment file
157
+ */
158
+ static detectNZipContract(): string | undefined {
159
+ const deploymentPath = path.join(process.cwd(), 'zipfile-nft-deployment.json');
160
+ if (fs.existsSync(deploymentPath)) {
161
+ try {
162
+ const deploymentInfo = JSON.parse(fs.readFileSync(deploymentPath, 'utf8'));
163
+ if (deploymentInfo.address) return deploymentInfo.address;
164
+ } catch {}
165
+ }
166
+ return undefined;
167
+ }
168
+ }
169
+
170
+ // Re-export the old class name for backward compatibility
171
+ export { WalletManagerNode as ZipkitWallet };