update claim factory abi and address
This commit is contained in:
parent
d8d0a8a18c
commit
228833aed4
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -5,14 +5,16 @@ import "../core/HasSignature.sol";
|
|||||||
import "../utils/TimeChecker.sol";
|
import "../utils/TimeChecker.sol";
|
||||||
|
|
||||||
interface IClaimBox {
|
interface IClaimBox {
|
||||||
function mint(address to) external returns (uint256);
|
function batchMint(
|
||||||
|
address to,
|
||||||
function balanceOf(address owner) external view returns (uint256);
|
uint256 count
|
||||||
|
) external returns (uint256[] memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ClaimBoxFactory is HasSignature, TimeChecker {
|
contract ClaimBoxFactory is HasSignature, TimeChecker {
|
||||||
address public executor;
|
address public executor;
|
||||||
mapping(address => bool) public tokenSupported;
|
mapping(address => bool) public tokenSupported;
|
||||||
|
mapping(address => uint256) public claimHistory;
|
||||||
|
|
||||||
event BoxClaimed(
|
event BoxClaimed(
|
||||||
address indexed nftAddress,
|
address indexed nftAddress,
|
||||||
@ -47,10 +49,7 @@ contract ClaimBoxFactory is HasSignature, TimeChecker {
|
|||||||
) external signatureValid(signature) timeValid(startTime) {
|
) external signatureValid(signature) timeValid(startTime) {
|
||||||
require(tokenSupported[nftAddress], "ClaimBoxFactory: unsupported NFT");
|
require(tokenSupported[nftAddress], "ClaimBoxFactory: unsupported NFT");
|
||||||
address to = _msgSender();
|
address to = _msgSender();
|
||||||
require(
|
require(claimHistory[to] == 0, "ClaimBoxFactory: claimed");
|
||||||
IClaimBox(nftAddress).balanceOf(to) == 0,
|
|
||||||
"ClaimBoxFactory: you already have a box"
|
|
||||||
);
|
|
||||||
bytes32 criteriaMessageHash = getMessageHash(
|
bytes32 criteriaMessageHash = getMessageHash(
|
||||||
to,
|
to,
|
||||||
nftAddress,
|
nftAddress,
|
||||||
@ -58,9 +57,10 @@ contract ClaimBoxFactory is HasSignature, TimeChecker {
|
|||||||
saltNonce
|
saltNonce
|
||||||
);
|
);
|
||||||
checkSigner(executor, criteriaMessageHash, signature);
|
checkSigner(executor, criteriaMessageHash, signature);
|
||||||
uint256 tokenId = IClaimBox(nftAddress).mint(to);
|
uint256[] memory tokenIds = IClaimBox(nftAddress).batchMint(to, 1);
|
||||||
|
claimHistory[to] = tokenIds[0];
|
||||||
_useSignature(signature);
|
_useSignature(signature);
|
||||||
emit BoxClaimed(nftAddress, to, saltNonce, tokenId);
|
emit BoxClaimed(nftAddress, to, saltNonce, tokenIds[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessageHash(
|
function getMessageHash(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const Factory = artifacts.require("activity/ClaimBoxFactory");
|
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 base = require("../scripts/base");
|
||||||
const config = require("../config/config");
|
const config = require("../config/config");
|
||||||
|
|
||||||
@ -12,9 +12,9 @@ module.exports = async function (deployer, network, accounts) {
|
|||||||
console.log("claim box successfully deployed.");
|
console.log("claim box successfully deployed.");
|
||||||
}
|
}
|
||||||
base.updateArray({
|
base.updateArray({
|
||||||
name: "NFTSbt",
|
name: "Gacha",
|
||||||
type: "erc721",
|
type: "erc721",
|
||||||
json: "assets/contracts/NFTSbt.json",
|
json: "assets/contracts/BEBadge.json",
|
||||||
address: boxInstance.address,
|
address: boxInstance.address,
|
||||||
network,
|
network,
|
||||||
});
|
});
|
||||||
@ -25,7 +25,7 @@ module.exports = async function (deployer, network, accounts) {
|
|||||||
console.log("claim box factory successfully deployed.");
|
console.log("claim box factory successfully deployed.");
|
||||||
}
|
}
|
||||||
base.updateArray({
|
base.updateArray({
|
||||||
name: "ClaimBoxFactory",
|
name: "ClaimGachaFactory",
|
||||||
type: "logic",
|
type: "logic",
|
||||||
json: "assets/contracts/ClaimBoxFactory.json",
|
json: "assets/contracts/ClaimBoxFactory.json",
|
||||||
address: factoryInstance.address,
|
address: factoryInstance.address,
|
||||||
|
@ -54,15 +54,15 @@
|
|||||||
"address": "0x1A27515c35a92Fb276c2670fa27C85ffAd75D094"
|
"address": "0x1A27515c35a92Fb276c2670fa27C85ffAd75D094"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "NFTSbt",
|
"name": "Gacha",
|
||||||
"type": "erc721",
|
"type": "erc721",
|
||||||
"json": "assets/contracts/NFTSbt.json",
|
"json": "assets/contracts/BEBadge.json",
|
||||||
"address": "0x86A8E6a23039c28b57C306b25dF257817957F132"
|
"address": "0xE4546FA6DdC15442a1FED835e7A007b001213495"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ClaimBoxFactory",
|
"name": "ClaimGachaFactory",
|
||||||
"type": "logic",
|
"type": "logic",
|
||||||
"json": "assets/contracts/ClaimBoxFactory.json",
|
"json": "assets/contracts/ClaimBoxFactory.json",
|
||||||
"address": "0xF06038807A700d67be3AA8a7D752761EaC88ab82"
|
"address": "0x41a7f94f0B3b615F84c7084F45556FEf1bd18A18"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user