Skip to content
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
3 changes: 2 additions & 1 deletion XRC721/Address.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/**
* @dev Collection of functions related to the address type,
Expand Down
71 changes: 36 additions & 35 deletions XRC721/Counters.sol
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "./SafeMath.sol";

/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
* of elements in a mapping, issuing XRC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
* Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the SafeMath
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using SafeMath for uint256;

struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/XDC/solidity/issues/4637
uint256 _value; // default: 0
}

function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}

function increment(Counter storage counter) internal {
counter._value += 1;
}

function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
import "./SafeMath.sol";

/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
* of elements in a mapping, issuing XRC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
* Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the SafeMath
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using SafeMath for uint256;

struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/XDC/solidity/issues/4637
uint256 _value; // default: 0
}

function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}

function increment(Counter storage counter) internal {
counter._value += 1;
}

function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
}

37 changes: 19 additions & 18 deletions XRC721/IXRC165.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/**
* @dev Interface of the XRC165 standard
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others (`XRC165Checker`).
*
* For an implementation, see `XRC165`.
*/
interface IXRC165 {
/**
* @dev Interface of the XRC165 standard
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others (`XRC165Checker`).
*
* For an implementation, see `XRC165`.
*/
interface IXRC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`.
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`.
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

103 changes: 52 additions & 51 deletions XRC721/IXRC721.sol
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
pragma solidity ^0.5.0;

import "./IXRC165.sol";
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "./IXRC165.sol";

/**
* @dev Required interface of an XRC721 compliant contract.
*/
interface IXRC721 is IXRC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

/**
* @dev Required interface of an XRC721 compliant contract.
*/
contract IXRC721 is IXRC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

/**
* @dev Returns the number of NFTs in `owner`'s account.
*/
function balanceOf(address owner) public view returns (uint256 balance);

/**
* @dev Returns the owner of the NFT specified by `tokenId`.
*/
function ownerOf(uint256 tokenId) public view returns (address owner);

/**
* @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
* another (`to`).
*
*
*
* Requirements:
* - `from`, `to` cannot be zero.
* - `tokenId` must be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this
* NFT by either `approve` or `setApproveForAll`.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public;
/**
* @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
* another (`to`).
*
* Requirements:
* - If the caller is not `from`, it must be approved to move this NFT by
* either `approve` or `setApproveForAll`.
*/
function transferFrom(address from, address to, uint256 tokenId) public;
function approve(address to, uint256 tokenId) public;
function getApproved(uint256 tokenId) public view returns (address operator);

function setApprovalForAll(address operator, bool _approved) public;
function isApprovedForAll(address owner, address operator) public view returns (bool);


function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public;
}
* @dev Returns the number of NFTs in `owner`'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);

/**
* @dev Returns the owner of the NFT specified by `tokenId`.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);

/**
* @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
* another (`to`).
*
*
*
* Requirements:
* - `from`, `to` cannot be zero.
* - `tokenId` must be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this
* NFT by either `approve` or `setApproveForAll`.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
* another (`to`).
*
* Requirements:
* - If the caller is not `from`, it must be approved to move this NFT by
* either `approve` or `setApproveForAll`.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
function approve(address to, uint256 tokenId) external;
function getApproved(uint256 tokenId) external view returns (address operator);

function setApprovalForAll(address operator, bool _approved) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);


function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) external;
}

46 changes: 23 additions & 23 deletions XRC721/IXRC721Receiver.sol
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/**
* @title XRC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from XRC721 asset contracts.
*/
interface IXRC721Receiver {
/**
* @title XRC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from XRC721 asset contracts.
*/
contract IXRC721Receiver {
/**
* @notice Handle the receipt of an NFT
* @dev The XRC721 smart contract calls this function on the recipient
* after a `safeTransfer`. This function MUST return the function selector,
* otherwise the caller will revert the transaction. The selector to be
* returned can be obtained as `this.onXRC721Received.selector`. This
* function MAY throw to revert and reject the transfer.
* Note: the XRC721 contract address is always the message sender.
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return bytes4 `bytes4(keccak256("onXRC721Received(address,address,uint256,bytes)"))`
*/
function onXRC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public returns (bytes4);
}
* @notice Handle the receipt of an NFT
* @dev The XRC721 smart contract calls this function on the recipient
* after a `safeTransfer`. This function MUST return the function selector,
* otherwise the caller will revert the transaction. The selector to be
* returned can be obtained as `this.onXRC721Received.selector`. This
* function MAY throw to revert and reject the transfer.
* Note: the XRC721 contract address is always the message sender.
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return bytes4 `bytes4(keccak256("onXRC721Received(address,address,uint256,bytes)"))`
*/
function onXRC721Received(address operator, address from, uint256 tokenId, bytes memory data) external returns (bytes4);
}

Loading