Skip to content

Commit

Permalink
remove referrals from membership and space (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppecrj authored Jun 28, 2024
1 parent 6ef5d47 commit 29c7687
Show file tree
Hide file tree
Showing 29 changed files with 28 additions and 695 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ contract DeployMembership is Deployer, FacetHelper {

// Minting
addSelector(IMembership.joinSpace.selector);
addSelector(IMembership.joinSpaceWithReferral.selector);
addSelector(IMembership.renewMembership.selector);

addSelector(IMembership.expiresAt.selector);
Expand Down
12 changes: 0 additions & 12 deletions contracts/src/spaces/facets/membership/IMembership.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@ interface IMembership is IMembershipBase {
*/
function joinSpace(address receiver) external payable;

/**
* @notice Join a space with a referral
* @param receiver The address of the receiver
* @param referrer The address of the referrer
* @param referralCode The referral code
*/
function joinSpaceWithReferral(
address receiver,
address referrer,
uint256 referralCode
) external payable;

/**
* @notice Renew a space membership
* @param tokenId The token id of the membership
Expand Down
46 changes: 0 additions & 46 deletions contracts/src/spaces/facets/membership/MembershipFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {EntitlementGated} from "contracts/src/spaces/facets/gated/EntitlementGat
contract MembershipFacet is
IMembership,
MembershipBase,
MembershipReferralBase,
ERC5643Base,
ReentrancyGuard,
ERC721A,
Expand Down Expand Up @@ -196,51 +195,6 @@ contract MembershipFacet is
emit MembershipTokenIssued(receiver, tokenId);
}

/// @inheritdoc IMembership
function joinSpaceWithReferral(
address receiver,
address referrer,
uint256 referralCode
) external payable nonReentrant {
_validateJoinSpace(receiver);

// get token id
uint256 tokenId = _nextTokenId();

// allocate protocol, membership and referral fees
uint256 membershipPrice = _getMembershipPrice(_totalSupply());

if (membershipPrice > 0) {
// set renewal price for referral
_setMembershipRenewalPrice(tokenId, membershipPrice);

uint256 protocolFee = _collectProtocolFee(receiver, membershipPrice);
uint256 surplus = membershipPrice - protocolFee;
address currency = _getMembershipCurrency();

if (surplus > 0) {
// calculate referral fee from net membership price
uint256 referralFee = _calculateReferralAmount(surplus, referralCode);
CurrencyTransfer.transferCurrency(
currency,
receiver,
referrer,
referralFee
);

// transfer remaining amount to fee recipient
uint256 recipientFee = surplus - referralFee;
if (recipientFee > 0) _transferIn(receiver, recipientFee);
}
}

// mint membership
_safeMint(receiver, 1);

// set expiration of membership
_renewSubscription(tokenId, _getMembershipDuration());
}

// =============================================================
// Renewal
// =============================================================
Expand Down
17 changes: 0 additions & 17 deletions contracts/test/spaces/membership/MembershipBaseSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,4 @@ contract MembershipBaseSetup is
referrals.createReferralCode(REFERRAL_CODE, REFERRAL_BPS);
_;
}

modifier givenAliceHasMintedReferralMembership() {
vm.prank(alice);
membership.joinSpaceWithReferral(alice, bob, REFERRAL_CODE);
_;
}

modifier givenAliceHasPaidReferralMembership() {
vm.prank(alice);
vm.deal(alice, MEMBERSHIP_PRICE);
membership.joinSpaceWithReferral{value: MEMBERSHIP_PRICE}(
alice,
bob,
REFERRAL_CODE
);
_;
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion packages/generated/dev/abis/Architect.bin

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/generated/dev/abis/Architect.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/generated/dev/abis/Architect.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -928,10 +928,10 @@
"license": "MIT"
},
"contracts/src/spaces/facets/membership/IMembership.sol": {
"keccak256": "0x6412840e6051b909892e0ac881214235a18a290a39394a5462b54e0e0ab09a46",
"keccak256": "0x7fbf37c681ae95610ed376a30d68808b9da602a3225dbe1724dfe7c1c82de672",
"urls": [
"bzz-raw://0a9a2be307336fd760d84d2adddf25a8ea10398672fb1447a299118649a9a544",
"dweb:/ipfs/QmR9553MSLHUw7mSN6M5dEuLBVfUb5g6tGoY6Xv7sGWaRs"
"bzz-raw://afa8d56cca2d01883595cfbd1a6aa3b63202ed25fb56ac1e57d3cf645665dd77",
"dweb:/ipfs/QmbLF87ZZCovJn3enbs78mcJu39zXi8FYum72fTufZt3e4"
],
"license": "MIT"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/generated/dev/abis/Channels.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/generated/dev/abis/EntitlementsManager.json

Large diffs are not rendered by default.

Loading

0 comments on commit 29c7687

Please sign in to comment.