@towns-protocol/contracts 0.0.328 → 0.0.330
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 +4 -4
- package/src/apps/BaseApp.sol +7 -7
- package/src/apps/ITownsApp.sol +4 -4
- package/src/apps/facets/registry/AppRegistryBase.sol +5 -5
- package/src/apps/facets/registry/IAppRegistry.sol +1 -1
- package/src/apps/helpers/SimpleApp.sol +4 -5
- package/src/spaces/facets/account/AppAccountBase.sol +11 -20
- package/src/spaces/facets/account/IAppAccount.sol +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@towns-protocol/contracts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.330",
|
|
4
4
|
"packageManager": "yarn@3.8.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "forge build",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"typings": "wagmi generate"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@erc6900/reference-implementation": "
|
|
19
|
+
"@erc6900/reference-implementation": "https://github.com/erc6900/reference-implementation/archive/refs/tags/v0.8.0.tar.gz",
|
|
20
20
|
"@ethereum-attestation-service/eas-contracts": "^1.8.0",
|
|
21
21
|
"@layerzerolabs/oft-evm": "^3.1.4",
|
|
22
22
|
"@openzeppelin/contracts": "^5.4.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@layerzerolabs/oapp-evm": "^0.3.2",
|
|
34
34
|
"@openzeppelin/merkle-tree": "^1.0.8",
|
|
35
35
|
"@prb/test": "^0.6.4",
|
|
36
|
-
"@towns-protocol/prettier-config": "^0.0.
|
|
36
|
+
"@towns-protocol/prettier-config": "^0.0.330",
|
|
37
37
|
"@typechain/ethers-v5": "^10.1.1",
|
|
38
38
|
"@wagmi/cli": "^2.2.0",
|
|
39
39
|
"account-abstraction": "https://github.com/eth-infinitism/account-abstraction/archive/refs/tags/v0.7.0.tar.gz",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "f472a3c4a6f67a96e378db552e2880327eef42ba"
|
|
60
60
|
}
|
package/src/apps/BaseApp.sol
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {IExecutionModule} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
6
|
+
import {IModule} from "@erc6900/reference-implementation/interfaces/IModule.sol";
|
|
7
7
|
import {ITownsApp} from "./ITownsApp.sol";
|
|
8
8
|
|
|
9
9
|
/// @title BaseApp
|
|
10
10
|
/// @notice Base contract for Towns apps implementing core ERC-6900 module functionality
|
|
11
11
|
/// @dev Provides base implementation for module installation/uninstallation and interface support
|
|
12
12
|
/// @dev Inheriting contracts should override _onInstall and _onUninstall as needed
|
|
13
|
-
/// @dev Implements
|
|
13
|
+
/// @dev Implements IModule, IExecutionModule, and ITownsApp interfaces
|
|
14
14
|
|
|
15
15
|
abstract contract BaseApp is ITownsApp {
|
|
16
16
|
receive() external payable {
|
|
@@ -20,17 +20,17 @@ abstract contract BaseApp is ITownsApp {
|
|
|
20
20
|
// External functions
|
|
21
21
|
function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
|
|
22
22
|
return
|
|
23
|
-
interfaceId == type(
|
|
24
|
-
interfaceId == type(
|
|
23
|
+
interfaceId == type(IExecutionModule).interfaceId ||
|
|
24
|
+
interfaceId == type(IModule).interfaceId ||
|
|
25
25
|
interfaceId == type(ITownsApp).interfaceId;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/// @notice Required by
|
|
28
|
+
/// @notice Required by IModule - called when module is installed
|
|
29
29
|
function onInstall(bytes calldata postInstallData) external {
|
|
30
30
|
_onInstall(postInstallData);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/// @notice Required by
|
|
33
|
+
/// @notice Required by IModule - called when module is uninstalled
|
|
34
34
|
function onUninstall(bytes calldata postUninstallData) external {
|
|
35
35
|
_onUninstall(postUninstallData);
|
|
36
36
|
}
|
package/src/apps/ITownsApp.sol
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {IExecutionModule} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
6
|
+
import {IModule} from "@erc6900/reference-implementation/interfaces/IModule.sol";
|
|
7
7
|
|
|
8
8
|
/// @title ITownsApp Interface
|
|
9
9
|
/// @notice Base interface for Towns apps implementing core module functionality
|
|
10
|
-
/// @dev Combines
|
|
10
|
+
/// @dev Combines IModule (module lifecycle), and IExecutionModule (execution)
|
|
11
11
|
/// @dev Apps must implement required permissions and support these interfaces
|
|
12
|
-
interface ITownsApp is
|
|
12
|
+
interface ITownsApp is IModule, IExecutionModule {
|
|
13
13
|
/// @notice Returns the required permissions for the app
|
|
14
14
|
/// @return permissions The required permissions for the app
|
|
15
15
|
function requiredPermissions() external view returns (bytes32[] memory);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {IExecutionModule} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
6
|
+
import {IModule} from "@erc6900/reference-implementation/interfaces/IModule.sol";
|
|
7
7
|
import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
|
|
8
8
|
import {ITownsApp} from "../../ITownsApp.sol";
|
|
9
9
|
import {IAppRegistryBase} from "./IAppRegistry.sol";
|
|
@@ -22,7 +22,7 @@ import {FixedPointMathLib} from "solady/utils/FixedPointMathLib.sol";
|
|
|
22
22
|
import {CurrencyTransfer} from "../../../utils/libraries/CurrencyTransfer.sol";
|
|
23
23
|
|
|
24
24
|
// types
|
|
25
|
-
import {ExecutionManifest} from "@erc6900/reference-implementation/interfaces/
|
|
25
|
+
import {ExecutionManifest} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
26
26
|
import {Attestation, EMPTY_UID} from "@ethereum-attestation-service/eas-contracts/Common.sol";
|
|
27
27
|
import {AttestationRequest, RevocationRequestData} from "@ethereum-attestation-service/eas-contracts/IEAS.sol";
|
|
28
28
|
|
|
@@ -389,8 +389,8 @@ abstract contract AppRegistryBase is IAppRegistryBase, SchemaBase, AttestationBa
|
|
|
389
389
|
if (client == address(0)) InvalidAddressInput.selector.revertWith();
|
|
390
390
|
|
|
391
391
|
if (
|
|
392
|
-
!IERC165(app).supportsInterface(type(
|
|
393
|
-
!IERC165(app).supportsInterface(type(
|
|
392
|
+
!IERC165(app).supportsInterface(type(IModule).interfaceId) ||
|
|
393
|
+
!IERC165(app).supportsInterface(type(IExecutionModule).interfaceId) ||
|
|
394
394
|
!IERC165(app).supportsInterface(type(ITownsApp).interfaceId)
|
|
395
395
|
) {
|
|
396
396
|
AppDoesNotImplementInterface.selector.revertWith();
|
|
@@ -8,7 +8,7 @@ import {ITownsApp} from "../../ITownsApp.sol";
|
|
|
8
8
|
|
|
9
9
|
// libraries
|
|
10
10
|
import {Attestation} from "@ethereum-attestation-service/eas-contracts/Common.sol";
|
|
11
|
-
import {ExecutionManifest} from "@erc6900/reference-implementation/interfaces/
|
|
11
|
+
import {ExecutionManifest} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
12
12
|
|
|
13
13
|
interface IAppRegistryBase {
|
|
14
14
|
struct AppParams {
|
|
@@ -4,13 +4,12 @@ pragma solidity ^0.8.23;
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {ISimpleApp} from "../../apps/helpers/ISimpleApp.sol";
|
|
6
6
|
import {ITownsApp} from "../../apps/ITownsApp.sol";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import {ExecutionManifest, IExecutionModule} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
8
|
+
import {IModule} from "@erc6900/reference-implementation/interfaces/IModule.sol";
|
|
9
9
|
|
|
10
10
|
// contracts
|
|
11
11
|
import {BaseApp} from "../../apps/BaseApp.sol";
|
|
12
12
|
import {Ownable} from "solady/auth/Ownable.sol";
|
|
13
|
-
import {ExecutionManifest} from "@erc6900/reference-implementation/interfaces/IERC6900ExecutionModule.sol";
|
|
14
13
|
import {Initializable} from "solady/utils/Initializable.sol";
|
|
15
14
|
|
|
16
15
|
// libraries
|
|
@@ -66,13 +65,13 @@ contract SimpleApp is ISimpleApp, Ownable, BaseApp, Initializable {
|
|
|
66
65
|
return $.permissions;
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
/// @inheritdoc
|
|
68
|
+
/// @inheritdoc IModule
|
|
70
69
|
function moduleId() public view returns (string memory) {
|
|
71
70
|
SimpleAppStorage.Layout storage $ = SimpleAppStorage.getLayout();
|
|
72
71
|
return $.name;
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
/// @inheritdoc
|
|
74
|
+
/// @inheritdoc IExecutionModule
|
|
76
75
|
function executionManifest() external pure returns (ExecutionManifest memory) {
|
|
77
76
|
// solhint-disable no-empty-blocks
|
|
78
77
|
}
|
|
@@ -5,12 +5,11 @@ pragma solidity ^0.8.23;
|
|
|
5
5
|
import {IAppAccountBase} from "./IAppAccount.sol";
|
|
6
6
|
import {IAppRegistry} from "src/apps/facets/registry/AppRegistryFacet.sol";
|
|
7
7
|
import {ITownsApp} from "src/apps/ITownsApp.sol";
|
|
8
|
-
import {
|
|
9
|
-
import {IERC6900ExecutionModule} from "@erc6900/reference-implementation/interfaces/IERC6900ExecutionModule.sol";
|
|
10
|
-
import {IERC6900Account} from "@erc6900/reference-implementation/interfaces/IERC6900Account.sol";
|
|
8
|
+
import {IExecutionModule} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
11
9
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
12
10
|
import {IDiamondCut} from "@towns-protocol/diamond/src/facets/cut/IDiamondCut.sol";
|
|
13
11
|
import {IAppRegistryBase} from "src/apps/facets/registry/IAppRegistry.sol";
|
|
12
|
+
import {IModule} from "@erc6900/reference-implementation/interfaces/IModule.sol";
|
|
14
13
|
|
|
15
14
|
// libraries
|
|
16
15
|
import {MembershipStorage} from "src/spaces/facets/membership/MembershipStorage.sol";
|
|
@@ -25,7 +24,7 @@ import {ExecutorBase} from "../executor/ExecutorBase.sol";
|
|
|
25
24
|
import {TokenOwnableBase} from "@towns-protocol/diamond/src/facets/ownable/token/TokenOwnableBase.sol";
|
|
26
25
|
|
|
27
26
|
// types
|
|
28
|
-
import {ExecutionManifest, ManifestExecutionFunction} from "@erc6900/reference-implementation/interfaces/
|
|
27
|
+
import {ExecutionManifest, ManifestExecutionFunction} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
29
28
|
import {Attestation, EMPTY_UID} from "@ethereum-attestation-service/eas-contracts/Common.sol";
|
|
30
29
|
|
|
31
30
|
abstract contract AppAccountBase is
|
|
@@ -86,11 +85,11 @@ abstract contract AppAccountBase is
|
|
|
86
85
|
// Call module's onInstall if it has install data using LibCall
|
|
87
86
|
// revert if it fails
|
|
88
87
|
if (postInstallData.length > 0) {
|
|
89
|
-
bytes memory callData = abi.encodeCall(
|
|
88
|
+
bytes memory callData = abi.encodeCall(IModule.onInstall, (postInstallData));
|
|
90
89
|
LibCall.callContract(app.module, 0, callData);
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
emit
|
|
92
|
+
emit ExecutionInstalled(app.module, app.manifest);
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
function _uninstallApp(bytes32 appId, bytes calldata uninstallData) internal {
|
|
@@ -119,12 +118,12 @@ abstract contract AppAccountBase is
|
|
|
119
118
|
bool onUninstallSuccess = true;
|
|
120
119
|
if (uninstallData.length > 0) {
|
|
121
120
|
// solhint-disable-next-line no-empty-blocks
|
|
122
|
-
try
|
|
121
|
+
try IModule(app.module).onUninstall(uninstallData) {} catch {
|
|
123
122
|
onUninstallSuccess = false;
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
emit
|
|
126
|
+
emit ExecutionUninstalled(app.module, onUninstallSuccess, app.manifest);
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
function _onRenewApp(bytes32 appId, bytes calldata /* data */) internal {
|
|
@@ -251,19 +250,11 @@ abstract contract AppAccountBase is
|
|
|
251
250
|
|
|
252
251
|
function _isInvalidSelector(bytes4 selector) internal pure returns (bool) {
|
|
253
252
|
return
|
|
254
|
-
selector == IERC6900Account.installExecution.selector ||
|
|
255
|
-
selector == IERC6900Account.uninstallExecution.selector ||
|
|
256
|
-
selector == IERC6900Account.installValidation.selector ||
|
|
257
|
-
selector == IERC6900Account.uninstallValidation.selector ||
|
|
258
|
-
selector == IERC6900Account.execute.selector ||
|
|
259
|
-
selector == IERC6900Account.executeBatch.selector ||
|
|
260
|
-
selector == IERC6900Account.executeWithRuntimeValidation.selector ||
|
|
261
|
-
selector == IERC6900Account.accountId.selector ||
|
|
262
253
|
selector == IERC165.supportsInterface.selector ||
|
|
263
|
-
selector ==
|
|
264
|
-
selector ==
|
|
265
|
-
selector ==
|
|
266
|
-
selector ==
|
|
254
|
+
selector == IModule.moduleId.selector ||
|
|
255
|
+
selector == IModule.onInstall.selector ||
|
|
256
|
+
selector == IModule.onUninstall.selector ||
|
|
257
|
+
selector == IExecutionModule.executionManifest.selector ||
|
|
267
258
|
selector == IDiamondCut.diamondCut.selector ||
|
|
268
259
|
selector == ITownsApp.requiredPermissions.selector;
|
|
269
260
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
+
import {ExecutionManifest} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
|
|
5
6
|
|
|
6
7
|
// libraries
|
|
7
8
|
|
|
@@ -14,6 +15,9 @@ interface IAppAccountBase {
|
|
|
14
15
|
error AppAlreadyInstalled();
|
|
15
16
|
error UnauthorizedApp(address app);
|
|
16
17
|
error InvalidCaller();
|
|
18
|
+
|
|
19
|
+
event ExecutionInstalled(address indexed module, ExecutionManifest manifest);
|
|
20
|
+
event ExecutionUninstalled(address indexed module, bool success, ExecutionManifest manifest);
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
interface IAppAccount is IAppAccountBase {
|