Skip to content

Commit

Permalink
Merge pull request #343 from moonstream-to/statblock-separate-terminus
Browse files Browse the repository at this point in the history
Created `StatBlockBase`
  • Loading branch information
zomglings authored Oct 25, 2023
2 parents d595dd7 + 13d20de commit 5675d80
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions contracts/stats/StatBlock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,17 @@ pragma solidity ^0.8.0;
import {IERC1155} from "@openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";
import {IStatBlock} from "./IStatBlock.sol";

contract StatBlock is IStatBlock {
contract StatBlockBase is IStatBlock {
string public statBlockVersion = "0.0.1";
address AdminTerminusAddress;
uint256 AdminTerminusPoolID;
// Stats are 0-indexed.
uint256 public NumStats;
mapping(uint256 => string) StatDescriptor;
mapping(address => mapping(uint256 => mapping(uint256 => uint256))) Stat;

constructor(address adminTerminusAddress, uint256 adminTerminusPoolID) {
AdminTerminusAddress = adminTerminusAddress;
AdminTerminusPoolID = adminTerminusPoolID;
}

function adminTerminusInfo() external view returns (address, uint256) {
return (AdminTerminusAddress, AdminTerminusPoolID);
}

function isAdministrator(address account) public view returns (bool) {
IERC1155 terminus = IERC1155(AdminTerminusAddress);
return terminus.balanceOf(account, AdminTerminusPoolID) > 0;
function isAdministrator(
address account
) public view virtual returns (bool) {
return false;
}

function createStat(
Expand Down Expand Up @@ -141,3 +131,24 @@ contract StatBlock is IStatBlock {
return values;
}
}

contract StatBlock is StatBlockBase {
address AdminTerminusAddress;
uint256 AdminTerminusPoolID;

constructor(address adminTerminusAddress, uint256 adminTerminusPoolID) {
AdminTerminusAddress = adminTerminusAddress;
AdminTerminusPoolID = adminTerminusPoolID;
}

function adminTerminusInfo() external view returns (address, uint256) {
return (AdminTerminusAddress, AdminTerminusPoolID);
}

function isAdministrator(
address account
) public view override returns (bool) {
IERC1155 terminus = IERC1155(AdminTerminusAddress);
return terminus.balanceOf(account, AdminTerminusPoolID) > 0;
}
}

0 comments on commit 5675d80

Please sign in to comment.