Skip to content

Commit

Permalink
Merge pull request #76 from MyriadFlow/PhygitalA
Browse files Browse the repository at this point in the history
Added phygital
  • Loading branch information
soumalya340 authored Jan 20, 2024
2 parents f8ab8a7 + a0ef0de commit c07c8ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
2 changes: 1 addition & 1 deletion contracts/phygital/Phygital.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ contract Phygital is Context, ERC721Enumerable, ERC2981, IERC4907 {
string memory metadataURI,
uint96 royaltyPercentBasisPoint,
bytes16 _nfcId
) public returns (uint256) {
) public onlyCreator returns (uint256) {
// We cannot just use balanceOf to create the new tokenId because tokens
// can be burned (destroyed), so we need a separate counter.
require(!nfcCheck[_nfcId], "Phygital: NFC Tag is already stored!");
Expand Down
42 changes: 14 additions & 28 deletions contracts/phygital/PhygitalA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ contract PhygitalA is
IERC4907,
ERC2981,
ERC721A,
ERC721ABurnable,
EIP712
ERC721ABurnable
{
// Set Constants for Interface ID and Roles
bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;
Expand Down Expand Up @@ -81,6 +80,14 @@ contract PhygitalA is
_;
}

modifier onlyOperator() {
require(
flowRoles.isOperator(_msgSender()),
"PhygitalA: User is not authorized "
);
_;
}

event PhygitalAAssetCreated(
uint256 currentIndex,
uint256 quantity,
Expand Down Expand Up @@ -111,12 +118,10 @@ contract PhygitalA is
string memory symbol,
address tradeHubAddress,
address accessControlAddress,
string memory domain,
string memory _version,
uint256 _maxSupply,
uint256 _royaltyBPS,
string memory _baseUri
) ERC721A(name, symbol) EIP712(domain, _version) {
) ERC721A(name, symbol) {
flowRoles = IACCESSMASTER(accessControlAddress);
tradeHub = tradeHubAddress;
maxSupply = _maxSupply;
Expand Down Expand Up @@ -159,20 +164,15 @@ contract PhygitalA is
return (prevQuantity, quantity);
}


/// @dev to register Asset NFC ID TO the tokenID
function registerAssetId(
LazyNFTVoucher calldata voucher,
uint256 tokenId,
bytes16 _nfcId
) external {
) external onlyOperator {
require(!nfcCheck[_nfcId],"PhygitalA: It's already registerd");
require(
flowRoles.isCreator(recover(voucher)),
"PhygitalA: Invalid Signature!"
);
_tokenURIs[tokenId] = voucher.uri;
nfcId[tokenId] = _nfcId;
nfcCheck[_nfcId] = true;
}

/**
Expand All @@ -194,21 +194,7 @@ contract PhygitalA is
emit PhygitalAAssetDestroyed(tokenId, _msgSender());
}

///@dev To recover the singer who has signed
function recover(
LazyNFTVoucher calldata voucher
) public view returns (address) {
bytes32 digest = _hashTypedDataV4(
keccak256(
abi.encode(
keccak256("LazyNFTVoucher(uint256 price,string uri)"),
keccak256(bytes(voucher.uri))
)
)
);
address signer = ECDSA.recover(digest, voucher.signature);
return signer;
}


/********************* ERC4907 *********************************/
/// @dev Owner can set the rental status of the token
Expand Down

0 comments on commit c07c8ea

Please sign in to comment.