Skip to content

Commit

Permalink
修复批量mint问题
Browse files Browse the repository at this point in the history
  • Loading branch information
LidamaoHub committed Oct 31, 2023
1 parent a08502b commit b46c32e
Show file tree
Hide file tree
Showing 11 changed files with 3,241 additions and 3,374 deletions.
50 changes: 25 additions & 25 deletions packages/contracts/out/IWorld.sol/IWorld.json
Original file line number Diff line number Diff line change
Expand Up @@ -3888,16 +3888,16 @@
116709,
116675,
71348,
127746,
127655,
127639,
127642,
127694,
171404,
127684,
127673,
127739,
127648,
127632,
127635,
127687,
171397,
127677,
127666,
64435,
124912,
124905,
64393,
64426,
64399,
Expand All @@ -3908,22 +3908,22 @@
"nameLocation": "735:6:166",
"scope": 116931,
"usedErrors": [
124877,
124883,
124885,
124887,
124893,
124899,
124905,
124911,
171373,
171377,
171383,
171387,
171391,
171395,
171399,
171403
124870,
124876,
124878,
124880,
124886,
124892,
124898,
124904,
171366,
171370,
171376,
171380,
171384,
171388,
171392,
171396
]
}
],
Expand Down
8 changes: 7 additions & 1 deletion packages/contracts/out/Loot.sol/MLoot.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,13 @@
"type": "function"
},
{
"inputs": [],
"inputs": [
{
"internalType": "address",
"name": "_addr",
"type": "address"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
Expand Down
2,570 changes: 1,224 additions & 1,346 deletions packages/contracts/out/Loot.sol/MLoot.json

Large diffs are not rendered by default.

556 changes: 328 additions & 228 deletions packages/contracts/out/Plugin.sol/MPlugin.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion packages/contracts/out/User.sol/MUser.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@
"type": "function"
},
{
"inputs": [],
"inputs": [
{
"internalType": "address",
"name": "_addr",
"type": "address"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
Expand Down
3,394 changes: 1,636 additions & 1,758 deletions packages/contracts/out/User.sol/MUser.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions packages/contracts/src/other/Loot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ contract MLoot is Suit, ERC721,MRandom {

function revealNFT(uint256 _tokenId) external {
Loot storage loot = lootList[_tokenId];
require(loot.owner == msg.sender, "only owner can reveal the box");
uint8[] memory random_numbers = getRandom(loot.randomId, 8,waitBlockCount);
loot.Weapon = luck(random_numbers[0], weapons);
loot.Chest = luck(random_numbers[1], chestArmor);
Expand All @@ -210,14 +209,14 @@ contract MLoot is Suit, ERC721,MRandom {
loot.state = RandomState.Confirmed;
}

function mint() external {
function mint(address _addr) external {
// init loot box
Loot storage loot = lootList[tokenId];
loot.owner = msg.sender;
loot.owner = _addr;
loot.state = RandomState.Pending;
loot.randomId = randomId;
requestRandom(randomId);
_mint(msg.sender, tokenId);
_mint(_addr, tokenId);
tokenId++;
randomId++;
}
Expand Down
7 changes: 4 additions & 3 deletions packages/contracts/src/other/Plugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ contract MPlugin {
function multMint() external {
User user = User(userAddress);
Loot loot = Loot(lootAddress);
user.mint();
loot.mint();
address _user = msg.sender;
user.mint(_user);
loot.mint(_user);
}

function multRevealNFT(uint256 _lootTokenId,uint256 _userTokenId) external {
Expand All @@ -26,5 +27,5 @@ contract MPlugin {
loot.revealNFT(_lootTokenId);
user.revealNFT(_userTokenId);
}

}
7 changes: 3 additions & 4 deletions packages/contracts/src/other/User.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,20 @@ contract MUser is ERC721, MRandom {

mapping(uint256 => User) public userList;

function mint() external {
function mint(address _addr) external {
// init loot box
User storage user = userList[tokenId];
user.owner = msg.sender;
user.owner = _addr;
user.state = RandomState.Pending;
user.randomId = randomId;
requestRandom(randomId);
_mint(msg.sender, tokenId);
_mint(_addr, tokenId);
tokenId++;
randomId++;
}

function revealNFT(uint256 _tokenId) external {
User storage user = userList[_tokenId];
require(user.owner == msg.sender, "only owner can reveal the box");
uint8[] memory random_numbers = getRandom(
user.randomId,
8,
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/src/systems/library/Interface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ interface User {
function getStructInfo(uint256 tokenId) external view returns (uint256,uint256,uint256,uint256,uint256,uint256);
function ownerOf(uint256 tokenId) external view returns (address);
function getUserTokenIdList() external view returns (uint256[] memory);
function mint() external;
function mint(address _addr) external;
function revealNFT(uint256 _tokenId) external;
}

// Loot
interface Loot {
function ownerOf(uint256 tokenId) external view returns (address);
function getStructInfo(uint256 tokenId) external view returns (string memory,string memory,string memory,string memory,string memory,string memory,string memory,string memory);
function mint() external;
function mint(address _addr) external;
function revealNFT(uint256 _tokenId) external;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/worlds.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"4242": {
"address": "0x7dB56159893190211E4dCAb38f37b4d117E89FC6",
"blockNumber": 29064962
"address": "0x01451FC65Ae8ECcEEbd468b264156ef0EC726f2d",
"blockNumber": 29069437
},
"31337": {
"address": "0x4000F8820522AC96C4221b299876e3e53bCc8525"
Expand Down

0 comments on commit b46c32e

Please sign in to comment.