Skip to content
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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8b134e3
feat(contracts): init commit
molekilla May 25, 2022
a360067
feat(contracts): init commit
molekilla May 25, 2022
fc58443
feat(contracts): refactoring propose
molekilla May 27, 2022
7111b38
feat(contracts): burn / transfer placeholders
molekilla May 27, 2022
7f18ede
feat(contracts): init dapp registry implementation
molekilla May 27, 2022
1448c17
feat(contracts): removing voting/challenge
molekilla May 30, 2022
a7bd882
feat(contracts): dapp add record test
molekilla May 31, 2022
2c790ea
Merge branch 'master' into dapp-tcr
molekilla May 31, 2022
cbc7204
feat(contracts): more tests
molekilla May 31, 2022
4521e38
feat(contracts): tests
molekilla Jun 2, 2022
89466c8
feat(contracts): fds registrar contracts
molekilla Jun 2, 2022
52f4668
feat(contracts): unit tests for fds registrar
molekilla Jun 4, 2022
ad9826d
feat(contracts): fds base registrar
molekilla Jun 7, 2022
79157a0
feat(contracts): negative tests
molekilla Jun 7, 2022
81b50cd
feat(contracts): using @ensdomains contract library
molekilla Jun 7, 2022
448339a
feat(contracts): grace period unit tests
molekilla Jun 7, 2022
d95bbf1
Merge remote-tracking branch 'origin/fds-registrar' into dapp-tcr
molekilla Jun 9, 2022
647cfef
feat(contracts): unit tests
molekilla Jun 9, 2022
a07150c
feat(contracts): dappregistry is using ENS and FDS as base registries
molekilla Jun 10, 2022
509e8c1
feat(contracts): removing unnecesary dependencies
molekilla Jun 15, 2022
7b766b8
Merge branch 'master' into dapp-tcr
molekilla Jun 17, 2022
b367a07
feat(contracts): removed stale code. refactor dapp registry. added da…
molekilla Jun 23, 2022
f79bc29
Merge branch 'master' into dapp-tcr
molekilla Jul 6, 2022
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
132 changes: 132 additions & 0 deletions contracts/DappRegistry.sol
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;
Copy link
Collaborator

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 the node as key.

// DApp description
string description;
// app version
uint8 version;
// indexation type
uint8 indexType;
// Data structure format
bytes32 dataFormat;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate this one please? it is related to BeeSon or any other datastructure signiture?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg based on the multibase tables.csv values

Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it is the node => Record mapping, isn't it?

Suggested change
// Maps listingHashes to associated node data
mapping(bytes32 => Record) private records;
// Maps ENS node to associated dApp record
mapping(bytes32 => Record) private records;



// Global Variables
ENS public ensInstance;
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be possible just check for a null value for records[_nodehash]?

);

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may need an additional optional parameter for register that indicates it was a dApp registration. Its default parameter should be false, and we need to save it to the ENS record.


// Sets record
records[_nodehash] = _record;
emit DappRecordAdded(_nodehash, _label, _duration);

return _nodehash;
}
}
Loading