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
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NZIP Contract Deployment Configuration
|
|
3
|
-
*
|
|
4
|
-
* Copy this file to deployment.config.js and update with your values
|
|
5
|
-
* The deployment scripts will automatically load this configuration
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
// Wallet Configuration (Required for deployment)
|
|
10
|
-
// Uncomment and set your private key (without 0x prefix)
|
|
11
|
-
// PRIVATE_KEY: '17e6f5c34c693cf989a579a80c0a50aad090030242b5edcc4dfed565a4804022',
|
|
12
|
-
|
|
13
|
-
// Network Configuration
|
|
14
|
-
CHAIN_ID: 84532, // Base Sepolia (testnet)
|
|
15
|
-
// CHAIN_ID: 8453, // Base Mainnet (production)
|
|
16
|
-
|
|
17
|
-
// Previous contract is now DEPRECATED - do not use:
|
|
18
|
-
// DEPRECATED: 0xb78CB3bcC788fca38c731b1E9D70CF60b04CA015
|
|
19
|
-
// EXISTING_CONTRACT: '0xb78CB3bcC788fca38c731b1E9D70CF60b04CA015', // DEPRECATED
|
|
20
|
-
|
|
21
|
-
// Deployment Notes:
|
|
22
|
-
// 1. Set PRIVATE_KEY to deploy new contracts (required - previous contract deprecated)
|
|
23
|
-
// 2. Make sure you have ETH for gas fees on the target network
|
|
24
|
-
// 3. Previous contract is deprecated - you must deploy a new one
|
|
25
|
-
};
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interactive Remix IDE Compilation Guide
|
|
5
|
-
*
|
|
6
|
-
* This script walks you through compiling NZIP contracts using Remix IDE
|
|
7
|
-
* Usage: node remix-compile.js
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
const path = require('path');
|
|
12
|
-
const readline = require('readline');
|
|
13
|
-
|
|
14
|
-
const rl = readline.createInterface({
|
|
15
|
-
input: process.stdin,
|
|
16
|
-
output: process.stdout
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
console.log('🌐 NZIP Contract - Remix IDE Compilation Guide');
|
|
20
|
-
console.log('==============================================\n');
|
|
21
|
-
|
|
22
|
-
const contractPath = path.join(__dirname, 'src/NZIP-NFT.sol');
|
|
23
|
-
|
|
24
|
-
function askQuestion(question) {
|
|
25
|
-
return new Promise((resolve) => {
|
|
26
|
-
rl.question(question, (answer) => {
|
|
27
|
-
resolve(answer);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function main() {
|
|
33
|
-
console.log('This guide will walk you through compiling the NZIP NFT contract using Remix IDE.\n');
|
|
34
|
-
|
|
35
|
-
// Step 1: Introduction
|
|
36
|
-
console.log('📋 Step 1: Preparation');
|
|
37
|
-
console.log('======================');
|
|
38
|
-
console.log('✅ Contract: NZIP NFT v2.0 (Public Contract)');
|
|
39
|
-
console.log('✅ Target: Production deployment');
|
|
40
|
-
console.log('✅ Method: Remix IDE (Online)\n');
|
|
41
|
-
|
|
42
|
-
await askQuestion('Press Enter to continue...');
|
|
43
|
-
console.clear();
|
|
44
|
-
|
|
45
|
-
// Step 2: Open Remix
|
|
46
|
-
console.log('🌐 Step 2: Open Remix IDE');
|
|
47
|
-
console.log('=========================');
|
|
48
|
-
console.log('1. Open your web browser');
|
|
49
|
-
console.log('2. Go to: https://remix.ethereum.org');
|
|
50
|
-
console.log('3. Wait for Remix to load completely\n');
|
|
51
|
-
|
|
52
|
-
console.log('💡 Tip: Use Chrome or Firefox for best compatibility\n');
|
|
53
|
-
|
|
54
|
-
const remixOpen = await askQuestion('Have you opened Remix IDE? (y/n): ');
|
|
55
|
-
if (remixOpen.toLowerCase() !== 'y') {
|
|
56
|
-
console.log('Please open Remix IDE first, then run this script again.');
|
|
57
|
-
rl.close();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
console.clear();
|
|
61
|
-
|
|
62
|
-
// Step 3: Create new file
|
|
63
|
-
console.log('📄 Step 3: Create Contract File');
|
|
64
|
-
console.log('===============================');
|
|
65
|
-
console.log('In Remix IDE:');
|
|
66
|
-
console.log('1. Look for the "File Explorer" tab (📁 icon on the left)');
|
|
67
|
-
console.log('2. Right-click in the file explorer');
|
|
68
|
-
console.log('3. Select "New File"');
|
|
69
|
-
console.log('4. Name it: NZIP-NFT.sol');
|
|
70
|
-
console.log('5. Press Enter to create the file\n');
|
|
71
|
-
|
|
72
|
-
await askQuestion('Have you created the NZIP-NFT.sol file? Press Enter when ready...');
|
|
73
|
-
console.clear();
|
|
74
|
-
|
|
75
|
-
// Step 4: Copy contract source
|
|
76
|
-
console.log('📝 Step 4: Copy Contract Source Code');
|
|
77
|
-
console.log('====================================');
|
|
78
|
-
console.log('I will now display the contract source code.');
|
|
79
|
-
console.log('Copy ALL of it and paste it into your NZIP-NFT.sol file in Remix.\n');
|
|
80
|
-
|
|
81
|
-
await askQuestion('Ready to see the contract source? Press Enter...');
|
|
82
|
-
console.log('\n' + '='.repeat(80));
|
|
83
|
-
console.log('CONTRACT SOURCE CODE - COPY EVERYTHING BELOW:');
|
|
84
|
-
console.log('='.repeat(80) + '\n');
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
const contractContent = fs.readFileSync(contractPath, 'utf8');
|
|
88
|
-
console.log(contractContent);
|
|
89
|
-
} catch (err) {
|
|
90
|
-
console.log('❌ Error reading contract:', err.message);
|
|
91
|
-
rl.close();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
console.log('\n' + '='.repeat(80));
|
|
96
|
-
console.log('END OF CONTRACT SOURCE CODE');
|
|
97
|
-
console.log('='.repeat(80) + '\n');
|
|
98
|
-
|
|
99
|
-
await askQuestion('Have you copied and pasted the contract into Remix? Press Enter when done...');
|
|
100
|
-
console.clear();
|
|
101
|
-
|
|
102
|
-
// Step 5: Install dependencies
|
|
103
|
-
console.log('📦 Step 5: Install OpenZeppelin Dependencies');
|
|
104
|
-
console.log('============================================');
|
|
105
|
-
console.log('In Remix IDE:');
|
|
106
|
-
console.log('1. Click on the "Solidity Compiler" tab (📄 icon on the left)');
|
|
107
|
-
console.log('2. Remix should automatically detect and install OpenZeppelin dependencies');
|
|
108
|
-
console.log('3. Look for "@openzeppelin/contracts" in the file explorer');
|
|
109
|
-
console.log('4. If dependencies don\'t auto-install, Remix will show import errors\n');
|
|
110
|
-
|
|
111
|
-
console.log('💡 If you see import errors:');
|
|
112
|
-
console.log('• Remix will offer to install dependencies automatically');
|
|
113
|
-
console.log('• Click "Install" when prompted\n');
|
|
114
|
-
|
|
115
|
-
await askQuestion('Are the OpenZeppelin dependencies installed? Press Enter when ready...');
|
|
116
|
-
console.clear();
|
|
117
|
-
|
|
118
|
-
// Step 6: Compile
|
|
119
|
-
console.log('⚙️ Step 6: Compile the Contract');
|
|
120
|
-
console.log('=================================');
|
|
121
|
-
console.log('In the Solidity Compiler tab:');
|
|
122
|
-
console.log('1. Set Compiler Version: 0.8.19 or higher');
|
|
123
|
-
console.log('2. Enable "Optimization" (recommended)');
|
|
124
|
-
console.log('3. Click "Compile NZIP-NFT.sol" button');
|
|
125
|
-
console.log('4. Wait for compilation to complete\n');
|
|
126
|
-
|
|
127
|
-
console.log('✅ Success indicators:');
|
|
128
|
-
console.log('• Green checkmark appears');
|
|
129
|
-
console.log('• No error messages');
|
|
130
|
-
console.log('• "ZipFileNFT" contract appears in compiled contracts list\n');
|
|
131
|
-
|
|
132
|
-
const compiled = await askQuestion('Did the contract compile successfully? (y/n): ');
|
|
133
|
-
if (compiled.toLowerCase() !== 'y') {
|
|
134
|
-
console.log('\n❌ Compilation Issues:');
|
|
135
|
-
console.log('• Check for red error messages in Remix');
|
|
136
|
-
console.log('• Ensure Solidity version is 0.8.19+');
|
|
137
|
-
console.log('• Make sure all OpenZeppelin dependencies are installed');
|
|
138
|
-
console.log('• Copy the contract source again if needed\n');
|
|
139
|
-
|
|
140
|
-
await askQuestion('Fix the issues and press Enter to continue...');
|
|
141
|
-
}
|
|
142
|
-
console.clear();
|
|
143
|
-
|
|
144
|
-
// Step 7: Extract compilation artifacts
|
|
145
|
-
console.log('📋 Step 7: Extract Bytecode and ABI');
|
|
146
|
-
console.log('===================================');
|
|
147
|
-
console.log('In Remix IDE:');
|
|
148
|
-
console.log('1. Stay in the "Solidity Compiler" tab');
|
|
149
|
-
console.log('2. Look for "ZipFileNFT" in the compiled contracts section');
|
|
150
|
-
console.log('3. Click on "ZipFileNFT" to expand it');
|
|
151
|
-
console.log('4. You\'ll see several options - we need two:\n');
|
|
152
|
-
|
|
153
|
-
console.log('📄 For BYTECODE:');
|
|
154
|
-
console.log('• Click on "ZipFileNFT" contract name');
|
|
155
|
-
console.log('• Scroll down to find "BYTECODE" section');
|
|
156
|
-
console.log('• Copy the "object" field (starts with 0x...)');
|
|
157
|
-
console.log('• This is your CONTRACT_BYTECODE\n');
|
|
158
|
-
|
|
159
|
-
console.log('📄 For ABI:');
|
|
160
|
-
console.log('• In the same expanded view');
|
|
161
|
-
console.log('• Look for "ABI" section');
|
|
162
|
-
console.log('• Copy the entire ABI array');
|
|
163
|
-
console.log('• This is your CONTRACT_ABI\n');
|
|
164
|
-
|
|
165
|
-
await askQuestion('Have you copied both BYTECODE and ABI? Press Enter when ready...');
|
|
166
|
-
console.clear();
|
|
167
|
-
|
|
168
|
-
// Step 8: Update deployment script
|
|
169
|
-
console.log('🔧 Step 8: Update Deployment Script');
|
|
170
|
-
console.log('===================================');
|
|
171
|
-
console.log('Now you need to update the deployment script with your compiled data:\n');
|
|
172
|
-
|
|
173
|
-
console.log('📁 File to edit: contracts/deploy/deploy-public-contract.js\n');
|
|
174
|
-
|
|
175
|
-
console.log('🔍 Find these lines and replace:');
|
|
176
|
-
console.log('1. Look for: const CONTRACT_BYTECODE = "0x608060..."; // PLACEHOLDER');
|
|
177
|
-
console.log(' Replace with your copied bytecode\n');
|
|
178
|
-
|
|
179
|
-
console.log('2. Look for: const CONTRACT_ABI = [ // PLACEHOLDER ABI');
|
|
180
|
-
console.log(' Replace with your copied ABI array\n');
|
|
181
|
-
|
|
182
|
-
console.log('💡 Tips:');
|
|
183
|
-
console.log('• Bytecode should be one long string starting with 0x');
|
|
184
|
-
console.log('• ABI should be an array of function definitions');
|
|
185
|
-
console.log('• Keep the semicolons and proper formatting\n');
|
|
186
|
-
|
|
187
|
-
await askQuestion('Have you updated the deployment script? Press Enter when ready...');
|
|
188
|
-
console.clear();
|
|
189
|
-
|
|
190
|
-
// Step 9: Deploy
|
|
191
|
-
console.log('🚀 Step 9: Deploy Your Contract');
|
|
192
|
-
console.log('===============================');
|
|
193
|
-
console.log('Now you\'re ready to deploy!\n');
|
|
194
|
-
|
|
195
|
-
console.log('📋 Pre-deployment checklist:');
|
|
196
|
-
console.log('✅ Contract compiled successfully');
|
|
197
|
-
console.log('✅ Bytecode copied to deployment script');
|
|
198
|
-
console.log('✅ ABI copied to deployment script');
|
|
199
|
-
console.log('✅ Wallet has ETH for gas fees\n');
|
|
200
|
-
|
|
201
|
-
console.log('🎯 Deploy commands:');
|
|
202
|
-
console.log('# Setup deployment configuration (if not done)');
|
|
203
|
-
console.log('npm run setup-deployment\n');
|
|
204
|
-
|
|
205
|
-
console.log('# Deploy to Base Sepolia (testnet)');
|
|
206
|
-
console.log('npm run deploy:public\n');
|
|
207
|
-
|
|
208
|
-
console.log('# Deploy to Base Mainnet (production)');
|
|
209
|
-
console.log('CHAIN_ID=8453 npm run deploy:public\n');
|
|
210
|
-
|
|
211
|
-
console.log('🎉 Congratulations!');
|
|
212
|
-
console.log('You\'ve successfully compiled your NZIP NFT contract using Remix IDE.');
|
|
213
|
-
console.log('Your contract is now ready for deployment to the blockchain!\n');
|
|
214
|
-
|
|
215
|
-
console.log('📚 Need help with deployment?');
|
|
216
|
-
console.log('• Run: npm run setup-deployment');
|
|
217
|
-
console.log('• Check: contracts/docs/DEPLOYMENT_GUIDE.md');
|
|
218
|
-
|
|
219
|
-
rl.close();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
main().catch(console.error);
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Deployment Setup Helper for NZIP Contracts
|
|
5
|
-
*
|
|
6
|
-
* This script helps you set up deployment configuration
|
|
7
|
-
* Usage: node setup-deployment.js
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
const path = require('path');
|
|
12
|
-
|
|
13
|
-
console.log('🚀 NZIP Contract Deployment Setup');
|
|
14
|
-
console.log('==================================\n');
|
|
15
|
-
|
|
16
|
-
// Check current status
|
|
17
|
-
const configPath = path.join(__dirname, 'deployment.config.js');
|
|
18
|
-
const examplePath = path.join(__dirname, 'deployment.config.example.js');
|
|
19
|
-
|
|
20
|
-
if (fs.existsSync(configPath)) {
|
|
21
|
-
console.log('✅ deployment.config.js already exists');
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const config = require(configPath);
|
|
25
|
-
console.log(`📋 Chain ID: ${config.CHAIN_ID || 'Not set'}`);
|
|
26
|
-
console.log(`📋 Private Key: ${config.PRIVATE_KEY ? '✅ Set' : '❌ Not set'}`);
|
|
27
|
-
console.log(`📋 Existing Contract: ${config.EXISTING_CONTRACT || 'None'}`);
|
|
28
|
-
} catch (err) {
|
|
29
|
-
console.log('⚠️ Config file exists but has errors:', err.message);
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
console.log('📁 Creating deployment.config.js from template...');
|
|
33
|
-
|
|
34
|
-
if (fs.existsSync(examplePath)) {
|
|
35
|
-
fs.copyFileSync(examplePath, configPath);
|
|
36
|
-
console.log('✅ Created deployment.config.js');
|
|
37
|
-
console.log('📝 Edit this file to add your PRIVATE_KEY');
|
|
38
|
-
} else {
|
|
39
|
-
console.log('❌ deployment.config.example.js not found');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log('\n🎯 Next Steps:');
|
|
44
|
-
console.log('1. Edit deployment.config.js and uncomment PRIVATE_KEY');
|
|
45
|
-
console.log('2. Add your wallet private key (without 0x prefix)');
|
|
46
|
-
console.log('3. Make sure you have ETH for gas fees');
|
|
47
|
-
console.log('4. Run: npm run deploy:public');
|
|
48
|
-
|
|
49
|
-
console.log('\n⚠️ Important Notice:');
|
|
50
|
-
console.log('Previous contract is now DEPRECATED: 0xb78CB3bcC788fca38c731b1E9D70CF60b04CA015');
|
|
51
|
-
console.log('You must deploy a new contract for production use!');
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.19;
|
|
3
|
-
|
|
4
|
-
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
|
5
|
-
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
|
|
6
|
-
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @title ZipFileNFT
|
|
10
|
-
* @dev Enhanced NFT contract for tokenizing ZIP files with timestamp support
|
|
11
|
-
* Allows multiple tokens for the same content by using timestamp as a differentiator
|
|
12
|
-
*/
|
|
13
|
-
contract ZipFileNFT is ERC721, ERC721URIStorage, Ownable {
|
|
14
|
-
|
|
15
|
-
// Counter for token IDs
|
|
16
|
-
uint256 private _tokenIdCounter;
|
|
17
|
-
|
|
18
|
-
// Struct to store ZIP file information
|
|
19
|
-
struct ZipFileInfo {
|
|
20
|
-
// File identification
|
|
21
|
-
string fileName; // Original ZIP file name
|
|
22
|
-
string merkleRootHash; // Merkle root hash of the ZIP contents
|
|
23
|
-
string ipfsHash; // IPFS hash where the ZIP file is stored
|
|
24
|
-
address creator; // Address that created/minted this token
|
|
25
|
-
|
|
26
|
-
// Timestamps (grouped together)
|
|
27
|
-
uint256 creationTimestamp; // Timestamp when the ZIP was created (user-provided)
|
|
28
|
-
uint256 tokenizationTime; // Timestamp when the NFT was minted (block.timestamp)
|
|
29
|
-
|
|
30
|
-
// Blockchain metadata (grouped with timestamps)
|
|
31
|
-
uint256 blockNumber; // Block number when the token was minted
|
|
32
|
-
bytes32 blockHash; // Block hash when the token was minted
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Mapping from token ID to ZIP file information
|
|
36
|
-
mapping(uint256 => ZipFileInfo) public zipFileInfo;
|
|
37
|
-
|
|
38
|
-
// Mapping from composite key (merkleRoot + timestamp) to token ID
|
|
39
|
-
// This prevents duplicate tokens with same content AND same timestamp
|
|
40
|
-
mapping(bytes32 => uint256) public compositeKeyToTokenId;
|
|
41
|
-
|
|
42
|
-
// Events
|
|
43
|
-
event ZipFileTokenized(
|
|
44
|
-
uint256 indexed tokenId,
|
|
45
|
-
address indexed creator,
|
|
46
|
-
string fileName,
|
|
47
|
-
string merkleRootHash,
|
|
48
|
-
uint256 creationTimestamp,
|
|
49
|
-
string ipfsHash,
|
|
50
|
-
uint256 tokenizationTime,
|
|
51
|
-
uint256 blockNumber,
|
|
52
|
-
bytes32 blockHash
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
constructor() ERC721("NeoZip File NFT", "NZIP") Ownable(msg.sender) {}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @dev Generate composite key from merkle root and timestamp
|
|
59
|
-
* @param merkleRootHash The merkle root hash
|
|
60
|
-
* @param creationTimestamp The creation timestamp
|
|
61
|
-
* @return The composite key
|
|
62
|
-
*/
|
|
63
|
-
function _generateCompositeKey(
|
|
64
|
-
string memory merkleRootHash,
|
|
65
|
-
uint256 creationTimestamp
|
|
66
|
-
) internal pure returns (bytes32) {
|
|
67
|
-
return keccak256(abi.encodePacked(merkleRootHash, creationTimestamp));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @dev Mint a new NFT representing a ZIP file with timestamp
|
|
72
|
-
* @param to Address to mint the token to
|
|
73
|
-
* @param fileName Original name of the ZIP file
|
|
74
|
-
* @param merkleRootHash Merkle root hash of the ZIP contents
|
|
75
|
-
* @param creationTimestamp Timestamp when the ZIP was created
|
|
76
|
-
* @param ipfsHash IPFS hash where the ZIP file is stored
|
|
77
|
-
* @param tokenURI Metadata URI for the token
|
|
78
|
-
* @return tokenId The ID of the newly minted token
|
|
79
|
-
*/
|
|
80
|
-
function mintZipFileToken(
|
|
81
|
-
address to,
|
|
82
|
-
string memory fileName,
|
|
83
|
-
string memory merkleRootHash,
|
|
84
|
-
uint256 creationTimestamp,
|
|
85
|
-
string memory ipfsHash,
|
|
86
|
-
string memory tokenURI
|
|
87
|
-
) public returns (uint256) {
|
|
88
|
-
require(bytes(merkleRootHash).length > 0, "Merkle root hash cannot be empty");
|
|
89
|
-
require(bytes(fileName).length > 0, "File name cannot be empty");
|
|
90
|
-
require(creationTimestamp > 0, "Creation timestamp must be greater than 0");
|
|
91
|
-
|
|
92
|
-
// Generate composite key
|
|
93
|
-
bytes32 compositeKey = _generateCompositeKey(merkleRootHash, creationTimestamp);
|
|
94
|
-
|
|
95
|
-
// Check that this specific combination hasn't been tokenized before
|
|
96
|
-
require(compositeKeyToTokenId[compositeKey] == 0, "ZIP file with this timestamp already tokenized");
|
|
97
|
-
|
|
98
|
-
uint256 tokenId = _tokenIdCounter;
|
|
99
|
-
_tokenIdCounter++;
|
|
100
|
-
|
|
101
|
-
// Mint the token
|
|
102
|
-
_safeMint(to, tokenId);
|
|
103
|
-
_setTokenURI(tokenId, tokenURI);
|
|
104
|
-
|
|
105
|
-
// Store ZIP file information
|
|
106
|
-
zipFileInfo[tokenId] = ZipFileInfo({
|
|
107
|
-
fileName: fileName,
|
|
108
|
-
merkleRootHash: merkleRootHash,
|
|
109
|
-
ipfsHash: ipfsHash,
|
|
110
|
-
creator: msg.sender,
|
|
111
|
-
creationTimestamp: creationTimestamp,
|
|
112
|
-
tokenizationTime: block.timestamp,
|
|
113
|
-
blockNumber: block.number,
|
|
114
|
-
blockHash: blockhash(block.number)
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// Map composite key to token ID for duplicate prevention
|
|
118
|
-
compositeKeyToTokenId[compositeKey] = tokenId;
|
|
119
|
-
|
|
120
|
-
emit ZipFileTokenized(tokenId, to, fileName, merkleRootHash, creationTimestamp, ipfsHash, block.timestamp, block.number, blockhash(block.number));
|
|
121
|
-
|
|
122
|
-
return tokenId;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @dev Public minting function with timestamp
|
|
127
|
-
* @param fileName Name of the ZIP file
|
|
128
|
-
* @param merkleRootHash Merkle root hash of the ZIP contents
|
|
129
|
-
* @param creationTimestamp Timestamp when the ZIP was created
|
|
130
|
-
* @param ipfsHash IPFS hash where the ZIP file is stored
|
|
131
|
-
* @param tokenURI Metadata URI for the token
|
|
132
|
-
* @return tokenId The ID of the newly minted token
|
|
133
|
-
*/
|
|
134
|
-
function publicMintZipFile(
|
|
135
|
-
string memory fileName,
|
|
136
|
-
string memory merkleRootHash,
|
|
137
|
-
uint256 creationTimestamp,
|
|
138
|
-
string memory ipfsHash,
|
|
139
|
-
string memory tokenURI
|
|
140
|
-
) public returns (uint256) {
|
|
141
|
-
return mintZipFileToken(
|
|
142
|
-
msg.sender,
|
|
143
|
-
fileName,
|
|
144
|
-
merkleRootHash,
|
|
145
|
-
creationTimestamp,
|
|
146
|
-
ipfsHash,
|
|
147
|
-
tokenURI
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* @dev Verify a ZIP file against its token
|
|
153
|
-
* @param tokenId Token ID to verify
|
|
154
|
-
* @param providedMerkleRoot Merkle root to verify against
|
|
155
|
-
* @return isValid Whether the provided hash matches the stored one
|
|
156
|
-
*/
|
|
157
|
-
function verifyZipFile(
|
|
158
|
-
uint256 tokenId,
|
|
159
|
-
string memory providedMerkleRoot
|
|
160
|
-
) public view returns (bool isValid) {
|
|
161
|
-
require(_ownerOf(tokenId) != address(0), "Token does not exist");
|
|
162
|
-
|
|
163
|
-
ZipFileInfo memory info = zipFileInfo[tokenId];
|
|
164
|
-
|
|
165
|
-
isValid = keccak256(abi.encodePacked(info.merkleRootHash)) == keccak256(abi.encodePacked(providedMerkleRoot));
|
|
166
|
-
|
|
167
|
-
return isValid;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @dev Get information about a ZIP file token
|
|
172
|
-
* @param tokenId Token ID to query
|
|
173
|
-
* @return info Complete ZipFileInfo struct
|
|
174
|
-
*/
|
|
175
|
-
function getZipFileInfo(uint256 tokenId) public view returns (ZipFileInfo memory info) {
|
|
176
|
-
require(_ownerOf(tokenId) != address(0), "Token does not exist");
|
|
177
|
-
return zipFileInfo[tokenId];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @dev Check if a ZIP file with specific timestamp has been tokenized
|
|
182
|
-
* @param merkleRootHash Merkle root to check
|
|
183
|
-
* @param creationTimestamp Creation timestamp to check
|
|
184
|
-
* @return exists Whether a token exists for this combination
|
|
185
|
-
* @return tokenId The token ID if it exists (0 if not)
|
|
186
|
-
*/
|
|
187
|
-
function isZipFileTokenized(
|
|
188
|
-
string memory merkleRootHash,
|
|
189
|
-
uint256 creationTimestamp
|
|
190
|
-
) public view returns (bool exists, uint256 tokenId) {
|
|
191
|
-
bytes32 compositeKey = _generateCompositeKey(merkleRootHash, creationTimestamp);
|
|
192
|
-
tokenId = compositeKeyToTokenId[compositeKey];
|
|
193
|
-
exists = (tokenId != 0);
|
|
194
|
-
return (exists, tokenId);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @dev Get all tokens for a specific merkle root (regardless of timestamp)
|
|
199
|
-
* @param merkleRootHash Merkle root to search for
|
|
200
|
-
* @return tokenIds Array of token IDs that match this merkle root
|
|
201
|
-
*/
|
|
202
|
-
function getTokensByMerkleRoot(string memory merkleRootHash) public view returns (uint256[] memory tokenIds) {
|
|
203
|
-
uint256 totalSupply = _tokenIdCounter;
|
|
204
|
-
uint256[] memory tempTokenIds = new uint256[](totalSupply);
|
|
205
|
-
uint256 count = 0;
|
|
206
|
-
|
|
207
|
-
for (uint256 i = 0; i < totalSupply; i++) {
|
|
208
|
-
if (_ownerOf(i) != address(0)) {
|
|
209
|
-
ZipFileInfo memory info = zipFileInfo[i];
|
|
210
|
-
if (keccak256(abi.encodePacked(info.merkleRootHash)) == keccak256(abi.encodePacked(merkleRootHash))) {
|
|
211
|
-
tempTokenIds[count] = i;
|
|
212
|
-
count++;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Create properly sized array
|
|
218
|
-
tokenIds = new uint256[](count);
|
|
219
|
-
for (uint256 i = 0; i < count; i++) {
|
|
220
|
-
tokenIds[i] = tempTokenIds[i];
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return tokenIds;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* @dev Get the current token ID counter
|
|
228
|
-
* @return The next token ID that will be minted
|
|
229
|
-
*/
|
|
230
|
-
function getCurrentTokenId() public view returns (uint256) {
|
|
231
|
-
return _tokenIdCounter;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* @dev Get total number of tokens minted
|
|
236
|
-
* @return Total supply of tokens
|
|
237
|
-
*/
|
|
238
|
-
function totalSupply() public view returns (uint256) {
|
|
239
|
-
return _tokenIdCounter;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* @dev Update IPFS hash for a token (only by token owner)
|
|
244
|
-
* @param tokenId Token ID to update
|
|
245
|
-
* @param ipfsHash New IPFS hash
|
|
246
|
-
*/
|
|
247
|
-
function updateIpfsHash(uint256 tokenId, string memory ipfsHash) public {
|
|
248
|
-
require(ownerOf(tokenId) == msg.sender, "Only token owner can update IPFS hash");
|
|
249
|
-
zipFileInfo[tokenId].ipfsHash = ipfsHash;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Override required functions
|
|
253
|
-
function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) {
|
|
254
|
-
return super.tokenURI(tokenId);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721URIStorage) returns (bool) {
|
|
258
|
-
return super.supportsInterface(interfaceId);
|
|
259
|
-
}
|
|
260
|
-
}
|