From 76c5ca9a5247a90e7fee185247d1a77079614284 Mon Sep 17 00:00:00 2001 From: "Quentin D.C" Date: Mon, 18 Dec 2023 11:51:20 +0000 Subject: [PATCH] Lint & format --- README.md | 6 +- contracts/interfaces/ITalentLayerEscrow.sol | 81 +++++++++++++------ contracts/interfaces/ITalentLayerID.sol | 35 +++++--- .../interfaces/ITalentLayerPlatformID.sol | 35 ++++++-- contracts/interfaces/ITalentLayerReview.sol | 3 +- contracts/interfaces/ITalentLayerService.sol | 69 ++++++++++++++-- docs/deploy.md | 6 +- 7 files changed, 178 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 0da67969..dd48583c 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ Understand the protocol and how we tackle our main problems: - [Mumbai](./.deployment/mumbai.json) - [Polygon](./.deployment/polygon.json) -## Audits +## Audits - Internal: https://talentlayer.notion.site/TLIP-0002-Security-Assessment-782ab9e80d774749811adfc61cbb7622 -- Externals: +- Externals: - Bios42: https://github.com/bios42eth/talenlayer-id-report - Ahmet: https://github.com/ahmedovv123/audits/blob/main/audits/TalentLayer.md @@ -36,7 +36,7 @@ Understand the protocol and how we tackle our main problems: - Launch your local node: `npx hardhat node` - Deploy contract: `npx hardhat deploy-full --use-test-erc20 --network localhost` -## Tests +## Tests ### Coverage diff --git a/contracts/interfaces/ITalentLayerEscrow.sol b/contracts/interfaces/ITalentLayerEscrow.sol index ee13d4c2..4aa852b2 100644 --- a/contracts/interfaces/ITalentLayerEscrow.sol +++ b/contracts/interfaces/ITalentLayerEscrow.sol @@ -29,7 +29,6 @@ interface ITalentLayerEscrow { Resolved // the transaction is solved (either no dispute has ever arisen or the dispute has been resolved) } - // Struct declarations struct Transaction { uint256 id; @@ -53,7 +52,6 @@ interface ITalentLayerEscrow { uint256 arbitrationFeeTimeout; } - // Function declarations function initialize( address _talentLayerServiceAddress, @@ -61,36 +59,38 @@ interface ITalentLayerEscrow { address _talentLayerPlatformIDAddress, address _protocolWallet ) external; + function getClaimableFeeBalance(address _token) external view returns (uint256 balance); + function getTransactionDetails(uint256 _transactionId) external view returns (Transaction memory); + function updateProtocolEscrowFeeRate(uint16 _protocolEscrowFeeRate) external; + function updateProtocolWallet(address payable _protocolWallet) external; + function pause() external; + function unpause() external; + function createTransaction( uint256 _serviceId, uint256 _proposalId, string memory _metaEvidence, string memory _originDataUri ) external payable returns (uint256); - function release( - uint256 _profileId, - uint256 _transactionId, - uint256 _amount - ) external; - function reimburse( - uint256 _profileId, - uint256 _transactionId, - uint256 _amount - ) external; + + function release(uint256 _profileId, uint256 _transactionId, uint256 _amount) external; + + function reimburse(uint256 _profileId, uint256 _transactionId, uint256 _amount) external; + function payArbitrationFeeBySender(uint256 _transactionId) external payable; + function payArbitrationFeeByReceiver(uint256 _transactionId) external payable; + function arbitrationFeeTimeout(uint256 _transactionId) external; - function submitEvidence( - uint256 _profileId, - uint256 _transactionId, - string memory _evidence - ) external; + + function submitEvidence(uint256 _profileId, uint256 _transactionId, string memory _evidence) external; + function appeal(uint256 _transactionId) external payable; // Platform functions @@ -99,17 +99,52 @@ interface ITalentLayerEscrow { // Arbitrator functions function rule(uint256 _disputeID, uint256 _ruling) external; - // Event declarations - event Payment(uint256 _transactionId, PaymentType _paymentType, address _token, uint256 _amount, uint256 _serviceId, uint256 _proposalId); + event Payment( + uint256 _transactionId, + PaymentType _paymentType, + address _token, + uint256 _amount, + uint256 _serviceId, + uint256 _proposalId + ); event PaymentCompleted(uint256 _serviceId); event ProtocolEscrowFeeRateUpdated(uint16 _protocolEscrowFeeRate); event FeesClaimed(uint256 _platformId, address indexed _token, uint256 _amount); - event OriginServiceFeeRateReleased(uint256 _platformId, uint256 _serviceId, address indexed _token, uint256 _amount); - event OriginValidatedProposalFeeRateReleased(uint256 _platformId, uint256 _serviceId, address indexed _token, uint256 _amount); + event OriginServiceFeeRateReleased( + uint256 _platformId, + uint256 _serviceId, + address indexed _token, + uint256 _amount + ); + event OriginValidatedProposalFeeRateReleased( + uint256 _platformId, + uint256 _serviceId, + address indexed _token, + uint256 _amount + ); event HasToPayFee(uint256 indexed _transactionId, Party _party); - event ArbitrationFeePayment(uint256 indexed _transactionId, ArbitrationFeePaymentType _paymentType, Party _party, uint256 _amount); + event ArbitrationFeePayment( + uint256 indexed _transactionId, + ArbitrationFeePaymentType _paymentType, + Party _party, + uint256 _amount + ); event RulingExecuted(uint256 indexed _transactionId, uint256 _ruling); - event TransactionCreated(uint256 _transactionId, uint256 _senderId, uint256 _receiverId, address _token, uint256 _amount, uint256 _serviceId, uint256 _proposalId, uint16 _protocolEscrowFeeRate, uint16 _originServiceFeeRate, uint16 _originValidatedProposalFeeRate, Arbitrator _arbitrator, bytes _arbitratorExtraData, uint256 _arbitrationFeeTimeout); + event TransactionCreated( + uint256 _transactionId, + uint256 _senderId, + uint256 _receiverId, + address _token, + uint256 _amount, + uint256 _serviceId, + uint256 _proposalId, + uint16 _protocolEscrowFeeRate, + uint16 _originServiceFeeRate, + uint16 _originValidatedProposalFeeRate, + Arbitrator _arbitrator, + bytes _arbitratorExtraData, + uint256 _arbitrationFeeTimeout + ); event EvidenceSubmitted(uint256 indexed _transactionId, uint256 indexed _partyId, string _evidenceUri); } diff --git a/contracts/interfaces/ITalentLayerID.sol b/contracts/interfaces/ITalentLayerID.sol index 9abe4c01..e2a5f392 100644 --- a/contracts/interfaces/ITalentLayerID.sol +++ b/contracts/interfaces/ITalentLayerID.sol @@ -21,57 +21,69 @@ interface ITalentLayerID { string dataUri; } - // Function declarations // View functions function ownerOf(uint256 _tokenId) external view returns (address); + function totalSupply() external view returns (uint256); + function getOriginatorPlatformIdByAddress(address _address) external view returns (uint256); + function isValid(uint256 _profileId) external view; + function isDelegate(uint256 _profileId, address _address) external view returns (bool); + function isOwnerOrDelegate(uint256 _profileId, address _address) external view returns (bool); + function ownersOf(uint256 _tokenId1, uint256 _tokenId2) external view returns (address, address); + function isWhitelisted( address _address, string memory _handle, bytes32[] memory _proof ) external view returns (bool); + function getHandlePrice(string calldata _handle) external view returns (uint256); + function tokenURI(uint256 tokenId) external view returns (string memory); // User functions - function mint( - uint256 _platformId, - string calldata _handle - ) external payable returns (uint256); + function mint(uint256 _platformId, string calldata _handle) external payable returns (uint256); + function mintForAddress( address _address, uint256 _platformId, string calldata _handle ) external payable returns (uint256); + function whitelistMint( uint256 _platformId, string calldata _handle, bytes32[] calldata _proof ) external payable returns (uint256); + function updateProfileData(uint256 _profileId, string memory _newCid) external; + function addDelegate(uint256 _profileId, address _delegate) external; + function removeDelegate(uint256 _profileId, address _delegate) external; + function setHasActivity(uint256 _profileId) external; // Owner functions function updateMintFee(uint256 _mintFee) external; + function withdraw() external; - function freeMint( - uint256 _platformId, - address _userAddress, - string calldata _handle - ) external returns (uint256); + + function freeMint(uint256 _platformId, address _userAddress, string calldata _handle) external returns (uint256); + function setWhitelistMerkleRoot(bytes32 root) external; + function updateMintStatus(MintStatus _mintStatus) external; + function updateShortHandlesMaxPrice(uint256 _shortHandlesMaxPrice) external; - function setIsServiceContract(address _address, bool _isServiceContract) external; + function setIsServiceContract(address _address, bool _isServiceContract) external; // Event declarations event Mint(address indexed user, uint256 profileId, string handle, uint256 platformId, uint256 fee); @@ -82,7 +94,6 @@ interface ITalentLayerID { event MintStatusUpdated(MintStatus mintStatus); event ShortHandlesMaxPriceUpdated(uint256 price); - // Error declarations error HandleLengthInvalid(); error HandleContainsInvalidCharacters(); diff --git a/contracts/interfaces/ITalentLayerPlatformID.sol b/contracts/interfaces/ITalentLayerPlatformID.sol index d831b104..02f1f5ea 100644 --- a/contracts/interfaces/ITalentLayerPlatformID.sol +++ b/contracts/interfaces/ITalentLayerPlatformID.sol @@ -16,7 +16,6 @@ interface ITalentLayerPlatformID is IERC721Upgradeable { PUBLIC } - // Struct declarations struct Platform { uint256 id; @@ -32,49 +31,75 @@ interface ITalentLayerPlatformID is IERC721Upgradeable { address signer; } - // Function declarations // View Functions function ids(address _user) external view returns (uint256); + function isValid(uint256 _platformId) external view; + function getOriginServiceFeeRate(uint256 _platformId) external view returns (uint16); + function getOriginValidatedProposalFeeRate(uint256 _platformId) external view returns (uint16); + function getServicePostingFee(uint256 _platformId) external view returns (uint256); + function getProposalPostingFee(uint256 _platformId) external view returns (uint256); + function getSigner(uint256 _platformId) external view returns (address); + function getPlatform(uint256 _platformId) external view returns (Platform memory); + function totalSupply() external view returns (uint256); // User Functions function mint(string calldata _platformName) external payable returns (uint256); + function mintForAddress(string calldata _platformName, address _platformAddress) external payable returns (uint256); + function updateProfileData(uint256 _platformId, string memory _newCid) external; + function updateOriginServiceFeeRate(uint256 _platformId, uint16 _originServiceFeeRate) external; + function updateOriginValidatedProposalFeeRate(uint256 _platformId, uint16 _originValidatedProposalFeeRate) external; + function updateArbitrator(uint256 _platformId, Arbitrator _arbitrator, bytes memory _extraData) external; + function updateArbitrationFeeTimeout(uint256 _platformId, uint256 _arbitrationFeeTimeout) external; + function updateServicePostingFee(uint256 _platformId, uint256 _servicePostingFee) external; + function updateProposalPostingFee(uint256 _platformId, uint256 _proposalPostingFee) external; + function updateSigner(uint256 _platformId, address _signer) external; // Owner Functions function whitelistUser(address _user) external; + function updateMintStatus(MintStatus _mintStatus) external; + function updateMintFee(uint256 _mintFee) external; + function withdraw() external; + function addArbitrator(address _arbitrator, bool _isInternal) external; + function removeArbitrator(address _arbitrator) external; - function updateMinArbitrationFeeTimeout(uint256 _minArbitrationFeeTimeout) external; + function updateMinArbitrationFeeTimeout(uint256 _minArbitrationFeeTimeout) external; // Error declarations error HandleLengthInvalid(); error HandleContainsInvalidCharacters(); error HandleFirstCharInvalid(); - // Event declarations - event Mint(address indexed platformOwnerAddress, uint256 platformId, string platformName, uint256 fee, uint256 arbitrationFeeTimeout); + event Mint( + address indexed platformOwnerAddress, + uint256 platformId, + string platformName, + uint256 fee, + uint256 arbitrationFeeTimeout + ); event CidUpdated(uint256 indexed platformId, string newCid); event MintFeeUpdated(uint256 mintFee); event OriginServiceFeeRateUpdated(uint256 platformId, uint16 originServiceFeeRate); diff --git a/contracts/interfaces/ITalentLayerReview.sol b/contracts/interfaces/ITalentLayerReview.sol index 6f99bde2..b5a205b0 100644 --- a/contracts/interfaces/ITalentLayerReview.sol +++ b/contracts/interfaces/ITalentLayerReview.sol @@ -15,10 +15,10 @@ interface ITalentLayerReview { uint256 rating; } - // Function declarations // View Functions function getReview(uint256 _reviewId) external view returns (Review memory); + function totalSupply() external view returns (uint256); // User Functions @@ -29,7 +29,6 @@ interface ITalentLayerReview { uint256 _rating ) external returns (uint256); - // Event declarations event Mint( uint256 indexed serviceId, diff --git a/contracts/interfaces/ITalentLayerService.sol b/contracts/interfaces/ITalentLayerService.sol index 5d86f70b..14824caa 100644 --- a/contracts/interfaces/ITalentLayerService.sol +++ b/contracts/interfaces/ITalentLayerService.sol @@ -48,30 +48,83 @@ interface ITalentLayerService { // Function declarations // View Functions function getService(uint256 _serviceId) external view returns (Service memory); + function getProposal(uint256 _serviceId, uint256 _proposalId) external view returns (Proposal memory); - function getServiceAndProposal(uint256 _serviceId, uint256 _proposalId) external view returns (Service memory, Proposal memory); + + function getServiceAndProposal( + uint256 _serviceId, + uint256 _proposalId + ) external view returns (Service memory, Proposal memory); + function isTokenAllowed(address _tokenAddress) external view returns (bool); // User Functions - function createService(uint256 _profileId, uint256 _platformId, string calldata _dataUri, bytes calldata _signature) external payable returns (uint256); - function createProposal(uint256 _profileId, uint256 _serviceId, address _rateToken, uint256 _rateAmount, uint256 _platformId, string calldata _dataUri, uint256 _expirationDate, bytes calldata _signature) external payable; - function updateProposal(uint256 _profileId, uint256 _serviceId, address _rateToken, uint256 _rateAmount, string calldata _dataUri, uint256 _expirationDate) external; + function createService( + uint256 _profileId, + uint256 _platformId, + string calldata _dataUri, + bytes calldata _signature + ) external payable returns (uint256); + + function createProposal( + uint256 _profileId, + uint256 _serviceId, + address _rateToken, + uint256 _rateAmount, + uint256 _platformId, + string calldata _dataUri, + uint256 _expirationDate, + bytes calldata _signature + ) external payable; + + function updateProposal( + uint256 _profileId, + uint256 _serviceId, + address _rateToken, + uint256 _rateAmount, + string calldata _dataUri, + uint256 _expirationDate + ) external; + function afterDeposit(uint256 _serviceId, uint256 _proposalId, uint256 _transactionId) external; + function afterFullPayment(uint256 _serviceId, uint256 _releasedAmount) external; + function updateServiceData(uint256 _profileId, uint256 _serviceId, string calldata _dataUri) external; + function cancelService(uint256 _profileId, uint256 _serviceId) external; // Owner Functions - function updateAllowedTokenList(address _tokenAddress, bool _isWhitelisted, uint256 _minimumTransactionAmount) external; - function updateMinCompletionPercentage(uint256 _minCompletionPercentage) external; + function updateAllowedTokenList( + address _tokenAddress, + bool _isWhitelisted, + uint256 _minimumTransactionAmount + ) external; + function updateMinCompletionPercentage(uint256 _minCompletionPercentage) external; // Event declarations event ServiceCreated(uint256 id, uint256 ownerId, uint256 platformId, string dataUri); event ServiceCancelled(uint256 id); event ServiceDetailedUpdated(uint256 indexed id, string dataUri); - event ProposalCreated(uint256 serviceId, uint256 ownerId, string dataUri, ProposalStatus status, address rateToken, uint256 rateAmount, uint256 platformId, uint256 expirationDate); - event ProposalUpdated(uint256 serviceId, uint256 ownerId, string dataUri, address rateToken, uint256 rateAmount, uint256 expirationDate); + event ProposalCreated( + uint256 serviceId, + uint256 ownerId, + string dataUri, + ProposalStatus status, + address rateToken, + uint256 rateAmount, + uint256 platformId, + uint256 expirationDate + ); + event ProposalUpdated( + uint256 serviceId, + uint256 ownerId, + string dataUri, + address rateToken, + uint256 rateAmount, + uint256 expirationDate + ); event AllowedTokenListUpdated(address tokenAddress, bool isWhitelisted, uint256 minimumTransactionAmount); event MinCompletionPercentageUpdated(uint256 minCompletionPercentage); } diff --git a/docs/deploy.md b/docs/deploy.md index c10e3514..d9ec7a25 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -56,12 +56,10 @@ ## Step 5: Defender - Transfer ownership to the multisig for every contracts - - for ownable contracts: + - for ownable contracts: - `npx hardhat transfer-ownership --contract-name "TalentLayerID" --address 0x0CFF3F17b62704A0fc76539dED9223a44CAf4825 --network polygon` - `npx hardhat transfer-ownership --contract-name "TalentLayerService" --address 0x0CFF3F17b62704A0fc76539dED9223a44CAf4825 --network polygon` - `npx hardhat transfer-ownership --contract-name "TalentLayerReview" --address 0x0CFF3F17b62704A0fc76539dED9223a44CAf4825 --network polygon` - `npx hardhat transfer-ownership --contract-name "TalentLayerEscrow" --address 0x0CFF3F17b62704A0fc76539dED9223a44CAf4825 --network polygon` - - for access control contracts: + - for access control contracts: - `npx hardhat grant-role --contract-name "TalentLayerPlatformID" --address 0x0CFF3F17b62704A0fc76539dED9223a44CAf4825 --network polygon` - -