@towns-protocol/contracts 0.0.440 → 0.0.442
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/scripts/deployments/diamonds/DeployAccountModules.s.sol +188 -0
- package/scripts/deployments/diamonds/DeploySpace.s.sol +0 -7
- package/scripts/deployments/facets/DeployAccountHubFacet.s.sol +47 -0
- package/scripts/deployments/facets/DeployAccountTippingFacet.s.sol +37 -0
- package/scripts/deployments/facets/DeployAppManagerFacet.s.sol +40 -0
- package/scripts/interactions/InteractBaseAlpha.s.sol +3 -0
- package/src/account/facets/app/AppManagerFacet.sol +68 -0
- package/src/account/facets/app/AppManagerMod.sol +321 -0
- package/src/account/facets/hub/AccountHubFacet.sol +226 -0
- package/src/account/facets/hub/AccountHubMod.sol +136 -0
- package/src/account/facets/hub/IAccountHub.sol +25 -0
- package/src/account/facets/tipping/AccountTippingFacet.sol +72 -0
- package/src/account/facets/tipping/AccountTippingMod.sol +144 -0
- package/src/apps/facets/registry/AppRegistryBase.sol +4 -2
- package/src/apps/facets/registry/IAppRegistry.sol +1 -1
- package/src/factory/facets/architect/IArchitect.sol +1 -0
- package/src/factory/facets/create/CreateSpaceBase.sol +2 -9
- package/src/spaces/facets/account/AppAccountStorage.sol +0 -1
- package/src/spaces/facets/membership/IMembership.sol +0 -16
- package/src/spaces/facets/membership/join/MembershipJoin.sol +6 -15
- package/src/spaces/facets/tipping/ITipping.sol +14 -19
- package/src/spaces/facets/tipping/TippingBase.sol +0 -1
- package/src/spaces/facets/xchain/SpaceEntitlementGated.sol +0 -2
- package/scripts/deployments/facets/DeployPrepayFacet.s.sol +0 -31
- package/scripts/interactions/InteractPrepay.s.sol +0 -30
- package/src/spaces/facets/prepay/IPrepay.sol +0 -44
- package/src/spaces/facets/prepay/PrepayBase.sol +0 -27
- package/src/spaces/facets/prepay/PrepayFacet.sol +0 -65
- package/src/spaces/facets/prepay/PrepayStorage.sol +0 -26
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.23;
|
|
3
|
-
|
|
4
|
-
// interfaces
|
|
5
|
-
import {IPrepayBase} from "./IPrepay.sol";
|
|
6
|
-
|
|
7
|
-
// libraries
|
|
8
|
-
import {PrepayStorage} from "./PrepayStorage.sol";
|
|
9
|
-
|
|
10
|
-
// contracts
|
|
11
|
-
|
|
12
|
-
abstract contract PrepayBase is IPrepayBase {
|
|
13
|
-
function _addPrepay(uint256 supply) internal {
|
|
14
|
-
PrepayStorage.Layout storage ds = PrepayStorage.layout();
|
|
15
|
-
ds.supply += supply;
|
|
16
|
-
emit Prepay__Prepaid(supply);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function _reducePrepay(uint256 supply) internal {
|
|
20
|
-
PrepayStorage.Layout storage ds = PrepayStorage.layout();
|
|
21
|
-
ds.supply -= supply;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function _getPrepaidSupply() internal view returns (uint256) {
|
|
25
|
-
return PrepayStorage.layout().supply;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.23;
|
|
3
|
-
|
|
4
|
-
// interfaces
|
|
5
|
-
|
|
6
|
-
import {IPlatformRequirements} from "src/factory/facets/platform/requirements/IPlatformRequirements.sol";
|
|
7
|
-
import {IPrepay} from "src/spaces/facets/prepay/IPrepay.sol";
|
|
8
|
-
|
|
9
|
-
// libraries
|
|
10
|
-
import {MembershipStorage} from "src/spaces/facets/membership/MembershipStorage.sol";
|
|
11
|
-
import {CurrencyTransfer} from "src/utils/libraries/CurrencyTransfer.sol";
|
|
12
|
-
|
|
13
|
-
// contracts
|
|
14
|
-
import {PrepayBase} from "./PrepayBase.sol";
|
|
15
|
-
|
|
16
|
-
import {Facet} from "@towns-protocol/diamond/src/facets/Facet.sol";
|
|
17
|
-
import {Entitled} from "src/spaces/facets/Entitled.sol";
|
|
18
|
-
import {ReentrancyGuard} from "solady/utils/ReentrancyGuard.sol";
|
|
19
|
-
|
|
20
|
-
contract PrepayFacet is IPrepay, PrepayBase, ReentrancyGuard, Entitled, Facet {
|
|
21
|
-
function __PrepayFacet_init() external onlyInitializing {
|
|
22
|
-
_addInterface(type(IPrepay).interfaceId);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function prepayMembership(uint256 supply) external payable nonReentrant {
|
|
26
|
-
_validatePrepayCaller();
|
|
27
|
-
if (supply == 0) revert Prepay__InvalidSupplyAmount();
|
|
28
|
-
|
|
29
|
-
MembershipStorage.Layout storage ds = MembershipStorage.layout();
|
|
30
|
-
IPlatformRequirements platform = IPlatformRequirements(ds.spaceFactory);
|
|
31
|
-
|
|
32
|
-
uint256 cost = supply * platform.getMembershipFee();
|
|
33
|
-
|
|
34
|
-
// validate payment covers membership fee
|
|
35
|
-
if (msg.value != cost) revert Prepay__InvalidAmount();
|
|
36
|
-
|
|
37
|
-
// add prepay
|
|
38
|
-
_addPrepay(supply);
|
|
39
|
-
|
|
40
|
-
// transfer fee to platform recipient
|
|
41
|
-
address currency = ds.membershipCurrency;
|
|
42
|
-
address platformRecipient = platform.getFeeRecipient();
|
|
43
|
-
CurrencyTransfer.transferCurrency(
|
|
44
|
-
currency,
|
|
45
|
-
msg.sender, // from
|
|
46
|
-
platformRecipient, // to
|
|
47
|
-
cost
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function prepaidMembershipSupply() external view returns (uint256) {
|
|
52
|
-
return _getPrepaidSupply();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function calculateMembershipPrepayFee(uint256 supply) external view returns (uint256) {
|
|
56
|
-
MembershipStorage.Layout storage ds = MembershipStorage.layout();
|
|
57
|
-
IPlatformRequirements platform = IPlatformRequirements(ds.spaceFactory);
|
|
58
|
-
return supply * platform.getMembershipFee();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function _validatePrepayCaller() internal view {
|
|
62
|
-
address spaceFactory = MembershipStorage.layout().spaceFactory;
|
|
63
|
-
if (msg.sender != spaceFactory && msg.sender != _owner()) revert Prepay__NotAllowed();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.23;
|
|
3
|
-
|
|
4
|
-
// interfaces
|
|
5
|
-
|
|
6
|
-
// libraries
|
|
7
|
-
|
|
8
|
-
// contracts
|
|
9
|
-
|
|
10
|
-
library PrepayStorage {
|
|
11
|
-
// keccak256(abi.encode(uint256(keccak256("spaces.facets.prepay.storage")) - 1)) &
|
|
12
|
-
// ~bytes32(uint256(0xff))
|
|
13
|
-
bytes32 constant STORAGE_SLOT =
|
|
14
|
-
0x097b4f25b64e012d0cf55f67e9b34fe5d57f15b11b95baa4ddd136b424967c00;
|
|
15
|
-
|
|
16
|
-
struct Layout {
|
|
17
|
-
uint256 supply;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function layout() internal pure returns (Layout storage l) {
|
|
21
|
-
bytes32 slot = STORAGE_SLOT;
|
|
22
|
-
assembly {
|
|
23
|
-
l.slot := slot
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|