Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add freeze upgrades #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions contracts/InstallationDiamond/facets/ERC1155Facet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ contract ERC1155Facet is Modifiers {
@param _value Transfer amount
@param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to`
*/
function safeTransferFrom(
address _from,
address _to,
uint256 _id,
uint256 _value,
bytes calldata _data
) external {
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external diamondPaused {
require(_to != address(0), "ERC1155Facet: Can't transfer to 0 address");
address sender = LibMeta.msgSender();
require(sender == _from || s.operators[_from][sender] || sender == address(this), "ERC1155Facet: Not owner and not approved to transfer");
Expand Down Expand Up @@ -67,7 +61,7 @@ contract ERC1155Facet is Modifiers {
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external {
) external diamondPaused {
require(_to != address(0), "ItemsTransfer: Can't transfer to 0 address");
require(_ids.length == _values.length, "ItemsTransfer: ids not same length as values");
address sender = LibMeta.msgSender();
Expand All @@ -83,7 +77,7 @@ contract ERC1155Facet is Modifiers {
LibERC1155.onERC1155BatchReceived(sender, _from, _to, _ids, _values, _data);
}

function setApprovalForAll(address _operator, bool _approved) external {
function setApprovalForAll(address _operator, bool _approved) external diamondPaused {
address sender = LibMeta.msgSender();
require(sender != _operator, "ERC1155Facet: setting approval status for self");
s.operators[sender][_operator] = _approved;
Expand Down
19 changes: 7 additions & 12 deletions contracts/InstallationDiamond/facets/InstallationAdminFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ contract InstallationAdminFacet is Modifiers {
emit AddInstallationType(s.installationTypes.length - 1);
emit SetInstallationUnequipType(s.installationTypes.length - 1, _installationTypes[i].unequipType);

if(_installationTypes[i].deprecateTime > 0){
if (_installationTypes[i].deprecateTime > 0) {
s.deprecateTime[s.installationTypes.length - 1] = _installationTypes[i].deprecateTime;
emit EditDeprecateTime(s.installationTypes.length - 1, _installationTypes[i].deprecateTime);
}
Expand Down Expand Up @@ -142,11 +142,7 @@ contract InstallationAdminFacet is Modifiers {
/// @param _installationIds An array containing the identifiers of the installationTypes to mint
/// @param _amounts An array containing the amounts of the installationTypes to mint
/// @param _toAddress Address to mint installations
function mintInstallations(
uint16[] calldata _installationIds,
uint16[] calldata _amounts,
address _toAddress
) external onlyOwner {
function mintInstallations(uint16[] calldata _installationIds, uint16[] calldata _amounts, address _toAddress) external onlyOwner {
require(_installationIds.length == _amounts.length, "InstallationFacet: Mismatched arrays");
for (uint256 i = 0; i < _installationIds.length; i++) {
uint256 installationId = _installationIds[i];
Expand Down Expand Up @@ -232,16 +228,15 @@ contract InstallationAdminFacet is Modifiers {
}
}

function getUniqueHash(
uint256 _parcelId,
uint16 _x,
uint16 _y,
uint256 _installationId
) external view returns (uint256) {
function getUniqueHash(uint256 _parcelId, uint16 _x, uint16 _y, uint256 _installationId) external view returns (uint256) {
return s.upgradeHashes[keccak256(abi.encodePacked(_parcelId, _x, _y, _installationId))];
}

function toggleGameManager(address _newGameManager, bool _active) external onlyOwner {
s.gameManager[_newGameManager] = _active;
}

function setDiamondPaused(bool _paused) external onlyOwner {
s.diamondPaused = _paused;
}
}
37 changes: 12 additions & 25 deletions contracts/InstallationDiamond/facets/InstallationFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ contract InstallationFacet is Modifiers {
/// @param _tokenId The ID of the parent token
/// @param _id ID of the token
/// @return value The balance of the token
function balanceOfToken(
address _tokenContract,
uint256 _tokenId,
uint256 _id
) public view returns (uint256 value) {
function balanceOfToken(address _tokenContract, uint256 _tokenId, uint256 _id) public view returns (uint256 value) {
value = s.nftInstallationBalances[_tokenContract][_tokenId][_id];
}

Expand All @@ -89,11 +85,10 @@ contract InstallationFacet is Modifiers {
/// @param _tokenContract Contract address for the token to query
/// @param _tokenId Identifier of the token to query
/// @return installationBalancesOfTokenWithTypes_ An array of structs containing details about each installation owned(including installation types)
function installationBalancesOfTokenWithTypes(address _tokenContract, uint256 _tokenId)
external
view
returns (ItemTypeIO[] memory installationBalancesOfTokenWithTypes_)
{
function installationBalancesOfTokenWithTypes(
address _tokenContract,
uint256 _tokenId
) external view returns (ItemTypeIO[] memory installationBalancesOfTokenWithTypes_) {
installationBalancesOfTokenWithTypes_ = LibERC998.itemBalancesOfTokenWithTypes(_tokenContract, _tokenId);
}

Expand Down Expand Up @@ -260,7 +255,7 @@ contract InstallationFacet is Modifiers {
// }
}

function batchCraftInstallations(BatchCraftInstallationsInput[] calldata _inputs) external {
function batchCraftInstallations(BatchCraftInstallationsInput[] calldata _inputs) external diamondPaused {
for (uint256 i = 0; i < _inputs.length; i++) {
_batchCraftInstallation(_inputs[i]);
}
Expand All @@ -271,7 +266,7 @@ contract InstallationFacet is Modifiers {
/// @dev Puts the installation into a queue
/// @param _installationTypes An array containing the identifiers of the installationTypes to craft
/// @param _gltr Array of GLTR to spend on each crafting
function craftInstallations(uint16[] calldata _installationTypes, uint40[] calldata _gltr) external {
function craftInstallations(uint16[] calldata _installationTypes, uint40[] calldata _gltr) external diamondPaused {
require(_installationTypes.length == _gltr.length, "InstallationFacet: Mismatched arrays");
address[4] memory alchemicaAddresses = RealmDiamond(s.realmDiamond).getAlchemicaAddresses();

Expand Down Expand Up @@ -319,7 +314,7 @@ contract InstallationFacet is Modifiers {
/// @dev Will throw if the caller is not the queue owner
/// @dev Will throw if one of the queues is not ready
/// @param _queueIds An array containing the identifiers of queues to claim
function claimInstallations(uint256[] calldata _queueIds) external {
function claimInstallations(uint256[] calldata _queueIds) external diamondPaused {
for (uint256 i; i < _queueIds.length; i++) {
uint256 queueId = _queueIds[i];

Expand All @@ -345,7 +340,7 @@ contract InstallationFacet is Modifiers {
/// @dev amount expressed in block numbers
/// @param _queueIds An array containing the identifiers of queues to speed up
/// @param _amounts An array containing the corresponding amounts of $GLTR tokens to pay for each queue speedup
function reduceCraftTime(uint256[] calldata _queueIds, uint40[] calldata _amounts) external {
function reduceCraftTime(uint256[] calldata _queueIds, uint40[] calldata _amounts) external diamondPaused {
require(_queueIds.length == _amounts.length, "InstallationFacet: Mismatched arrays");
for (uint256 i; i < _queueIds.length; i++) {
uint256 queueId = _queueIds[i];
Expand All @@ -358,7 +353,7 @@ contract InstallationFacet is Modifiers {

uint40 blockLeft = queueItem.readyBlock - uint40(block.number);
uint40 removeBlocks = _amounts[i] <= blockLeft ? _amounts[i] : blockLeft;
uint256 burnAmount = uint256(removeBlocks) * 10**18;
uint256 burnAmount = uint256(removeBlocks) * 10 ** 18;
gltr.burnFrom(msg.sender, burnAmount);
queueItem.readyBlock -= removeBlocks;
emit CraftTimeReduced(queueId, removeBlocks);
Expand All @@ -371,23 +366,15 @@ contract InstallationFacet is Modifiers {
/// @param _owner Owner of the installation to equip
/// @param _realmId The identifier of the parcel to equip the installation to
/// @param _installationId Identifier of the installation to equip
function equipInstallation(
address _owner,
uint256 _realmId,
uint256 _installationId
) external onlyRealmDiamond {
function equipInstallation(address _owner, uint256 _realmId, uint256 _installationId) external onlyRealmDiamond diamondPaused {
LibInstallation._equipInstallation(_owner, _realmId, _installationId);
}

/// @notice Allow a user to unequip an installation from a parcel
/// @dev Will throw if the caller is not the parcel diamond contract
/// @param _realmId The identifier of the parcel to unequip the installation from
/// @param _installationId Identifier of the installation to unequip
function unequipInstallation(
address _owner,
uint256 _realmId,
uint256 _installationId
) external onlyRealmDiamond {
function unequipInstallation(address _owner, uint256 _realmId, uint256 _installationId) external onlyRealmDiamond diamondPaused {
LibInstallation._unequipInstallation(_owner, _realmId, _installationId);
}

Expand Down
23 changes: 4 additions & 19 deletions contracts/InstallationDiamond/facets/InstallationUpgradeFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ contract InstallationUpgradeFacet is Modifiers {
/// @param _gotchiId The id of the gotchi which is upgrading the installation
///@param _signature API signature
///@param _gltr Amount of GLTR to use, can be 0
function upgradeInstallation(
UpgradeQueue memory _upgradeQueue,
uint256 _gotchiId,
bytes memory _signature,
uint40 _gltr
) external {
function upgradeInstallation(UpgradeQueue memory _upgradeQueue, uint256 _gotchiId, bytes memory _signature, uint40 _gltr) external diamondPaused {
// Check signature
require(
LibSignature.isValid(
Expand Down Expand Up @@ -79,19 +74,14 @@ contract InstallationUpgradeFacet is Modifiers {
}

/// @notice Allow anyone to finalize any existing queue upgrade
function finalizeUpgrades(uint256[] memory _upgradeIndexes) external {
function finalizeUpgrades(uint256[] memory _upgradeIndexes) external diamondPaused {
for (uint256 i; i < _upgradeIndexes.length; i++) {
UpgradeQueue storage upgradeQueue = s.upgradeQueue[_upgradeIndexes[i]];
LibInstallation.finalizeUpgrade(upgradeQueue.owner, _upgradeIndexes[i]);
}
}

function reduceUpgradeTime(
uint256 _upgradeIndex,
uint256 _gotchiId,
uint40 _blocks,
bytes memory _signature
) external {
function reduceUpgradeTime(uint256 _upgradeIndex, uint256 _gotchiId, uint40 _blocks, bytes memory _signature) external diamondPaused {
UpgradeQueue storage queue = s.upgradeQueue[_upgradeIndex];

require(
Expand Down Expand Up @@ -212,12 +202,7 @@ contract InstallationUpgradeFacet is Modifiers {
return s.parcelIdToUpgradeIds[_parcelId].length == 0;
}

function parcelInstallationUpgrading(
uint256 _parcelId,
uint256 _installationId,
uint256 _x,
uint256 _y
) external view returns (bool) {
function parcelInstallationUpgrading(uint256 _parcelId, uint256 _installationId, uint256 _x, uint256 _y) external view returns (bool) {
uint256[] memory parcelQueue = s.parcelIdToUpgradeIds[_parcelId];

for (uint256 i; i < parcelQueue.length; i++) {
Expand Down
17 changes: 4 additions & 13 deletions contracts/RealmDiamond/facets/BounceGateFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,19 @@ contract BounceGateFacet is Modifiers {
uint64 _durationInMinutes,
uint256[4] calldata _alchemicaSpent,
uint256 _realmId
) external {
) external diamondPaused {
LibBounceGate._createEvent(_title, _startTime, _durationInMinutes, _alchemicaSpent, _realmId);
}

function updateEvent(
uint256 _realmId,
uint256[4] calldata _alchemicaSpent,
uint40 _durationExtensionInMinutes
) external {
function updateEvent(uint256 _realmId, uint256[4] calldata _alchemicaSpent, uint40 _durationExtensionInMinutes) external diamondPaused {
LibBounceGate._updateEvent(_realmId, _alchemicaSpent, _durationExtensionInMinutes);
}

function cancelEvent(uint256 _realmId) external {
function cancelEvent(uint256 _realmId) external diamondPaused {
LibBounceGate._cancelEvent(_realmId);
}

function recreateEvent(
uint256 _realmId,
uint64 _startTime,
uint64 _durationInMinutes,
uint256[4] calldata _alchemicaSpent
) external {
function recreateEvent(uint256 _realmId, uint64 _startTime, uint64 _durationInMinutes, uint256[4] calldata _alchemicaSpent) external diamondPaused {
LibBounceGate._recreateEvent(_realmId, _startTime, _durationInMinutes, _alchemicaSpent);
}

Expand Down
30 changes: 6 additions & 24 deletions contracts/RealmDiamond/facets/ERC721Facet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,7 @@ contract ERC721Facet is Modifiers {
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
/// @param _data Additional data with no specified format, sent in call to `_to`
function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes calldata _data
) public {
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata _data) public diamondPaused {
address sender = LibMeta.msgSender();
LibERC721.transferFrom(sender, _from, _to, _tokenId);
LibERC721.checkOnERC721Received(sender, _from, _to, _tokenId, _data);
Expand All @@ -101,11 +96,7 @@ contract ERC721Facet is Modifiers {
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId
) external {
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external diamondPaused {
address sender = LibMeta.msgSender();
LibERC721.transferFrom(sender, _from, _to, _tokenId);
LibERC721.checkOnERC721Received(sender, _from, _to, _tokenId, "");
Expand All @@ -126,11 +117,7 @@ contract ERC721Facet is Modifiers {
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
function transferFrom(
address _from,
address _to,
uint256 _tokenId
) external {
function transferFrom(address _from, address _to, uint256 _tokenId) external diamondPaused {
address sender = LibMeta.msgSender();
LibERC721.transferFrom(sender, _from, _to, _tokenId);

Expand All @@ -145,7 +132,7 @@ contract ERC721Facet is Modifiers {
/// operator of the current owner.
/// @param _approved The new approved NFT controller
/// @param _tokenId The NFT to approve
function approve(address _approved, uint256 _tokenId) external {
function approve(address _approved, uint256 _tokenId) external diamondPaused {
address owner = s.parcels[_tokenId].owner;
address sender = LibMeta.msgSender();
require(owner == sender || s.operators[owner][sender], "ERC721: Not owner or operator of token.");
Expand All @@ -159,7 +146,7 @@ contract ERC721Facet is Modifiers {
/// multiple operators per owner.
/// @param _operator Address to add to the set of authorized operators
/// @param _approved True if the operator is approved, false to revoke approval
function setApprovalForAll(address _operator, bool _approved) external {
function setApprovalForAll(address _operator, bool _approved) external diamondPaused {
address sender = LibMeta.msgSender();
s.operators[sender][_operator] = _approved;
emit LibEvents.ApprovalForAll(sender, _operator, _approved);
Expand Down Expand Up @@ -198,12 +185,7 @@ contract ERC721Facet is Modifiers {
uint256 alphaBoost;
}

function safeBatchTransfer(
address _from,
address _to,
uint256[] calldata _tokenIds,
bytes calldata _data
) external {
function safeBatchTransfer(address _from, address _to, uint256[] calldata _tokenIds, bytes calldata _data) external diamondPaused {
for (uint256 index = 0; index < _tokenIds.length; index++) {
safeTransferFrom(_from, _to, _tokenIds[index], _data);
}
Expand Down
Loading