mirror of
https://github.com/lens-protocol/core.git
synced 2026-01-09 22:28:04 -05:00
Merge pull request #166 from lens-protocol/feat/permissionless-creator
Feat/permissionless creator
This commit is contained in:
@@ -149,7 +149,7 @@
|
||||
"ProfileTokenURI": "0xCCF77B802160326282F260bb6e275333fEA9E76C",
|
||||
"HandleTokenURI": "0x33b7C0692DD8267f936936C0A0f7079144d78B92",
|
||||
"FollowTokenURI": "0x1a4D3f97770925A14997B351C5cC3Cd47192a5B8"
|
||||
"PermissionlessCreatorImpl": "0x9f077d03DBf4aB8c68e181baA3308F3B12C52Ae8",
|
||||
"PermissionlessCreatorImpl": "0x80a4D78179Cf8C1B0a0621Ba5b33A55Fba469688",
|
||||
"PermissionlessCreator": "0x0b5e6100243f793e480DE6088dE6bA70aA9f3872"
|
||||
},
|
||||
"testnet": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -218,7 +218,7 @@ contract PermissionlessCreator is ImmutableOwnable {
|
||||
}
|
||||
|
||||
function _validateHandleLength(string calldata handle) private view {
|
||||
if (bytes(handle).length < _handleLengthMin) {
|
||||
if (!_isCreditProvider[msg.sender] && bytes(handle).length < _handleLengthMin) {
|
||||
revert HandleLengthNotAllowed();
|
||||
}
|
||||
}
|
||||
@@ -230,6 +230,10 @@ contract PermissionlessCreator is ImmutableOwnable {
|
||||
}
|
||||
|
||||
function _spendCredit(address account) private {
|
||||
if (_isCreditProvider[msg.sender]) {
|
||||
// Credit providers do not need credits.
|
||||
return;
|
||||
}
|
||||
_credits[account] -= 1;
|
||||
emit CreditBalanceChanged(account, _credits[account], block.timestamp);
|
||||
}
|
||||
|
||||
@@ -1011,3 +1011,71 @@ contract PermissionlessCreatorTest_Credits is PermissionlessCreatorTestBase {
|
||||
assertEq(permissionlessCreator.getCreditBalance(targetAddress), balanceBefore + addBalance - subBalance);
|
||||
}
|
||||
}
|
||||
|
||||
contract PermissionlessCreatorTest_CreditProviders is PermissionlessCreatorTestBase {
|
||||
address creditProvider = makeAddr('CREDIT_PROVIDER');
|
||||
|
||||
function setUp() public override {
|
||||
super.setUp();
|
||||
|
||||
vm.prank(permissionlessCreatorOwner);
|
||||
permissionlessCreator.addCreditProvider(creditProvider);
|
||||
}
|
||||
|
||||
// Scenarios
|
||||
|
||||
function testCreateProfile_byCreditProvider(address to) public {
|
||||
vm.assume(to != address(0));
|
||||
|
||||
Types.CreateProfileParams memory createProfileParams = Types.CreateProfileParams({
|
||||
to: to,
|
||||
followModule: address(0),
|
||||
followModuleInitData: ''
|
||||
});
|
||||
|
||||
address[] memory delegates = new address[](1);
|
||||
delegates[0] = makeAddr('DE0');
|
||||
|
||||
vm.prank(creditProvider);
|
||||
uint256 profileId = permissionlessCreator.createProfileUsingCredits(createProfileParams, delegates);
|
||||
|
||||
assertEq(hub.ownerOf(profileId), to);
|
||||
assertTrue(hub.isDelegatedExecutorApproved(profileId, delegates[0]));
|
||||
}
|
||||
|
||||
function testCreateHandle_byCreditProvider(address to) public {
|
||||
vm.assume(to != address(0));
|
||||
|
||||
string memory handle = 'q4w';
|
||||
|
||||
vm.prank(creditProvider);
|
||||
uint256 handleId = permissionlessCreator.createHandleUsingCredits(to, handle);
|
||||
|
||||
assertEq(lensHandles.ownerOf(handleId), to);
|
||||
}
|
||||
|
||||
function testCreateProfileWithHandle_byCreditProvider(address to) public {
|
||||
vm.assume(to != address(0));
|
||||
|
||||
Types.CreateProfileParams memory createProfileParams = Types.CreateProfileParams({
|
||||
to: to,
|
||||
followModule: address(0),
|
||||
followModuleInitData: ''
|
||||
});
|
||||
|
||||
string memory handle = 'q4w';
|
||||
address[] memory delegates = new address[](1);
|
||||
delegates[0] = makeAddr('DE0');
|
||||
|
||||
vm.prank(creditProvider);
|
||||
(uint256 profileId, uint256 handleId) = permissionlessCreator.createProfileWithHandleUsingCredits(
|
||||
createProfileParams,
|
||||
handle,
|
||||
delegates
|
||||
);
|
||||
|
||||
assertEq(hub.ownerOf(profileId), to);
|
||||
assertTrue(hub.isDelegatedExecutorApproved(profileId, delegates[0]));
|
||||
assertEq(lensHandles.ownerOf(handleId), to);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user