From 2a6cfbf2981d65f7f09fe2bb6a26c77cfa51d1eb Mon Sep 17 00:00:00 2001 From: Yoginth Date: Fri, 6 Dec 2024 11:25:38 +0530 Subject: [PATCH] Remove Contracts Completely --- packages/contracts/.env.example | 3 - packages/contracts/.gitignore | 16 -- .../contracts/HeyLensSignup/HeyLensSignup.sol | 145 ----------------- .../HeyLensSignup/HeyLensSignupV2.sol | 146 ------------------ .../contracts/HeyLensSignup/README.md | 38 ----- .../contracts/HeyTipping/HeyTipping.sol | 93 ----------- .../contracts/contracts/HeyTipping/README.md | 25 --- packages/contracts/hardhat.config.ts | 42 ----- packages/contracts/package.json | 21 --- .../contracts/script/HeyLensSignup/deploy.ts | 25 --- .../contracts/script/HeyLensSignup/upgrade.ts | 15 -- .../contracts/script/HeyTipping/deploy.ts | 20 --- packages/contracts/tsconfig.json | 7 - 13 files changed, 596 deletions(-) delete mode 100644 packages/contracts/.env.example delete mode 100644 packages/contracts/.gitignore delete mode 100644 packages/contracts/contracts/HeyLensSignup/HeyLensSignup.sol delete mode 100644 packages/contracts/contracts/HeyLensSignup/HeyLensSignupV2.sol delete mode 100644 packages/contracts/contracts/HeyLensSignup/README.md delete mode 100644 packages/contracts/contracts/HeyTipping/HeyTipping.sol delete mode 100644 packages/contracts/contracts/HeyTipping/README.md delete mode 100644 packages/contracts/hardhat.config.ts delete mode 100644 packages/contracts/package.json delete mode 100644 packages/contracts/script/HeyLensSignup/deploy.ts delete mode 100644 packages/contracts/script/HeyLensSignup/upgrade.ts delete mode 100644 packages/contracts/script/HeyTipping/deploy.ts delete mode 100644 packages/contracts/tsconfig.json diff --git a/packages/contracts/.env.example b/packages/contracts/.env.example deleted file mode 100644 index 176fd8f0b837..000000000000 --- a/packages/contracts/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -POLYGON_ETHERSCAN_API_KEY="" -ALCHEMY_API_KEY="" -PRIVATE_KEY="" diff --git a/packages/contracts/.gitignore b/packages/contracts/.gitignore deleted file mode 100644 index be85e7ddaac8..000000000000 --- a/packages/contracts/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -node_modules -.env - -# Hardhat files -/cache -/artifacts - -# TypeChain files -/typechain -/typechain-types - -# solidity-coverage files -/coverage -/coverage.json - -.openzeppelin diff --git a/packages/contracts/contracts/HeyLensSignup/HeyLensSignup.sol b/packages/contracts/contracts/HeyLensSignup/HeyLensSignup.sol deleted file mode 100644 index 212c31fba463..000000000000 --- a/packages/contracts/contracts/HeyLensSignup/HeyLensSignup.sol +++ /dev/null @@ -1,145 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0 - -pragma solidity ^0.8.23; -import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -struct CreateProfileParams { - address to; - address followModule; - bytes followModuleInitData; -} - -interface ILensPermissionlessCreator { - function createProfileWithHandleUsingCredits( - CreateProfileParams calldata createProfileParams, - string calldata handle, - address[] calldata delegatedExecutors - ) external returns (uint256, uint256); -} - -contract HeyLensSignup is Initializable, OwnableUpgradeable { - ILensPermissionlessCreator public lensPermissionlessCreator; - uint256 public signupPrice; - uint256 public profilesCreatedViaCard; - uint256 public profilesCreatedViaCrypto; - mapping(uint256 => bool) public profileCreated; - mapping(address => bool) public allowedAddresses; - - modifier onlyAllowed() { - require(allowedAddresses[msg.sender], "HeyLensSignup: Not allowed"); - _; - } - - event ProfileCreated(uint256 profileId, uint256 handleId); - - error InvalidFunds(); - error NotAllowed(); - error WithdrawalFailed(); - - // Initializer instead of constructor for upgradeable contracts - function initialize( - address owner, - address _lensPermissionlessCreator, - uint256 _signupPrice - ) public initializer { - __Ownable_init(owner); - lensPermissionlessCreator = ILensPermissionlessCreator( - _lensPermissionlessCreator - ); - signupPrice = _signupPrice; - profilesCreatedViaCard = 0; - profilesCreatedViaCrypto = 0; - } - - function addAllowedAddresses( - address[] calldata newAddresses - ) external onlyOwner { - for (uint256 i = 0; i < newAddresses.length; i++) { - allowedAddresses[newAddresses[i]] = true; - } - } - - function removeAllowedAddress(address addressToRemove) external onlyOwner { - allowedAddresses[addressToRemove] = false; - } - - function setSignupPrice(uint256 _signupPrice) external onlyOwner { - signupPrice = _signupPrice; - } - - function setLensPermissionlessCreatorAddress( - address creatorAddress - ) external onlyOwner { - lensPermissionlessCreator = ILensPermissionlessCreator(creatorAddress); - } - - function totalProfilesCreated() external view returns (uint256) { - return profilesCreatedViaCard + profilesCreatedViaCrypto; - } - - function createProfileWithHandle( - CreateProfileParams calldata createProfileParams, - string calldata handle, - address[] calldata delegatedExecutors - ) external onlyAllowed returns (uint256 profileId, uint256 handleId) { - // Call the lensPermissionlessCreator to create a profile - (profileId, handleId) = lensPermissionlessCreator - .createProfileWithHandleUsingCredits( - createProfileParams, - handle, - delegatedExecutors - ); - - // Mark the profile as created - profileCreated[profileId] = true; - profilesCreatedViaCard++; - - // Emit the event to signal that a profile has been successfully created - emit ProfileCreated(profileId, handleId); - - return (profileId, handleId); - } - - function createProfileWithHandleUsingCredits( - CreateProfileParams calldata createProfileParams, - string calldata handle, - address[] calldata delegatedExecutors - ) external payable returns (uint256 profileId, uint256 handleId) { - if (msg.value < signupPrice) { - revert InvalidFunds(); - } - - if ( - delegatedExecutors.length > 0 && - createProfileParams.to != msg.sender - ) { - revert NotAllowed(); - } - - // Call the lensPermissionlessCreator to create a profile - (profileId, handleId) = lensPermissionlessCreator - .createProfileWithHandleUsingCredits( - createProfileParams, - handle, - delegatedExecutors - ); - - // Mark the profile as created - profileCreated[profileId] = true; - profilesCreatedViaCrypto++; - - // Emit the event to signal that a profile has been successfully created - emit ProfileCreated(profileId, handleId); - - return (profileId, handleId); - } - - // Remove this function on V2 and add direct transfer of funds to the owner - function withdrawFunds() external onlyOwner { - (bool sent, ) = payable(owner()).call{value: address(this).balance}(""); - if (!sent) { - revert WithdrawalFailed(); - } - } -} diff --git a/packages/contracts/contracts/HeyLensSignup/HeyLensSignupV2.sol b/packages/contracts/contracts/HeyLensSignup/HeyLensSignupV2.sol deleted file mode 100644 index 2c7964804e39..000000000000 --- a/packages/contracts/contracts/HeyLensSignup/HeyLensSignupV2.sol +++ /dev/null @@ -1,146 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0 - -pragma solidity ^0.8.23; -import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; - -struct CreateProfileParams { - address to; - address followModule; - bytes followModuleInitData; -} - -interface ILensPermissionlessCreator { - function createProfileWithHandleUsingCredits( - CreateProfileParams calldata createProfileParams, - string calldata handle, - address[] calldata delegatedExecutors - ) external returns (uint256, uint256); -} - -contract HeyLensSignupV2 is Initializable, OwnableUpgradeable { - ILensPermissionlessCreator public lensPermissionlessCreator; - uint256 public signupPrice; - uint256 public profilesCreatedViaCard; - uint256 public profilesCreatedViaCrypto; - mapping(uint256 => bool) public profileCreated; - mapping(address => bool) public allowedAddresses; - - modifier onlyAllowed() { - require(allowedAddresses[msg.sender], "HeyLensSignup: Not allowed"); - _; - } - - event ProfileCreated(uint256 profileId, uint256 handleId); - - error InvalidFunds(); - error NotAllowed(); - // Rename to TransferFailed with custom message in V3 - error WithdrawalFailed(); - - // Initializer instead of constructor for upgradeable contracts - function initialize( - address owner, - address _lensPermissionlessCreator, - uint256 _signupPrice - ) public initializer { - __Ownable_init(owner); - lensPermissionlessCreator = ILensPermissionlessCreator( - _lensPermissionlessCreator - ); - signupPrice = _signupPrice; - profilesCreatedViaCard = 0; - profilesCreatedViaCrypto = 0; - } - - function addAllowedAddresses( - address[] calldata newAddresses - ) external onlyOwner { - for (uint256 i = 0; i < newAddresses.length; i++) { - allowedAddresses[newAddresses[i]] = true; - } - } - - function removeAllowedAddress(address addressToRemove) external onlyOwner { - allowedAddresses[addressToRemove] = false; - } - - function setSignupPrice(uint256 _signupPrice) external onlyOwner { - signupPrice = _signupPrice; - } - - function setLensPermissionlessCreatorAddress( - address creatorAddress - ) external onlyOwner { - lensPermissionlessCreator = ILensPermissionlessCreator(creatorAddress); - } - - function totalProfilesCreated() external view returns (uint256) { - return profilesCreatedViaCard + profilesCreatedViaCrypto; - } - - function createProfileWithHandle( - CreateProfileParams calldata createProfileParams, - string calldata handle, - address[] calldata delegatedExecutors - ) external onlyAllowed returns (uint256 profileId, uint256 handleId) { - // Call the lensPermissionlessCreator to create a profile - (profileId, handleId) = lensPermissionlessCreator - .createProfileWithHandleUsingCredits( - createProfileParams, - handle, - delegatedExecutors - ); - - // Mark the profile as created - profileCreated[profileId] = true; - profilesCreatedViaCard++; - - // Emit the event to signal that a profile has been successfully created - emit ProfileCreated(profileId, handleId); - - return (profileId, handleId); - } - - function createProfileWithHandleUsingCredits( - CreateProfileParams calldata createProfileParams, - string calldata handle, - address[] calldata delegatedExecutors - ) external payable returns (uint256 profileId, uint256 handleId) { - if (msg.value < signupPrice) { - revert InvalidFunds(); - } - - if ( - delegatedExecutors.length > 0 && - createProfileParams.to != msg.sender - ) { - revert NotAllowed(); - } - - // Call the lensPermissionlessCreator to create a profile - (profileId, handleId) = lensPermissionlessCreator - .createProfileWithHandleUsingCredits( - createProfileParams, - handle, - delegatedExecutors - ); - - // Mark the profile as created - profileCreated[profileId] = true; - profilesCreatedViaCrypto++; - - // Remove this on V3 and move to _transferFunds function - // Transfer the funds to the owner - (bool sent, ) = payable(owner()).call{value: msg.value}(""); - - if (!sent) { - revert WithdrawalFailed(); - } - - // Emit the event to signal that a profile has been successfully created - emit ProfileCreated(profileId, handleId); - - return (profileId, handleId); - } -} diff --git a/packages/contracts/contracts/HeyLensSignup/README.md b/packages/contracts/contracts/HeyLensSignup/README.md deleted file mode 100644 index c6909038e084..000000000000 --- a/packages/contracts/contracts/HeyLensSignup/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# HeyLensSignup - -Try running some of the following tasks: - -```sh -npx hardhat compile - -# Deploy to Amoy -npx hardhat run script/HeyLensSignup/deploy.ts --network polygonAmoy -npx hardhat verify 0x82Bcb5DA51c6F3D0Ce942bDBEbb0B8A7774d62e8 --network polygonAmoy - -# Deploy to Polygon -npx hardhat run script/HeyLensSignup/deploy.ts --network polygon -npx hardhat verify 0x4b8845ACb8148dE64D1D99Cf27A3890a91F55E53 --network polygon -``` - -## Upgrade Contracts - -```sh -# Upgrade on Amoy -npx hardhat run script/HeyLensSignup/upgrade.ts --network polygonAmoy -npx hardhat verify 0x82Bcb5DA51c6F3D0Ce942bDBEbb0B8A7774d62e8 --network polygonAmoy - -# Upgrade on Polygon -npx hardhat run script/HeyLensSignup/upgrade.ts --network polygon -npx hardhat verify 0x4b8845ACb8148dE64D1D99Cf27A3890a91F55E53 --network polygon -``` - -## Versions - -- `HeyLensSignupV2` - Add direct transfer of funds to the owner and remove `withdrawFunds` function. -- `HeyLensSignup` - Initial version of the contract. - -## Contracts - -| Contract | Amoy | Mainnet | -| --------------- | -------------------------------------------- | -------------------------------------------- | -| `HeyLensSignup` | `0x82Bcb5DA51c6F3D0Ce942bDBEbb0B8A7774d62e8` | `0x4b8845ACb8148dE64D1D99Cf27A3890a91F55E53` | diff --git a/packages/contracts/contracts/HeyTipping/HeyTipping.sol b/packages/contracts/contracts/HeyTipping/HeyTipping.sol deleted file mode 100644 index 6c0d978caf1d..000000000000 --- a/packages/contracts/contracts/HeyTipping/HeyTipping.sol +++ /dev/null @@ -1,93 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0 - -pragma solidity ^0.8.24; -import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; - -contract HeyTipping is - Initializable, - OwnableUpgradeable, - ReentrancyGuardUpgradeable, - PausableUpgradeable -{ - using SafeERC20 for IERC20; - uint256 public feesBps; - - event TipSent( - uint256 indexed fromProfileId, - uint256 indexed toProfileId, - uint256 indexed publicationId, - address token, - address from, - address to, - uint256 amount - ); - - error TipFailed(string message); - error InsufficientAllowance(string message); - error FeesBpsTooHigh(); - - // Initializer instead of constructor for upgradeable contracts - function initialize(address owner, uint256 _feesBps) public initializer { - __Ownable_init(owner); - __ReentrancyGuard_init(); - __Pausable_init(); - feesBps = _feesBps; - } - - function pause() external onlyOwner { - _pause(); - } - - function unpause() external onlyOwner { - _unpause(); - } - - function setFees(uint256 _feesBps) external onlyOwner { - if (_feesBps > 10000) { - revert FeesBpsTooHigh(); - } - - feesBps = _feesBps; - } - - function checkAllowance( - address tokenAddress, - address owner - ) external view returns (uint256) { - IERC20 token = IERC20(tokenAddress); - return token.allowance(owner, address(this)); - } - - function tip( - address tokenAddress, - address recipient, - uint256 amount, - uint256 fromProfileId, - uint256 toProfileId, - uint256 publicationId - ) external whenNotPaused nonReentrant { - IERC20 token = IERC20(tokenAddress); - - // Calculate fee and net amount - uint256 fee = (amount * feesBps) / 10000; - uint256 netAmount = amount - fee; - - token.safeTransferFrom(msg.sender, owner(), fee); - token.safeTransferFrom(msg.sender, recipient, netAmount); - - emit TipSent( - fromProfileId, - toProfileId, - publicationId, - tokenAddress, - msg.sender, - recipient, - netAmount - ); - } -} diff --git a/packages/contracts/contracts/HeyTipping/README.md b/packages/contracts/contracts/HeyTipping/README.md deleted file mode 100644 index fd954ba7fa51..000000000000 --- a/packages/contracts/contracts/HeyTipping/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# HeyTipping - -Try running some of the following tasks: - -```sh -npx hardhat compile - -# Deploy to Amoy -npx hardhat run script/HeyTipping/deploy.ts --network polygonAmoy -npx hardhat verify 0xAadeC94DCD26555F464455d309a5E896f78cC65f --network polygonAmoy - -# Deploy to Polygon -npx hardhat run script/HeyTipping/deploy.ts --network polygon -npx hardhat verify 0xCFeB907551c3C7E4Df2627B2Ed3D0C782702785B --network polygon -``` - -## Versions - -- `HeyTipping` - Initial version of the contract. - -## Contracts - -| Contract | Amoy | Mainnet | -| ------------ | -------------------------------------------- | -------------------------------------------- | -| `HeyTipping` | `0xAadeC94DCD26555F464455d309a5E896f78cC65f` | `0xCFeB907551c3C7E4Df2627B2Ed3D0C782702785B` | diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts deleted file mode 100644 index 7be61306fa86..000000000000 --- a/packages/contracts/hardhat.config.ts +++ /dev/null @@ -1,42 +0,0 @@ -require("dotenv").config(); -import "@nomicfoundation/hardhat-toolbox"; -import "@nomiclabs/hardhat-ethers"; -import "@openzeppelin/hardhat-upgrades"; -import type { HardhatUserConfig } from "hardhat/config"; - -const config: HardhatUserConfig = { - etherscan: { - apiKey: { - polygon: process.env.POLYGON_ETHERSCAN_API_KEY as string, - polygonAmoy: process.env.POLYGON_ETHERSCAN_API_KEY as string - }, - customChains: [ - { - chainId: 80002, - network: "polygonAmoy", - urls: { - apiURL: "https://api-amoy.polygonscan.com/api", - browserURL: "https://amoy.polygonscan.com" - } - } - ] - }, - networks: { - polygon: { - accounts: [process.env.PRIVATE_KEY as string], - gasPrice: 200000000000, // 200 gwei - url: `https://polygon-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}` - }, - polygonAmoy: { - accounts: [process.env.PRIVATE_KEY as string], - gasPrice: 100000000000, // 100 gwei - url: `https://polygon-amoy.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}` - } - }, - solidity: { - settings: { optimizer: { enabled: true }, viaIR: true }, - version: "0.8.24" - } -}; - -export default config; diff --git a/packages/contracts/package.json b/packages/contracts/package.json deleted file mode 100644 index 94321922ac76..000000000000 --- a/packages/contracts/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@hey/contracts", - "version": "0.0.0", - "private": true, - "license": "AGPL-3.0", - "scripts": { - "typecheck": "tsc --pretty" - }, - "devDependencies": { - "@hey/config": "workspace:*", - "@nomicfoundation/hardhat-toolbox": "2.0.2", - "@nomiclabs/hardhat-ethers": "^2.2.3", - "@openzeppelin/contracts": "^5.1.0", - "@openzeppelin/contracts-upgradeable": "^5.1.0", - "@openzeppelin/hardhat-upgrades": "1.28.0", - "dotenv": "^16.4.5", - "ethers": "5.7.2", - "hardhat": "^2.22.16", - "typescript": "^5.7.2" - } -} diff --git a/packages/contracts/script/HeyLensSignup/deploy.ts b/packages/contracts/script/HeyLensSignup/deploy.ts deleted file mode 100644 index 576ee2af0c9a..000000000000 --- a/packages/contracts/script/HeyLensSignup/deploy.ts +++ /dev/null @@ -1,25 +0,0 @@ -import hre from "hardhat"; - -async function deployProxy() { - const owner = "0x698386C93513d6D0C58f296633A7A3e529bd4026"; - // Amoy: 0x36440da1D98FF46637f0b98AAA082bc77977B49B - // Mainnet: 0x0b5e6100243f793e480DE6088dE6bA70aA9f3872 - const lensPermissionlessCreator = - "0x0b5e6100243f793e480DE6088dE6bA70aA9f3872"; - const signupPrice = "1000000000000000000"; - - const HeyLensSignup = await hre.ethers.getContractFactory("HeyLensSignupV2"); - const deployProxy = await hre.upgrades.deployProxy(HeyLensSignup as any, [ - owner, - lensPermissionlessCreator, - signupPrice - ]); - await deployProxy.deployed(); - - console.log(`HeyLensSignup deployed to ${await deployProxy.address}`); -} - -deployProxy().catch((error) => { - console.error(error); - process.exitCode = 1; -}); diff --git a/packages/contracts/script/HeyLensSignup/upgrade.ts b/packages/contracts/script/HeyLensSignup/upgrade.ts deleted file mode 100644 index 00da7ae97f52..000000000000 --- a/packages/contracts/script/HeyLensSignup/upgrade.ts +++ /dev/null @@ -1,15 +0,0 @@ -import hre from "hardhat"; - -async function upgradeProxy() { - const PROXY_ADDRESS = "0x82Bcb5DA51c6F3D0Ce942bDBEbb0B8A7774d62e8"; - - const HeyLensSignupV2 = - await hre.ethers.getContractFactory("HeyLensSignupV2"); - await hre.upgrades.upgradeProxy(PROXY_ADDRESS, HeyLensSignupV2 as any); - console.log("Proxy upgraded"); -} - -upgradeProxy().catch((error) => { - console.error(error); - process.exitCode = 1; -}); diff --git a/packages/contracts/script/HeyTipping/deploy.ts b/packages/contracts/script/HeyTipping/deploy.ts deleted file mode 100644 index c20c2d840c03..000000000000 --- a/packages/contracts/script/HeyTipping/deploy.ts +++ /dev/null @@ -1,20 +0,0 @@ -import hre from "hardhat"; - -async function deployProxy() { - const owner = "0x03Ba34f6Ea1496fa316873CF8350A3f7eaD317EF"; - const feesBps = "500"; // 5% - - const HeyTipping = await hre.ethers.getContractFactory("HeyTipping"); - const deployProxy = await hre.upgrades.deployProxy(HeyTipping as any, [ - owner, - feesBps - ]); - await deployProxy.deployed(); - - console.log(`HeyTipping deployed to ${await deployProxy.address}`); -} - -deployProxy().catch((error) => { - console.error(error); - process.exitCode = 1; -}); diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json deleted file mode 100644 index 56e1e36548de..000000000000 --- a/packages/contracts/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@hey/config/base.tsconfig.json", - "compilerOptions": { - "module": "CommonJS" - }, - "exclude": ["typechain-types"] -}