update claim factory abi and address

This commit is contained in:
zhl 2023-06-14 15:59:33 +08:00
parent d8d0a8a18c
commit 228833aed4
5 changed files with 4504 additions and 3040 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -5,14 +5,16 @@ import "../core/HasSignature.sol";
import "../utils/TimeChecker.sol";
interface IClaimBox {
function mint(address to) external returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function batchMint(
address to,
uint256 count
) external returns (uint256[] memory);
}
contract ClaimBoxFactory is HasSignature, TimeChecker {
address public executor;
mapping(address => bool) public tokenSupported;
mapping(address => uint256) public claimHistory;
event BoxClaimed(
address indexed nftAddress,
@ -47,10 +49,7 @@ contract ClaimBoxFactory is HasSignature, TimeChecker {
) external signatureValid(signature) timeValid(startTime) {
require(tokenSupported[nftAddress], "ClaimBoxFactory: unsupported NFT");
address to = _msgSender();
require(
IClaimBox(nftAddress).balanceOf(to) == 0,
"ClaimBoxFactory: you already have a box"
);
require(claimHistory[to] == 0, "ClaimBoxFactory: claimed");
bytes32 criteriaMessageHash = getMessageHash(
to,
nftAddress,
@ -58,9 +57,10 @@ contract ClaimBoxFactory is HasSignature, TimeChecker {
saltNonce
);
checkSigner(executor, criteriaMessageHash, signature);
uint256 tokenId = IClaimBox(nftAddress).mint(to);
uint256[] memory tokenIds = IClaimBox(nftAddress).batchMint(to, 1);
claimHistory[to] = tokenIds[0];
_useSignature(signature);
emit BoxClaimed(nftAddress, to, saltNonce, tokenId);
emit BoxClaimed(nftAddress, to, saltNonce, tokenIds[0]);
}
function getMessageHash(

View File

@ -1,5 +1,5 @@
const Factory = artifacts.require("activity/ClaimBoxFactory");
const Box = artifacts.require("tokens/erc721/NFTSbt");
const Box = artifacts.require("tokens/erc721/BEBadge");
const base = require("../scripts/base");
const config = require("../config/config");
@ -12,9 +12,9 @@ module.exports = async function (deployer, network, accounts) {
console.log("claim box successfully deployed.");
}
base.updateArray({
name: "NFTSbt",
name: "Gacha",
type: "erc721",
json: "assets/contracts/NFTSbt.json",
json: "assets/contracts/BEBadge.json",
address: boxInstance.address,
network,
});
@ -25,7 +25,7 @@ module.exports = async function (deployer, network, accounts) {
console.log("claim box factory successfully deployed.");
}
base.updateArray({
name: "ClaimBoxFactory",
name: "ClaimGachaFactory",
type: "logic",
json: "assets/contracts/ClaimBoxFactory.json",
address: factoryInstance.address,

View File

@ -54,15 +54,15 @@
"address": "0x1A27515c35a92Fb276c2670fa27C85ffAd75D094"
},
{
"name": "NFTSbt",
"name": "Gacha",
"type": "erc721",
"json": "assets/contracts/NFTSbt.json",
"address": "0x86A8E6a23039c28b57C306b25dF257817957F132"
"json": "assets/contracts/BEBadge.json",
"address": "0xE4546FA6DdC15442a1FED835e7A007b001213495"
},
{
"name": "ClaimBoxFactory",
"name": "ClaimGachaFactory",
"type": "logic",
"json": "assets/contracts/ClaimBoxFactory.json",
"address": "0xF06038807A700d67be3AA8a7D752761EaC88ab82"
"address": "0x41a7f94f0B3b615F84c7084F45556FEf1bd18A18"
}
]