@towns-protocol/contracts 0.0.302 → 0.0.304
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/facets/DeployMainnetDelegation.s.sol +2 -1
- package/src/base/registry/facets/mainnet/IMainnetDelegation.sol +7 -0
- package/src/base/registry/facets/mainnet/MainnetDelegation.sol +7 -0
- package/src/spaces/facets/tipping/ITipping.sol +2 -6
- package/src/spaces/facets/tipping/TippingBase.sol +2 -1
- package/src/spaces/facets/tipping/TippingFacet.sol +19 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@towns-protocol/contracts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.304",
|
|
4
4
|
"packageManager": "yarn@3.8.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "forge build",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@layerzerolabs/oapp-evm": "^0.3.2",
|
|
33
33
|
"@openzeppelin/merkle-tree": "^1.0.8",
|
|
34
34
|
"@prb/test": "^0.6.4",
|
|
35
|
-
"@towns-protocol/prettier-config": "^0.0.
|
|
35
|
+
"@towns-protocol/prettier-config": "^0.0.304",
|
|
36
36
|
"@wagmi/cli": "^2.2.0",
|
|
37
37
|
"account-abstraction": "https://github.com/eth-infinitism/account-abstraction/archive/refs/tags/v0.7.0.tar.gz",
|
|
38
38
|
"forge-std": "github:foundry-rs/forge-std#v1.10.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "f288ff8d07f5c94aa46d291dc8554c8233d6fd60"
|
|
57
57
|
}
|
|
@@ -14,7 +14,7 @@ library DeployMainnetDelegation {
|
|
|
14
14
|
using DynamicArrayLib for DynamicArrayLib.DynamicArray;
|
|
15
15
|
|
|
16
16
|
function selectors() internal pure returns (bytes4[] memory res) {
|
|
17
|
-
DynamicArrayLib.DynamicArray memory arr = DynamicArrayLib.p().reserve(
|
|
17
|
+
DynamicArrayLib.DynamicArray memory arr = DynamicArrayLib.p().reserve(12);
|
|
18
18
|
arr.p(MainnetDelegation.setProxyDelegation.selector);
|
|
19
19
|
arr.p(MainnetDelegation.setDelegationDigest.selector);
|
|
20
20
|
arr.p(MainnetDelegation.relayDelegations.selector);
|
|
@@ -26,6 +26,7 @@ library DeployMainnetDelegation {
|
|
|
26
26
|
arr.p(MainnetDelegation.getAuthorizedClaimer.selector);
|
|
27
27
|
arr.p(MainnetDelegation.getProxyDelegation.selector);
|
|
28
28
|
arr.p(MainnetDelegation.getMessenger.selector);
|
|
29
|
+
arr.p(MainnetDelegation.getDelegatorsByAuthorizedClaimer.selector);
|
|
29
30
|
|
|
30
31
|
bytes32[] memory selectors_ = arr.asBytes32Array();
|
|
31
32
|
assembly ("memory-safe") {
|
|
@@ -124,4 +124,11 @@ interface IMainnetDelegation is IMainnetDelegationBase {
|
|
|
124
124
|
/// @param delegator The mainnet delegator address
|
|
125
125
|
/// @return The authorized claimer address for the delegator
|
|
126
126
|
function getAuthorizedClaimer(address delegator) external view returns (address);
|
|
127
|
+
|
|
128
|
+
/// @notice Get all delegators that have the specified authorized claimer
|
|
129
|
+
/// @param claimer The address of the authorized claimer to check for
|
|
130
|
+
/// @return An array of addresses that have the specified authorized claimer
|
|
131
|
+
function getDelegatorsByAuthorizedClaimer(
|
|
132
|
+
address claimer
|
|
133
|
+
) external view returns (address[] memory);
|
|
127
134
|
}
|
|
@@ -116,4 +116,11 @@ contract MainnetDelegation is IMainnetDelegation, MainnetDelegationBase, Ownable
|
|
|
116
116
|
function getAuthorizedClaimer(address delegator) external view returns (address) {
|
|
117
117
|
return _getAuthorizedClaimer(delegator);
|
|
118
118
|
}
|
|
119
|
+
|
|
120
|
+
/// @inheritdoc IMainnetDelegation
|
|
121
|
+
function getDelegatorsByAuthorizedClaimer(
|
|
122
|
+
address claimer
|
|
123
|
+
) external view returns (address[] memory) {
|
|
124
|
+
return _getDelegatorsByAuthorizedClaimer(claimer);
|
|
125
|
+
}
|
|
119
126
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
|
-
// interfaces
|
|
5
|
-
|
|
6
|
-
// libraries
|
|
7
|
-
|
|
8
|
-
// contracts
|
|
9
|
-
|
|
10
4
|
interface ITippingBase {
|
|
11
5
|
// =============================================================
|
|
12
6
|
// Structs
|
|
@@ -44,6 +38,8 @@ interface ITippingBase {
|
|
|
44
38
|
error CannotTipSelf();
|
|
45
39
|
error AmountIsZero();
|
|
46
40
|
error CurrencyIsZero();
|
|
41
|
+
error MsgValueMismatch();
|
|
42
|
+
error UnexpectedETH();
|
|
47
43
|
}
|
|
48
44
|
|
|
49
45
|
interface ITipping is ITippingBase {
|
|
@@ -5,7 +5,8 @@ pragma solidity ^0.8.23;
|
|
|
5
5
|
|
|
6
6
|
// libraries
|
|
7
7
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
8
|
-
import {CurrencyTransfer} from "
|
|
8
|
+
import {CurrencyTransfer} from "../../../utils/libraries/CurrencyTransfer.sol";
|
|
9
|
+
|
|
9
10
|
// contracts
|
|
10
11
|
|
|
11
12
|
library TippingBase {
|
|
@@ -2,24 +2,26 @@
|
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
+
import {ITownsPointsBase} from "../../../airdrop/points/ITownsPoints.sol";
|
|
6
|
+
import {IPlatformRequirements} from "../../../factory/facets/platform/requirements/IPlatformRequirements.sol";
|
|
5
7
|
import {ITipping} from "./ITipping.sol";
|
|
6
|
-
import {ITownsPointsBase} from "src/airdrop/points/ITownsPoints.sol";
|
|
7
|
-
import {IPlatformRequirements} from "src/factory/facets/platform/requirements/IPlatformRequirements.sol";
|
|
8
8
|
|
|
9
9
|
// libraries
|
|
10
|
+
import {BasisPoints} from "../../../utils/libraries/BasisPoints.sol";
|
|
11
|
+
import {CurrencyTransfer} from "../../../utils/libraries/CurrencyTransfer.sol";
|
|
12
|
+
import {CustomRevert} from "../../../utils/libraries/CustomRevert.sol";
|
|
13
|
+
import {MembershipStorage} from "../membership/MembershipStorage.sol";
|
|
10
14
|
import {TippingBase} from "./TippingBase.sol";
|
|
11
|
-
import {MembershipStorage} from "src/spaces/facets/membership/MembershipStorage.sol";
|
|
12
|
-
import {BasisPoints} from "src/utils/libraries/BasisPoints.sol";
|
|
13
|
-
import {CurrencyTransfer} from "src/utils/libraries/CurrencyTransfer.sol";
|
|
14
|
-
import {CustomRevert} from "src/utils/libraries/CustomRevert.sol";
|
|
15
15
|
|
|
16
16
|
// contracts
|
|
17
17
|
import {Facet} from "@towns-protocol/diamond/src/facets/Facet.sol";
|
|
18
18
|
import {ReentrancyGuard} from "solady/utils/ReentrancyGuard.sol";
|
|
19
|
-
import {ERC721ABase} from "
|
|
19
|
+
import {ERC721ABase} from "../../../diamond/facets/token/ERC721A/ERC721ABase.sol";
|
|
20
20
|
import {PointsBase} from "../points/PointsBase.sol";
|
|
21
21
|
|
|
22
22
|
contract TippingFacet is ITipping, ERC721ABase, PointsBase, Facet, ReentrancyGuard {
|
|
23
|
+
using CustomRevert for bytes4;
|
|
24
|
+
|
|
23
25
|
function __Tipping_init() external onlyInitializing {
|
|
24
26
|
_addInterface(type(ITipping).interfaceId);
|
|
25
27
|
}
|
|
@@ -35,9 +37,13 @@ contract TippingFacet is ITipping, ERC721ABase, PointsBase, Facet, ReentrancyGua
|
|
|
35
37
|
|
|
36
38
|
uint256 tipAmount = tipRequest.amount;
|
|
37
39
|
|
|
38
|
-
if (tipRequest.currency
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
if (tipRequest.currency != CurrencyTransfer.NATIVE_TOKEN) {
|
|
41
|
+
if (msg.value != 0) UnexpectedETH.selector.revertWith();
|
|
42
|
+
} else {
|
|
43
|
+
if (msg.value != tipAmount) MsgValueMismatch.selector.revertWith();
|
|
44
|
+
|
|
45
|
+
uint256 protocolFee = _payProtocol(msg.sender, tipAmount);
|
|
46
|
+
tipAmount -= protocolFee;
|
|
41
47
|
|
|
42
48
|
address airdropDiamond = _getAirdropDiamond();
|
|
43
49
|
uint256 points = _getPoints(
|
|
@@ -100,11 +106,9 @@ contract TippingFacet is ITipping, ERC721ABase, PointsBase, Facet, ReentrancyGua
|
|
|
100
106
|
address currency,
|
|
101
107
|
uint256 amount
|
|
102
108
|
) internal pure {
|
|
103
|
-
if (currency == address(0))
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (sender == receiver) CustomRevert.revertWith(CannotTipSelf.selector);
|
|
107
|
-
if (amount == 0) CustomRevert.revertWith(AmountIsZero.selector);
|
|
109
|
+
if (currency == address(0)) CurrencyIsZero.selector.revertWith();
|
|
110
|
+
if (sender == receiver) CannotTipSelf.selector.revertWith();
|
|
111
|
+
if (amount == 0) AmountIsZero.selector.revertWith();
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
function _payProtocol(address sender, uint256 amount) internal returns (uint256 protocolFee) {
|