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

feat: hey lens signup contract #4611

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions apps/web/src/components/Shared/Auth/Signup/ChooseHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ const ChooseHandle: FC = () => {
'0x'
],
handle,
['0x03Ba34f6Ea1496fa316873CF8350A3f7eaD317EF']
['0x6C1e1bC39b13f9E0Af9424D76De899203F47755F']
],
functionName: 'createProfileWithHandleUsingCredits',
value: parseEther('1')
value: parseEther('2')
});
};

Expand Down
201 changes: 67 additions & 134 deletions packages/abis/HeyLensSignup.ts
Original file line number Diff line number Diff line change
@@ -1,115 +1,31 @@
export const HeyLensSignup = [
{ inputs: [], name: 'InvalidFunds', type: 'error' },
{ inputs: [], name: 'InvalidInitialization', type: 'error' },
{ inputs: [], name: 'NotAllowed', type: 'error' },
{ inputs: [], name: 'NotInitializing', type: 'error' },
{
inputs: [
{
internalType: 'address payable',
name: 'newBeneficiary',
type: 'address'
}
],
name: 'changeBeneficiary',
outputs: [],
stateMutability: 'nonpayable',
type: 'function'
},
{
inputs: [
{
components: [
{
internalType: 'address',
name: 'to',
type: 'address'
},
{
internalType: 'address',
name: 'followModule',
type: 'address'
},
{
internalType: 'bytes',
name: 'followModuleInitData',
type: 'bytes'
}
],
internalType: 'struct CreateProfileParams',
name: 'createProfileParams',
type: 'tuple'
},
{
internalType: 'string',
name: 'handle',
type: 'string'
},
{
internalType: 'address[]',
name: 'delegatedExecutors',
type: 'address[]'
}
],
name: 'createProfileWithHandleUsingCredits',
outputs: [
{
internalType: 'uint256',
name: 'profileId',
type: 'uint256'
},
{
internalType: 'uint256',
name: 'handleId',
type: 'uint256'
}
],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{
internalType: 'address',
name: 'initialOwner',
type: 'address'
},
{
internalType: 'address',
name: 'permissionlessCreator',
type: 'address'
},
{
internalType: 'address payable',
name: 'beneficiary_',
type: 'address'
}
],
stateMutability: 'nonpayable',
type: 'constructor'
},
{
inputs: [],
name: 'InvalidFunds',
inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
name: 'OwnableInvalidOwner',
type: 'error'
},
{
inputs: [
{
internalType: 'address',
name: 'owner',
type: 'address'
}
],
name: 'OwnableInvalidOwner',
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
name: 'OwnableUnauthorizedAccount',
type: 'error'
},
{ inputs: [], name: 'WithdrawalFailed', type: 'error' },
{
anonymous: false,
inputs: [
{
internalType: 'address',
name: 'account',
type: 'address'
indexed: false,
internalType: 'uint64',
name: 'version',
type: 'uint64'
}
],
name: 'OwnableUnauthorizedAccount',
type: 'error'
name: 'Initialized',
type: 'event'
},
{
anonymous: false,
Expand All @@ -131,44 +47,59 @@ export const HeyLensSignup = [
type: 'event'
},
{
inputs: [],
name: 'renounceOwnership',
outputs: [],
stateMutability: 'nonpayable',
inputs: [
{
components: [
{ internalType: 'address', name: 'to', type: 'address' },
{ internalType: 'address', name: 'followModule', type: 'address' },
{ internalType: 'bytes', name: 'followModuleInitData', type: 'bytes' }
],
internalType: 'struct CreateProfileParams',
name: 'createProfileParams',
type: 'tuple'
},
{ internalType: 'string', name: 'handle', type: 'string' },
{
internalType: 'address[]',
name: 'delegatedExecutors',
type: 'address[]'
}
],
name: 'createProfileWithHandleUsingCredits',
outputs: [
{ internalType: 'uint256', name: 'profileId', type: 'uint256' },
{ internalType: 'uint256', name: 'handleId', type: 'uint256' }
],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [
{
internalType: 'address',
name: 'newOwner',
name: '_permissonlessCreator',
type: 'address'
}
},
{ internalType: 'address', name: 'owner', type: 'address' }
],
name: 'transferOwnership',
name: 'initialize',
outputs: [],
stateMutability: 'nonpayable',
type: 'function'
},
{
inputs: [],
name: 'beneficiary',
outputs: [
{
internalType: 'address payable',
name: '',
type: 'address'
}
],
name: 'owner',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function'
},
{
inputs: [],
name: 'owner',
name: 'permissonlessCreator',
outputs: [
{
internalType: 'address',
internalType: 'contract IPermissonlessCreator',
name: '',
type: 'address'
}
Expand All @@ -178,28 +109,30 @@ export const HeyLensSignup = [
},
{
inputs: [],
name: 'PERMISSIONLESS_CREATOR',
outputs: [
{
internalType: 'contract IPermissionlessCreator',
name: '',
type: 'address'
}
],
name: 'profileWithHandleCreationCost',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
},
{
inputs: [],
name: 'profileWithHandleCreationCost',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256'
}
],
stateMutability: 'view',
name: 'renounceOwnership',
outputs: [],
stateMutability: 'nonpayable',
type: 'function'
},
{
inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }],
name: 'transferOwnership',
outputs: [],
stateMutability: 'nonpayable',
type: 'function'
},
{
inputs: [],
name: 'withdrawFunds',
outputs: [],
stateMutability: 'nonpayable',
type: 'function'
}
];
3 changes: 3 additions & 0 deletions packages/contracts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: [require.resolve('@hey/config/eslint/base.js')]
};
16 changes: 16 additions & 0 deletions packages/contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

.openzeppelin
13 changes: 13 additions & 0 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts
```
74 changes: 74 additions & 0 deletions packages/contracts/contracts/HeyLensSignup.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: MIT

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 IPermissonlessCreator {
function createProfileWithHandleUsingCredits(
CreateProfileParams calldata createProfileParams,
string calldata handle,
address[] calldata delegatedExecutors
) external returns (uint256, uint256);
}

contract HeyLensSignup is Initializable, OwnableUpgradeable {
IPermissonlessCreator public permissonlessCreator;
uint256 public profileWithHandleCreationCost;

error InvalidFunds();
error NotAllowed();
error WithdrawalFailed();

// Initializer instead of constructor for upgradeable contracts
function initialize(
address _permissonlessCreator,
address owner
) public initializer {
__Ownable_init(owner);
permissonlessCreator = IPermissonlessCreator(_permissonlessCreator);
profileWithHandleCreationCost = 1 ether;
}

function setSignupPrice(
uint256 _profileWithHandleCreationCost
) external onlyOwner {
profileWithHandleCreationCost = _profileWithHandleCreationCost;
}

function createProfileWithHandleUsingCredits(
CreateProfileParams calldata createProfileParams,
string calldata handle,
address[] calldata delegatedExecutors
) external payable returns (uint256 profileId, uint256 handleId) {
if (msg.value != profileWithHandleCreationCost) {
revert InvalidFunds();
}

if (delegatedExecutors.length > 0 && createProfileParams.to != msg.sender) {
revert NotAllowed();
}

// Call the permissonlessCreator to create a profile
return
permissonlessCreator.createProfileWithHandleUsingCredits(
createProfileParams,
handle,
delegatedExecutors
);
}

function withdrawFunds() external onlyOwner {
(bool sent, ) = payable(owner()).call{ value: address(this).balance }('');
if (!sent) {
revert WithdrawalFailed();
}
}
}
Loading
Loading