Skip to content

Commit

Permalink
Merge pull request #77 from MyriadFlow/Update1
Browse files Browse the repository at this point in the history
Added Phygital Scripts
  • Loading branch information
soumalya340 authored Jan 24, 2024
2 parents a3cbdbe + c4c1875 commit fe6e7e9
Show file tree
Hide file tree
Showing 13 changed files with 1,479 additions and 522 deletions.
48 changes: 24 additions & 24 deletions contracts/phygital/Phygital.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ contract Phygital is Context, ERC721Enumerable, ERC2981, IERC4907 {
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;

mapping(uint256 => bytes16) public nfcId;
mapping(uint256 => bytes16) public phygitalID;

mapping(bytes16 => bool) public nfcCheck;
mapping(bytes16 => bool) public assetStatus;

IACCESSMASTER flowRoles;

Expand Down Expand Up @@ -111,14 +111,12 @@ contract Phygital is Context, ERC721Enumerable, ERC2981, IERC4907 {
constructor(
string memory name,
string memory symbol,
uint256 _nftPrice,
address tradeHubAddress,
address flowContract
) ERC721(name, symbol) {
flowRoles = IACCESSMASTER(flowContract);
tradeHub = tradeHubAddress;
accessMasterAddress = flowContract;
nftPrice = _nftPrice;
}

/// @notice transferring funds
Expand Down Expand Up @@ -152,16 +150,16 @@ contract Phygital is Context, ERC721Enumerable, ERC2981, IERC4907 {
function createAsset(
string memory metadataURI,
uint96 royaltyPercentBasisPoint,
bytes16 _nfcId
bytes16 _phygitalID
) 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!");
require(!assetStatus[_phygitalID], "Phygital: NFC Tag is already stored!");
Counter++;
uint256 currentTokenID = Counter;

nfcId[currentTokenID] = _nfcId;
nfcCheck[_nfcId] = true;
phygitalID[currentTokenID] = _phygitalID;
assetStatus[_phygitalID] = true;

_safeMint(_msgSender(), currentTokenID);
_setTokenURI(currentTokenID, metadataURI);
Expand Down Expand Up @@ -197,16 +195,16 @@ contract Phygital is Context, ERC721Enumerable, ERC2981, IERC4907 {
address creator,
string memory metadataURI,
uint96 royaltyPercentBasisPoint,
bytes16 _nfcId
bytes16 _phygitalID
) public onlyOperator 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!");
require(!assetStatus[_phygitalID], "Phygital: NFC Tag is already stored!");
Counter++;
uint256 currentTokenID = Counter;

nfcId[currentTokenID] = _nfcId;
nfcCheck[_nfcId] = true;
phygitalID[currentTokenID] = _phygitalID;
assetStatus[_phygitalID] = true;

_safeMint(creator, currentTokenID);
_setTokenURI(currentTokenID, metadataURI);
Expand Down Expand Up @@ -333,18 +331,6 @@ contract Phygital is Context, ERC721Enumerable, ERC2981, IERC4907 {

/** Getter Functions **/

/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(
uint256 tokenId
) public view virtual override returns (string memory) {
require(_exists(tokenId), "Phygital: Non-Existent Asset");
string memory _tokenURI = _tokenURIs[tokenId];

return _tokenURI;
}

/************* Rental(ERC4907) ***************** */
/// @dev IERC4907 implementation
function userOf(uint256 tokenId) public view returns (address) {
Expand All @@ -371,6 +357,20 @@ contract Phygital is Context, ERC721Enumerable, ERC2981, IERC4907 {

/////////////////////////////////////////////////

/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(
uint256 tokenId
) public view virtual override returns (string memory) {
require(_exists(tokenId), "SignatureSeries: Non-Existent Asset");
string memory _tokenURI = _tokenURIs[tokenId];

return _tokenURI;
}



function _beforeTokenTransfer(
address from,
address to,
Expand Down
13 changes: 6 additions & 7 deletions contracts/phygital/PhygitalA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ contract PhygitalA is

mapping(uint256 => string) private _tokenURIs;

mapping(uint256 => bytes16) public nfcId;
mapping(uint256 => bytes16) public phygitalID;

mapping(bytes16 => bool) public nfcCheck;
mapping(bytes16 => bool) public assetStatus;

// INTERFACES
IACCESSMASTER flowRoles;
Expand Down Expand Up @@ -164,15 +164,14 @@ contract PhygitalA is
return (prevQuantity, quantity);
}


/// @dev to register Asset NFC ID TO the tokenID
function registerAssetId(
uint256 tokenId,
bytes16 _nfcId
bytes16 _phygitalID
) external onlyOperator {
require(!nfcCheck[_nfcId],"PhygitalA: It's already registerd");
nfcId[tokenId] = _nfcId;
nfcCheck[_nfcId] = true;
require(!assetStatus[_phygitalID],"PhygitalA: It's already registerd");
phygitalID[tokenId] = _phygitalID;
assetStatus[_phygitalID] = true;
}

/**
Expand Down
Loading

0 comments on commit fe6e7e9

Please sign in to comment.