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,294 @@
|
|
|
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.WalletManager = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const readline = __importStar(require("readline"));
|
|
40
|
+
const ethers_1 = require("ethers");
|
|
41
|
+
const types_1 = require("./types");
|
|
42
|
+
class WalletManager {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.wallet = null;
|
|
45
|
+
this.provider = null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Prompts the user for input
|
|
49
|
+
*/
|
|
50
|
+
async promptUser(question) {
|
|
51
|
+
const rl = readline.createInterface({
|
|
52
|
+
input: process.stdin,
|
|
53
|
+
output: process.stdout
|
|
54
|
+
});
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
rl.question(question, (answer) => {
|
|
57
|
+
rl.close();
|
|
58
|
+
resolve(answer.trim());
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Looks for existing wallet files in the current directory and wallet subdirectory
|
|
64
|
+
*/
|
|
65
|
+
findExistingWallets() {
|
|
66
|
+
const walletFiles = [];
|
|
67
|
+
const currentDir = process.cwd();
|
|
68
|
+
const walletDir = path.join(currentDir, 'wallet');
|
|
69
|
+
// Common wallet file names to look for
|
|
70
|
+
const walletFileNames = [
|
|
71
|
+
'neozip-wallet.json',
|
|
72
|
+
'wallet.json',
|
|
73
|
+
'private-key.txt',
|
|
74
|
+
'private.key'
|
|
75
|
+
];
|
|
76
|
+
// Search in current directory
|
|
77
|
+
for (const fileName of walletFileNames) {
|
|
78
|
+
const filePath = path.join(currentDir, fileName);
|
|
79
|
+
if (fs.existsSync(filePath)) {
|
|
80
|
+
walletFiles.push(filePath);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Search in wallet subdirectory
|
|
84
|
+
if (fs.existsSync(walletDir)) {
|
|
85
|
+
for (const fileName of walletFileNames) {
|
|
86
|
+
const filePath = path.join(walletDir, fileName);
|
|
87
|
+
if (fs.existsSync(filePath)) {
|
|
88
|
+
walletFiles.push(filePath);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return walletFiles;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Loads wallet information from a file
|
|
96
|
+
*/
|
|
97
|
+
loadWalletFromFile(filePath) {
|
|
98
|
+
try {
|
|
99
|
+
const content = fs.readFileSync(filePath, 'utf8').trim();
|
|
100
|
+
// Try to parse as JSON first (for neozip-wallet.json format)
|
|
101
|
+
try {
|
|
102
|
+
const walletData = JSON.parse(content);
|
|
103
|
+
if (walletData.privateKey) {
|
|
104
|
+
console.log(`Found wallet file: ${filePath}`);
|
|
105
|
+
console.log(`Wallet address: ${walletData.address}`);
|
|
106
|
+
return walletData.privateKey;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// If not JSON, treat as plain private key
|
|
111
|
+
if (content.startsWith('0x') && content.length === 66) {
|
|
112
|
+
console.log(`Found private key file: ${filePath}`);
|
|
113
|
+
return content;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
console.warn(`Could not read wallet file ${filePath}:`, error);
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Sets up a Base wallet for token operations
|
|
125
|
+
*/
|
|
126
|
+
async setupWallet(options) {
|
|
127
|
+
try {
|
|
128
|
+
const networkConfig = types_1.NETWORKS[options.network] || types_1.NETWORKS['base-sepolia'];
|
|
129
|
+
let privateKey;
|
|
130
|
+
// Check if wallet is explicitly provided via command line
|
|
131
|
+
if (options.wallet) {
|
|
132
|
+
if (fs.existsSync(options.wallet)) {
|
|
133
|
+
// Read wallet from specified file
|
|
134
|
+
const loadedKey = this.loadWalletFromFile(options.wallet);
|
|
135
|
+
if (!loadedKey) {
|
|
136
|
+
throw new Error(`Could not load valid private key from ${options.wallet}`);
|
|
137
|
+
}
|
|
138
|
+
privateKey = loadedKey;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// Use directly provided private key or mnemonic
|
|
142
|
+
privateKey = options.wallet;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// Look for existing wallet files
|
|
147
|
+
const existingWallets = this.findExistingWallets();
|
|
148
|
+
if (existingWallets.length > 0) {
|
|
149
|
+
// Automatically use the first available wallet
|
|
150
|
+
const selectedWallet = existingWallets[0];
|
|
151
|
+
const relativePath = path.relative(process.cwd(), selectedWallet);
|
|
152
|
+
console.log(`Using existing wallet: ${relativePath}`);
|
|
153
|
+
const loadedKey = this.loadWalletFromFile(selectedWallet);
|
|
154
|
+
if (!loadedKey) {
|
|
155
|
+
throw new Error(`Could not load valid private key from ${selectedWallet}`);
|
|
156
|
+
}
|
|
157
|
+
privateKey = loadedKey;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// Automatically create new wallet
|
|
161
|
+
console.log('No existing wallet found. Creating new wallet...');
|
|
162
|
+
privateKey = await this.createNewWallet();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Create wallet instance without provider first
|
|
166
|
+
this.wallet = new ethers_1.ethers.Wallet(privateKey);
|
|
167
|
+
console.log(`Using wallet: ${this.wallet.address}`);
|
|
168
|
+
// Try to connect to the network - FAIL if connection fails
|
|
169
|
+
const networkConnected = await this.connectToNetwork(networkConfig, options.mintToken);
|
|
170
|
+
if (!networkConnected) {
|
|
171
|
+
return {
|
|
172
|
+
wallet: null,
|
|
173
|
+
provider: null,
|
|
174
|
+
success: false,
|
|
175
|
+
message: `Failed to connect to ${networkConfig.name} network. Blockchain operations require network connectivity.`
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
wallet: this.wallet,
|
|
180
|
+
provider: this.provider,
|
|
181
|
+
success: true,
|
|
182
|
+
message: `Wallet setup successful for ${networkConfig.name}`
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
console.error('Error setting up wallet:', error);
|
|
187
|
+
return {
|
|
188
|
+
wallet: null,
|
|
189
|
+
provider: null,
|
|
190
|
+
success: false,
|
|
191
|
+
message: `Wallet setup failed: ${error instanceof Error ? error.message : String(error)}`
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Creates a new wallet and saves it to file
|
|
197
|
+
*/
|
|
198
|
+
async createNewWallet() {
|
|
199
|
+
console.log('Creating a new wallet...');
|
|
200
|
+
const newWallet = ethers_1.ethers.Wallet.createRandom();
|
|
201
|
+
// Save the wallet info
|
|
202
|
+
const walletInfo = {
|
|
203
|
+
address: newWallet.address,
|
|
204
|
+
privateKey: newWallet.privateKey,
|
|
205
|
+
mnemonic: newWallet.mnemonic?.phrase || ""
|
|
206
|
+
};
|
|
207
|
+
// Ensure wallet directory exists
|
|
208
|
+
const walletDir = path.join(process.cwd(), 'wallet');
|
|
209
|
+
if (!fs.existsSync(walletDir)) {
|
|
210
|
+
fs.mkdirSync(walletDir, { recursive: true });
|
|
211
|
+
}
|
|
212
|
+
const walletFilePath = path.join(walletDir, 'neozip-wallet.json');
|
|
213
|
+
fs.writeFileSync(walletFilePath, JSON.stringify(walletInfo, null, 2));
|
|
214
|
+
console.log(`New wallet created and saved to ${walletFilePath}`);
|
|
215
|
+
console.log(`Wallet address: ${newWallet.address}`);
|
|
216
|
+
console.log(`IMPORTANT: Please fund this wallet with BASE to use for minting NFTs!`);
|
|
217
|
+
return newWallet.privateKey;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Connects to the specified blockchain network
|
|
221
|
+
*/
|
|
222
|
+
async connectToNetwork(networkConfig, mintToken) {
|
|
223
|
+
try {
|
|
224
|
+
console.log(`Attempting to connect to ${networkConfig.name} network...`);
|
|
225
|
+
this.provider = new ethers_1.ethers.JsonRpcProvider(networkConfig.rpcUrl);
|
|
226
|
+
// Set a timeout for network connection
|
|
227
|
+
let networkTimedOut = false;
|
|
228
|
+
const networkTimeout = setTimeout(() => {
|
|
229
|
+
networkTimedOut = true;
|
|
230
|
+
console.error("Network connection timeout");
|
|
231
|
+
}, 5000);
|
|
232
|
+
// Test the connection
|
|
233
|
+
const network = await Promise.race([
|
|
234
|
+
this.provider.getNetwork(),
|
|
235
|
+
new Promise((_, reject) => setTimeout(() => {
|
|
236
|
+
if (networkTimedOut)
|
|
237
|
+
reject(new Error("Network connection timeout"));
|
|
238
|
+
}, 5100))
|
|
239
|
+
]);
|
|
240
|
+
clearTimeout(networkTimeout);
|
|
241
|
+
// Connect wallet to provider
|
|
242
|
+
if (this.wallet) {
|
|
243
|
+
this.wallet = this.wallet.connect(this.provider);
|
|
244
|
+
// Check wallet balance
|
|
245
|
+
const balance = await this.provider.getBalance(this.wallet.address);
|
|
246
|
+
const balanceEth = ethers_1.ethers.formatEther(balance);
|
|
247
|
+
console.log(`Wallet balance: ${balanceEth} ETH`);
|
|
248
|
+
// Check if balance is sufficient for minting
|
|
249
|
+
const minBalance = 0.0001;
|
|
250
|
+
if (parseFloat(balanceEth) < minBalance && mintToken) {
|
|
251
|
+
console.error(`ERROR: Insufficient balance (${balanceEth} ETH). Minimum required: ${minBalance} ETH`);
|
|
252
|
+
console.error('Get testnet ETH from: https://www.coinbase.com/faucets/base-ethereum-sepolia-faucet');
|
|
253
|
+
throw new Error(`Insufficient balance for minting. Current: ${balanceEth} ETH, Required: ${minBalance} ETH`);
|
|
254
|
+
}
|
|
255
|
+
else if (mintToken) {
|
|
256
|
+
console.log(`✅ Sufficient balance for token minting`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
console.log(`✅ Successfully connected to ${networkConfig.name}`);
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
catch (networkError) {
|
|
263
|
+
const errorMessage = networkError instanceof Error ? networkError.message : String(networkError);
|
|
264
|
+
console.error(`Failed to connect to ${networkConfig.name} network: ${errorMessage}`);
|
|
265
|
+
this.provider = null;
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Gets the current wallet instance
|
|
271
|
+
*/
|
|
272
|
+
getWallet() {
|
|
273
|
+
return this.wallet;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Gets the current provider instance
|
|
277
|
+
*/
|
|
278
|
+
getProvider() {
|
|
279
|
+
return this.provider;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Checks if wallet is connected and ready for transactions
|
|
283
|
+
*/
|
|
284
|
+
isReady() {
|
|
285
|
+
return this.wallet !== null;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Checks if provider is connected
|
|
289
|
+
*/
|
|
290
|
+
isOnline() {
|
|
291
|
+
return this.provider !== null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
exports.WalletManager = WalletManager;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NZipTokenInfo, ContractInfo } from './types';
|
|
2
|
+
export declare class ZipMetadata {
|
|
3
|
+
/**
|
|
4
|
+
* Creates the META-INF/NZIP.TOKEN content
|
|
5
|
+
*/
|
|
6
|
+
static createTokenInfo(tokenId: string, transactionHash: string, contractInfo: ContractInfo, merkleRoot: string, fileName: string, network: string, blockNumber?: number, ipfsHash?: string, creationTimestamp?: number): NZipTokenInfo;
|
|
7
|
+
/**
|
|
8
|
+
* Creates the META-INF directory and NZIP.TOKEN file
|
|
9
|
+
*/
|
|
10
|
+
static createTokenFile(tokenInfo: NZipTokenInfo): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Reads token information from a ZIP file's META-INF/NZIP.TOKEN
|
|
13
|
+
*/
|
|
14
|
+
static readTokenInfo(zipFilePath: string): NZipTokenInfo | null;
|
|
15
|
+
/**
|
|
16
|
+
* Validates token information structure
|
|
17
|
+
*/
|
|
18
|
+
static validateTokenInfo(tokenInfo: any): tokenInfo is NZipTokenInfo;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a human-readable summary of the token information
|
|
21
|
+
*/
|
|
22
|
+
static createTokenSummary(tokenInfo: NZipTokenInfo): string;
|
|
23
|
+
/**
|
|
24
|
+
* No cleanup needed since we write to the current directory
|
|
25
|
+
*/
|
|
26
|
+
static cleanupTokenFile(tokenFilePath: string): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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.ZipMetadata = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const types_1 = require("./types");
|
|
40
|
+
class ZipMetadata {
|
|
41
|
+
/**
|
|
42
|
+
* Creates the META-INF/NZIP.TOKEN content
|
|
43
|
+
*/
|
|
44
|
+
static createTokenInfo(tokenId, transactionHash, contractInfo, merkleRoot, fileName, network, blockNumber, ipfsHash, creationTimestamp) {
|
|
45
|
+
const networkConfig = types_1.NETWORKS[network];
|
|
46
|
+
return {
|
|
47
|
+
version: "1.0",
|
|
48
|
+
tokenId,
|
|
49
|
+
contractAddress: contractInfo.address,
|
|
50
|
+
network: networkConfig.name,
|
|
51
|
+
networkChainId: networkConfig.chainId,
|
|
52
|
+
transactionHash,
|
|
53
|
+
merkleRoot,
|
|
54
|
+
fileName,
|
|
55
|
+
mintedAt: new Date().toISOString(),
|
|
56
|
+
creationTimestamp,
|
|
57
|
+
blockNumber,
|
|
58
|
+
ipfsHash
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates the META-INF directory and NZIP.TOKEN file
|
|
63
|
+
*/
|
|
64
|
+
static async createTokenFile(tokenInfo) {
|
|
65
|
+
const currentDir = process.cwd();
|
|
66
|
+
// Create META-INF directory in current directory
|
|
67
|
+
const metaInfDir = path.join(currentDir, 'META-INF');
|
|
68
|
+
if (!fs.existsSync(metaInfDir)) {
|
|
69
|
+
fs.mkdirSync(metaInfDir, { recursive: true });
|
|
70
|
+
}
|
|
71
|
+
// Create NZIP.TOKEN file
|
|
72
|
+
const tokenFilePath = path.join(metaInfDir, 'NZIP.TOKEN');
|
|
73
|
+
const tokenContent = JSON.stringify(tokenInfo, null, 2);
|
|
74
|
+
fs.writeFileSync(tokenFilePath, tokenContent);
|
|
75
|
+
console.log(`Created token metadata file: ${path.relative(currentDir, tokenFilePath)}`);
|
|
76
|
+
return tokenFilePath;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Reads token information from a ZIP file's META-INF/NZIP.TOKEN
|
|
80
|
+
*/
|
|
81
|
+
static readTokenInfo(zipFilePath) {
|
|
82
|
+
// This would require extracting the META-INF/NZIP.TOKEN file from the ZIP
|
|
83
|
+
// For now, return null - this can be implemented when needed
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validates token information structure
|
|
88
|
+
*/
|
|
89
|
+
static validateTokenInfo(tokenInfo) {
|
|
90
|
+
return (typeof tokenInfo === 'object' &&
|
|
91
|
+
typeof tokenInfo.version === 'string' &&
|
|
92
|
+
typeof tokenInfo.tokenId === 'string' &&
|
|
93
|
+
typeof tokenInfo.contractAddress === 'string' &&
|
|
94
|
+
typeof tokenInfo.network === 'string' &&
|
|
95
|
+
typeof tokenInfo.networkChainId === 'number' &&
|
|
96
|
+
typeof tokenInfo.transactionHash === 'string' &&
|
|
97
|
+
typeof tokenInfo.merkleRoot === 'string' &&
|
|
98
|
+
typeof tokenInfo.fileName === 'string' &&
|
|
99
|
+
typeof tokenInfo.mintedAt === 'string');
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Creates a human-readable summary of the token information
|
|
103
|
+
*/
|
|
104
|
+
static createTokenSummary(tokenInfo) {
|
|
105
|
+
return `
|
|
106
|
+
═══════════════════════════════════════════════════════════════
|
|
107
|
+
NeoZip Token Information
|
|
108
|
+
═══════════════════════════════════════════════════════════════
|
|
109
|
+
Token ID: ${tokenInfo.tokenId}
|
|
110
|
+
Contract: ${tokenInfo.contractAddress}
|
|
111
|
+
Network: ${tokenInfo.network} (Chain ID: ${tokenInfo.networkChainId})
|
|
112
|
+
Transaction: ${tokenInfo.transactionHash}
|
|
113
|
+
Block Number: ${tokenInfo.blockNumber || 'Unknown'}
|
|
114
|
+
Merkle Root: ${tokenInfo.merkleRoot}
|
|
115
|
+
File Name: ${tokenInfo.fileName}
|
|
116
|
+
Minted At: ${tokenInfo.mintedAt}
|
|
117
|
+
IPFS Hash: ${tokenInfo.ipfsHash || 'Not uploaded'}
|
|
118
|
+
Version: ${tokenInfo.version}
|
|
119
|
+
═══════════════════════════════════════════════════════════════
|
|
120
|
+
`.trim();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* No cleanup needed since we write to the current directory
|
|
124
|
+
*/
|
|
125
|
+
static cleanupTokenFile(tokenFilePath) {
|
|
126
|
+
// No cleanup needed since we're writing to the current directory
|
|
127
|
+
// The META-INF/NZIP.TOKEN file should remain in the current directory
|
|
128
|
+
console.log(`Token metadata file preserved at: ${path.relative(process.cwd(), tokenFilePath)}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.ZipMetadata = ZipMetadata;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { WalletManager } from './WalletManager';
|
|
2
|
+
import { NFTMinter } from './NFTMinter';
|
|
3
|
+
import { MintingOptions, ZipTokenData, WalletSetupResult, MintingResult, NZipTokenInfo } from './types';
|
|
4
|
+
interface ProcessorState {
|
|
5
|
+
walletSetup?: WalletSetupResult;
|
|
6
|
+
mintingResult?: MintingResult;
|
|
7
|
+
tokenInfo?: NZipTokenInfo;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ZipTokenProcessor {
|
|
11
|
+
private walletManager;
|
|
12
|
+
private nftMinter;
|
|
13
|
+
private zipTokenData;
|
|
14
|
+
constructor(zipFile: string, merkleRoot: string, options: MintingOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Processes the complete ZIP token workflow
|
|
17
|
+
*/
|
|
18
|
+
processZipToken(options: MintingOptions): Promise<ProcessorState>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the ZIP token data
|
|
21
|
+
*/
|
|
22
|
+
getZipTokenData(): ZipTokenData;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the wallet manager instance
|
|
25
|
+
*/
|
|
26
|
+
getWalletManager(): WalletManager;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the NFT minter instance
|
|
29
|
+
*/
|
|
30
|
+
getNFTMinter(): NFTMinter | null;
|
|
31
|
+
/**
|
|
32
|
+
* Loads contract deployment information
|
|
33
|
+
*/
|
|
34
|
+
private loadContractInfo;
|
|
35
|
+
/**
|
|
36
|
+
* Creates token information object
|
|
37
|
+
*/
|
|
38
|
+
private createTokenInfo;
|
|
39
|
+
/**
|
|
40
|
+
* Creates token information object from existing token
|
|
41
|
+
*/
|
|
42
|
+
private createTokenInfoFromExisting;
|
|
43
|
+
}
|
|
44
|
+
export {};
|