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

Update Phygital Version #80

Merged
merged 2 commits into from
Jun 25, 2024
Merged
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
17 changes: 6 additions & 11 deletions contracts/accessmaster/AccessMaster.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol";

/**
* @dev This Contract Module helps to deploy the
Expand All @@ -21,22 +21,17 @@ contract AccessMaster is AccessControlEnumerable {
keccak256("FLOW_OPERATOR_ROLE");
bytes32 public constant FLOW_CREATOR_ROLE = keccak256("FLOW_CREATOR_ROLE");

constructor(address storefrontAdmin) {
_setupRole(FLOW_ADMIN_ROLE, _msgSender());

constructor(address _payoutAddress) {
_setRoleAdmin(FLOW_ADMIN_ROLE, FLOW_ADMIN_ROLE);
_setRoleAdmin(FLOW_OPERATOR_ROLE, FLOW_ADMIN_ROLE);
_setRoleAdmin(FLOW_CREATOR_ROLE, FLOW_OPERATOR_ROLE);

_grantRole(FLOW_ADMIN_ROLE, _msgSender());
// add Admin to operator and Creator
grantRole(FLOW_OPERATOR_ROLE, _msgSender());

// assigning storefront publisher Wallet the Admin role
grantRole(FLOW_ADMIN_ROLE, storefrontAdmin);
grantRole(FLOW_OPERATOR_ROLE, storefrontAdmin);
grantRole(FLOW_CREATOR_ROLE, storefrontAdmin);
grantRole(FLOW_CREATOR_ROLE, _msgSender());

payoutAddress = storefrontAdmin;
payoutAddress = _payoutAddress;
}

function updateName(
Expand Down
2 changes: 1 addition & 1 deletion contracts/accessmaster/interfaces/IAccessMaster.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
pragma solidity ^0.8.17;

/**
* @dev External interface of AccessMaster declared to support ERC165 detection.
Expand Down
44 changes: 29 additions & 15 deletions contracts/eternalsoul/EternalSoul.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ pragma solidity ^0.8.17;

import "@openzeppelin/contracts/utils/Context.sol";
import "../accessmaster/interfaces/IAccessMaster.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";

/**
Expand Down Expand Up @@ -175,7 +176,7 @@ contract EternalSoul is Context, ERC721Enumerable, EIP712 {
*/
function destroyAsset(uint256 tokenId) public {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
_isAuthorized(_ownerOf(tokenId), _msgSender(), tokenId),
"EternalSoul: Caller is not token owner or approved"
);
_burn(tokenId);
Expand All @@ -193,7 +194,10 @@ contract EternalSoul is Context, ERC721Enumerable, EIP712 {
uint256 tokenId,
string memory _tokenURI
) internal virtual {
require(_exists(tokenId), "EternalSoul: Non-Existent Asset");
require(
_requireOwned(tokenId) == _msgSender(),
"EternalSoul: Non-Existent Asset"
);
_tokenURIs[tokenId] = _tokenURI;
}

