编译器
0.8.20+commit.a1b79de6
文件 1 的 18:Actions.sol
pragma solidity ^0.8.17;
uint64 constant DAILY_EPOCH_DURATION = 1 days;
uint64 constant DAILY_EPOCH_OFFSET = 0 hours;
uint64 constant HOURLY_EPOCH_DURATION = 1 hours;
uint64 constant NO_OFFSET = 0 hours;
uint256 constant ACTION_LOCK = 101;
uint256 constant ACTION_ADVENTURER_HOMAGE = 1001;
uint256 constant ACTION_ADVENTURER_BATTLE_V3 = 1002;
uint256 constant ACTION_ADVENTURER_COLLECT_EPOCH_REWARDS = 1003;
uint256 constant ACTION_ADVENTURER_VOID_CRAFTING = 1004;
uint256 constant ACTION_ADVENTURER_REALM_CRAFTING = 1005;
uint256 constant ACTION_ADVENTURER_ANIMA_REGENERATION = 1006;
uint256 constant ACTION_ADVENTURER_BATTLE_V3_OPPONENT = 1007;
uint256 constant ACTION_ADVENTURER_TRAINING = 1008;
uint256 constant ACTION_ADVENTURER_TRANSCENDENCE = 1009;
uint256 constant ACTION_ADVENTURER_MINT_MULTIPASS = 1010;
uint256 constant ACTION_ARMORY_STAKE_RARITY_ITEM = 2001;
uint256 constant ACTION_ARMORY_UNSTAKE_RARITY_ITEM = 2002;
uint256 constant ACTION_ARMORY_STAKE_RARITY_ITEM_SHARD = 2011;
uint256 constant ACTION_ARMORY_UNSTAKE_RARITY_ITEM_SHARD = 2012;
uint256 constant ACTION_ARMORY_STAKE_MATERIAL_SHARD = 2021;
uint256 constant ACTION_ARMORY_UNSTAKE_MATERIAL_SHARD = 2022;
uint256 constant ACTION_ARMORY_STAKE_LAB = 2031;
uint256 constant ACTION_ARMORY_UNSTAKE_LAB = 2032;
uint256 constant ACTION_ARMORY_STAKE_COLLECTIBLE = 2041;
uint256 constant ACTION_ARMORY_UNSTAKE_COLLECTIBLE = 2042;
uint256 constant ACTION_ARMORY_STAKE_MATERIAL = 2051;
uint256 constant ACTION_ARMORY_UNSTAKE_MATERIAL = 2052;
uint256 constant ACTION_ARMORY_STAKE_CITY = 2061;
uint256 constant ACTION_ARMORY_UNSTAKE_CITY = 2062;
uint256 constant ACTION_ARMORY_STAKE_MONUMENT = 2061;
uint256 constant ACTION_ARMORY_UNSTAKE_MONUMENT = 2062;
uint256 constant ACTION_REALM_COLLECT_COLLECTIBLES = 4001;
uint256 constant ACTION_REALM_BUILD_LAB = 4011;
文件 2 的 18:CollectibleProducerWithProductivity.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "../Productivity/IProductivity.sol";
import "../Productivity/IProductionCapacity.sol";
import "../lib/FloatingPointConstants.sol";
import "../Manager/ManagerModifier.sol";
import "../Action/Actions.sol";
import "../Action/IActionPermit.sol";
import "../Staker/IStructureStaker.sol";
import "../Realm/IRealm.sol";
import "./ICollectible.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
struct CollectibleConfig {
uint tokenCost;
bool enabled;
uint32 baseProductivity;
uint32 productivityCost;
uint32 productionAmountProductivityCap;
uint32 productivityCostPercentage;
}
struct CollectibleConfigGeos {
uint[] geos;
}
contract CollectibleProducerWithProductivity is
Pausable,
ManagerModifier,
ReentrancyGuard
{
IProductivity public immutable PRODUCTIVITY;
IProductionCapacity public immutable PRODUCTION_CAPACITY;
IActionPermit public ACTION_PERMIT;
IStructureStaker public immutable STRUCTURE_STAKER;
IRealm public immutable REALM;
ICollectible public immutable COLLECTIBLE;
address public immutable REACTOR;
ERC20Burnable public immutable TOKEN;
event Produced(
uint256 realmId,
uint256 collectibleId,
uint256 quantity,
uint256 tokenCost,
uint256 productivityDelta,
uint256 spentCapacity
);
error InvalidRealmIdOrder(int realmId);
error DisabledCollectible(uint realmId, uint collectible);
error UnsupportedCollectible(uint realmId, uint collectible);
error MultiProductivityProductivityExceeded(
uint realmId,
uint collectible,
uint amount,
uint maxAmount
);
error MultiProductivityCapacityExceeded(
uint realmId,
uint collectible,
uint amount,
uint maxAmount
);
error ProductionCapacityExceeded(
uint realmId,
uint collectible,
uint amount,
uint maxAmount
);
mapping(uint => CollectibleConfig) public COLLECTIBLE_CONFIGS;
mapping(uint => CollectibleConfigGeos) internal COLLECTIBLE_CONFIGS_GEOS;
mapping(uint => mapping(uint => bool)) public GEO_SUPPORTED_COLLECTIBLES;
constructor(
address _manager,
address _productivityStorage,
address _actionPermit,
address _structureStaker,
address _realm,
address _reactor,
address _token,
address _collectible,
address _productionCapacity
) ManagerModifier(_manager) {
PRODUCTIVITY = IProductivity(_productivityStorage);
ACTION_PERMIT = IActionPermit(_actionPermit);
STRUCTURE_STAKER = IStructureStaker(_structureStaker);
REALM = IRealm(_realm);
REACTOR = _reactor;
TOKEN = ERC20Burnable(_token);
COLLECTIBLE = ICollectible(_collectible);
PRODUCTION_CAPACITY = IProductionCapacity(_productionCapacity);
}
function collect(
uint256[] calldata _realmIds,
uint256[] calldata _collectibleIds,
uint256[] calldata _quantities,
bytes32[][] calldata proofs
) external whenNotPaused nonReentrant {
require(
_realmIds.length == _collectibleIds.length &&
_realmIds.length == _quantities.length
);
ACTION_PERMIT.checkPermissionsMany(
msg.sender,
address(REALM),
_realmIds,
proofs,
ACTION_REALM_COLLECT_COLLECTIBLES
);
uint[] memory productivities = PRODUCTIVITY.currentProductivityBatch(
_realmIds
);
uint[] memory capacities = PRODUCTION_CAPACITY.productionCapacityBatch(
_realmIds
);
uint totalCost = 0;
uint singularCost;
int lastRealmId = -1;
for (uint i = 0; i < _realmIds.length; i++) {
int currentRealmId = int(_realmIds[i]);
if (lastRealmId > currentRealmId) {
revert InvalidRealmIdOrder(currentRealmId);
} else if (lastRealmId == currentRealmId) {
if (int(productivities[i]) < -int(productivities[i - 1])) {
revert MultiProductivityProductivityExceeded(
_realmIds[i],
_collectibleIds[i],
productivities[i],
productivities[i - 1]
);
}
productivities[i] += productivities[i - 1];
if (capacities[i] < capacities[i - 1]) {
revert MultiProductivityCapacityExceeded(
_realmIds[i],
_collectibleIds[i],
capacities[i],
capacities[i - 1]
);
}
capacities[i] -= capacities[i - 1];
}
lastRealmId = int(_realmIds[i]);
(singularCost, productivities[i], capacities[i]) = _produce(
_realmIds[i],
_collectibleIds[i],
_quantities[i],
productivities[i],
capacities[i]
);
totalCost += singularCost;
}
TOKEN.burnFrom(msg.sender, totalCost);
COLLECTIBLE.mintBatchFor(msg.sender, _collectibleIds, _quantities);
PRODUCTIVITY.decreaseBatch(_realmIds, productivities, true);
PRODUCTION_CAPACITY.spendProductionCapacityBatch(_realmIds, capacities);
}
function collectionCostsAndMaxAmounts(
uint256[] calldata _realmIds,
uint256[][] calldata _collectibleIds
)
external
returns (
uint[][] memory costs,
uint[][] memory maxAmounts,
uint[] memory capacities
)
{
require(_realmIds.length == _collectibleIds.length);
uint[] memory productivities = PRODUCTIVITY.currentProductivityBatch(
_realmIds
);
capacities = PRODUCTION_CAPACITY.productionCapacityBatch(_realmIds);
bool hasReactor;
costs = new uint[][](_realmIds.length);
maxAmounts = new uint[][](_realmIds.length);
for (uint i = 0; i < _realmIds.length; i++) {
hasReactor = STRUCTURE_STAKER.hasStaked(_realmIds[i], REACTOR, 0);
costs[i] = new uint[](_collectibleIds[i].length);
maxAmounts[i] = new uint[](_collectibleIds[i].length);
for (uint j = 0; j < _collectibleIds[i].length; j++) {
CollectibleConfig storage cfg = COLLECTIBLE_CONFIGS[
_collectibleIds[i][j]
];
costs[i][j] = cfg.tokenCost;
maxAmounts[i][j] =
_calculateAmount(capacities[i], uint(productivities[i]), cfg) /
1000;
if (hasReactor) {
maxAmounts[i][j] *= 2;
}
}
}
}
function _produce(
uint _realmId,
uint _collectibleId,
uint _amount,
uint _productivity,
uint _capacity
)
internal
returns (uint totalCost, uint productivitySpent, uint spentCapacity)
{
CollectibleConfig memory cfg = COLLECTIBLE_CONFIGS[_collectibleId];
if (!cfg.enabled) {
revert DisabledCollectible(_realmId, _collectibleId);
}
if (_amount == 0) {
return (totalCost, productivitySpent, spentCapacity);
}
_verifyProduction(_realmId, _collectibleId);
totalCost += _amount * cfg.tokenCost;
uint reactorCoefficient = STRUCTURE_STAKER.hasStaked(_realmId, REACTOR, 0)
? 2
: 1;
uint maxAmount = _calculateAmount(_capacity, _productivity, cfg) *
reactorCoefficient;
uint integerMaxAmount = maxAmount / DECIMAL_POINT;
if (_amount > integerMaxAmount) {
revert ProductionCapacityExceeded(
_realmId,
_collectibleId,
_amount,
integerMaxAmount
);
}
spentCapacity = ((_capacity * _amount * DECIMAL_POINT) / maxAmount);
uint baseAmount = (spentCapacity * cfg.baseProductivity) / ONE_HUNDRED;
productivitySpent = (cfg.productivityCost * _amount) / reactorCoefficient;
if (baseAmount > productivitySpent) {
productivitySpent = 0;
} else {
productivitySpent -= baseAmount;
}
productivitySpent =
(cfg.productivityCostPercentage * productivitySpent) /
ONE_HUNDRED;
emit Produced(
_realmId,
_collectibleId,
_amount,
totalCost,
productivitySpent,
spentCapacity
);
}
function _verifyProduction(uint _realmId, uint _collectibleId) internal view {
for (uint i = 0; i < 3; i++) {
uint feature = REALM.realmFeatures(_realmId, i);
if (GEO_SUPPORTED_COLLECTIBLES[feature][_collectibleId]) {
return;
}
}
revert UnsupportedCollectible(_realmId, _collectibleId);
}
function _calculateAmount(
uint _productionCapacity,
uint _productivity,
CollectibleConfig memory collectibleConfig
) internal view returns (uint amount) {
if (_productionCapacity == 0) {
return 0;
}
uint adjustedProductivity = collectibleConfig.baseProductivity +
_productivity;
uint cappedAdjustedProductivity = adjustedProductivity >
collectibleConfig.productionAmountProductivityCap
? collectibleConfig.productionAmountProductivityCap
: adjustedProductivity;
if (
adjustedProductivity > collectibleConfig.productionAmountProductivityCap
) {
uint coefficient = ONE_HUNDRED +
((ONE_HUNDRED *
(adjustedProductivity -
collectibleConfig.productionAmountProductivityCap)) /
adjustedProductivity);
cappedAdjustedProductivity =
(cappedAdjustedProductivity * coefficient) /
ONE_HUNDRED;
}
return
(cappedAdjustedProductivity * uint(_productionCapacity)) /
(collectibleConfig.productivityCost * 100);
}
function pause() external onlyAdmin {
_pause();
}
function unpause() external onlyAdmin {
_unpause();
}
function updateCollectibleConfigs(
uint[] calldata _collectibleIds,
CollectibleConfig[] calldata _configs,
CollectibleConfigGeos[] calldata _geoConfigs
) external onlyAdmin {
require(_collectibleIds.length == _configs.length);
for (uint i = 0; i < _collectibleIds.length; i++) {
uint collectibleId = _collectibleIds[i];
CollectibleConfig storage existingConfig = COLLECTIBLE_CONFIGS[
collectibleId
];
CollectibleConfigGeos
storage existingGeoConfig = COLLECTIBLE_CONFIGS_GEOS[collectibleId];
for (uint j = 0; j < existingGeoConfig.geos.length; j++) {
GEO_SUPPORTED_COLLECTIBLES[existingGeoConfig.geos[j]][
collectibleId
] = false;
}
COLLECTIBLE_CONFIGS[_collectibleIds[i]] = _configs[i];
COLLECTIBLE_CONFIGS_GEOS[_collectibleIds[i]] = _geoConfigs[i];
for (uint j = 0; j < _geoConfigs[i].geos.length; j++) {
GEO_SUPPORTED_COLLECTIBLES[_geoConfigs[i].geos[j]][
collectibleId
] = true;
}
}
}
function updatePermit(address _permit) external onlyAdmin {
ACTION_PERMIT = IActionPermit(_permit);
}
}
文件 3 的 18:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 4 的 18:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
文件 5 的 18:ERC20Burnable.sol
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
abstract contract ERC20Burnable is Context, ERC20 {
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}
文件 6 的 18:FloatingPointConstants.sol
pragma solidity ^0.8.17;
uint256 constant DECIMAL_POINT = 10 ** 3;
uint256 constant ROUNDING_ADJUSTER = DECIMAL_POINT - 1;
int256 constant SIGNED_DECIMAL_POINT = int256(DECIMAL_POINT);
uint256 constant ONE_HUNDRED = 100 * DECIMAL_POINT;
uint256 constant ONE_HUNDRED_SQUARE = ONE_HUNDRED * ONE_HUNDRED;
int256 constant SIGNED_ONE_HUNDRED = 100 * SIGNED_DECIMAL_POINT;
int256 constant SIGNED_ONE_HUNDRED_SQUARE = SIGNED_ONE_HUNDRED * SIGNED_ONE_HUNDRED;
int256 constant SIGNED_ZERO = 0;
文件 7 的 18:IActionPermit.sol
pragma solidity ^0.8.17;
error Unauthorized(address _tokenAddr, uint256 _tokenId);
error EntityLocked(address _tokenAddr, uint256 _tokenId, uint _lockedUntil);
error MinEpochsTooLow(uint256 _minEpochs);
error InsufficientEpochSpan(
uint256 _minEpochs,
uint256 _epochs,
address _tokenAddr,
uint256 _tokenId
);
error DuplicateActionAttempt(address _tokenAddr, uint256 _tokenId);
interface IActionPermit {
function checkAndMarkActionComplete(
address _sender,
address _tokenAddr,
uint256 _tokenId,
bytes32[] calldata _proof,
uint256 _action,
uint256 _minEpochs,
uint128 _epochConfig
) external;
function checkAndMarkActionCompleteMany(
address _sender,
address[] calldata _tokenAddrs,
uint256[] calldata _tokenIds,
bytes32[][] calldata _proofs,
uint256 _action,
uint256 _minEpochs,
uint128 _epochConfig
) external;
function checkAndMarkActionCompleteMany(
address _sender,
address[] calldata _tokenAddrs,
uint256[] calldata _tokenIds,
bytes32[][] calldata _proofs,
uint256 _action,
uint256[] calldata _minEpochs,
uint128 _epochConfig
) external;
function forceMarkActionComplete(address _tokenAddr, uint256 _tokenId, uint256 _action) external;
function checkPermissions(
address _sender,
address _tokenAddr,
uint256 _tokenId,
bytes32[] calldata _proof,
uint256 _action
) external view;
function checkOwner(
address _tokenAddr,
uint256 _tokenId,
bytes32[] calldata _proof
) external view returns (address);
function checkPermissionsMany(
address _sender,
address[] calldata _tokenAddr,
uint256[] calldata _tokenId,
bytes32[][] calldata _proofs,
uint256 _action
) external view;
function checkPermissionsMany(
address _sender,
address _tokenAddr,
uint256[] calldata _tokenId,
bytes32[][] calldata _proofs,
uint256 _action
) external view;
function checkOwnerBatch(
address[] calldata _tokenAddrs,
uint256[] calldata _tokenIds,
bytes32[][] calldata _proofs
) external view returns (address[] memory);
function checkIfEnoughEpochsElapsed(
address _tokenAddr,
uint256 _tokenId,
uint256 _action,
uint256 _minEpochs,
uint128 _epochConfig
) external view;
function checkIfEnoughEpochsElapsedBatch(
address[] calldata _tokenAddrs,
uint256[] calldata _tokenIds,
uint256 _action,
uint256 _minEpochs,
uint128 _epochConfig
) external view;
function checkIfEnoughEpochsElapsedBatch(
address[] calldata _tokenAddrs,
uint256[] calldata _tokenIds,
uint256 _action,
uint256[] calldata _minEpochs,
uint128 _epochConfig
) external view;
function getElapsedEpochs(
address[] calldata _tokenAddrs,
uint256[] calldata _tokenIds,
uint256 _action,
uint128 _epochConfig
) external view returns (uint[] memory result);
}
文件 8 的 18:ICollectible.sol
pragma solidity ^0.8.4;
interface ICollectible {
function mintFor(address _for, uint256 _id, uint256 _amount) external;
function mintBatchFor(
address _for,
uint256[] memory _ids,
uint256[] memory _amounts
) external;
function burn(uint256 _id, uint256 _amount) external;
function burnBatch(uint256[] memory ids, uint256[] memory amounts) external;
function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _amounts,
bytes calldata data
) external;
function safeTransferFrom(
address _from,
address _to,
uint256 _ids,
uint256 _amounts,
bytes calldata data
) external;
}
文件 9 的 18:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 10 的 18:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 11 的 18:IManager.sol
pragma solidity ^0.8.4;
interface IManager {
function isAdmin(address _addr) external view returns (bool);
function isManager(address _addr, uint256 _type) external view returns (bool);
function addManager(address _addr, uint256 _type) external;
function removeManager(address _addr, uint256 _type) external;
function addAdmin(address _addr) external;
function removeAdmin(address _addr) external;
}
文件 12 的 18:IProductionCapacity.sol
pragma solidity ^0.8.17;
interface IProductionCapacity {
function productionCapacity(uint _realmId) external view returns (uint);
function productionCapacityBatch(
uint[] calldata _realmIds
) external view returns (uint[] memory result);
function spendProductionCapacity(uint _realmId, uint _spentCapacity) external;
function spendProductionCapacityBatch(
uint[] calldata _realmIds,
uint[] calldata _spentCapacity
) external;
function resetProductionCapacity(uint _realmId) external;
function resetProductionCapacityBatch(uint[] calldata _realmIds) external;
}
文件 13 的 18:IProductivity.sol
pragma solidity ^0.8.17;
interface IProductivity {
function currentProductivity(uint256 _realmId) external view returns (uint);
function currentProductivityBatch(
uint[] calldata _realmIds
) external view returns (uint[] memory result);
function previousEpochsProductivityTotals(
uint _realmId,
uint _numberOfEpochs,
bool _includeCurrentEpoch
) external view returns (uint gains, uint losses);
function epochsProductivityTotals(
uint _realmId,
uint _startEpoch,
uint _endEpoch
) external view returns (uint gains, uint losses);
function previousEpochsProductivityTotalsBatch(
uint[] calldata _realmIds,
uint _numberOfEpochs,
bool _includeCurrentEpoch
) external view returns (uint[] memory gains, uint[] memory spending);
function epochsProductivityTotalsBatch(
uint[] calldata _realmIds,
uint _startEpoch,
uint _endEpoch
) external view returns (uint[] memory gains, uint[] memory spending);
function change(uint256 _realmId, int _delta, bool _includeInTotals) external;
function changeBatch(
uint256[] calldata _tokenIds,
int[] calldata _deltas,
bool _includeInTotals
) external;
function changeBatch(uint256[] calldata _tokenIds, int _delta, bool _includeInTotals) external;
function increase(uint256 _realmId, uint _delta, bool _includeInTotals) external;
function increaseBatch(
uint256[] calldata _tokenIds,
uint[] calldata _delta,
bool _includeInTotals
) external;
function increaseBatch(uint256[] calldata _tokenIds, uint _delta, bool _includeInTotals) external;
function decrease(uint256 _realmId, uint _delta, bool _includeInTotals) external;
function decreaseBatch(
uint256[] calldata _tokenIds,
uint[] calldata _delta,
bool _includeInTotals
) external;
function decreaseBatch(uint256[] calldata _tokenIds, uint _delta, bool _includeInTotals) external;
}
文件 14 的 18:IRealm.sol
pragma solidity ^0.8.4;
interface IRealm {
function balanceOf(address owner) external view returns (uint256);
function ownerOf(uint256 _realmId) external view returns (address owner);
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function isApprovedForAll(
address owner,
address operator
) external returns (bool);
function realmFeatures(
uint256 realmId,
uint256 index
) external view returns (uint256);
}
文件 15 的 18:IStructureStaker.sol
pragma solidity ^0.8.4;
interface IStructureStaker {
function stakeFor(
address _staker,
uint256 _realmId,
address _addr,
uint256 _structureId
) external;
function unstakeFor(
address _staker,
uint256 _realmId,
address _addr,
uint256 _structureId
) external;
function stakeBatchFor(
address _staker,
uint256[] calldata _realmIds,
address[] calldata _addrs,
uint256[] calldata _structureIds
) external;
function unstakeBatchFor(
address _staker,
uint256[] calldata _realmIds,
address[] calldata _addrs,
uint256[] calldata _structureIds
) external;
function getStaker(
uint256 _realmId,
address _addr,
uint256 _structureId
) external;
function hasStaked(
uint256 _realmId,
address _addr,
uint256 _count
) external returns (bool);
}
文件 16 的 18:ManagerModifier.sol
pragma solidity ^0.8.4;
import "../Manager/IManager.sol";
abstract contract ManagerModifier {
IManager public immutable MANAGER;
constructor(address _manager) {
MANAGER = IManager(_manager);
}
modifier onlyAdmin() {
require(MANAGER.isAdmin(msg.sender), "Manager: Not an Admin");
_;
}
modifier onlyManager() {
require(MANAGER.isManager(msg.sender, 0), "Manager: Not manager");
_;
}
modifier onlyMinter() {
require(MANAGER.isManager(msg.sender, 1), "Manager: Not minter");
_;
}
modifier onlyTokenMinter() {
require(MANAGER.isManager(msg.sender, 2), "Manager: Not token minter");
_;
}
modifier onlyBinder() {
require(MANAGER.isManager(msg.sender, 3), "Manager: Not binder");
_;
}
}
文件 17 的 18:Pausable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Pausable is Context {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor() {
_paused = false;
}
modifier whenNotPaused() {
_requireNotPaused();
_;
}
modifier whenPaused() {
_requirePaused();
_;
}
function paused() public view virtual returns (bool) {
return _paused;
}
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
文件 18 的 18:ReentrancyGuard.sol
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
}
function _nonReentrantAfter() private {
_status = _NOT_ENTERED;
}
}
{
"compilationTarget": {
"contracts/Collectible/CollectibleProducerWithProductivity.sol": "CollectibleProducerWithProductivity"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_manager","type":"address"},{"internalType":"address","name":"_productivityStorage","type":"address"},{"internalType":"address","name":"_actionPermit","type":"address"},{"internalType":"address","name":"_structureStaker","type":"address"},{"internalType":"address","name":"_realm","type":"address"},{"internalType":"address","name":"_reactor","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_collectible","type":"address"},{"internalType":"address","name":"_productionCapacity","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"realmId","type":"uint256"},{"internalType":"uint256","name":"collectible","type":"uint256"}],"name":"DisabledCollectible","type":"error"},{"inputs":[{"internalType":"int256","name":"realmId","type":"int256"}],"name":"InvalidRealmIdOrder","type":"error"},{"inputs":[{"internalType":"uint256","name":"realmId","type":"uint256"},{"internalType":"uint256","name":"collectible","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"name":"MultiProductivityCapacityExceeded","type":"error"},{"inputs":[{"internalType":"uint256","name":"realmId","type":"uint256"},{"internalType":"uint256","name":"collectible","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"name":"MultiProductivityProductivityExceeded","type":"error"},{"inputs":[{"internalType":"uint256","name":"realmId","type":"uint256"},{"internalType":"uint256","name":"collectible","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"name":"ProductionCapacityExceeded","type":"error"},{"inputs":[{"internalType":"uint256","name":"realmId","type":"uint256"},{"internalType":"uint256","name":"collectible","type":"uint256"}],"name":"UnsupportedCollectible","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"realmId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collectibleId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenCost","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"productivityDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"spentCapacity","type":"uint256"}],"name":"Produced","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ACTION_PERMIT","outputs":[{"internalType":"contract IActionPermit","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"COLLECTIBLE","outputs":[{"internalType":"contract ICollectible","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"COLLECTIBLE_CONFIGS","outputs":[{"internalType":"uint256","name":"tokenCost","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"},{"internalType":"uint32","name":"baseProductivity","type":"uint32"},{"internalType":"uint32","name":"productivityCost","type":"uint32"},{"internalType":"uint32","name":"productionAmountProductivityCap","type":"uint32"},{"internalType":"uint32","name":"productivityCostPercentage","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"GEO_SUPPORTED_COLLECTIBLES","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER","outputs":[{"internalType":"contract IManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRODUCTION_CAPACITY","outputs":[{"internalType":"contract IProductionCapacity","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRODUCTIVITY","outputs":[{"internalType":"contract IProductivity","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REACTOR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REALM","outputs":[{"internalType":"contract IRealm","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STRUCTURE_STAKER","outputs":[{"internalType":"contract IStructureStaker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN","outputs":[{"internalType":"contract ERC20Burnable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_realmIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_collectibleIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_quantities","type":"uint256[]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"}],"name":"collect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_realmIds","type":"uint256[]"},{"internalType":"uint256[][]","name":"_collectibleIds","type":"uint256[][]"}],"name":"collectionCostsAndMaxAmounts","outputs":[{"internalType":"uint256[][]","name":"costs","type":"uint256[][]"},{"internalType":"uint256[][]","name":"maxAmounts","type":"uint256[][]"},{"internalType":"uint256[]","name":"capacities","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_collectibleIds","type":"uint256[]"},{"components":[{"internalType":"uint256","name":"tokenCost","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"},{"internalType":"uint32","name":"baseProductivity","type":"uint32"},{"internalType":"uint32","name":"productivityCost","type":"uint32"},{"internalType":"uint32","name":"productionAmountProductivityCap","type":"uint32"},{"internalType":"uint32","name":"productivityCostPercentage","type":"uint32"}],"internalType":"struct CollectibleConfig[]","name":"_configs","type":"tuple[]"},{"components":[{"internalType":"uint256[]","name":"geos","type":"uint256[]"}],"internalType":"struct CollectibleConfigGeos[]","name":"_geoConfigs","type":"tuple[]"}],"name":"updateCollectibleConfigs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_permit","type":"address"}],"name":"updatePermit","outputs":[],"stateMutability":"nonpayable","type":"function"}]