neozip-blockchain 0.5.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/LICENSE +22 -0
- package/README.md +189 -0
- package/dist/browser/TokenVerifierBrowser.d.ts +63 -0
- package/dist/browser/TokenVerifierBrowser.d.ts.map +1 -0
- package/dist/browser/TokenVerifierBrowser.js +358 -0
- package/dist/browser/TokenVerifierBrowser.js.map +1 -0
- package/dist/browser/WalletManagerBrowser.d.ts +99 -0
- package/dist/browser/WalletManagerBrowser.d.ts.map +1 -0
- package/dist/browser/WalletManagerBrowser.js +434 -0
- package/dist/browser/WalletManagerBrowser.js.map +1 -0
- package/dist/browser/ZipkitMinterBrowser.d.ts +59 -0
- package/dist/browser/ZipkitMinterBrowser.d.ts.map +1 -0
- package/dist/browser/ZipkitMinterBrowser.js +337 -0
- package/dist/browser/ZipkitMinterBrowser.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 +19 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +21 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/metadata.d.ts +18 -0
- package/dist/constants/metadata.d.ts.map +1 -0
- package/dist/constants/metadata.js +33 -0
- package/dist/constants/metadata.js.map +1 -0
- package/dist/constants/servers.d.ts +38 -0
- package/dist/constants/servers.d.ts.map +1 -0
- package/dist/constants/servers.js +54 -0
- package/dist/constants/servers.js.map +1 -0
- package/dist/core/ContractVersionRegistry.d.ts +63 -0
- package/dist/core/ContractVersionRegistry.d.ts.map +1 -0
- package/dist/core/ContractVersionRegistry.js +128 -0
- package/dist/core/ContractVersionRegistry.js.map +1 -0
- package/dist/core/WalletManager.d.ts +123 -0
- package/dist/core/WalletManager.d.ts.map +1 -0
- package/dist/core/WalletManager.js +360 -0
- package/dist/core/WalletManager.js.map +1 -0
- package/dist/core/ZipkitMinter.d.ts +155 -0
- package/dist/core/ZipkitMinter.d.ts.map +1 -0
- package/dist/core/ZipkitMinter.js +625 -0
- package/dist/core/ZipkitMinter.js.map +1 -0
- package/dist/core/ZipkitVerifier.d.ts +252 -0
- package/dist/core/ZipkitVerifier.d.ts.map +1 -0
- package/dist/core/ZipkitVerifier.js +1370 -0
- package/dist/core/ZipkitVerifier.js.map +1 -0
- package/dist/core/adapters/AdapterFactory.d.ts +22 -0
- package/dist/core/adapters/AdapterFactory.d.ts.map +1 -0
- package/dist/core/adapters/AdapterFactory.js +62 -0
- package/dist/core/adapters/AdapterFactory.js.map +1 -0
- package/dist/core/adapters/ContractVersionAdapter.d.ts +96 -0
- package/dist/core/adapters/ContractVersionAdapter.d.ts.map +1 -0
- package/dist/core/adapters/ContractVersionAdapter.js +9 -0
- package/dist/core/adapters/ContractVersionAdapter.js.map +1 -0
- package/dist/core/adapters/V2_10Adapter.d.ts +24 -0
- package/dist/core/adapters/V2_10Adapter.d.ts.map +1 -0
- package/dist/core/adapters/V2_10Adapter.js +87 -0
- package/dist/core/adapters/V2_10Adapter.js.map +1 -0
- package/dist/core/adapters/V2_11Adapter.d.ts +24 -0
- package/dist/core/adapters/V2_11Adapter.d.ts.map +1 -0
- package/dist/core/adapters/V2_11Adapter.js +87 -0
- package/dist/core/adapters/V2_11Adapter.js.map +1 -0
- package/dist/core/adapters/V2_50Adapter.d.ts +105 -0
- package/dist/core/adapters/V2_50Adapter.d.ts.map +1 -0
- package/dist/core/adapters/V2_50Adapter.js +263 -0
- package/dist/core/adapters/V2_50Adapter.js.map +1 -0
- package/dist/core/contracts.d.ts +169 -0
- package/dist/core/contracts.d.ts.map +1 -0
- package/dist/core/contracts.js +731 -0
- package/dist/core/contracts.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 +82 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/node/WalletManagerNode.d.ts +47 -0
- package/dist/node/WalletManagerNode.d.ts.map +1 -0
- package/dist/node/WalletManagerNode.js +203 -0
- package/dist/node/WalletManagerNode.js.map +1 -0
- package/dist/node/index.d.ts +12 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +21 -0
- package/dist/node/index.js.map +1 -0
- package/dist/ots/ZipkitOTS.d.ts +152 -0
- package/dist/ots/ZipkitOTS.d.ts.map +1 -0
- package/dist/ots/ZipkitOTS.js +544 -0
- package/dist/ots/ZipkitOTS.js.map +1 -0
- package/dist/ots/index.d.ts +9 -0
- package/dist/ots/index.d.ts.map +1 -0
- package/dist/ots/index.js +25 -0
- package/dist/ots/index.js.map +1 -0
- package/dist/types/index.d.ts +84 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +37 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/Logger.d.ts +73 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +156 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/crc32.d.ts +6 -0
- package/dist/utils/crc32.d.ts.map +1 -0
- package/dist/utils/crc32.js +23 -0
- package/dist/utils/crc32.js.map +1 -0
- package/dist/zipstamp-server/CalendarManager.d.ts +238 -0
- package/dist/zipstamp-server/CalendarManager.d.ts.map +1 -0
- package/dist/zipstamp-server/CalendarManager.js +364 -0
- package/dist/zipstamp-server/CalendarManager.js.map +1 -0
- package/dist/zipstamp-server/ZipstampServerAPI.d.ts +427 -0
- package/dist/zipstamp-server/ZipstampServerAPI.d.ts.map +1 -0
- package/dist/zipstamp-server/ZipstampServerAPI.js +696 -0
- package/dist/zipstamp-server/ZipstampServerAPI.js.map +1 -0
- package/dist/zipstamp-server/ZipstampServerClient.d.ts +590 -0
- package/dist/zipstamp-server/ZipstampServerClient.d.ts.map +1 -0
- package/dist/zipstamp-server/ZipstampServerClient.js +433 -0
- package/dist/zipstamp-server/ZipstampServerClient.js.map +1 -0
- package/dist/zipstamp-server/ZipstampServerHelpers.d.ts +430 -0
- package/dist/zipstamp-server/ZipstampServerHelpers.d.ts.map +1 -0
- package/dist/zipstamp-server/ZipstampServerHelpers.js +503 -0
- package/dist/zipstamp-server/ZipstampServerHelpers.js.map +1 -0
- package/dist/zipstamp-server/index.d.ts +24 -0
- package/dist/zipstamp-server/index.d.ts.map +1 -0
- package/dist/zipstamp-server/index.js +67 -0
- package/dist/zipstamp-server/index.js.map +1 -0
- package/package.json +117 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V2_50Adapter - Adapter for contract version 2.50
|
|
3
|
+
*
|
|
4
|
+
* Handles v2.50 contract operations:
|
|
5
|
+
* - Full v2.11 compatibility (encryptedHash, publicMintZipFile)
|
|
6
|
+
* - Timestamp proof minting via mintWithTimestampProof()
|
|
7
|
+
* - NZIPTimestampReg integration
|
|
8
|
+
* - Mint fee support
|
|
9
|
+
* - Authorized minters
|
|
10
|
+
*/
|
|
11
|
+
import type { Contract, ContractTransactionResponse, BaseContract } from 'ethers';
|
|
12
|
+
import type { ContractVersionAdapter, ZipFileInfo, ZipFileTokenizedEvent, TimestampProofData } from './ContractVersionAdapter';
|
|
13
|
+
export declare class V2_50Adapter implements ContractVersionAdapter {
|
|
14
|
+
readonly version = "2.50";
|
|
15
|
+
mintZipFile(contract: Contract | BaseContract, merkleRoot: string, encryptedHash: string | undefined, creationTimestamp: number, ipfsHash: string, metadataURI: string, gasOptions?: {
|
|
16
|
+
gasLimit: bigint;
|
|
17
|
+
gasPrice: bigint;
|
|
18
|
+
}): Promise<ContractTransactionResponse>;
|
|
19
|
+
getZipFileInfo(contract: Contract | BaseContract, tokenId: bigint): Promise<ZipFileInfo>;
|
|
20
|
+
parseZipFileTokenizedEvent(log: {
|
|
21
|
+
topics: string[];
|
|
22
|
+
data: string;
|
|
23
|
+
}): ZipFileTokenizedEvent;
|
|
24
|
+
estimateGasForMint(contract: Contract | BaseContract, merkleRoot: string, encryptedHash: string | undefined, creationTimestamp: number, ipfsHash: string, metadataURI: string): Promise<bigint>;
|
|
25
|
+
/**
|
|
26
|
+
* Mint an NFT with timestamp proof (requires NZIPTimestampReg verification)
|
|
27
|
+
* @param contract Contract instance
|
|
28
|
+
* @param merkleRootHash The merkle root hash of the ZIP (as string)
|
|
29
|
+
* @param proof The merkle proof path
|
|
30
|
+
* @param batchMerkleRoot The merkle root of the batch in NZIPTimestampReg
|
|
31
|
+
* @param value Optional ETH value to send (for mint fee)
|
|
32
|
+
* @param gasOptions Optional gas limit and price
|
|
33
|
+
* @returns Transaction response
|
|
34
|
+
*/
|
|
35
|
+
mintWithTimestampProof(contract: Contract | BaseContract, merkleRootHash: string, proof: string[], batchMerkleRoot: string, value?: bigint, gasOptions?: {
|
|
36
|
+
gasLimit?: bigint;
|
|
37
|
+
gasPrice?: bigint;
|
|
38
|
+
}): Promise<ContractTransactionResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a token has timestamp proof
|
|
41
|
+
* @param contract Contract instance
|
|
42
|
+
* @param tokenId Token ID to check
|
|
43
|
+
* @returns True if token was minted with timestamp proof
|
|
44
|
+
*/
|
|
45
|
+
hasTimestampProof(contract: Contract | BaseContract, tokenId: bigint): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Get timestamp proof data for a token
|
|
48
|
+
* @param contract Contract instance
|
|
49
|
+
* @param tokenId Token ID to query
|
|
50
|
+
* @returns Timestamp proof data and merkle proof
|
|
51
|
+
*/
|
|
52
|
+
getTimestampProof(contract: Contract | BaseContract, tokenId: bigint): Promise<{
|
|
53
|
+
data: TimestampProofData;
|
|
54
|
+
merkleProof: string[];
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Get unified token data (for verification compatibility)
|
|
58
|
+
* @param contract Contract instance
|
|
59
|
+
* @param tokenId Token ID to query
|
|
60
|
+
* @returns Unified token data
|
|
61
|
+
*/
|
|
62
|
+
getTokenData(contract: Contract | BaseContract, tokenId: bigint): Promise<{
|
|
63
|
+
merkleRoot: string;
|
|
64
|
+
mintedAt: bigint;
|
|
65
|
+
mintBlockNumber: bigint;
|
|
66
|
+
originalOwner: string;
|
|
67
|
+
hasProof: boolean;
|
|
68
|
+
batchMerkleRoot: string;
|
|
69
|
+
batchTimestamp: bigint;
|
|
70
|
+
batchBlockNumber: bigint;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Verify a token's timestamp proof is still valid
|
|
74
|
+
* @param contract Contract instance
|
|
75
|
+
* @param tokenId Token ID to verify
|
|
76
|
+
* @returns True if valid (or if token has no timestamp proof)
|
|
77
|
+
*/
|
|
78
|
+
verifyToken(contract: Contract | BaseContract, tokenId: bigint): Promise<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the NZIPTimestampReg address
|
|
81
|
+
* @param contract Contract instance
|
|
82
|
+
* @returns Registry address
|
|
83
|
+
*/
|
|
84
|
+
getRegistry(contract: Contract | BaseContract): Promise<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Get the minting fee
|
|
87
|
+
* @param contract Contract instance
|
|
88
|
+
* @returns Mint fee in wei
|
|
89
|
+
*/
|
|
90
|
+
getMintFee(contract: Contract | BaseContract): Promise<bigint>;
|
|
91
|
+
/**
|
|
92
|
+
* Check if minting fee is required
|
|
93
|
+
* @param contract Contract instance
|
|
94
|
+
* @returns True if fee is required
|
|
95
|
+
*/
|
|
96
|
+
isMintFeeRequired(contract: Contract | BaseContract): Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Check if an address is an authorized minter
|
|
99
|
+
* @param contract Contract instance
|
|
100
|
+
* @param minter Address to check
|
|
101
|
+
* @returns True if authorized
|
|
102
|
+
*/
|
|
103
|
+
isAuthorizedMinter(contract: Contract | BaseContract, minter: string): Promise<boolean>;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=V2_50Adapter.d.ts.map
|
|
@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;;OAIG;IACG,iBAAiB,CACrB,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAChC,OAAO,CAAC,OAAO,CAAC;IAanB;;;;;OAKG;IACG,kBAAkB,CACtB,QAAQ,EAAE,QAAQ,GAAG,YAAY,EACjC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;CAYpB"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* V2_50Adapter - Adapter for contract version 2.50
|
|
4
|
+
*
|
|
5
|
+
* Handles v2.50 contract operations:
|
|
6
|
+
* - Full v2.11 compatibility (encryptedHash, publicMintZipFile)
|
|
7
|
+
* - Timestamp proof minting via mintWithTimestampProof()
|
|
8
|
+
* - NZIPTimestampReg integration
|
|
9
|
+
* - Mint fee support
|
|
10
|
+
* - Authorized minters
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.V2_50Adapter = void 0;
|
|
14
|
+
const ethers_1 = require("ethers");
|
|
15
|
+
// Full ABI for v2.50 operations
|
|
16
|
+
const V2_50_ABI = [
|
|
17
|
+
// v2.11 compatible functions
|
|
18
|
+
"function publicMintZipFile(string memory merkleRootHash, string memory encryptedHash, uint256 creationTimestamp, string memory ipfsHash, string memory metadataURI) public payable returns (uint256)",
|
|
19
|
+
"function publicMintZipFile(string memory merkleRootHash, uint256 creationTimestamp, string memory ipfsHash, string memory metadataURI) public payable returns (uint256)",
|
|
20
|
+
"function getZipFileInfo(uint256 tokenId) external view returns (tuple(string merkleRootHash, string encryptedHash, string ipfsHash, address creator, uint256 creationTimestamp, uint256 tokenizationTime, uint256 blockNumber))",
|
|
21
|
+
"function getEncryptedHash(uint256 tokenId) external view returns (string memory)",
|
|
22
|
+
"function isZipFileTokenized(string memory merkleRootHash, uint256 creationTimestamp) external view returns (bool exists, uint256 tokenId)",
|
|
23
|
+
"function verifyZipFile(uint256 tokenId, string memory providedMerkleRoot) external view returns (bool isValid)",
|
|
24
|
+
"function verifyEncryptedZipFile(uint256 tokenId, string memory providedEncryptedHash) external view returns (bool isValid)",
|
|
25
|
+
"function getBlockchainMetadata(uint256 tokenId) public view returns (uint256 blockNumber, uint256 tokenizationTime)",
|
|
26
|
+
"function generateCompositeKey(string memory merkleRootHash, uint256 creationTimestamp) public pure returns (bytes32)",
|
|
27
|
+
"function totalSupply() public view returns (uint256)",
|
|
28
|
+
"function getVersion() external pure returns (string memory)",
|
|
29
|
+
"function ownerOf(uint256 tokenId) external view returns (address)",
|
|
30
|
+
"function balanceOf(address owner) external view returns (uint256)",
|
|
31
|
+
// v2.50 timestamp proof functions
|
|
32
|
+
"function mintWithTimestampProof(string memory merkleRootHash, bytes32[] calldata proof, bytes32 batchMerkleRoot) external payable returns (uint256)",
|
|
33
|
+
"function hasTimestampProof(uint256 tokenId) external view returns (bool)",
|
|
34
|
+
"function getTimestampProof(uint256 tokenId) external view returns (tuple(bool hasTimestampProof, bytes32 batchMerkleRoot, uint256 batchTimestamp, uint256 batchBlockNumber) data, bytes32[] memory merkleProof)",
|
|
35
|
+
"function getTokenData(uint256 tokenId) external view returns (bytes32 merkleRoot, uint256 mintedAt, uint256 mintBlockNumber, address originalOwner, bool hasProof, bytes32 batchMerkleRoot, uint256 batchTimestamp, uint256 batchBlockNumber)",
|
|
36
|
+
"function verifyToken(uint256 tokenId) external view returns (bool isValid)",
|
|
37
|
+
"function getRegistry() external view returns (address)",
|
|
38
|
+
// v2.50 admin functions
|
|
39
|
+
"function mintFee() public view returns (uint256)",
|
|
40
|
+
"function mintFeeRequired() public view returns (bool)",
|
|
41
|
+
"function setMintFee(uint256 newFee) external",
|
|
42
|
+
"function setMintFeeRequired(bool required) external",
|
|
43
|
+
"function withdrawFees(address payable to) external",
|
|
44
|
+
"function authorizeMinter(address minter) external",
|
|
45
|
+
"function deauthorizeMinter(address minter) external",
|
|
46
|
+
"function isAuthorizedMinter(address minter) external view returns (bool)",
|
|
47
|
+
"function authorizedMinters(address) public view returns (bool)",
|
|
48
|
+
// Events
|
|
49
|
+
"event ZipFileTokenized(uint256 indexed tokenId, address indexed creator, string merkleRootHash, string encryptedHash, uint256 creationTimestamp, string ipfsHash, uint256 tokenizationTime, uint256 blockNumber)",
|
|
50
|
+
"event TimestampProofMinted(uint256 indexed tokenId, address indexed creator, bytes32 indexed batchMerkleRoot, string merkleRootHash, uint256 batchTimestamp, uint256 tokenizationTime, uint256 blockNumber)",
|
|
51
|
+
"event FeeUpdated(uint256 oldFee, uint256 newFee)",
|
|
52
|
+
"event MinterAuthorized(address indexed minter, address indexed authorizedBy)",
|
|
53
|
+
"event MinterDeauthorized(address indexed minter, address indexed deauthorizedBy)"
|
|
54
|
+
];
|
|
55
|
+
const iface = new ethers_1.Interface(V2_50_ABI);
|
|
56
|
+
class V2_50Adapter {
|
|
57
|
+
constructor() {
|
|
58
|
+
this.version = '2.50';
|
|
59
|
+
}
|
|
60
|
+
async mintZipFile(contract, merkleRoot, encryptedHash, creationTimestamp, ipfsHash, metadataURI, gasOptions) {
|
|
61
|
+
// v2.50 signature: publicMintZipFile(merkleRootHash, encryptedHash, creationTimestamp, ipfsHash, metadataURI)
|
|
62
|
+
// Use empty string if encryptedHash is not provided
|
|
63
|
+
const contractTyped = contract;
|
|
64
|
+
const args = [
|
|
65
|
+
merkleRoot,
|
|
66
|
+
encryptedHash || '',
|
|
67
|
+
creationTimestamp,
|
|
68
|
+
ipfsHash,
|
|
69
|
+
metadataURI
|
|
70
|
+
];
|
|
71
|
+
if (gasOptions) {
|
|
72
|
+
return await contractTyped.publicMintZipFile(...args, gasOptions);
|
|
73
|
+
}
|
|
74
|
+
return await contractTyped.publicMintZipFile(...args);
|
|
75
|
+
}
|
|
76
|
+
async getZipFileInfo(contract, tokenId) {
|
|
77
|
+
// v2.50 returns: (merkleRootHash, encryptedHash, ipfsHash, creator, creationTimestamp, tokenizationTime, blockNumber)
|
|
78
|
+
const contractTyped = contract;
|
|
79
|
+
// Get the provider/runner from the contract
|
|
80
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
81
|
+
// Create a contract with the adapter's ABI to get the full return structure
|
|
82
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
83
|
+
const result = await adapterContract.getZipFileInfo(tokenId);
|
|
84
|
+
return {
|
|
85
|
+
merkleRootHash: result[0],
|
|
86
|
+
encryptedHash: result[1] || undefined, // May be empty string
|
|
87
|
+
ipfsHash: result[2],
|
|
88
|
+
creator: result[3],
|
|
89
|
+
creationTimestamp: result[4],
|
|
90
|
+
tokenizationTime: result[5],
|
|
91
|
+
blockNumber: result[6],
|
|
92
|
+
// fileName not available in v2.50
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
parseZipFileTokenizedEvent(log) {
|
|
96
|
+
const parsed = iface.parseLog({
|
|
97
|
+
topics: log.topics,
|
|
98
|
+
data: log.data
|
|
99
|
+
});
|
|
100
|
+
if (!parsed || parsed.name !== 'ZipFileTokenized') {
|
|
101
|
+
throw new Error('Invalid ZipFileTokenized event');
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
tokenId: parsed.args.tokenId,
|
|
105
|
+
creator: parsed.args.creator,
|
|
106
|
+
merkleRootHash: parsed.args.merkleRootHash,
|
|
107
|
+
encryptedHash: parsed.args.encryptedHash || undefined, // May be empty string
|
|
108
|
+
creationTimestamp: parsed.args.creationTimestamp,
|
|
109
|
+
ipfsHash: parsed.args.ipfsHash,
|
|
110
|
+
tokenizationTime: parsed.args.tokenizationTime,
|
|
111
|
+
blockNumber: parsed.args.blockNumber,
|
|
112
|
+
// fileName not in v2.50 event
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async estimateGasForMint(contract, merkleRoot, encryptedHash, creationTimestamp, ipfsHash, metadataURI) {
|
|
116
|
+
// v2.50 signature: publicMintZipFile(merkleRootHash, encryptedHash, creationTimestamp, ipfsHash, metadataURI)
|
|
117
|
+
const contractTyped = contract;
|
|
118
|
+
return await contractTyped.publicMintZipFile.estimateGas(merkleRoot, encryptedHash || '', creationTimestamp, ipfsHash, metadataURI);
|
|
119
|
+
}
|
|
120
|
+
// ============================================================================
|
|
121
|
+
// v2.50 Timestamp Proof Methods
|
|
122
|
+
// ============================================================================
|
|
123
|
+
/**
|
|
124
|
+
* Mint an NFT with timestamp proof (requires NZIPTimestampReg verification)
|
|
125
|
+
* @param contract Contract instance
|
|
126
|
+
* @param merkleRootHash The merkle root hash of the ZIP (as string)
|
|
127
|
+
* @param proof The merkle proof path
|
|
128
|
+
* @param batchMerkleRoot The merkle root of the batch in NZIPTimestampReg
|
|
129
|
+
* @param value Optional ETH value to send (for mint fee)
|
|
130
|
+
* @param gasOptions Optional gas limit and price
|
|
131
|
+
* @returns Transaction response
|
|
132
|
+
*/
|
|
133
|
+
async mintWithTimestampProof(contract, merkleRootHash, proof, batchMerkleRoot, value, gasOptions) {
|
|
134
|
+
const contractTyped = contract;
|
|
135
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
136
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
137
|
+
const txOptions = {};
|
|
138
|
+
if (value)
|
|
139
|
+
txOptions.value = value;
|
|
140
|
+
if (gasOptions?.gasLimit)
|
|
141
|
+
txOptions.gasLimit = gasOptions.gasLimit;
|
|
142
|
+
if (gasOptions?.gasPrice)
|
|
143
|
+
txOptions.gasPrice = gasOptions.gasPrice;
|
|
144
|
+
return await adapterContract.mintWithTimestampProof(merkleRootHash, proof, batchMerkleRoot, txOptions);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Check if a token has timestamp proof
|
|
148
|
+
* @param contract Contract instance
|
|
149
|
+
* @param tokenId Token ID to check
|
|
150
|
+
* @returns True if token was minted with timestamp proof
|
|
151
|
+
*/
|
|
152
|
+
async hasTimestampProof(contract, tokenId) {
|
|
153
|
+
const contractTyped = contract;
|
|
154
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
155
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
156
|
+
return await adapterContract.hasTimestampProof(tokenId);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get timestamp proof data for a token
|
|
160
|
+
* @param contract Contract instance
|
|
161
|
+
* @param tokenId Token ID to query
|
|
162
|
+
* @returns Timestamp proof data and merkle proof
|
|
163
|
+
*/
|
|
164
|
+
async getTimestampProof(contract, tokenId) {
|
|
165
|
+
const contractTyped = contract;
|
|
166
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
167
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
168
|
+
const result = await adapterContract.getTimestampProof(tokenId);
|
|
169
|
+
return {
|
|
170
|
+
data: {
|
|
171
|
+
hasTimestampProof: result[0][0],
|
|
172
|
+
batchMerkleRoot: result[0][1],
|
|
173
|
+
batchTimestamp: result[0][2],
|
|
174
|
+
batchBlockNumber: result[0][3]
|
|
175
|
+
},
|
|
176
|
+
merkleProof: result[1]
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get unified token data (for verification compatibility)
|
|
181
|
+
* @param contract Contract instance
|
|
182
|
+
* @param tokenId Token ID to query
|
|
183
|
+
* @returns Unified token data
|
|
184
|
+
*/
|
|
185
|
+
async getTokenData(contract, tokenId) {
|
|
186
|
+
const contractTyped = contract;
|
|
187
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
188
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
189
|
+
const result = await adapterContract.getTokenData(tokenId);
|
|
190
|
+
return {
|
|
191
|
+
merkleRoot: result[0],
|
|
192
|
+
mintedAt: result[1],
|
|
193
|
+
mintBlockNumber: result[2],
|
|
194
|
+
originalOwner: result[3],
|
|
195
|
+
hasProof: result[4],
|
|
196
|
+
batchMerkleRoot: result[5],
|
|
197
|
+
batchTimestamp: result[6],
|
|
198
|
+
batchBlockNumber: result[7]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Verify a token's timestamp proof is still valid
|
|
203
|
+
* @param contract Contract instance
|
|
204
|
+
* @param tokenId Token ID to verify
|
|
205
|
+
* @returns True if valid (or if token has no timestamp proof)
|
|
206
|
+
*/
|
|
207
|
+
async verifyToken(contract, tokenId) {
|
|
208
|
+
const contractTyped = contract;
|
|
209
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
210
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
211
|
+
return await adapterContract.verifyToken(tokenId);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get the NZIPTimestampReg address
|
|
215
|
+
* @param contract Contract instance
|
|
216
|
+
* @returns Registry address
|
|
217
|
+
*/
|
|
218
|
+
async getRegistry(contract) {
|
|
219
|
+
const contractTyped = contract;
|
|
220
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
221
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
222
|
+
return await adapterContract.getRegistry();
|
|
223
|
+
}
|
|
224
|
+
// ============================================================================
|
|
225
|
+
// v2.50 Fee Methods
|
|
226
|
+
// ============================================================================
|
|
227
|
+
/**
|
|
228
|
+
* Get the minting fee
|
|
229
|
+
* @param contract Contract instance
|
|
230
|
+
* @returns Mint fee in wei
|
|
231
|
+
*/
|
|
232
|
+
async getMintFee(contract) {
|
|
233
|
+
const contractTyped = contract;
|
|
234
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
235
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
236
|
+
return await adapterContract.mintFee();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Check if minting fee is required
|
|
240
|
+
* @param contract Contract instance
|
|
241
|
+
* @returns True if fee is required
|
|
242
|
+
*/
|
|
243
|
+
async isMintFeeRequired(contract) {
|
|
244
|
+
const contractTyped = contract;
|
|
245
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
246
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
247
|
+
return await adapterContract.mintFeeRequired();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Check if an address is an authorized minter
|
|
251
|
+
* @param contract Contract instance
|
|
252
|
+
* @param minter Address to check
|
|
253
|
+
* @returns True if authorized
|
|
254
|
+
*/
|
|
255
|
+
async isAuthorizedMinter(contract, minter) {
|
|
256
|
+
const contractTyped = contract;
|
|
257
|
+
const runner = contractTyped.runner || contractTyped.provider;
|
|
258
|
+
const adapterContract = new ethers_1.Contract(contractTyped.target, V2_50_ABI, runner);
|
|
259
|
+
return await adapterContract.isAuthorizedMinter(minter);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
exports.V2_50Adapter = V2_50Adapter;
|
|
263
|
+
//# sourceMappingURL=V2_50Adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"V2_50Adapter.js","sourceRoot":"","sources":["../../../src/core/adapters/V2_50Adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAGH,mCAA+D;AAG/D,gCAAgC;AAChC,MAAM,SAAS,GAAG;IAChB,6BAA6B;IAC7B,sMAAsM;IACtM,yKAAyK;IACzK,iOAAiO;IACjO,kFAAkF;IAClF,2IAA2I;IAC3I,gHAAgH;IAChH,4HAA4H;IAC5H,qHAAqH;IACrH,sHAAsH;IACtH,sDAAsD;IACtD,6DAA6D;IAC7D,mEAAmE;IACnE,mEAAmE;IAEnE,kCAAkC;IAClC,qJAAqJ;IACrJ,0EAA0E;IAC1E,iNAAiN;IACjN,+OAA+O;IAC/O,4EAA4E;IAC5E,wDAAwD;IAExD,wBAAwB;IACxB,kDAAkD;IAClD,uDAAuD;IACvD,8CAA8C;IAC9C,qDAAqD;IACrD,oDAAoD;IACpD,mDAAmD;IACnD,q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EF,OAAO,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CACrB,QAAiC;QAEjC,MAAM,aAAa,GAAG,QAAoB,CAAC;QAC3C,MAAM,MAAM,GAAI,aAAqB,CAAC,MAAM,IAAK,aAAqB,CAAC,QAAQ,CAAC;QAEhF,MAAM,eAAe,GAAG,IAAI,iBAAc,CACxC,aAAa,CAAC,MAAgB,EAC9B,SAAS,EACT,MAAM,CACP,CAAC;QAEF,OAAO,MAAM,eAAe,CAAC,eAAe,EAAE,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kBAAkB,CACtB,QAAiC,EACjC,MAAc;QAEd,MAAM,aAAa,GAAG,QAAoB,CAAC;QAC3C,MAAM,MAAM,GAAI,aAAqB,CAAC,MAAM,IAAK,aAAqB,CAAC,QAAQ,CAAC;QAEhF,MAAM,eAAe,GAAG,IAAI,iBAAc,CACxC,aAAa,CAAC,MAAgB,EAC9B,SAAS,EACT,MAAM,CACP,CAAC;QAEF,OAAO,MAAM,eAAe,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF;AA9VD,oCA8VC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export declare const TOKENIZED_METADATA = "META-INF/TOKEN.NZIP";
|
|
2
|
+
export declare const TOKENIZED_METADATA_LEGACY = "META-INF/NZIP.TOKEN";
|
|
3
|
+
export interface ContractConfig {
|
|
4
|
+
address: string;
|
|
5
|
+
network: string;
|
|
6
|
+
chainId: number;
|
|
7
|
+
explorerUrl: string;
|
|
8
|
+
rpcUrls: string[];
|
|
9
|
+
version: string;
|
|
10
|
+
registryAddress?: string;
|
|
11
|
+
registryVersion?: string;
|
|
12
|
+
nameAliases?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare const CONTRACT_CONFIGS: Record<number, ContractConfig>;
|
|
15
|
+
export declare const NZIP_CONTRACT_ABI: string[];
|
|
16
|
+
export declare const NZIP_CONTRACT_ABI_V250: string[];
|
|
17
|
+
export declare const NZIP_TIMESTAMP_REG_ABI: string[];
|
|
18
|
+
export declare const TIMESTAMP_PROOF_NFT_ABI: string[];
|
|
19
|
+
export declare const UNIFIED_NFT_VERIFY_ABI: string[];
|
|
20
|
+
export declare const NZIP_CONTRACT_ABI_WEB3: ({
|
|
21
|
+
inputs: {
|
|
22
|
+
name: string;
|
|
23
|
+
type: string;
|
|
24
|
+
}[];
|
|
25
|
+
name: string;
|
|
26
|
+
outputs: {
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
}[];
|
|
30
|
+
stateMutability: string;
|
|
31
|
+
type: string;
|
|
32
|
+
anonymous?: undefined;
|
|
33
|
+
} | {
|
|
34
|
+
inputs: {
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
}[];
|
|
38
|
+
name: string;
|
|
39
|
+
outputs: {
|
|
40
|
+
components: {
|
|
41
|
+
name: string;
|
|
42
|
+
type: string;
|
|
43
|
+
}[];
|
|
44
|
+
name: string;
|
|
45
|
+
type: string;
|
|
46
|
+
}[];
|
|
47
|
+
stateMutability: string;
|
|
48
|
+
type: string;
|
|
49
|
+
anonymous?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
anonymous: boolean;
|
|
52
|
+
inputs: {
|
|
53
|
+
indexed: boolean;
|
|
54
|
+
name: string;
|
|
55
|
+
type: string;
|
|
56
|
+
}[];
|
|
57
|
+
name: string;
|
|
58
|
+
type: string;
|
|
59
|
+
outputs?: undefined;
|
|
60
|
+
stateMutability?: undefined;
|
|
61
|
+
})[];
|
|
62
|
+
export declare const DEFAULT_NETWORK = 84532;
|
|
63
|
+
export declare const CURRENT_DEPLOYMENT: ContractConfig;
|
|
64
|
+
/** Default contract version used when version is unspecified (e.g. legacy metadata). Prefer v2.50. */
|
|
65
|
+
export declare const DEFAULT_CONTRACT_VERSION = "2.50";
|
|
66
|
+
export declare const getContractConfig: (chainId: number) => ContractConfig;
|
|
67
|
+
export declare const getSupportedNetworks: () => number[];
|
|
68
|
+
export declare const isNetworkSupported: (chainId: number) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Normalize network name for matching (lowercase, trim, replace spaces with hyphens)
|
|
71
|
+
*/
|
|
72
|
+
export declare function normalizeNetworkName(networkName: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get chain ID by network name (supports aliases)
|
|
75
|
+
* Returns chain ID if found, null otherwise
|
|
76
|
+
*/
|
|
77
|
+
export declare function getChainIdByName(networkName: string): number | null;
|
|
78
|
+
/**
|
|
79
|
+
* Get network configuration by network name (supports aliases)
|
|
80
|
+
* Returns ContractConfig if found, null otherwise
|
|
81
|
+
*/
|
|
82
|
+
export declare function getNetworkByName(networkName: string): ContractConfig | null;
|
|
83
|
+
/**
|
|
84
|
+
* Get all supported network name aliases
|
|
85
|
+
* Returns array of all supported network names (primary + aliases)
|
|
86
|
+
*/
|
|
87
|
+
export declare function getSupportedNetworkNames(): string[];
|
|
88
|
+
/**
|
|
89
|
+
* Get contract adapter for a given chain ID
|
|
90
|
+
* Uses the version from CONTRACT_CONFIGS to select the appropriate adapter
|
|
91
|
+
* @param chainId Chain ID
|
|
92
|
+
* @returns ContractVersionAdapter instance
|
|
93
|
+
* @throws Error if chainId not found or version not supported
|
|
94
|
+
*/
|
|
95
|
+
export declare function getContractAdapter(chainId: number): import('./adapters/ContractVersionAdapter').ContractVersionAdapter;
|
|
96
|
+
/**
|
|
97
|
+
* Get contract adapter by version string
|
|
98
|
+
* @param version Contract version (e.g., "2.11", "2.10")
|
|
99
|
+
* @returns ContractVersionAdapter instance
|
|
100
|
+
* @throws Error if version not supported
|
|
101
|
+
*/
|
|
102
|
+
export declare function getContractAdapterByVersion(version: string): import('./adapters/ContractVersionAdapter').ContractVersionAdapter;
|
|
103
|
+
/**
|
|
104
|
+
* Fuzzy match network name (for backward compatibility)
|
|
105
|
+
* Handles partial matches like "sepolia" matching "Base Sepolia" or "Arbitrum Sepolia"
|
|
106
|
+
* Returns best match or null
|
|
107
|
+
*/
|
|
108
|
+
export declare function fuzzyMatchNetworkName(networkName: string): ContractConfig | null;
|
|
109
|
+
/**
|
|
110
|
+
* Validate that a token ID is a valid uint256 format
|
|
111
|
+
* Token IDs must be numeric strings that can be converted to BigInt and be within uint256 bounds
|
|
112
|
+
*
|
|
113
|
+
* @param tokenId Token ID string to validate
|
|
114
|
+
* @returns Validation result with success status and error message if failed
|
|
115
|
+
*/
|
|
116
|
+
export declare function validateTokenId(tokenId: string): {
|
|
117
|
+
success: boolean;
|
|
118
|
+
error?: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Validate that an Ethereum address is in the correct format
|
|
122
|
+
* Uses ethers.js validation to ensure proper format and checksum
|
|
123
|
+
*
|
|
124
|
+
* @param address Ethereum address to validate
|
|
125
|
+
* @returns Validation result with success status and error message if failed
|
|
126
|
+
*/
|
|
127
|
+
export declare function validateEthereumAddress(address: string): {
|
|
128
|
+
success: boolean;
|
|
129
|
+
error?: string;
|
|
130
|
+
normalizedAddress?: string;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Sanitize and validate network name
|
|
134
|
+
* Removes leading/trailing whitespace, validates length, and removes potentially dangerous characters
|
|
135
|
+
*
|
|
136
|
+
* @param networkName Network name to sanitize
|
|
137
|
+
* @returns Validation result with success status, sanitized name, and error message if failed
|
|
138
|
+
*/
|
|
139
|
+
export declare function sanitizeNetworkName(networkName: string): {
|
|
140
|
+
success: boolean;
|
|
141
|
+
sanitized?: string;
|
|
142
|
+
error?: string;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Validate that a merkle root is in the correct format
|
|
146
|
+
* Merkle roots should be valid hexadecimal strings of 64 characters (SHA-256 hash)
|
|
147
|
+
*
|
|
148
|
+
* @param merkleRoot Merkle root string to validate
|
|
149
|
+
* @returns Validation result with success status and error message if failed
|
|
150
|
+
*/
|
|
151
|
+
export declare function validateMerkleRootFormat(merkleRoot: string): {
|
|
152
|
+
success: boolean;
|
|
153
|
+
error?: string;
|
|
154
|
+
normalized?: string;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Validate that a contract address matches the expected contract address for a network
|
|
158
|
+
* This prevents attackers from creating fake metadata pointing to malicious contracts
|
|
159
|
+
*
|
|
160
|
+
* @param contractAddress Contract address to validate
|
|
161
|
+
* @param networkChainId Chain ID of the network
|
|
162
|
+
* @param debug Optional debug flag for logging
|
|
163
|
+
* @returns Validation result with success status and error message if failed
|
|
164
|
+
*/
|
|
165
|
+
export declare function validateContractAddress(contractAddress: string, networkChainId: number, debug?: boolean): {
|
|
166
|
+
success: boolean;
|
|
167
|
+
error?: string;
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/core/contracts.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,wBAAa,CAAC;AAC7C,eAAO,MAAM,yBAAyB,wBAAoB,CAAC;AAK3D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA8E3D,CAAA;AAID,eAAO,MAAM,iBAAiB,UAc7B,CAAA;AAGD,eAAO,MAAM,sBAAsB,UAyClC,CAAA;AAGD,eAAO,MAAM,sBAAsB,UAgBlC,CAAC;AAIF,eAAO,MAA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