Expand Down Expand Up @@ -222,7 +226,10 @@ contract EternalSoul is Context, ERC721Enumerable, EIP712 {
function tokenURI(
uint256 tokenId
) public view virtual override returns (string memory) {
require(_exists(tokenId), "EternalSoul: Non-Existent Asset");
require(
_requireOwned(tokenId) == _msgSender(),
"EternalSoul: Non-Existent Asset"
);
if (bytes(_tokenURIs[tokenId]).length == 0) {
string memory _tokenUri = _baseURI(); //ERC721
return _tokenUri;
Expand All @@ -235,19 +242,26 @@ contract EternalSoul is Context, ERC721Enumerable, EIP712 {
return baseURI;
}

/// @dev only minting and burning can happen
/// token transfer are restricted
function _beforeTokenTransfer(
address from,
// function _transfer(
// address from,
// address to,
// uint256 tokenId
// ) internal override {
// require(
// from == address(0) || to == address(0),
// "EternalSoul : Asset cannot be transferred"
// );
// super._transfer(from, to, tokenId);
// }

function _update(
address to,
uint256 tokenId,
uint256 batchSize
) internal virtual override(ERC721Enumerable) {
require(
from == address(0) || to == address(0),
"EternalSoul : Asset cannot be transferred"
);
super._beforeTokenTransfer(from, to, tokenId, batchSize);
address auth
) internal virtual override returns (address) {
require(to == address(0), "EternalSoul : Asset cannot be transferred");
address from = super._update(to, tokenId, auth);
return from;
}

/**
Expand Down
37 changes: 20 additions & 17 deletions contracts/eturnumpass/EternumPass.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
pragma solidity ^0.8.20;

import "../common/interface/IERC4907.sol";
import "../common/interface/IERC5643.sol";
Expand Down Expand Up @@ -73,7 +73,10 @@ contract EternumPass is Context, IERC4907, IERC5643, ERC2981, ERC721Enumerable {
}

modifier onlyWhenTokenExist(uint256 tokenId) {
require(_exists(tokenId), "EternumPass: Not a valid tokenId");
require(
_requireOwned(tokenId) == _msgSender(),
"EternumPass: Not a valid tokenId"
);
_;
}

Expand Down Expand Up @@ -224,7 +227,7 @@ contract EternumPass is Context, IERC4907, IERC5643, ERC2981, ERC721Enumerable {
*/
function revokeSubscription(uint256 _tokenId) public {
require(
_isApprovedOrOwner(_msgSender(), _tokenId),
_isAuthorized(_ownerOf(_tokenId), _msgSender(), _tokenId),
"EternumPass: Not Owner Or Approved"
);
_burn(_tokenId);
Expand All @@ -247,7 +250,7 @@ contract EternumPass is Context, IERC4907, IERC5643, ERC2981, ERC721Enumerable {
uint64 expires
) public override {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
_isAuthorized(_ownerOf(tokenId), _msgSender(), tokenId),
"EternumPass: Not token owner Or approved"
);
require(
Expand All @@ -267,7 +270,7 @@ contract EternumPass is Context, IERC4907, IERC5643, ERC2981, ERC721Enumerable {
uint256 pricePerHour
) public {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
_isAuthorized(_ownerOf(tokenId), _msgSender(), tokenId),
"EternumPass: Caller is not token owner or approved"
);
rentables[tokenId].isRentable = isRentable;
Expand All @@ -283,7 +286,10 @@ contract EternumPass is Context, IERC4907, IERC5643, ERC2981, ERC721Enumerable {
/// @param _timeInHours is in hours , Ex- 1,2,3

function rent(uint256 _tokenId, uint256 _timeInHours) external payable {
require(_exists(_tokenId), "SignatureSeries: Invalide Token Id");
require(
_requireOwned(_tokenId) == _msgSender(),
"Eternumpass: Invalide Token Id"
);
require(
rentables[_tokenId].isRentable,
"EternumPass: Not available for rent"
Expand Down Expand Up @@ -339,7 +345,8 @@ contract EternumPass is Context, IERC4907, IERC5643, ERC2981, ERC721Enumerable {
) external payable onlyWhenTokenExist(tokenId) {
bool isOperator = flowRoles.isOperator(_msgSender());
require(
_isApprovedOrOwner(_msgSender(), tokenId) || isOperator,
_isAuthorized(_ownerOf(tokenId), _msgSender(), tokenId) ||
isOperator,
"EternumPass: Caller is owner nor approved or the Operator"
);
require(
Expand Down Expand Up @@ -385,7 +392,7 @@ contract EternumPass is Context, IERC4907, IERC5643, ERC2981, ERC721Enumerable {
bool isOperator = flowRoles.isOperator(_msgSender());
if (!isOperator) {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
_isAuthorized(_ownerOf(tokenId), _msgSender(), tokenId),
"EternumPass: Caller is owner nor approved"
);
require(
Expand Down Expand Up @@ -498,21 +505,17 @@ contract EternumPass is Context, IERC4907, IERC5643, ERC2981, ERC721Enumerable {
return baseURI;
}

function _beforeTokenTransfer(
address from,
function _update(
address to,
uint256 tokenId,
uint256 batchSize
) internal virtual override(ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId, batchSize);
address auth
) internal virtual override returns (address) {
address from = super._update(to, tokenId, auth);
if (from != to && rentables[tokenId].user != address(0)) {
delete rentables[tokenId];
emit UpdateUser(tokenId, address(0), 0);
}
}

function timeStamp() external view returns (uint256) {
return block.timestamp;
return from;
}

function supportsInterface(
Expand Down
3 changes: 2 additions & 1 deletion contracts/flow-contracts/cybermaven/CyberMaven.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ contract CyberMaven is
}
_nounce++;
}

// Put Getter

function getValueFromMyContract(
Expand Down Expand Up @@ -260,7 +261,7 @@ contract CyberMaven is

function supportsInterface(
bytes4 interfaceId
) public view virtual override(IERC165, ERC1155Receiver) returns (bool) {
) public view virtual override(IERC165, ERC1155Holder) returns (bool) {
if (
interfaceId == type(IERC165).interfaceId ||
interfaceId == type(IERC6551Account).interfaceId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "../../accessmaster/interfaces/IAccessMaster.sol";
Expand Down
Loading
Loading