-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
164 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
pragma solidity ^0.8.0; | ||
// Copyright 2020 Keyko GmbH. | ||
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) | ||
// Code is Apache-2.0 and docs are CC-BY-4.0 | ||
|
||
import '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol'; | ||
|
||
/** | ||
* | ||
* @dev Implementation of the Royalties EIP-2981 base contract | ||
* See https://eips.ethereum.org/EIPS/eip-2981 | ||
*/ | ||
abstract contract ERC2981 is IERC2981Upgradeable { | ||
|
||
struct RoyaltyInfo { | ||
address receiver; | ||
uint256 royaltyAmount; | ||
} | ||
|
||
// Mapping of Royalties per tokenId (DID) | ||
mapping(uint256 => RoyaltyInfo) internal _royalties; | ||
|
||
function supportsInterface(bytes4 interfaceId) | ||
public | ||
view | ||
virtual | ||
override | ||
returns (bool) | ||
{ | ||
return | ||
interfaceId == type(IERC2981Upgradeable).interfaceId || | ||
supportsInterface(interfaceId); | ||
} | ||
|
||
function _setTokenRoyalty( | ||
uint256 tokenId, | ||
address receiver, | ||
uint256 royaltyAmount | ||
) | ||
internal | ||
{ | ||
require(royaltyAmount <= 100, 'ERC2981Royalties: Too high'); | ||
_royalties[tokenId] = RoyaltyInfo(receiver, royaltyAmount); | ||
} | ||
|
||
/** | ||
* @inheritdoc IERC2981Upgradeable | ||
*/ | ||
function royaltyInfo( | ||
uint256 tokenId, | ||
uint256 value | ||
) | ||
external | ||
view | ||
override | ||
returns (address receiver, uint256 royaltyAmount) | ||
{ | ||
RoyaltyInfo memory royalties = _royalties[tokenId]; | ||
receiver = royalties.receiver; | ||
royaltyAmount = (value * royalties.royaltyAmount) / 100; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters