-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip: royalties * wip: fallback on creator * feat: use soliditiy 0.8 * wip: make old test pass * feat: test royalties; * feat: enhance error messages * feat: add missing test cases * feat: compute royalties * refactor: unused var * feat: add more tests * feat: send fees on publication fees * feat: add deployers * feat: deploy with priv * fix: tests
- Loading branch information
1 parent
efb1507
commit 32d17b0
Showing
29 changed files
with
5,038 additions
and
267 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
pragma solidity ^0.7.6; | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.10; | ||
|
||
|
||
contract ContextMixin { | ||
|
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
pragma solidity ^0.7.6; | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.10; | ||
|
||
|
||
contract EIP712Base { | ||
|
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,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.10; | ||
pragma experimental ABIEncoderV2; | ||
|
||
|
||
interface IERC721CollectionV2 { | ||
function creator() external view returns (address); | ||
function decodeTokenId(uint256 _tokenId) external view returns (uint256, uint256); | ||
function items(uint256 _itemId) external view returns (string memory, uint256, uint256, uint256, address, string memory, string memory); | ||
} |
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,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.10; | ||
|
||
import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; | ||
|
||
|
||
interface IERC721Verifiable is IERC721 { | ||
function verifyFingerprint(uint256, bytes memory) external view returns (bool); | ||
} |
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,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.10; | ||
|
||
interface IRoyaltiesManager { | ||
function getRoyaltiesReceiver(address _contractAddress, uint256 _tokenId) external view returns (address); | ||
} |
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,65 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.10; | ||
|
||
|
||
import '../interfaces/IERC721CollectionV2.sol'; | ||
|
||
|
||
contract RoyaltiesManager{ | ||
|
||
constructor() {} | ||
|
||
/** | ||
* @notice Get the royalties receiver for an specific token | ||
* @dev It tries to get the item beneficiary. If it is the ZERO address, will try to get the creator | ||
* @param _contractAddress - contract address | ||
* @param _tokenId - token id | ||
* @return royaltiesReceiver - address of the royalties receiver | ||
*/ | ||
function getRoyaltiesReceiver(address _contractAddress, uint256 _tokenId) external view returns(address royaltiesReceiver) { | ||
bool success; | ||
bytes memory res; | ||
|
||
(success, res) = _contractAddress.staticcall( | ||
abi.encodeWithSelector( | ||
IERC721CollectionV2(_contractAddress).decodeTokenId.selector, | ||
_tokenId | ||
) | ||
); | ||
|
||
if (!success) { | ||
return royaltiesReceiver; | ||
} | ||
|
||
(uint256 itemId,) = abi.decode(res, (uint256, uint256)); | ||
|
||
(success, res) = _contractAddress.staticcall( | ||
abi.encodeWithSelector( | ||
IERC721CollectionV2(_contractAddress).items.selector, | ||
itemId | ||
) | ||
); | ||
|
||
if (success) { | ||
// Get item beneficiary | ||
(,,,,royaltiesReceiver,,) = abi.decode(res, (string, uint256, uint256, uint256, address, string, string)); | ||
} | ||
|
||
if (royaltiesReceiver == address(0)) { | ||
// If still the zero address, use the creator | ||
(success, res) = _contractAddress.staticcall( | ||
abi.encodeWithSelector( | ||
IERC721CollectionV2(_contractAddress).creator.selector | ||
)); | ||
|
||
if (!success) { | ||
return royaltiesReceiver; | ||
} | ||
|
||
royaltiesReceiver = abi.decode(res, (address)); | ||
} | ||
|
||
return royaltiesReceiver; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
pragma solidity ^0.7.6; | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.10; | ||
|
||
|
||
/** | ||
|
Oops, something went wrong.