-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Contracts): DApp registry contract using ENS and FDS registrar as base #27
base: master
Are you sure you want to change the base?
Changes from all commits
8b134e3
a360067
fc58443
7111b38
7f18ede
1448c17
a7bd882
2c790ea
cbc7204
4521e38
89466c8
52f4668
ad9826d
79157a0
81b50cd
448339a
d95bbf1
647cfef
a07150c
509e8c1
7b766b8
b367a07
f79bc29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,132 @@ | ||||||||||
// SPDX-License-Identifier: MIT | ||||||||||
pragma solidity ^0.8.0; | ||||||||||
|
||||||||||
import "@ensdomains/ens-contracts/contracts/registry/ENSRegistry.sol"; | ||||||||||
import "@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol"; | ||||||||||
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; | ||||||||||
import "@ensdomains/solsha1/contracts/SHA1.sol"; | ||||||||||
import "@ensdomains/buffer/contracts/Buffer.sol"; | ||||||||||
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; | ||||||||||
import "@ensdomains/ens-contracts/contracts/registry/ENS.sol"; | ||||||||||
import "./FDSRegistrar.sol"; | ||||||||||
|
||||||||||
contract DappRegistry { | ||||||||||
|
||||||||||
struct Record { | ||||||||||
// ENS app name | ||||||||||
bytes32 node; | ||||||||||
// DApp description | ||||||||||
string description; | ||||||||||
// app version | ||||||||||
uint8 version; | ||||||||||
// indexation type | ||||||||||
uint8 indexType; | ||||||||||
// Data structure format | ||||||||||
bytes32 dataFormat; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you elaborate this one please? it is related to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should leave this agnostic, beeson by default, but they could use other dataformats. If is always beeson, then I wil remove it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eg based on the multibase tables.csv values There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no it is fine as it is for now |
||||||||||
// Data structure reference | ||||||||||
bytes32 blobRef; | ||||||||||
// Creation date | ||||||||||
uint256 timestamp; | ||||||||||
} | ||||||||||
event DappRecordAdded( | ||||||||||
bytes32 indexed node, | ||||||||||
bytes32 label, | ||||||||||
uint256 duration | ||||||||||
); | ||||||||||
event DappRecordUpdated( | ||||||||||
bytes32 indexed node, | ||||||||||
string description, | ||||||||||
uint8 version | ||||||||||
); | ||||||||||
// Maps listingHashes to associated node data | ||||||||||
mapping(bytes32 => Record) private records; | ||||||||||
Comment on lines
+41
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so it is the
Suggested change
|
||||||||||
|
||||||||||
|
||||||||||
// Global Variables | ||||||||||
ENS public ensInstance; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove indent |
||||||||||
FDSRegistrar fdsRegistrar; | ||||||||||
|
||||||||||
constructor( | ||||||||||
ENS _ens, | ||||||||||
FDSRegistrar _fdsRegistrar | ||||||||||
) { | ||||||||||
ensInstance = _ens; | ||||||||||
fdsRegistrar = _fdsRegistrar; | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* @dev Gets dapp record. | ||||||||||
* | ||||||||||
* Returns a Record object. | ||||||||||
*/ | ||||||||||
function get(bytes32 _nodehash) | ||||||||||
public | ||||||||||
view | ||||||||||
returns (Record memory) | ||||||||||
{ | ||||||||||
|
||||||||||
require( | ||||||||||
records[_nodehash].node == _nodehash, | ||||||||||
"Dapp does not exist." | ||||||||||
Comment on lines
+69
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be possible just check for a null value for |
||||||||||
); | ||||||||||
|
||||||||||
return (records[_nodehash]); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* @dev Updates a dapp record. | ||||||||||
* | ||||||||||
* Returns the node hash | ||||||||||
* | ||||||||||
* Emits an {DappRecordUpdated} event. | ||||||||||
*/ | ||||||||||
function update( | ||||||||||
bytes32 _nodehash, | ||||||||||
Record calldata _record | ||||||||||
) external returns (bytes32) { | ||||||||||
|
||||||||||
require( | ||||||||||
records[_nodehash].node == _nodehash, | ||||||||||
"Dapp does not exist." | ||||||||||
); | ||||||||||
if (bytes(_record.description).length > 0) { | ||||||||||
records[_nodehash].description = _record.description; | ||||||||||
} | ||||||||||
records[_nodehash].version = _record.version; | ||||||||||
records[_nodehash].indexType = _record.indexType; | ||||||||||
if (bytes32(_record.dataFormat).length > 0) { | ||||||||||
records[_nodehash].dataFormat = _record.dataFormat; | ||||||||||
} | ||||||||||
if (bytes32(_record.blobRef).length > 0) { | ||||||||||
records[_nodehash].blobRef = _record.blobRef; | ||||||||||
} | ||||||||||
records[_nodehash].timestamp = block.timestamp; | ||||||||||
|
||||||||||
emit DappRecordUpdated(_nodehash, _record.description, _record.version); | ||||||||||
|
||||||||||
return _nodehash; | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* @dev Registers a new dapp record. | ||||||||||
* | ||||||||||
* Returns the node hash | ||||||||||
* | ||||||||||
* Emits an {DappRecordAdded} event. | ||||||||||
*/ | ||||||||||
function add( | ||||||||||
bytes32 _nodehash, | ||||||||||
bytes32 _label, | ||||||||||
address _owner, | ||||||||||
uint _duration, | ||||||||||
Record calldata _record | ||||||||||
) external returns (bytes32) { | ||||||||||
fdsRegistrar.register(uint256(_label), _owner, _duration); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we may need an additional optional parameter for |
||||||||||
|
||||||||||
// Sets record | ||||||||||
records[_nodehash] = _record; | ||||||||||
emit DappRecordAdded(_nodehash, _label, _duration); | ||||||||||
|
||||||||||
return _nodehash; | ||||||||||
} | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary? we just store records in the
records
mapping where you need to pass thenode
as key.