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.
- package/README.md +400 -0
- package/contracts/Lock.sol +34 -0
- package/contracts/bytecode.txt +1 -0
- package/contracts/compile-contract.js +168 -0
- package/contracts/deploy/deploy-both-contracts.js +286 -0
- package/contracts/deploy/deploy-enhanced-contract.js +197 -0
- package/contracts/deploy/deploy-private-contract.js +190 -0
- package/contracts/deploy/deploy-public-clean.js +1063 -0
- package/contracts/deploy/deploy-public-contract.js +1107 -0
- package/contracts/deployment.config.example.js +25 -0
- package/contracts/remix-compile.js +222 -0
- package/contracts/setup-deployment.js +51 -0
- package/contracts/src/NZIP-NFT-Private.sol +350 -0
- package/contracts/src/NZIP-NFT.sol +265 -0
- package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +260 -0
- package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +289 -0
- package/dist/browser/CertificateGeneratorBrowser.d.ts +75 -0
- package/dist/browser/CertificateGeneratorBrowser.js +433 -0
- package/dist/browser/TokenVerifierBrowser.d.ts +76 -0
- package/dist/browser/TokenVerifierBrowser.js +299 -0
- package/dist/browser/ZipKitBrowser.d.ts +18 -0
- package/dist/browser/ZipKitBrowser.js +250 -0
- package/dist/browser/ZipKitStampBrowser.d.ts +2 -0
- package/dist/browser/ZipKitStampBrowser.js +12 -0
- package/dist/browser-index.d.ts +21 -0
- package/dist/browser-index.js +58 -0
- package/dist/browser.d.ts +21 -0
- package/dist/browser.js +58 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +76 -0
- package/dist/server/blockchain/CertificateToken.d.ts +48 -0
- package/dist/server/blockchain/CertificateToken.js +386 -0
- package/dist/server/blockchain/NFTMinter.d.ts +41 -0
- package/dist/server/blockchain/NFTMinter.js +323 -0
- package/dist/server/blockchain/TokenQuerier.d.ts +31 -0
- package/dist/server/blockchain/TokenQuerier.js +259 -0
- package/dist/server/blockchain/TokenVerifier.d.ts +20 -0
- package/dist/server/blockchain/TokenVerifier.js +395 -0
- package/dist/server/blockchain/WalletAnalyzer.d.ts +81 -0
- package/dist/server/blockchain/WalletAnalyzer.js +356 -0
- package/dist/server/blockchain/WalletFormatter.d.ts +39 -0
- package/dist/server/blockchain/WalletFormatter.js +196 -0
- package/dist/server/blockchain/WalletManager.d.ts +46 -0
- package/dist/server/blockchain/WalletManager.js +294 -0
- package/dist/server/blockchain/ZipMetadata.d.ts +27 -0
- package/dist/server/blockchain/ZipMetadata.js +131 -0
- package/dist/server/blockchain/ZipTokenProcessor.d.ts +44 -0
- package/dist/server/blockchain/ZipTokenProcessor.js +204 -0
- package/dist/server/blockchain/constants.d.ts +102 -0
- package/dist/server/blockchain/constants.js +968 -0
- package/dist/server/blockchain/index.d.ts +9 -0
- package/dist/server/blockchain/index.js +44 -0
- package/dist/server/blockchain/test-certificate.d.ts +8 -0
- package/dist/server/blockchain/test-certificate.js +100 -0
- package/dist/server/blockchain/types.d.ts +69 -0
- package/dist/server/blockchain/types.js +51 -0
- package/dist/server/platform/server/ZipKitServer.d.ts +105 -0
- package/dist/server/platform/server/ZipKitServer.js +437 -0
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +91 -0
- package/dist/server/platform/servercomponents/ZipKitOTS.js +271 -0
- package/dist/shared/ZipEntry.d.ts +131 -0
- package/dist/shared/ZipEntry.js +686 -0
- package/dist/shared/ZipKit.d.ts +249 -0
- package/dist/shared/ZipKit.js +789 -0
- package/dist/shared/components/CertificateOTS.d.ts +15 -0
- package/dist/shared/components/CertificateOTS.js +116 -0
- package/dist/shared/components/FileSys.d.ts +2 -0
- package/dist/shared/components/FileSys.js +113 -0
- package/dist/shared/components/HashAccumulator.d.ts +55 -0
- package/dist/shared/components/HashAccumulator.js +100 -0
- package/dist/shared/components/Support.d.ts +63 -0
- package/dist/shared/components/Support.js +70 -0
- package/dist/shared/components/Util.d.ts +21 -0
- package/dist/shared/components/Util.js +115 -0
- package/dist/shared/components/ZipCrypto.d.ts +3 -0
- package/dist/shared/components/ZipCrypto.js +78 -0
- package/dist/shared/components/merkleTree.d.ts +66 -0
- package/dist/shared/components/merkleTree.js +136 -0
- package/dist/shared/constants/Errors.d.ts +53 -0
- package/dist/shared/constants/Errors.js +69 -0
- package/dist/shared/constants/Headers.d.ts +167 -0
- package/dist/shared/constants/Headers.js +191 -0
- package/dist/shared/types/index.d.ts +21 -0
- package/dist/shared/types/index.js +3 -0
- package/dist/shared/types.d.ts +33 -0
- package/dist/shared/types.js +8 -0
- package/dist/shared/version.d.ts +4 -0
- package/dist/shared/version.js +7 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.js +3 -0
- package/examples/unzip-token.ts +488 -0
- package/examples/zip-token.ts +604 -0
- package/package.json +117 -0
- package/src/browser/CertificateGeneratorBrowser.ts +498 -0
- package/src/browser/TokenVerifierBrowser.ts +344 -0
- package/src/browser/ZipKitBrowser.ts +242 -0
- package/src/browser/ZipKitStampBrowser.ts +9 -0
- package/src/browser-index.ts +36 -0
- package/src/index.ts +48 -0
- package/src/server/blockchain/CertificateToken.ts +444 -0
- package/src/server/blockchain/NFTMinter.ts +357 -0
- package/src/server/blockchain/TokenQuerier.ts +287 -0
- package/src/server/blockchain/TokenVerifier.ts +453 -0
- package/src/server/blockchain/WalletAnalyzer.ts +397 -0
- package/src/server/blockchain/WalletFormatter.ts +206 -0
- package/src/server/blockchain/WalletManager.ts +294 -0
- package/src/server/blockchain/ZipMetadata.ts +117 -0
- package/src/server/blockchain/ZipTokenProcessor.ts +234 -0
- package/src/server/blockchain/constants.ts +969 -0
- package/src/server/blockchain/index.ts +42 -0
- package/src/server/blockchain/test-certificate.ts +137 -0
- package/src/server/blockchain/types.ts +134 -0
- package/src/server/platform/server/ZipKitServer.ts +459 -0
- package/src/server/platform/servercomponents/ZipKitOTS.ts +313 -0
- package/src/server/platform/servercomponents/opentimestamps.d.ts +23 -0
- package/src/shared/ZipEntry.ts +767 -0
- package/src/shared/ZipKit.ts +899 -0
- package/src/shared/components/CertificateOTS.ts +132 -0
- package/src/shared/components/FileSys.ts +87 -0
- package/src/shared/components/HashAccumulator.ts +113 -0
- package/src/shared/components/Support.ts +77 -0
- package/src/shared/components/Util.ts +113 -0
- package/src/shared/components/ZipCrypto.ts +91 -0
- package/src/shared/components/merkleTree.ts +162 -0
- package/src/shared/constants/Errors.ts +82 -0
- package/src/shared/constants/Headers.ts +203 -0
- package/src/shared/types/index.ts +25 -0
- package/src/shared/types/modules.d.ts +22 -0
- package/src/shared/types/opentimestamps.d.ts +23 -0
- package/src/shared/types.d.ts +8 -0
- package/src/shared/types.ts +43 -0
- package/src/shared/version.ts +4 -0
- package/src/types/index.ts +25 -0
- package/src/types/modules.d.ts +22 -0
- package/src/types/opentimestamps.d.ts +23 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ZipTokenProcessor = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const WalletManager_1 = require("./WalletManager");
|
|
40
|
+
const NFTMinter_1 = require("./NFTMinter");
|
|
41
|
+
const ZipMetadata_1 = require("./ZipMetadata");
|
|
42
|
+
class ZipTokenProcessor {
|
|
43
|
+
constructor(zipFile, merkleRoot, options) {
|
|
44
|
+
this.nftMinter = null;
|
|
45
|
+
this.walletManager = new WalletManager_1.WalletManager();
|
|
46
|
+
this.zipTokenData = {
|
|
47
|
+
zipFile,
|
|
48
|
+
merkleRoot,
|
|
49
|
+
fileName: path.basename(zipFile),
|
|
50
|
+
timestamp: new Date().toISOString()
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Processes the complete ZIP token workflow
|
|
55
|
+
*/
|
|
56
|
+
async processZipToken(options) {
|
|
57
|
+
const state = {};
|
|
58
|
+
try {
|
|
59
|
+
// Setup wallet if needed
|
|
60
|
+
if (options.wallet || options.mintToken) {
|
|
61
|
+
console.log('Setting up wallet...');
|
|
62
|
+
const walletResult = await this.walletManager.setupWallet(options);
|
|
63
|
+
state.walletSetup = walletResult;
|
|
64
|
+
if (!walletResult.success) {
|
|
65
|
+
state.error = `Wallet setup failed: ${walletResult.message}`;
|
|
66
|
+
return state;
|
|
67
|
+
}
|
|
68
|
+
// Initialize NFT minter with wallet and provider
|
|
69
|
+
this.nftMinter = new NFTMinter_1.NFTMinter(walletResult.wallet, walletResult.provider);
|
|
70
|
+
}
|
|
71
|
+
// Mint token if requested
|
|
72
|
+
if (options.mintToken && this.nftMinter) {
|
|
73
|
+
console.log('Minting NFT token...');
|
|
74
|
+
const mintingResult = await this.nftMinter.mintZipFileNFT(this.zipTokenData);
|
|
75
|
+
state.mintingResult = mintingResult;
|
|
76
|
+
if (!mintingResult.success) {
|
|
77
|
+
state.error = `Minting failed: ${mintingResult.message}`;
|
|
78
|
+
return state;
|
|
79
|
+
}
|
|
80
|
+
// Validate that we have complete token data for successful minting
|
|
81
|
+
if (!mintingResult.tokenId || !mintingResult.txHash) {
|
|
82
|
+
state.error = `Minting incomplete: Missing token ID or transaction hash`;
|
|
83
|
+
return state;
|
|
84
|
+
}
|
|
85
|
+
console.log('Preparing token metadata...');
|
|
86
|
+
// Check if this was an existing token (message contains "existing token")
|
|
87
|
+
if (mintingResult.message.includes('existing token')) {
|
|
88
|
+
console.log('Using existing token from your wallet...');
|
|
89
|
+
// Create token info from existing token data
|
|
90
|
+
const tokenInfo = await this.createTokenInfoFromExisting(mintingResult, options);
|
|
91
|
+
if (!tokenInfo) {
|
|
92
|
+
state.error = `Failed to create token metadata from existing token`;
|
|
93
|
+
return state;
|
|
94
|
+
}
|
|
95
|
+
state.tokenInfo = tokenInfo;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// Create token info from new minting
|
|
99
|
+
const tokenInfo = this.createTokenInfo(mintingResult, options);
|
|
100
|
+
if (!tokenInfo) {
|
|
101
|
+
state.error = `Failed to create token metadata`;
|
|
102
|
+
return state;
|
|
103
|
+
}
|
|
104
|
+
state.tokenInfo = tokenInfo;
|
|
105
|
+
}
|
|
106
|
+
console.log('\n' + ZipMetadata_1.ZipMetadata.createTokenSummary(state.tokenInfo));
|
|
107
|
+
}
|
|
108
|
+
return state;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
112
|
+
console.error('Error in ZIP token processing:', error);
|
|
113
|
+
state.error = `Processing error: ${errorMessage}`;
|
|
114
|
+
return state;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Gets the ZIP token data
|
|
119
|
+
*/
|
|
120
|
+
getZipTokenData() {
|
|
121
|
+
return this.zipTokenData;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Gets the wallet manager instance
|
|
125
|
+
*/
|
|
126
|
+
getWalletManager() {
|
|
127
|
+
return this.walletManager;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Gets the NFT minter instance
|
|
131
|
+
*/
|
|
132
|
+
getNFTMinter() {
|
|
133
|
+
return this.nftMinter;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Loads contract deployment information
|
|
137
|
+
*/
|
|
138
|
+
loadContractInfo() {
|
|
139
|
+
try {
|
|
140
|
+
const contractInfoPath = path.join(process.cwd(), 'zipfile-nft-deployment.json');
|
|
141
|
+
if (!fs.existsSync(contractInfoPath)) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const contractInfo = JSON.parse(fs.readFileSync(contractInfoPath, 'utf8'));
|
|
145
|
+
return contractInfo;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.error('Error loading contract info:', error);
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Creates token information object
|
|
154
|
+
*/
|
|
155
|
+
createTokenInfo(mintingResult, options) {
|
|
156
|
+
if (!mintingResult.success || !mintingResult.tokenId || !mintingResult.txHash) {
|
|
157
|
+
console.error('Cannot create token metadata: minting was not successful or missing token data');
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
// Load contract information
|
|
162
|
+
const contractInfo = this.loadContractInfo();
|
|
163
|
+
if (!contractInfo) {
|
|
164
|
+
console.error('Cannot load contract information for token metadata');
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
// Create token information with REAL data only
|
|
168
|
+
const tokenInfo = ZipMetadata_1.ZipMetadata.createTokenInfo(mintingResult.tokenId, mintingResult.txHash, contractInfo, this.zipTokenData.merkleRoot, this.zipTokenData.fileName, options.network, undefined, // blockNumber - will be filled later if needed
|
|
169
|
+
undefined, // ipfsHash - not implemented yet
|
|
170
|
+
Math.floor(Date.now() / 1000) // creationTimestamp
|
|
171
|
+
);
|
|
172
|
+
return tokenInfo;
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.error('Error creating token metadata:', error);
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Creates token information object from existing token
|
|
181
|
+
*/
|
|
182
|
+
async createTokenInfoFromExisting(mintingResult, options) {
|
|
183
|
+
if (!mintingResult.success || !mintingResult.tokenId || !mintingResult.txHash) {
|
|
184
|
+
console.error('Cannot create token metadata: minting was not successful or missing token data');
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
// Load contract information
|
|
189
|
+
const contractInfo = this.loadContractInfo();
|
|
190
|
+
if (!contractInfo) {
|
|
191
|
+
console.error('Cannot load contract information for token metadata');
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
// Create token information with REAL data only
|
|
195
|
+
const tokenInfo = ZipMetadata_1.ZipMetadata.createTokenInfo(mintingResult.tokenId, mintingResult.txHash, contractInfo, this.zipTokenData.merkleRoot, this.zipTokenData.fileName, options.network);
|
|
196
|
+
return tokenInfo;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
console.error('Error creating token metadata:', error);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.ZipTokenProcessor = ZipTokenProcessor;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract addresses for different networks
|
|
3
|
+
*/
|
|
4
|
+
export declare const CONTRACT_ADDRESSES: {
|
|
5
|
+
NZIP_NFT: Record<number, string>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Deprecated contract addresses (no longer in use)
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEPRECATED_CONTRACTS: {
|
|
11
|
+
NZIP_NFT_V1: Record<number, string>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Complete NZIP NFT Contract v2.0 ABI
|
|
15
|
+
* This is the full ABI from Remix compilation used by the current deployment
|
|
16
|
+
*/
|
|
17
|
+
export declare const NZIP_CONTRACT_ABI: ({
|
|
18
|
+
inputs: never[];
|
|
19
|
+
stateMutability: string;
|
|
20
|
+
type: string;
|
|
21
|
+
name?: undefined;
|
|
22
|
+
anonymous?: undefined;
|
|
23
|
+
outputs?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
inputs: {
|
|
26
|
+
internalType: string;
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
}[];
|
|
30
|
+
name: string;
|
|
31
|
+
type: string;
|
|
32
|
+
stateMutability?: undefined;
|
|
33
|
+
anonymous?: undefined;
|
|
34
|
+
outputs?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
anonymous: boolean;
|
|
37
|
+
inputs: {
|
|
38
|
+
indexed: boolean;
|
|
39
|
+
internalType: string;
|
|
40
|
+
name: string;
|
|
41
|
+
type: string;
|
|
42
|
+
}[];
|
|
43
|
+
name: string;
|
|
44
|
+
type: string;
|
|
45
|
+
stateMutability?: undefined;
|
|
46
|
+
outputs?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
inputs: {
|
|
49
|
+
internalType: string;
|
|
50
|
+
name: string;
|
|
51
|
+
type: string;
|
|
52
|
+
}[];
|
|
53
|
+
name: string;
|
|
54
|
+
outputs: {
|
|
55
|
+
internalType: string;
|
|
56
|
+
name: string;
|
|
57
|
+
type: string;
|
|
58
|
+
}[];
|
|
59
|
+
stateMutability: string;
|
|
60
|
+
type: string;
|
|
61
|
+
anonymous?: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
inputs: {
|
|
64
|
+
internalType: string;
|
|
65
|
+
name: string;
|
|
66
|
+
type: string;
|
|
67
|
+
}[];
|
|
68
|
+
name: string;
|
|
69
|
+
outputs: {
|
|
70
|
+
components: {
|
|
71
|
+
internalType: string;
|
|
72
|
+
name: string;
|
|
73
|
+
type: string;
|
|
74
|
+
}[];
|
|
75
|
+
internalType: string;
|
|
76
|
+
name: string;
|
|
77
|
+
type: string;
|
|
78
|
+
}[];
|
|
79
|
+
stateMutability: string;
|
|
80
|
+
type: string;
|
|
81
|
+
anonymous?: undefined;
|
|
82
|
+
})[];
|
|
83
|
+
/**
|
|
84
|
+
* Helper function to get contract address for a chain
|
|
85
|
+
*/
|
|
86
|
+
export declare function getNZipContractAddress(chainId: number): string;
|
|
87
|
+
/**
|
|
88
|
+
* Network configurations
|
|
89
|
+
*/
|
|
90
|
+
export declare const NETWORK_CONFIG: Record<number, string>;
|
|
91
|
+
/**
|
|
92
|
+
* Current deployment information
|
|
93
|
+
*/
|
|
94
|
+
export declare const CURRENT_DEPLOYMENT: {
|
|
95
|
+
version: string;
|
|
96
|
+
network: string;
|
|
97
|
+
chainId: number;
|
|
98
|
+
address: string;
|
|
99
|
+
deployedAt: string;
|
|
100
|
+
txHash: string;
|
|
101
|
+
explorer: string;
|
|
102
|
+
};
|