Skip to content

Commit

Permalink
Add call to KeyValuePairs contract to tie HatId and streamId for tyin…
Browse files Browse the repository at this point in the history
…g payments to streams
  • Loading branch information
Da-Colon committed Nov 19, 2024
1 parent 50072bf commit a9afc86
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions contracts/modules/DecentHatsModuleUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {IHats} from "../interfaces/hats/IHats.sol";
import {LockupLinear, Broker} from "../interfaces/sablier/types/DataTypes.sol";
import {IHatsModuleFactory} from "../interfaces/hats/IHatsModuleFactory.sol";
import {ISablierV2LockupLinear} from "../interfaces/sablier/ISablierV2LockupLinear.sol";
import {KeyValuePairs} from "../KeyValuePairs.sol";

abstract contract DecentHatsModuleUtils {
bytes32 public constant SALT =
Expand Down Expand Up @@ -86,7 +87,9 @@ abstract contract DecentHatsModuleUtils {
// Create streams
_processSablierStreams(
hatParams.sablierStreamsParams,
streamRecipient
streamRecipient,
keyValuePairs,
hatId
);

unchecked {
Expand Down Expand Up @@ -205,7 +208,9 @@ abstract contract DecentHatsModuleUtils {

function _processSablierStreams(
SablierStreamParams[] memory streamParams,
address streamRecipient
address streamRecipient,
KeyValuePairs keyValuePairs,
uint256 hatId
) private {
for (uint256 i = 0; i < streamParams.length; ) {
SablierStreamParams memory sablierStreamParams = streamParams[i];
Expand All @@ -221,6 +226,9 @@ abstract contract DecentHatsModuleUtils {
),
Enum.Operation.Call
);
uint128 streamId = ISablierV2LockupLinear(
sablierStreamParams.sablier
).nextStreamId();

// Proxy the Sablier call through IAvatar
IAvatar(msg.sender).execTransactionFromModule(
Expand All @@ -242,6 +250,25 @@ abstract contract DecentHatsModuleUtils {
Enum.Operation.Call
);

// Update KeyValuePairs with the stream ID and Hat ID
string[] memory keys = new string[](2);
string[] memory values = new string[](2);
keys[0] = "hatId";
values[0] = Strings.toString(hatId);
keys[1] = "streamId";
values[1] = Strings.toString(streamId);

IAvatar(msg.sender).execTransactionFromModule(
keyValuePairs,
0,
abi.encodeWithSignature(
"updateValues(string[],string[])",
keys,
values
),
Enum.Operation.Call
);

unchecked {
++i;
}
Expand Down

0 comments on commit a9afc86

Please sign in to comment.