@towns-protocol/contracts 0.0.359 → 0.0.361
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 +9 -9
- package/scripts/deployments/diamonds/DeploySubscriptionModule.s.sol +30 -1
- package/scripts/interactions/InteractBaseAlpha.s.sol +9 -0
- package/src/apps/modules/subscription/ISubscriptionModule.sol +6 -2
- package/src/apps/modules/subscription/SubscriptionModuleFacet.sol +17 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@towns-protocol/contracts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.361",
|
|
4
4
|
"packageManager": "yarn@3.8.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build-types": "bash scripts/build-contract-types.sh",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"@openzeppelin/contracts-upgradeable": "^5.4.0",
|
|
24
24
|
"@prb/math": "^4.1.0",
|
|
25
25
|
"@towns-protocol/diamond": "^0.6.3",
|
|
26
|
-
"@uniswap/permit2": "
|
|
27
|
-
"account-abstraction": "
|
|
28
|
-
"crypto-lib": "
|
|
29
|
-
"modular-account": "
|
|
26
|
+
"@uniswap/permit2": "github:towns-protocol/permit2#v1.0.0",
|
|
27
|
+
"account-abstraction": "github:eth-infinitism/account-abstraction#v0.7.0",
|
|
28
|
+
"crypto-lib": "github:towns-protocol/crypto-lib#v1.0.1",
|
|
29
|
+
"modular-account": "github:towns-protocol/modular-account#v1.0.0",
|
|
30
30
|
"solady": "^0.1.24"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"@layerzerolabs/oapp-evm": "^0.3.2",
|
|
36
36
|
"@openzeppelin/merkle-tree": "^1.0.8",
|
|
37
37
|
"@prb/test": "^0.6.4",
|
|
38
|
-
"@towns-protocol/prettier-config": "^0.0.
|
|
39
|
-
"@typechain/ethers-v5": "^
|
|
38
|
+
"@towns-protocol/prettier-config": "^0.0.361",
|
|
39
|
+
"@typechain/ethers-v5": "^11.1.2",
|
|
40
40
|
"@wagmi/cli": "^2.2.0",
|
|
41
41
|
"forge-std": "github:foundry-rs/forge-std#v1.10.0",
|
|
42
42
|
"prettier": "^3.5.3",
|
|
43
43
|
"prettier-plugin-solidity": "^1.4.2",
|
|
44
44
|
"solhint": "^5.0.5",
|
|
45
45
|
"solidity-bytes-utils": "^0.8.4",
|
|
46
|
-
"typechain": "^8.
|
|
46
|
+
"typechain": "^8.3.2"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"docs/**/*",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "601c0fa728a8738f2fd558d7084a78f477af1c08"
|
|
61
61
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IDiamondInitHelper} from "./IDiamondInitHelper.sol";
|
|
6
|
+
|
|
4
7
|
// libraries
|
|
5
8
|
import {DeployDiamondCut} from "@towns-protocol/diamond/scripts/deployments/facets/DeployDiamondCut.sol";
|
|
6
9
|
import {DeployDiamondLoupe} from "@towns-protocol/diamond/scripts/deployments/facets/DeployDiamondLoupe.sol";
|
|
@@ -19,7 +22,7 @@ import {DiamondHelper} from "@towns-protocol/diamond/scripts/common/helpers/Diam
|
|
|
19
22
|
import {DeployFacet} from "../../common/DeployFacet.s.sol";
|
|
20
23
|
import {Deployer} from "../../common/Deployer.s.sol";
|
|
21
24
|
|
|
22
|
-
contract DeploySubscriptionModule is DiamondHelper, Deployer {
|
|
25
|
+
contract DeploySubscriptionModule is DiamondHelper, Deployer, IDiamondInitHelper {
|
|
23
26
|
using LibString for string;
|
|
24
27
|
|
|
25
28
|
DeployFacet private facetHelper = new DeployFacet();
|
|
@@ -30,6 +33,32 @@ contract DeploySubscriptionModule is DiamondHelper, Deployer {
|
|
|
30
33
|
return "subscriptionModule";
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
function diamondInitHelper(
|
|
37
|
+
address deployer,
|
|
38
|
+
string[] memory facetNames
|
|
39
|
+
) external override returns (FacetCut[] memory) {
|
|
40
|
+
// Queue up all requested facets for batch deployment
|
|
41
|
+
for (uint256 i; i < facetNames.length; ++i) {
|
|
42
|
+
facetHelper.add(facetNames[i]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Deploy all requested facets in a single batch transaction
|
|
46
|
+
facetHelper.deployBatch(deployer);
|
|
47
|
+
|
|
48
|
+
for (uint256 i; i < facetNames.length; ++i) {
|
|
49
|
+
string memory facetName = facetNames[i];
|
|
50
|
+
address facet = facetHelper.getDeployedAddress(facetName);
|
|
51
|
+
|
|
52
|
+
if (facetName.eq("SubscriptionModuleFacet")) {
|
|
53
|
+
addCut(
|
|
54
|
+
makeCut(facet, FacetCutAction.Add, DeploySubscriptionModuleFacet.selectors())
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return baseFacets();
|
|
60
|
+
}
|
|
61
|
+
|
|
33
62
|
function diamondInitParams(address deployer) public returns (Diamond.InitParams memory) {
|
|
34
63
|
// Queue up feature facets for batch deployment
|
|
35
64
|
facetHelper.add("MultiInit");
|
|
@@ -12,6 +12,7 @@ import {DeploySpace} from "scripts/deployments/diamonds/DeploySpace.s.sol";
|
|
|
12
12
|
import {DeploySpaceFactory} from "scripts/deployments/diamonds/DeploySpaceFactory.s.sol";
|
|
13
13
|
import {DeploySpaceOwner} from "scripts/deployments/diamonds/DeploySpaceOwner.s.sol";
|
|
14
14
|
import {DeployAppRegistry} from "scripts/deployments/diamonds/DeployAppRegistry.s.sol";
|
|
15
|
+
import {DeploySubscriptionModule} from "scripts/deployments/diamonds/DeploySubscriptionModule.s.sol";
|
|
15
16
|
import {AlphaHelper} from "scripts/interactions/helpers/AlphaHelper.sol";
|
|
16
17
|
|
|
17
18
|
contract InteractBaseAlpha is AlphaHelper {
|
|
@@ -21,6 +22,7 @@ contract InteractBaseAlpha is AlphaHelper {
|
|
|
21
22
|
DeploySpaceOwner deploySpaceOwner = new DeploySpaceOwner();
|
|
22
23
|
DeployRiverAirdrop deployRiverAirdrop = new DeployRiverAirdrop();
|
|
23
24
|
DeployAppRegistry deployAppRegistry = new DeployAppRegistry();
|
|
25
|
+
DeploySubscriptionModule deploySubscriptionModule = new DeploySubscriptionModule();
|
|
24
26
|
|
|
25
27
|
function __interact(address deployer) internal override {
|
|
26
28
|
vm.pauseGasMetering();
|
|
@@ -31,6 +33,7 @@ contract InteractBaseAlpha is AlphaHelper {
|
|
|
31
33
|
address baseRegistry = getDeployment("baseRegistry");
|
|
32
34
|
address riverAirdrop = getDeployment("riverAirdrop");
|
|
33
35
|
address appRegistry = getDeployment("appRegistry");
|
|
36
|
+
address subscriptionModule = getDeployment("subscriptionModule");
|
|
34
37
|
|
|
35
38
|
executeDiamondCutsWithLogging(deployer, space, "Space", deploySpace);
|
|
36
39
|
executeDiamondCutsWithLogging(deployer, spaceOwner, "SpaceOwner", deploySpaceOwner);
|
|
@@ -49,6 +52,12 @@ contract InteractBaseAlpha is AlphaHelper {
|
|
|
49
52
|
executeDiamondCutsWithLogging(deployer, baseRegistry, "BaseRegistry", deployBaseRegistry);
|
|
50
53
|
executeDiamondCutsWithLogging(deployer, riverAirdrop, "RiverAirdrop", deployRiverAirdrop);
|
|
51
54
|
executeDiamondCutsWithLogging(deployer, appRegistry, "AppRegistry", deployAppRegistry);
|
|
55
|
+
executeDiamondCutsWithLogging(
|
|
56
|
+
deployer,
|
|
57
|
+
subscriptionModule,
|
|
58
|
+
"SubscriptionModule",
|
|
59
|
+
deploySubscriptionModule
|
|
60
|
+
);
|
|
52
61
|
|
|
53
62
|
vm.resumeGasMetering();
|
|
54
63
|
}
|
|
@@ -49,7 +49,8 @@ interface ISubscriptionModuleBase {
|
|
|
49
49
|
uint32 indexed entityId,
|
|
50
50
|
address indexed space,
|
|
51
51
|
uint256 tokenId,
|
|
52
|
-
uint64 nextRenewalTime
|
|
52
|
+
uint64 nextRenewalTime,
|
|
53
|
+
uint256 expiresAt
|
|
53
54
|
);
|
|
54
55
|
|
|
55
56
|
event SubscriptionDeactivated(address indexed account, uint32 indexed entityId);
|
|
@@ -66,7 +67,10 @@ interface ISubscriptionModuleBase {
|
|
|
66
67
|
event SubscriptionRenewed(
|
|
67
68
|
address indexed account,
|
|
68
69
|
uint32 indexed entityId,
|
|
69
|
-
|
|
70
|
+
address indexed space,
|
|
71
|
+
uint256 tokenId,
|
|
72
|
+
uint256 nextRenewalTime,
|
|
73
|
+
uint256 expiresAt
|
|
70
74
|
);
|
|
71
75
|
|
|
72
76
|
/// @notice Emitted when a subscription's next renewal time is synced to on-chain expiration
|
|
@@ -95,7 +95,14 @@ contract SubscriptionModuleFacet is
|
|
|
95
95
|
sub.installTime = uint40(block.timestamp);
|
|
96
96
|
sub.nextRenewalTime = _calculateNextRenewalTime(expiresAt, sub.installTime);
|
|
97
97
|
|
|
98
|
-
emit SubscriptionConfigured(
|
|
98
|
+
emit SubscriptionConfigured(
|
|
99
|
+
msg.sender,
|
|
100
|
+
entityId,
|
|
101
|
+
space,
|
|
102
|
+
tokenId,
|
|
103
|
+
sub.nextRenewalTime,
|
|
104
|
+
expiresAt
|
|
105
|
+
);
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
/// @inheritdoc IModule
|
|
@@ -385,7 +392,15 @@ contract SubscriptionModuleFacet is
|
|
|
385
392
|
sub.lastRenewalTime = uint40(block.timestamp);
|
|
386
393
|
sub.spent += actualRenewalPrice;
|
|
387
394
|
|
|
388
|
-
emit SubscriptionRenewed(
|
|
395
|
+
emit SubscriptionRenewed(
|
|
396
|
+
params.account,
|
|
397
|
+
params.entityId,
|
|
398
|
+
sub.space,
|
|
399
|
+
sub.tokenId,
|
|
400
|
+
sub.nextRenewalTime,
|
|
401
|
+
newExpiresAt
|
|
402
|
+
);
|
|
403
|
+
emit SubscriptionSpent(params.account, params.entityId, actualRenewalPrice, sub.spent);
|
|
389
404
|
}
|
|
390
405
|
|
|
391
406
|
/// @dev Determines the appropriate renewal buffer time based on original membership duration
|