Skip to content

Commit

Permalink
deployed new metadata and modified mint/pay logic in anybodyproblem
Browse files Browse the repository at this point in the history
  • Loading branch information
okwme committed Aug 11, 2024
1 parent 74d4a13 commit 3d50cf0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 22 deletions.
50 changes: 29 additions & 21 deletions contracts/AnybodyProblem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ contract AnybodyProblem is Ownable, ERC2981 {
uint256 public constant FIRST_SUNDAY_AT_6_PM_UTC = 324000;

bool public paused = false;
uint256 public price = 0.0025 ether;
uint256 public priceToMint = 0.0025 ether;
uint256 public priceToSave = 0 ether;
uint256 public discount = 2;
address payable public proceedRecipient;
address public externalMetadata;
Expand Down Expand Up @@ -139,14 +140,15 @@ contract AnybodyProblem is Ownable, ERC2981 {
function batchSolve(
uint256 runId,
bool alsoMint,
uint256 day,
uint256[] memory tickCounts,
uint[2][] memory a,
uint[2][2][] memory b,
uint[2][] memory c,
uint[][] memory input
) public payable {
require(!paused, 'Contract is paused');
uint256 day = currentDay();
// uint256 day = currentDay(); // TODO: this version does not enforce day for solving, just for minting NFT
if (runId == 0) {
runId = addNewRun(day);
addNewLevelData(runId);
Expand Down Expand Up @@ -420,16 +422,9 @@ contract AnybodyProblem is Ownable, ERC2981 {
if (level == LEVELS) {
runs[runId].solved = true;
if (alsoMint) {
require(msg.value >= price / discount, 'Incorrect payment');
require(
proceedRecipient != address(0),
'Invalid recipient'
);
(bool sent, bytes memory data) = proceedRecipient.call{
value: msg.value
}('');
Speedruns(speedruns).__mint(msg.sender, day, 1, '');
emit EthMoved(proceedRecipient, sent, data, msg.value);
mint(priceToSave + (priceToMint / discount), day);
} else if (priceToSave > 0) {
makePayment(priceToSave);
}
emit RunSolved(
msg.sender,
Expand All @@ -445,15 +440,24 @@ contract AnybodyProblem is Ownable, ERC2981 {
}
}

function mint() public payable {
uint256 day = currentDay();
require(msg.value == price, 'Incorrect payment');
function makePayment(uint256 payment) internal {
require(msg.value >= payment, 'Incorrect payment');
require(proceedRecipient != address(0), 'Invalid recipient');
(bool sent, bytes memory data) = proceedRecipient.call{
value: msg.value
}('');
(bool sent, bytes memory data) = proceedRecipient.call{value: payment}(
''
);
emit EthMoved(proceedRecipient, sent, data, payment);
}

function mint(uint256 payment, uint256 day) internal {
require(day == currentDay(), 'Can only mint on the current day');
require(payment == priceToMint, 'Incorrect price');
makePayment(payment);
Speedruns(speedruns).__mint(msg.sender, day, 1, '');
emit EthMoved(proceedRecipient, sent, data, msg.value);
}

function mint() public payable {
mint(msg.value, currentDay());
}

function addToLeaderboard(uint256 runId) internal {
Expand Down Expand Up @@ -865,8 +869,12 @@ contract AnybodyProblem is Ownable, ERC2981 {
discount = discount_;
}

function updatePrice(uint256 price_) public onlyOwner {
price = price_;
function updatePriceToSave(uint256 priceToSave_) public onlyOwner {
priceToSave = priceToSave_;
}

function updatePriceToMint(uint256 priceToMint_) public onlyOwner {
priceToMint = priceToMint_;
}

function updatePaused(bool paused_) public onlyOwner {
Expand Down
2 changes: 1 addition & 1 deletion server/contractData/84532-ExternalMetadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x731D1B164F2BAad81810152163787D1E1eDBcFd0",
"address": "0x7BAfC364a068134dAE05525ce005A16601769c9A",
"chain": { "chainId": 84532, "name": "unknown" }
}
22 changes: 22 additions & 0 deletions server/contractData/ABI-84532-ExternalMetadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "date", "type": "uint256" }
],
"name": "getBestTimeEncoded",
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "date", "type": "uint256" },
{ "internalType": "uint256", "name": "placeIndex", "type": "uint256" }
],
"name": "getFastestTime",
"outputs": [
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "string", "name": "sec", "type": "string" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "date", "type": "uint256" }
Expand Down

0 comments on commit 3d50cf0

Please sign in to comment.