Skip to content

Commit

Permalink
Refactor (#156)
Browse files Browse the repository at this point in the history
* feat: refactor grantOperatorPermissionsWithSig

* feat: rename

* feat: minor refactor with storageLib

* feat: minor refactor with OperatorLib & PostLib

* feat: minor refactor for LinkLib

* feat: minor refactor

* feat: use _handleHash

* feat: use ValidationLib

* feat: remove duplicated code

* feat: optimize _validateCallerPermission & _validateCallerPermission4Note

* Update Web3EntryBase.sol

* chore: optimize code size

* chore: minor refactor

* feat: add test cases for grantOperatorPermissionsWithSig

* feat: update test cases

* feat: remove ProxyAdmin

* feat: minor refactor

* feat: minor refactor

* feat: update test cases

* feat: rename LinklistLogic as LinklistLib

* feat: remove unused scripts

* feat: fix for solhint

* feat: fix compile

* feat: update test cases for operators

* feat: add testGrantOperatorPermissionsWithSigMultiple

* feat: add deleteAttachedLinklistId to StorageLib

* feat: add testInitialize

* feat: add return value for collectTips4Character

* feat: add testCollectTips4CharacterAfterEndTime

* feat: removed unused functions for linklist

* feat: update test cases

* feat: update test cases for operators

* feat: update test cases for linkAddress

* feat: add test cases for linklist

* feat: add test cases for linkCharacter & linkERC721 & linkLinklist

* feat: add test cases for linkModule

* feat: add test cases for linkNote &linkUri

* feat: update test case for web3Entry & remove Web3EntryBase

* feat: add testInitialize for web3Entry

* feat: update deploy script

* feat: update testCheckStorage
  • Loading branch information
iavl authored Aug 31, 2023
1 parent a067791 commit 3f7df6b
Show file tree
Hide file tree
Showing 57 changed files with 3,476 additions and 3,407 deletions.
1 change: 1 addition & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"const-name-snakecase": "off",
"constructor-syntax": "error",
"contract-name-camelcase": "error",
"custom-errors": "off",
"event-name-camelcase": "error",
"function-max-lines": ["warn",50],
"func-name-mixedcase": "error",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ solhint :; solhint -f table "{contracts,test,scripts}/**/*.sol"

# slither
# to install slither, visit [https://github.com/crytic/slither]
slither :; slither . --fail-low --triage-mode
slither :; slither . --fail-low #--triage-mode

# mythril
mythril :
Expand Down
230 changes: 4 additions & 226 deletions build-info/Linklist.json

Large diffs are not rendered by default.

58 changes: 19 additions & 39 deletions contracts/Linklist.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// SPDX-License-Identifier: MIT
// slither-disable-start unused-return
pragma solidity 0.8.18;

import {ILinklist} from "./interfaces/ILinklist.sol";
import {LinklistBase} from "./base/LinklistBase.sol";
import {ERC721} from "./base/ERC721.sol";
import {Events} from "./libraries/Events.sol";
import {DataTypes} from "./libraries/DataTypes.sol";
import {
Expand Down Expand Up @@ -100,7 +98,7 @@ contract Linklist is
string memory uri
) external override onlyExistingToken(tokenId) {
// caller must be web3Entry or owner
if (msg.sender != Web3Entry && msg.sender != ownerOf(tokenId))
if (msg.sender != Web3Entry && msg.sender != _ownerOf(tokenId))
revert ErrCallerNotWeb3EntryOrNotOwner();

_uris[tokenId] = uri;
Expand Down Expand Up @@ -426,16 +424,15 @@ contract Linklist is
return _linkTypes[tokenId];
}

// slither-disable-start naming-convention
// solhint-disable-next-line func-name-mixedcase
/// @inheritdoc ILinklist
// solhint-disable func-name-mixedcase
// slither-disable-next-line naming-convention
function Uri(
uint256 tokenId
) external view override onlyExistingToken(tokenId) returns (string memory) {
return _uris[tokenId];
}

// slither-disable-end naming-convention

/// @inheritdoc ILinklist
function characterOwnerOf(
uint256 tokenId
Expand All @@ -444,50 +441,33 @@ contract Linklist is
}

/// @inheritdoc ILinklist
function balanceOf(uint256 characterId) public view override returns (uint256) {
function totalSupply() external view override returns (uint256) {
return _totalSupply;
}

/// @inheritdoc ILinklist
function balanceOf(uint256 characterId) external view override returns (uint256) {
return _linklistBalances[characterId];
}

// slither-disable-next-line calls-loop
function balanceOf(address account) public view override(ERC721) returns (uint256 balance) {
/// @inheritdoc ILinklist
function balanceOf(address account) external view override returns (uint256 balance) {
uint256 characterCount = IERC721(Web3Entry).balanceOf(account);
for (uint256 i = 0; i < characterCount; i++) {
uint256 characterId = IERC721Enumerable(Web3Entry).tokenOfOwnerByIndex(account, i);
balance += balanceOf(characterId);
balance += _linklistBalances[characterId];
}
}

/// @inheritdoc ERC721
/// @inheritdoc ILinklist
function ownerOf(
uint256 tokenId
) public view override(ERC721) onlyExistingToken(tokenId) returns (address) {
uint256 characterId = _linklistOwners[tokenId];
address owner = IERC721(Web3Entry).ownerOf(characterId);
return owner;
) external view override onlyExistingToken(tokenId) returns (address) {
return _ownerOf(tokenId);
}

/// @inheritdoc ILinklist
function totalSupply() external view override returns (uint256) {
return _totalSupply;
}

function _safeTransfer(
address,
address,
uint256,
bytes memory // solhint-disable-next-line no-empty-blocks
) internal pure override {
// this function will do nothing, as linklist is a character bounded token
// users should never transfer a linklist directly
}

function _transfer(
address,
address,
uint256 // solhint-disable-next-line no-empty-blocks
) internal pure override {
// this function will do nothing, as linklist is a character bounded token
// users should never transfer a linklist directly
function _ownerOf(uint256 tokenId) internal view returns (address) {
uint256 characterId = _linklistOwners[tokenId];
return IERC721(Web3Entry).ownerOf(characterId);
}
}
// slither-disable-end unused-return
Loading

0 comments on commit 3f7df6b

Please sign in to comment.