From 22ff29c2c49d38274eff17d77679af569b5f9f05 Mon Sep 17 00:00:00 2001 From: Channing Date: Thu, 25 Jul 2024 14:28:10 -0700 Subject: [PATCH 1/2] Random Games --- contracts/RandomGames.sol | 78 ++++++++++++++++++++++ hardhat.config.ts | 35 ++++++++++ scripts/deployRandomGame.ts | 127 ++++++++++++++++++++++++++++++++++++ scripts/index.ts | 1 + 4 files changed, 241 insertions(+) create mode 100644 contracts/RandomGames.sol create mode 100644 scripts/deployRandomGame.ts diff --git a/contracts/RandomGames.sol b/contracts/RandomGames.sol new file mode 100644 index 00000000..f8616c03 --- /dev/null +++ b/contracts/RandomGames.sol @@ -0,0 +1,78 @@ +//SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; + +import {ERC721CM, ERC721ACQueryable, IERC721A} from "./ERC721CM.sol"; + +/** + * @title RandomGamesMinting + */ +contract RandomGamesMinting is ERC721CM { + address immutable _proxyContract; + + constructor( + string memory collectionName, + string memory collectionSymbol, + string memory tokenURISuffix, + uint256 maxMintableSupply, + uint256 globalWalletLimit, + address cosigner, + uint64 timestampExpirySeconds, + address mintCurrency, + address fundReceiver, + address proxyContract + ) + ERC721CM( + collectionName, + collectionSymbol, + tokenURISuffix, + maxMintableSupply, + globalWalletLimit, + cosigner, + timestampExpirySeconds, + mintCurrency, + fundReceiver + ) + { + _proxyContract = proxyContract; + } + + function setProxyContract(address newProxyContract) external onlyOwner { + _proxyContract = newProxyContract; + } + + function mint( + uint32 qty, + bytes32[] calldata proof, + uint64 timestamp, + bytes calldata signature + ) external override payable virtual nonReentrant { + _mintInternal(qty, msg.sender, 0, proof, timestamp, signature); + + address[] memory minters = new address[](qty); + for (uint256 i = 0; i < qty; i++) { + minters[i] = msg.sender; + } + (bool success, ) = _proxyContract.call(abi.encodeWithSignature("mint(address[])", minters)); + + require(success, "Proxy call failed"); + } + + function mintWithLimit( + uint32 qty, + uint32 limit, + bytes32[] calldata proof, + uint64 timestamp, + bytes calldata signature + ) external override payable virtual nonReentrant { + _mintInternal(qty, msg.sender, limit, proof, timestamp, signature); + + address[] memory minters = new address[](qty); + for (uint256 i = 0; i < qty; i++) { + minters[i] = msg.sender; + } + (bool success, ) = _proxyContract.call(abi.encodeWithSignature("mint(address[])", minters)); + + require(success, "Proxy call failed"); + } +} diff --git a/hardhat.config.ts b/hardhat.config.ts index 922dc43a..c9f2bb4c 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -15,6 +15,7 @@ import { deploy, deploy1155, deployClone, + deployRandomGame, setBaseURI, setCrossmintAddress, mint, @@ -228,6 +229,40 @@ task('deploy', 'Deploy ERC721M') await deploy(tasksArgs, hre); }); +task('deployRandomGame', 'Deploy RandomGrames') + .addParam('name', 'name') + .addParam('symbol', 'symbol') + .addParam('maxsupply', 'max supply') + .addParam('tokenurisuffix', 'token uri suffix', '.json') + .addParam('globalwalletlimit', 'global wallet limit', '0') + .addParam('timestampexpiryseconds', 'timestamp expiry in seconds', '300') + .addParam('proxycontract', 'minting proxy contract') + .addParam( + 'openedition', + 'whether or not a open edition mint (unlimited supply, 999,999,999)', + false, + types.boolean, + ) + .addOptionalParam( + 'cosigner', + 'cosigner address (0x00...000 if not using cosign)', + '0x0000000000000000000000000000000000000000', + ) + .addOptionalParam( + 'mintcurrency', + 'ERC-20 contract address (if minting with ERC-20)', + '0x0000000000000000000000000000000000000000', + ) + .addOptionalParam( + 'fundreceiver', + 'The treasury wallet to receive mint fund', + ) + .addOptionalParam('gaspricegwei', 'Set gas price in Gwei') + .addOptionalParam('gaslimit', 'Set maximum gas units to spend on transaction') + .setAction(async (tasksArgs, hre) => { + console.log('Deploying random games...'); + await deployRandomGame(tasksArgs, hre); + }); task('deploy1155', 'Deploy ERC1155M') .addParam('name', 'name') diff --git a/scripts/deployRandomGame.ts b/scripts/deployRandomGame.ts new file mode 100644 index 00000000..d1c145f1 --- /dev/null +++ b/scripts/deployRandomGame.ts @@ -0,0 +1,127 @@ +// We require the Hardhat Runtime Environment explicitly here. This is optional +// but useful for running the script in a standalone fashion through `node