formatting
Some checks failed
CI / Foundry project (push) Has been cancelled

This commit is contained in:
Ciara Nightingale 2025-02-07 10:00:33 +00:00
parent 5b65dfcc38
commit 878bd34ef6
4 changed files with 22 additions and 20 deletions

View File

@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.19; pragma solidity ^0.8.19;
import "./SoulboundProfileNFT.sol"; import "./SoulboundProfileNFT.sol";
import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/access/Ownable.sol";
import "./MultiSig.sol"; import "./MultiSig.sol";
contract LikeRegistry is Ownable{ contract LikeRegistry is Ownable {
struct Like { struct Like {
address liker; address liker;
address liked; address liked;
@ -24,13 +24,11 @@ contract LikeRegistry is Ownable{
event Liked(address indexed liker, address indexed liked); event Liked(address indexed liker, address indexed liked);
event Matched(address indexed user1, address indexed user2); event Matched(address indexed user1, address indexed user2);
constructor(address _profileNFT) Ownable(msg.sender){ constructor(address _profileNFT) Ownable(msg.sender) {
profileNFT = SoulboundProfileNFT(_profileNFT); profileNFT = SoulboundProfileNFT(_profileNFT);
} }
function likeUser( function likeUser(address liked) external payable {
address liked
) external payable {
require(msg.value >= 1 ether, "Must send at least 1 ETH"); require(msg.value >= 1 ether, "Must send at least 1 ETH");
require(!likes[msg.sender][liked], "Already liked"); require(!likes[msg.sender][liked], "Already liked");
require(msg.sender != liked, "Cannot like yourself"); require(msg.sender != liked, "Cannot like yourself");
@ -56,7 +54,7 @@ contract LikeRegistry is Ownable{
userBalances[to] = 0; userBalances[to] = 0;
uint256 totalRewards = matchUserOne + matchUserTwo; uint256 totalRewards = matchUserOne + matchUserTwo;
uint256 matchingFees = (totalRewards * FIXEDFEE ) / 100; uint256 matchingFees = (totalRewards * FIXEDFEE) / 100;
uint256 rewards = totalRewards - matchingFees; uint256 rewards = totalRewards - matchingFees;
totalFees += matchingFees; totalFees += matchingFees;
@ -64,7 +62,7 @@ contract LikeRegistry is Ownable{
MultiSigWallet multiSigWallet = new MultiSigWallet(from, to); MultiSigWallet multiSigWallet = new MultiSigWallet(from, to);
// Send ETH to the deployed multisig wallet // Send ETH to the deployed multisig wallet
(bool success, ) = payable(address(multiSigWallet)).call{value: rewards}(""); (bool success,) = payable(address(multiSigWallet)).call{value: rewards}("");
require(success, "Transfer failed"); require(success, "Transfer failed");
} }
@ -75,9 +73,9 @@ contract LikeRegistry is Ownable{
function withdrawFees() external onlyOwner { function withdrawFees() external onlyOwner {
require(totalFees > 0, "No fees to withdraw"); require(totalFees > 0, "No fees to withdraw");
uint256 totalFeesToWithdraw = totalFees; uint256 totalFeesToWithdraw = totalFees;
totalFees = 0; totalFees = 0;
(bool success, ) = payable(owner()).call{value: totalFeesToWithdraw}(""); (bool success,) = payable(owner()).call{value: totalFeesToWithdraw}("");
require(success, "Transfer failed"); require(success, "Transfer failed");
} }

View File

@ -72,7 +72,7 @@ contract MultiSigWallet {
require(txn.approvedByOwner1 && txn.approvedByOwner2, "Not enough approvals"); require(txn.approvedByOwner1 && txn.approvedByOwner2, "Not enough approvals");
txn.executed = true; txn.executed = true;
(bool success, ) = payable(txn.to).call{value: txn.value}(""); (bool success,) = payable(txn.to).call{value: txn.value}("");
require(success, "Transaction failed"); require(success, "Transaction failed");
emit TransactionExecuted(_txId, txn.to, txn.value); emit TransactionExecuted(_txId, txn.to, txn.value);

View File

@ -6,7 +6,6 @@ import "@openzeppelin/contracts/access/Ownable.sol";
import {Base64} from "@openzeppelin/contracts/utils/Base64.sol"; import {Base64} from "@openzeppelin/contracts/utils/Base64.sol";
import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/Strings.sol";
contract SoulboundProfileNFT is ERC721, Ownable { contract SoulboundProfileNFT is ERC721, Ownable {
error ERC721Metadata__URI_QueryFor_NonExistentToken(); error ERC721Metadata__URI_QueryFor_NonExistentToken();
error SoulboundTokenCannotBeTransferred(); error SoulboundTokenCannotBeTransferred();
@ -54,7 +53,7 @@ contract SoulboundProfileNFT is ERC721, Ownable {
emit ProfileBurned(msg.sender, tokenId); emit ProfileBurned(msg.sender, tokenId);
} }
/// @notice App owner can block users /// @notice App owner can block users
function blockProfile(address blockAddress) external onlyOwner { function blockProfile(address blockAddress) external onlyOwner {
uint256 tokenId = profileToToken[blockAddress]; uint256 tokenId = profileToToken[blockAddress];
require(tokenId != 0, "No profile found"); require(tokenId != 0, "No profile found");
@ -67,12 +66,12 @@ contract SoulboundProfileNFT is ERC721, Ownable {
} }
/// @notice Override of transferFrom to prevent any transfer. /// @notice Override of transferFrom to prevent any transfer.
function transferFrom(address, address, uint256) public pure override{ function transferFrom(address, address, uint256) public pure override {
// Soulbound token cannot be transferred // Soulbound token cannot be transferred
revert SoulboundTokenCannotBeTransferred(); revert SoulboundTokenCannotBeTransferred();
} }
function safeTransferFrom(address, address, uint256, bytes memory) public pure override{ function safeTransferFrom(address, address, uint256, bytes memory) public pure override {
// Soulbound token cannot be transferred // Soulbound token cannot be transferred
revert SoulboundTokenCannotBeTransferred(); revert SoulboundTokenCannotBeTransferred();
} }
@ -91,10 +90,16 @@ contract SoulboundProfileNFT is ERC721, Ownable {
Base64.encode( Base64.encode(
bytes( // bytes casting actually unnecessary as 'abi.encodePacked()' returns a bytes bytes( // bytes casting actually unnecessary as 'abi.encodePacked()' returns a bytes
abi.encodePacked( abi.encodePacked(
'{"name":"', profileName, '", ', '{"name":"',
'"description":"A soulbound dating profile NFT.", ', profileName,
'"attributes": [{"trait_type": "Age", "value": ', Strings.toString(profileAge), '}], ', '", ',
'"image":"', imageURI, '"}' '"description":"A soulbound dating profile NFT.", ',
'"attributes": [{"trait_type": "Age", "value": ',
Strings.toString(profileAge),
"}], ",
'"image":"',
imageURI,
'"}'
) )
) )
) )

View File

@ -32,7 +32,6 @@ contract SoulboundProfileNFTTest is Test {
vm.prank(user); vm.prank(user);
vm.expectRevert("Profile already exists"); vm.expectRevert("Profile already exists");
soulboundNFT.mintProfile("Alice", 25, "ipfs://profileImage"); soulboundNFT.mintProfile("Alice", 25, "ipfs://profileImage");
} }
function testTokenURI() public { function testTokenURI() public {