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

Contract fixes #3

Merged
merged 35 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ea0549c
Initial changes
kafann Jul 2, 2023
ecdd86a
fixes and tests
kafann Jul 14, 2023
0f373c6
Merge branch 'main' into contract-fixes
kafann Jul 14, 2023
29c38c4
Test coverage
Corantin Jul 15, 2023
a39073b
Add OVm and covergae
Corantin Jul 15, 2023
27961c2
Workflow
Corantin Jul 15, 2023
8d46a88
Covergae worflow fix
Corantin Jul 15, 2023
327249d
Merge branch 'Dev' into contract-fixes
Corantin Jul 15, 2023
b542eb4
node 18
Corantin Jul 15, 2023
7ac4929
yarn install --immutable
Corantin Jul 15, 2023
e069f8c
18
Corantin Jul 15, 2023
016f570
yarn install --frozen-lockfile
Corantin Jul 15, 2023
0d782cf
yarn install --immutable-cache
Corantin Jul 15, 2023
d2f2739
updater yarn lock
Corantin Jul 15, 2023
5e50d87
yarn install --immutable
Corantin Jul 15, 2023
ee4eff9
Update contract-coverage.yml
Corantin Jul 15, 2023
6f717a2
lint
Corantin Jul 15, 2023
7225ab8
solidity lint
Corantin Jul 15, 2023
e570854
Lint
Corantin Jul 15, 2023
7f38918
Cache
Corantin Jul 15, 2023
2cde026
Cache
Corantin Jul 15, 2023
9844567
fetch-depth > 1
Corantin Jul 15, 2023
3fc199c
Cache
Corantin Jul 15, 2023
9655763
actions/setup-node@v3
Corantin Jul 15, 2023
372ba92
Update codeql-analysis.yml
Corantin Jul 15, 2023
e6e7d7c
Merge branch 'dev' into contract-fixes
Corantin Jul 15, 2023
0aec6ec
Sonarcube
Corantin Jul 15, 2023
e2499e8
Update sonarqube.yml
Corantin Jul 15, 2023
185631d
Merge branch 'dev' into contract-fixes
Corantin Jul 15, 2023
5248ab2
Merge branch 'dev' into contract-fixes
Corantin Jul 15, 2023
7fd9fce
Format
Corantin Jul 15, 2023
92a4500
Merge branch 'dev' into contract-fixes
Corantin Jul 15, 2023
1964f94
Merge branch 'dev' into contract-fixes
Corantin Jul 15, 2023
6f8289f
modif
kafann Aug 17, 2023
bcd05ed
createLease,setagent removeAgent
kafann Aug 17, 2023
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
20 changes: 19 additions & 1 deletion CommonDAO-DeedProtocol.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,26 @@
"path": "."
},
],

"settings": {
"editor.tabSize": 2,
"prettier.tabWidth": 4

"prettier.tabWidth": 4,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
}
},
"extensions": {
"recommendations": [
"esbenp.prettier-vscode",
"dsznajder.es7-react-js-snippets",
"dbaeumer.vscode-eslint",
"xabikos.javascriptsnippets",
"styled-components.vscode-styled-components"
]
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
"resolutions": {
"usehooks-ts@^2.7.2": "patch:usehooks-ts@npm:^2.7.2#./.yarn/patches/usehooks-ts-npm-2.7.2-fceffe0e43.patch"
}
}
}
34 changes: 15 additions & 19 deletions packages/hardhat/contracts/DeedNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,38 @@ pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";


contract DeedNFT is ERC721, AccessControl {
uint256 private _nextTokenId;

mapping(uint256 => string) private _tokenNames;
mapping(uint256 => string) private _tokenSymbols;
mapping(uint256 => string) private _tokenURIs;
mapping(uint256 => AssetType) private _tokenAssetTypes;

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

enum AssetType { Land, Vehicle, Estate }
enum AssetType {
Land,
Vehicle,
Estate,
CommercialEquipment
}

constructor() ERC721("DeedNFT", "DEED") {
_nextTokenId = 1;
_setupRole(MINTER_ROLE, _msgSender());
_setupRole(MINTER_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

function mintAsset(
address _to,
string memory _tokenURI,
string memory _name,
string memory _symbol,
AssetType _assetType
) public onlyRole(MINTER_ROLE) {
// require(_to != address(0), "invalid address");
_mint(_to, _nextTokenId);
_setTokenURI(_nextTokenId, _tokenURI);
_setName(_nextTokenId, _name);
_setSymbol(_nextTokenId, _symbol);
_setAssetType(_nextTokenId, _assetType);
_nextTokenId = _nextTokenId + 1;
}
Expand All @@ -50,21 +53,12 @@ contract DeedNFT is ERC721, AccessControl {
require(_exists(tokenId), "ERC721Metadata: Name set of nonexistent token");
_tokenNames[tokenId] = _name;
}

function getTokenName(uint256 tokenId) public view returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: Name query for nonexistent token");
return _tokenNames[tokenId];
}

function _setSymbol(uint256 tokenId, string memory _symbol) internal virtual {
require(_exists(tokenId), "ERC721Metadata: Symbol set of nonexistent token");
_tokenSymbols[tokenId] = _symbol;
}

function getTokenSymbol(uint256 tokenId) public view returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: Symbol query for nonexistent token");
return _tokenSymbols[tokenId];
}

function _setAssetType(uint256 tokenId, AssetType _assetType) internal virtual {
require(_exists(tokenId), "ERC721Metadata: Asset type set of nonexistent token");
_tokenAssetTypes[tokenId] = _assetType;
Expand All @@ -82,13 +76,15 @@ contract DeedNFT is ERC721, AccessControl {
function removeMinter(address minter) public onlyRole(DEFAULT_ADMIN_ROLE) {
revokeRole(MINTER_ROLE, minter);
}

function canSubdivide(uint256 tokenId) public view returns (bool) {

//External instead of public?
function canSubdivide(uint256 tokenId) external view returns (bool) {
AssetType assetType = getAssetType(tokenId);
return assetType == AssetType.Land || assetType == AssetType.Estate;
}

//Use?
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, AccessControl) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
}
Loading
Loading