@paulstinchcombe/gasless-nft-tx 0.6.6 → 0.7.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/README.md +41 -10
- package/dist/KAMI-NFTs/KAMI1155C.sol +28 -23
- package/dist/KAMI-NFTs/KAMI721AC.sol +45 -19
- package/dist/KAMI-NFTs/KAMI721C.sol +24 -14
- package/dist/KAMI-NFTs/artifacts/contracts/KAMI1155C.sol/KAMI1155C.dbg.json +1 -1
- package/dist/KAMI-NFTs/artifacts/contracts/KAMI1155C.sol/KAMI1155C.json +41 -7
- package/dist/KAMI-NFTs/artifacts/contracts/KAMI721AC.sol/KAMI721AC.dbg.json +1 -1
- package/dist/KAMI-NFTs/artifacts/contracts/KAMI721AC.sol/KAMI721AC.json +98 -7
- package/dist/KAMI-NFTs/artifacts/contracts/KAMI721C.sol/KAMI721C.dbg.json +1 -1
- package/dist/KAMI-NFTs/artifacts/contracts/KAMI721C.sol/KAMI721C.json +41 -7
- package/dist/KAMI-NFTs/artifacts/contracts/libraries/KamiNFTCore.sol/IExists.dbg.json +1 -1
- package/dist/KAMI-NFTs/artifacts/contracts/libraries/KamiNFTCore.sol/KamiNFTCore.dbg.json +1 -1
- package/dist/KAMI-NFTs/artifacts/contracts/libraries/KamiPlatform.sol/KamiPlatform.dbg.json +1 -1
- package/dist/KAMI-NFTs/artifacts/contracts/libraries/KamiRental.sol/KamiRental.dbg.json +1 -1
- package/dist/KAMI-NFTs/artifacts/contracts/libraries/KamiRoyalty.sol/KamiRoyalty.dbg.json +1 -1
- package/dist/KAMI-NFTs/artifacts/contracts/libraries/KamiTransfer.sol/KamiTransfer.dbg.json +1 -1
- package/dist/kami-gasless-with-libraries.d.ts +0 -3
- package/dist/kami-gasless-with-libraries.d.ts.map +1 -1
- package/dist/kami-gasless-with-libraries.js +5 -10
- package/dist/kami-gasless-with-libraries.js.map +1 -1
- package/dist/kami-simpleaccount-1155c.d.ts +39 -3
- package/dist/kami-simpleaccount-1155c.d.ts.map +1 -1
- package/dist/kami-simpleaccount-1155c.js +123 -6
- package/dist/kami-simpleaccount-1155c.js.map +1 -1
- package/dist/kami-simpleaccount-721ac.d.ts +41 -4
- package/dist/kami-simpleaccount-721ac.d.ts.map +1 -1
- package/dist/kami-simpleaccount-721ac.js +138 -8
- package/dist/kami-simpleaccount-721ac.js.map +1 -1
- package/dist/kami-simpleaccount-721c.d.ts +39 -3
- package/dist/kami-simpleaccount-721c.d.ts.map +1 -1
- package/dist/kami-simpleaccount-721c.js +123 -6
- package/dist/kami-simpleaccount-721c.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -299,9 +299,9 @@ const params: KAMI721CParams = {
|
|
|
299
299
|
name: 'My NFT Collection',
|
|
300
300
|
symbol: 'MNFT',
|
|
301
301
|
baseTokenURI: 'ipfs://QmYourBaseURI/',
|
|
302
|
-
initialMintPrice: parseEther('0.001'), // 0.001 ETH per mint
|
|
303
302
|
platformAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address,
|
|
304
303
|
platformCommissionPercentage: 250, // 2.5%
|
|
304
|
+
adminAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address, // Admin address
|
|
305
305
|
};
|
|
306
306
|
|
|
307
307
|
const result = await deployer.deployKAMI721C(params);
|
|
@@ -332,9 +332,9 @@ const params: KAMI721ACParams = {
|
|
|
332
332
|
name: 'Creator Collection',
|
|
333
333
|
symbol: 'CNFT',
|
|
334
334
|
baseTokenURI: 'ipfs://QmYourBaseURI/',
|
|
335
|
-
initialMintPrice: parseEther('0.001'),
|
|
336
335
|
platformAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address,
|
|
337
336
|
platformCommissionPercentage: 250,
|
|
337
|
+
adminAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address,
|
|
338
338
|
};
|
|
339
339
|
|
|
340
340
|
const result = await deployer.deployKAMI721AC(params);
|
|
@@ -366,9 +366,9 @@ Mint 10 NFTs for nearly the same gas cost as minting 1!
|
|
|
366
366
|
const params: KAMI1155CParams = {
|
|
367
367
|
paymentToken: '0x0000000000000000000000000000000000000000',
|
|
368
368
|
baseTokenURI: 'ipfs://QmYourBaseURI/{id}.json', // {id} auto-replaced
|
|
369
|
-
initialMintPrice: parseEther('0.001'),
|
|
370
369
|
platformAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address,
|
|
371
370
|
platformCommissionPercentage: 250,
|
|
371
|
+
adminAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address,
|
|
372
372
|
};
|
|
373
373
|
|
|
374
374
|
const result = await deployer.deployKAMI1155C(params);
|
|
@@ -410,9 +410,9 @@ Deploy a KAMI721C contract (ERC721 + Creator).
|
|
|
410
410
|
- `name` (string): NFT collection name
|
|
411
411
|
- `symbol` (string): NFT collection symbol
|
|
412
412
|
- `baseTokenURI` (string): Base URI for token metadata
|
|
413
|
-
- `initialMintPrice` (bigint): Price per mint in wei
|
|
414
413
|
- `platformAddress` (Address): Platform fee recipient
|
|
415
414
|
- `platformCommissionPercentage` (number): Platform fee (250 = 2.5%)
|
|
415
|
+
- `adminAddress` (Address): Admin address for contract management
|
|
416
416
|
|
|
417
417
|
**Returns:**
|
|
418
418
|
|
|
@@ -447,9 +447,9 @@ Deploy a KAMI1155C contract (ERC1155 + Creator).
|
|
|
447
447
|
|
|
448
448
|
- `paymentToken` (Address): Payment token address
|
|
449
449
|
- `baseTokenURI` (string): Base URI with {id} placeholder
|
|
450
|
-
- `initialMintPrice` (bigint): Price per token in wei
|
|
451
450
|
- `platformAddress` (Address): Platform fee recipient
|
|
452
451
|
- `platformCommissionPercentage` (number): Platform fee percentage
|
|
452
|
+
- `adminAddress` (Address): Admin address for contract management
|
|
453
453
|
|
|
454
454
|
##### getBalance
|
|
455
455
|
|
|
@@ -564,10 +564,19 @@ See the guide for cost analysis, implementation examples, and when users would n
|
|
|
564
564
|
|
|
565
565
|
## KAMI Handler APIs
|
|
566
566
|
|
|
567
|
-
**Important**: All three KAMI handlers now have consistent APIs! (v0.
|
|
567
|
+
**Important**: All three KAMI handlers now have consistent APIs! (v0.7.0+)
|
|
568
568
|
|
|
569
569
|
👉 **[KAMI721AC Handler API Reference](docs/KAMI721AC_HANDLER_API.md)**
|
|
570
570
|
|
|
571
|
+
**What Changed in v0.7.0:**
|
|
572
|
+
|
|
573
|
+
- ✅ **New Constructor Parameters**: All contracts now require `adminAddress` parameter
|
|
574
|
+
- ✅ **Removed `initialMintPrice`**: Price is now set per-token during minting
|
|
575
|
+
- ✅ **New Methods Added**: `setMintRoyalties`, `setTransferRoyalties`, `setPlatformCommission`, `hasClaimed`, `hasActiveRentals`
|
|
576
|
+
- ✅ **Enhanced Royalty Management**: Token-specific and global royalty controls
|
|
577
|
+
- ✅ **Platform Commission Management**: Dynamic platform fee updates
|
|
578
|
+
- ✅ **Claim Tracking**: Built-in claim status tracking for KAMI721AC
|
|
579
|
+
|
|
571
580
|
**What Changed in v0.5.3:**
|
|
572
581
|
|
|
573
582
|
- ✅ `KAMI721ACSimpleAccountHandler` now matches `KAMI721CSimpleAccountHandler` API
|
|
@@ -575,14 +584,36 @@ See the guide for cost analysis, implementation examples, and when users would n
|
|
|
575
584
|
- ✅ Added missing methods: `setPrice()`, `setTokenURI()`
|
|
576
585
|
- ✅ Batch methods now require `prices` and `uris` arrays
|
|
577
586
|
|
|
578
|
-
**Migration
|
|
587
|
+
**Migration Examples:**
|
|
579
588
|
|
|
580
589
|
```typescript
|
|
581
|
-
// ❌ OLD (v0.
|
|
590
|
+
// ❌ OLD Constructor (v0.6.x)
|
|
591
|
+
const params = {
|
|
592
|
+
paymentToken: '0x...',
|
|
593
|
+
name: 'My NFT',
|
|
594
|
+
symbol: 'NFT',
|
|
595
|
+
baseTokenURI: 'ipfs://...',
|
|
596
|
+
initialMintPrice: parseEther('0.001'), // ❌ Removed
|
|
597
|
+
platformAddress: '0x...',
|
|
598
|
+
platformCommissionPercentage: 250,
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
// ✅ NEW Constructor (v0.7.0+)
|
|
602
|
+
const params = {
|
|
603
|
+
paymentToken: '0x...',
|
|
604
|
+
name: 'My NFT',
|
|
605
|
+
symbol: 'NFT',
|
|
606
|
+
baseTokenURI: 'ipfs://...',
|
|
607
|
+
platformAddress: '0x...',
|
|
608
|
+
platformCommissionPercentage: 250,
|
|
609
|
+
adminAddress: '0x...', // ✅ Required
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
// ❌ OLD Mint (v0.5.2)
|
|
582
613
|
await handler.mint(recipientAddress);
|
|
583
614
|
|
|
584
|
-
// ✅ NEW (v0.
|
|
585
|
-
await handler.mint(recipientAddress, tokenPrice, tokenURI);
|
|
615
|
+
// ✅ NEW Mint (v0.7.0+)
|
|
616
|
+
await handler.mint(recipientAddress, tokenPrice, tokenURI, mintRoyalties);
|
|
586
617
|
```
|
|
587
618
|
|
|
588
619
|
See the guide for complete API reference, migration instructions, and examples.
|
|
@@ -145,7 +145,6 @@ contract KAMI1155C is AccessControl, ERC1155, ERC1155Supply, ERC2981, Pausable {
|
|
|
145
145
|
constructor(
|
|
146
146
|
address paymentToken_,
|
|
147
147
|
string memory baseTokenURI_,
|
|
148
|
-
uint256 /* initialMintPrice_ */,
|
|
149
148
|
address platformAddress_,
|
|
150
149
|
uint96 platformCommissionPercentage_,
|
|
151
150
|
address adminAddress_
|
|
@@ -542,30 +541,33 @@ contract KAMI1155C is AccessControl, ERC1155, ERC1155Supply, ERC2981, Pausable {
|
|
|
542
541
|
* - Caller must have approved sufficient payment tokens
|
|
543
542
|
* - Caller must have sufficient payment token balance
|
|
544
543
|
*/
|
|
545
|
-
function mint(address recipient, uint256 amount, uint256 tokenPrice, string calldata tokenURI) external whenNotPaused {
|
|
544
|
+
function mint(address recipient, uint256 amount, uint256 tokenPrice, string calldata tokenURI, KamiNFTCore.RoyaltyData[] calldata mintRoyalties) external whenNotPaused {
|
|
546
545
|
require(recipient != address(0), "Recipient cannot be zero address");
|
|
547
546
|
require(amount > 0, "Amount must be greater than 0");
|
|
548
|
-
require(tokenPrice > 0, "Price must be greater than 0");
|
|
549
547
|
require(bytes(tokenURI).length > 0, "Token URI cannot be empty");
|
|
550
548
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
549
|
+
if(tokenPrice > 0) {
|
|
550
|
+
uint256 totalPrice = tokenPrice * amount;
|
|
551
|
+
require(PAYMENT_TOKEN.balanceOf(msg.sender) >= totalPrice, "Insufficient payment token balance");
|
|
552
|
+
require(PAYMENT_TOKEN.allowance(msg.sender, address(this)) >= totalPrice, "Insufficient payment token allowance");
|
|
553
|
+
PAYMENT_TOKEN.safeTransferFrom(msg.sender, address(this), totalPrice);
|
|
554
|
+
}
|
|
555
555
|
|
|
556
556
|
uint256 tokenId = _tokenIdCounter.current();
|
|
557
557
|
_tokenIdCounter.increment();
|
|
558
558
|
_mint(recipient, tokenId, amount, "");
|
|
559
559
|
|
|
560
|
+
if(tokenPrice > 0) {
|
|
561
|
+
if(mintRoyalties.length > 0) {
|
|
562
|
+
KamiRoyalty.setTokenMintRoyalties(tokenId, mintRoyalties, KamiNFTCore.getExternalExistsReference(address(this)));
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
560
566
|
// Set token price and URI
|
|
561
567
|
tokenPrices[tokenId] = tokenPrice;
|
|
562
568
|
tokenURIs[tokenId] = tokenURI;
|
|
563
569
|
|
|
564
|
-
|
|
565
|
-
// Temporarily comment out royalty distribution to fix test issues
|
|
566
|
-
// KamiRoyalty.distributeMintRoyalties(tokenId, totalPrice, PAYMENT_TOKEN);
|
|
567
|
-
|
|
568
|
-
emit TokenMinted(recipient, tokenId, amount, totalPrice);
|
|
570
|
+
emit TokenMinted(recipient, tokenId, amount, tokenPrice * amount);
|
|
569
571
|
}
|
|
570
572
|
|
|
571
573
|
/**
|
|
@@ -579,30 +581,33 @@ contract KAMI1155C is AccessControl, ERC1155, ERC1155Supply, ERC2981, Pausable {
|
|
|
579
581
|
* - Caller must have approved sufficient payment tokens
|
|
580
582
|
* - Caller must have sufficient payment token balance
|
|
581
583
|
*/
|
|
582
|
-
function mintFor(address recipient, uint256 amount, uint256 tokenPrice, string calldata tokenURI) external whenNotPaused {
|
|
584
|
+
function mintFor(address recipient, uint256 amount, uint256 tokenPrice, string calldata tokenURI, KamiNFTCore.RoyaltyData[] calldata mintRoyalties) external whenNotPaused {
|
|
583
585
|
require(amount > 0, "Amount must be greater than 0");
|
|
584
586
|
require(recipient != address(0), "Recipient cannot be zero address");
|
|
585
|
-
require(tokenPrice > 0, "Price must be greater than 0");
|
|
586
587
|
require(bytes(tokenURI).length > 0, "Token URI cannot be empty");
|
|
587
588
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
589
|
+
if(tokenPrice > 0) {
|
|
590
|
+
uint256 totalPrice = tokenPrice * amount;
|
|
591
|
+
require(PAYMENT_TOKEN.balanceOf(msg.sender) >= totalPrice, "Insufficient payment token balance");
|
|
592
|
+
require(PAYMENT_TOKEN.allowance(msg.sender, address(this)) >= totalPrice, "Insufficient payment token allowance");
|
|
593
|
+
PAYMENT_TOKEN.safeTransferFrom(msg.sender, address(this), totalPrice);
|
|
594
|
+
}
|
|
592
595
|
|
|
593
596
|
uint256 tokenId = _tokenIdCounter.current();
|
|
594
597
|
_tokenIdCounter.increment();
|
|
595
598
|
_mint(recipient, tokenId, amount, "");
|
|
596
599
|
|
|
600
|
+
if(tokenPrice > 0) {
|
|
601
|
+
if(mintRoyalties.length > 0) {
|
|
602
|
+
KamiRoyalty.setTokenMintRoyalties(tokenId, mintRoyalties, KamiNFTCore.getExternalExistsReference(address(this)));
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
597
606
|
// Set token price and URI
|
|
598
607
|
tokenPrices[tokenId] = tokenPrice;
|
|
599
608
|
tokenURIs[tokenId] = tokenURI;
|
|
600
609
|
|
|
601
|
-
|
|
602
|
-
// Temporarily comment out royalty distribution to fix test issues
|
|
603
|
-
// KamiRoyalty.distributeMintRoyalties(tokenId, totalPrice, PAYMENT_TOKEN);
|
|
604
|
-
|
|
605
|
-
emit TokenMinted(recipient, tokenId, amount, totalPrice);
|
|
610
|
+
emit TokenMinted(recipient, tokenId, amount, tokenPrice * amount);
|
|
606
611
|
}
|
|
607
612
|
|
|
608
613
|
/**
|
|
@@ -135,7 +135,6 @@ contract KAMI721AC is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
135
135
|
string memory name_,
|
|
136
136
|
string memory symbol_,
|
|
137
137
|
string memory baseTokenURI_,
|
|
138
|
-
uint256 /* initialMintPrice_ */,
|
|
139
138
|
address platformAddress_,
|
|
140
139
|
uint96 platformCommissionPercentage_,
|
|
141
140
|
address adminAddress_
|
|
@@ -593,26 +592,30 @@ contract KAMI721AC is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
593
592
|
* @param recipient Address to receive the minted token
|
|
594
593
|
* @param tokenPrice Price for this specific token
|
|
595
594
|
* @param uri Individual URI for this token's metadata
|
|
595
|
+
* @param mintRoyalties Array of royalty receivers and percentages
|
|
596
596
|
*/
|
|
597
|
-
function mint(address recipient, uint256 tokenPrice, string calldata uri) external whenNotPaused {
|
|
598
|
-
if (recipient == address(0)) revert ZeroAddress();
|
|
599
|
-
if (tokenPrice == 0) revert InvalidPrice();
|
|
597
|
+
function mint(address recipient, uint256 tokenPrice, string calldata uri, KamiNFTCore.RoyaltyData[] calldata mintRoyalties) external whenNotPaused {
|
|
598
|
+
if (recipient == address(0)) revert ZeroAddress();
|
|
600
599
|
if (bytes(uri).length == 0) revert EmptyTokenURI();
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
600
|
+
|
|
601
|
+
if(tokenPrice > 0) {
|
|
602
|
+
PAYMENT_TOKEN.safeTransferFrom(msg.sender, address(this), tokenPrice);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
605
|
// Mint token
|
|
606
606
|
uint256 tokenId = _tokenIdCounter.current();
|
|
607
607
|
_tokenIdCounter.increment();
|
|
608
608
|
_safeMint(recipient, tokenId);
|
|
609
609
|
|
|
610
|
+
if(tokenPrice > 0) {
|
|
611
|
+
if(mintRoyalties.length > 0) {
|
|
612
|
+
KamiRoyalty.setTokenMintRoyalties(tokenId, mintRoyalties, KamiNFTCore.getExternalExistsReference(address(this)));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
610
616
|
// Set token price and URI
|
|
611
617
|
tokenPrices[tokenId] = tokenPrice;
|
|
612
618
|
tokenURIs[tokenId] = uri;
|
|
613
|
-
|
|
614
|
-
// Distribute mint royalties
|
|
615
|
-
KamiRoyalty.distributeMintRoyalties(tokenId, tokenPrice, PAYMENT_TOKEN);
|
|
616
619
|
}
|
|
617
620
|
|
|
618
621
|
// ============ CLAIMING FUNCTIONS ============
|
|
@@ -624,16 +627,27 @@ contract KAMI721AC is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
624
627
|
* - Caller must have approved sufficient payment tokens
|
|
625
628
|
* - Caller must have sufficient payment token balance
|
|
626
629
|
*/
|
|
627
|
-
function claim(uint256 tokenPrice, string calldata uri) external {
|
|
630
|
+
function claim(uint256 tokenPrice, string calldata uri, KamiNFTCore.RoyaltyData[] calldata mintRoyalties) external {
|
|
628
631
|
if (hasClaimed[msg.sender]) revert AlreadyClaimed();
|
|
629
632
|
if (tokenPrice == 0) revert InvalidPrice();
|
|
630
633
|
if (bytes(uri).length == 0) revert EmptyTokenURI();
|
|
631
|
-
|
|
634
|
+
|
|
635
|
+
if(tokenPrice > 0) {
|
|
636
|
+
PAYMENT_TOKEN.safeTransferFrom(msg.sender, address(this), tokenPrice);
|
|
637
|
+
}
|
|
638
|
+
|
|
632
639
|
uint256 tokenId = _tokenIdCounter.current();
|
|
633
640
|
_tokenIdCounter.increment();
|
|
634
641
|
_safeMint(msg.sender, tokenId);
|
|
635
642
|
tokenPrices[tokenId] = tokenPrice;
|
|
636
643
|
tokenURIs[tokenId] = uri;
|
|
644
|
+
|
|
645
|
+
if(tokenPrice > 0) {
|
|
646
|
+
if(mintRoyalties.length > 0) {
|
|
647
|
+
KamiRoyalty.setTokenMintRoyalties(tokenId, mintRoyalties, KamiNFTCore.getExternalExistsReference(address(this)));
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
637
651
|
KamiRoyalty.distributeMintRoyalties(tokenId, tokenPrice, PAYMENT_TOKEN);
|
|
638
652
|
hasClaimed[msg.sender] = true;
|
|
639
653
|
emit TokenClaimed(msg.sender, tokenId, tokenPrice);
|
|
@@ -649,7 +663,7 @@ contract KAMI721AC is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
649
663
|
* - Recipients array must not be empty or exceed 100
|
|
650
664
|
* - No zero addresses
|
|
651
665
|
*/
|
|
652
|
-
function batchClaimFor(address[] calldata recipients, uint256[] calldata prices, string[] calldata uris) external {
|
|
666
|
+
function batchClaimFor(address[] calldata recipients, uint256[] calldata prices, string[] calldata uris, KamiNFTCore.RoyaltyData[] calldata mintRoyalties) external {
|
|
653
667
|
if (!hasRole(OWNER_ROLE, msg.sender)) revert CallerNotOwner();
|
|
654
668
|
if (recipients.length == 0) revert EmptyRecipientsArray();
|
|
655
669
|
if (recipients.length > 100) revert TooManyRecipients();
|
|
@@ -662,7 +676,9 @@ contract KAMI721AC is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
662
676
|
if (bytes(uris[i]).length == 0) revert EmptyTokenURI();
|
|
663
677
|
totalCost += prices[i];
|
|
664
678
|
}
|
|
665
|
-
|
|
679
|
+
if(totalCost > 0) {
|
|
680
|
+
PAYMENT_TOKEN.safeTransferFrom(msg.sender, address(this), totalCost);
|
|
681
|
+
}
|
|
666
682
|
|
|
667
683
|
for (uint256 i = 0; i < recipients.length; i++) {
|
|
668
684
|
address recipient = recipients[i];
|
|
@@ -673,8 +689,13 @@ contract KAMI721AC is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
673
689
|
_safeMint(recipient, tokenId);
|
|
674
690
|
tokenPrices[tokenId] = prices[i];
|
|
675
691
|
tokenURIs[tokenId] = uris[i];
|
|
676
|
-
KamiRoyalty.distributeMintRoyalties(tokenId, prices[i], PAYMENT_TOKEN);
|
|
677
692
|
hasClaimed[recipient] = true;
|
|
693
|
+
if(prices[i] > 0) {
|
|
694
|
+
if(mintRoyalties.length > 0) {
|
|
695
|
+
KamiRoyalty.setTokenMintRoyalties(tokenId, mintRoyalties, KamiNFTCore.getExternalExistsReference(address(this)));
|
|
696
|
+
}
|
|
697
|
+
KamiRoyalty.distributeMintRoyalties(tokenId, prices[i], PAYMENT_TOKEN);
|
|
698
|
+
}
|
|
678
699
|
}
|
|
679
700
|
emit BatchClaimedFor(msg.sender, recipients, totalCost);
|
|
680
701
|
}
|
|
@@ -688,7 +709,7 @@ contract KAMI721AC is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
688
709
|
* - Recipients array must not be empty or exceed 100
|
|
689
710
|
* - No zero addresses
|
|
690
711
|
*/
|
|
691
|
-
function batchClaim(address[] calldata recipients, uint256[] calldata prices, string[] calldata uris) external {
|
|
712
|
+
function batchClaim(address[] calldata recipients, uint256[] calldata prices, string[] calldata uris, KamiNFTCore.RoyaltyData[] calldata mintRoyalties) external {
|
|
692
713
|
if (recipients.length == 0) revert EmptyRecipientsArray();
|
|
693
714
|
if (recipients.length > 100) revert TooManyRecipients();
|
|
694
715
|
if (recipients.length != prices.length) revert ArrayLengthMismatch();
|
|
@@ -700,13 +721,18 @@ contract KAMI721AC is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
700
721
|
if (hasClaimed[recipient]) revert RecipientAlreadyClaimed();
|
|
701
722
|
if (prices[i] == 0) revert InvalidPrice();
|
|
702
723
|
if (bytes(uris[i]).length == 0) revert EmptyTokenURI();
|
|
703
|
-
|
|
724
|
+
if(prices[i] > 0) {
|
|
725
|
+
PAYMENT_TOKEN.safeTransferFrom(recipient, address(this), prices[i]);
|
|
726
|
+
}
|
|
704
727
|
uint256 tokenId = _tokenIdCounter.current();
|
|
705
728
|
_tokenIdCounter.increment();
|
|
706
729
|
_safeMint(recipient, tokenId);
|
|
707
730
|
tokenPrices[tokenId] = prices[i];
|
|
708
731
|
tokenURIs[tokenId] = uris[i];
|
|
709
|
-
|
|
732
|
+
if(mintRoyalties.length > 0) {
|
|
733
|
+
KamiRoyalty.setTokenMintRoyalties(tokenId, mintRoyalties, KamiNFTCore.getExternalExistsReference(address(this)));
|
|
734
|
+
KamiRoyalty.distributeMintRoyalties(tokenId, prices[i], PAYMENT_TOKEN);
|
|
735
|
+
}
|
|
710
736
|
hasClaimed[recipient] = true;
|
|
711
737
|
}
|
|
712
738
|
emit BatchClaimed(msg.sender, recipients);
|
|
@@ -116,7 +116,6 @@ contract KAMI721C is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
116
116
|
string memory name_,
|
|
117
117
|
string memory symbol_,
|
|
118
118
|
string memory baseTokenURI_,
|
|
119
|
-
uint256 /* initialMintPrice_ */,
|
|
120
119
|
address platformAddress_,
|
|
121
120
|
uint96 platformCommissionPercentage_,
|
|
122
121
|
address adminAddress_
|
|
@@ -157,20 +156,27 @@ contract KAMI721C is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
157
156
|
* @param recipient Address to receive the minted token
|
|
158
157
|
* @param tokenPrice Price for this specific token
|
|
159
158
|
* @param uri Individual URI for this token's metadata
|
|
159
|
+
* @param mintRoyalties Array of royalty receivers and percentages
|
|
160
160
|
*/
|
|
161
|
-
function mint(address recipient, uint256 tokenPrice, string calldata uri) external whenNotPaused {
|
|
162
|
-
if (recipient == address(0)) revert ZeroAddress();
|
|
163
|
-
if (tokenPrice == 0) revert InvalidPrice();
|
|
161
|
+
function mint(address recipient, uint256 tokenPrice, string calldata uri, KamiNFTCore.RoyaltyData[] calldata mintRoyalties) external whenNotPaused {
|
|
162
|
+
if (recipient == address(0)) revert ZeroAddress();
|
|
164
163
|
if (bytes(uri).length == 0) revert EmptyTokenURI();
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
|
|
165
|
+
if(tokenPrice > 0) {
|
|
166
|
+
PAYMENT_TOKEN.safeTransferFrom(msg.sender, address(this), tokenPrice);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
169
|
// Mint token
|
|
170
170
|
uint256 tokenId = _tokenIdCounter.current();
|
|
171
171
|
_tokenIdCounter.increment();
|
|
172
172
|
_safeMint(recipient, tokenId);
|
|
173
173
|
|
|
174
|
+
if(tokenPrice > 0) {
|
|
175
|
+
if(mintRoyalties.length > 0) {
|
|
176
|
+
KamiRoyalty.setTokenMintRoyalties(tokenId, mintRoyalties, KamiNFTCore.getExternalExistsReference(address(this)));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
174
180
|
// Set token price and URI
|
|
175
181
|
tokenPrices[tokenId] = tokenPrice;
|
|
176
182
|
tokenURIs[tokenId] = uri;
|
|
@@ -186,25 +192,29 @@ contract KAMI721C is AccessControl, ERC721Enumerable, ERC2981, Pausable {
|
|
|
186
192
|
* @param tokenPrice Price for this specific token
|
|
187
193
|
* @param uri Individual URI for this token's metadata
|
|
188
194
|
*/
|
|
189
|
-
function mintFor(address recipient, uint256 tokenPrice, string calldata uri) external whenNotPaused {
|
|
190
|
-
if (tokenPrice == 0) revert InvalidPrice();
|
|
195
|
+
function mintFor(address recipient, uint256 tokenPrice, string calldata uri, KamiNFTCore.RoyaltyData[] calldata mintRoyalties) external whenNotPaused {
|
|
191
196
|
if (recipient == address(0)) revert ZeroAddress();
|
|
192
197
|
if (bytes(uri).length == 0) revert EmptyTokenURI();
|
|
193
198
|
|
|
194
199
|
// Transfer payment from caller
|
|
195
|
-
|
|
200
|
+
if(tokenPrice > 0) {
|
|
201
|
+
PAYMENT_TOKEN.safeTransferFrom(msg.sender, address(this), tokenPrice);
|
|
202
|
+
}
|
|
196
203
|
|
|
197
204
|
// Mint token to recipient
|
|
198
205
|
uint256 tokenId = _tokenIdCounter.current();
|
|
199
206
|
_tokenIdCounter.increment();
|
|
200
207
|
_safeMint(recipient, tokenId);
|
|
201
208
|
|
|
209
|
+
if(tokenPrice > 0) {
|
|
210
|
+
if(mintRoyalties.length > 0) {
|
|
211
|
+
KamiRoyalty.setTokenMintRoyalties(tokenId, mintRoyalties, KamiNFTCore.getExternalExistsReference(address(this)));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
202
215
|
// Set token price and URI
|
|
203
216
|
tokenPrices[tokenId] = tokenPrice;
|
|
204
217
|
tokenURIs[tokenId] = uri;
|
|
205
|
-
|
|
206
|
-
// Distribute mint royalties
|
|
207
|
-
KamiRoyalty.distributeMintRoyalties(tokenId, tokenPrice, PAYMENT_TOKEN);
|
|
208
218
|
}
|
|
209
219
|
|
|
210
220
|
/**
|