Skip to content

Commit

Permalink
fix the storage
Browse files Browse the repository at this point in the history
  • Loading branch information
backmeupplz committed May 18, 2023
1 parent bc2d8b6 commit 2078f85
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 621 deletions.
95 changes: 52 additions & 43 deletions contracts/OBSSStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,73 +103,82 @@ contract OBSSStorage is OwnableUpgradeable, ERC2771Recipient {

function addProfilePost(CID memory postMetadata) external {
uint feedId = uint(keccak256(abi.encodePacked(_msgSender())));
profiles.addPost(_msgSender(), feedId, postMetadata);
profiles.addPost(_msgSender(), PostRequest(feedId, postMetadata));
}

function addProfileComment(
uint feedId,
uint postId,
uint replyTo,
CID memory commentMetadata
) external {
profiles.addComment(_msgSender(), feedId, postId, replyTo, commentMetadata);
function addProfileComment(CommentRequest memory commentRequest) external {
profiles.addComment(_msgSender(), commentRequest);
}

function addProfileReaction(
uint feedId,
uint postId,
uint commentId,
uint8 reactionType
AddReactionRequest memory reactionRequest
) external payable {
profiles.addReaction(_msgSender(), feedId, postId, commentId, reactionType);
profiles.addReaction(_msgSender(), reactionRequest);
}

function removeProfileReaction(
uint feedId,
uint postId,
uint commentId,
uint reactionId
RemoveReactionRequest memory reactionRequest
) external {
profiles.removeReaction(
_msgSender(),
feedId,
postId,
commentId,
reactionId
);
profiles.removeReaction(_msgSender(), reactionRequest);
}

// Feeds

function addFeedPost(uint feedId, CID memory postMetadata) external {
feeds.addPost(_msgSender(), feedId, postMetadata);
function addFeedPost(PostRequest memory postRequest) external {
feeds.addPost(_msgSender(), postRequest);
}

function addFeedComment(
uint feedId,
uint postId,
uint replyTo,
CID memory commentMetadata
) external {
feeds.addComment(_msgSender(), feedId, postId, replyTo, commentMetadata);
function addBatchFeedPosts(PostRequest[] memory postRequests) public {
for (uint i = 0; i < postRequests.length; i++) {
feeds.addPost(_msgSender(), postRequests[i]);
}
}

function addFeedComment(CommentRequest memory commentRequest) external {
feeds.addComment(_msgSender(), commentRequest);
}

function addBatchFeedComments(
CommentRequest[] memory commentRequests
) public {
for (uint i = 0; i < commentRequests.length; i++) {
feeds.addComment(_msgSender(), commentRequests[i]);
}
}

function addFeedReaction(
uint feedId,
uint postId,
uint commentId,
uint8 reactionType
AddReactionRequest memory reactionRequest
) external payable {
feeds.addReaction(_msgSender(), feedId, postId, commentId, reactionType);
feeds.addReaction(_msgSender(), reactionRequest);
}

function removeFeedReaction(
uint feedId,
uint postId,
uint commentId,
uint reactionId
RemoveReactionRequest memory reactionRequest
) external {
feeds.removeReaction(_msgSender(), reactionRequest);
}

function batchAddRemoveReactions(
AddReactionRequest[] memory addReactionRequests,
RemoveReactionRequest[] memory removeReactionRequests
) public {
for (uint i = 0; i < addReactionRequests.length; i++) {
feeds.addReaction(_msgSender(), addReactionRequests[i]);
}
for (uint i = 0; i < removeReactionRequests.length; i++) {
feeds.removeReaction(_msgSender(), removeReactionRequests[i]);
}
}

function batchFeedAddPostsCommentsReactions(
PostRequest[] memory postRequests,
CommentRequest[] memory commentRequests,
AddReactionRequest[] memory addReactionRequests,
RemoveReactionRequest[] memory removeReactionRequests
) external {
feeds.removeReaction(_msgSender(), feedId, postId, commentId, reactionId);
addBatchFeedPosts(postRequests);
addBatchFeedComments(commentRequests);
batchAddRemoveReactions(addReactionRequests, removeReactionRequests);
}

// OpenGSN boilerplate
Expand Down
69 changes: 69 additions & 0 deletions contracts/models/CommentRequest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// ,-,
// * . /.( .
// \|/ \ {
// . _ . , . -*- . `-`
// ,'-. * / \_ * / \_ /|\ * /\'__ *. *
// (____". / \ / \, __ . _/ / \ * . .
// . /\/\ /\/ :' __ \_ / \ _^/ ^/ `—./\ /\ .
// * _ / \/ \ _/ \-‘\/ ` \ /\ /.' ^_ \_ .’\\ /_/\ ,'-.
// /_\ /\ .- `. \/ \ /. / \ ;. _/ \ -. `_/ \/. \ _ (____". *
// . / \ / `-.__ ^ / .-'.--\ - \/ _ `--./ .-' `-/. \ / \ .
// / /. `. / / `. / ` .-' '-._ `._ /. \
// ~._,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'
// ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~~
// ~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~
// ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
// ๐
// _
// ₒ ><_>
// _______ __ _______
// .-' | _ "\ |" \ /" _ "| ๐
// '--./ / _.---. (. |_) :) || | (: ( \___)
// '-, (__..-` \ |: \/ |: | \/ \
// \ . | (| _ \\ |. | // \ ___
// `,.__. ,__.--/ |: |_) :) |\ | (: _( _|
// '._/_.'___.-` (_______/ |__\| \_______) ๐
//
// __ __ ___ __ __ __ ___ _______
// |" |/ \| "| /" | | "\ /""\ |" | /" "|
// ๐ |' / \: |(: (__) :) / \ || | (: ______)
// |: /' | \/ \/ /' /\ \ |: | ₒ \/ |
// \// /\' | // __ \\ // __' \ \ |___ // ___)_
// / / \\ |(: ( ) :) / / \\ \ ( \_|: \ (: "|
// |___/ \___| \__| |__/ (___/ \___) \_______) \_______)
// ₒ৹
// ___ __ _______ ________
// _ |" | ₒ /""\ | _ "\ /" )
// ><_> || | / \ (. |_) :) (: \___/
// |: | /' /\ \ |: \/ \___ \
// \ |___ // __' \ (| _ \\ __/ \\ \_____)\_____
// ( \_|: \ / / \\ \ |: |_) :) /" \ :) /--v____ __`<
// \_______) (___/ \___)(_______/ (_______/ )/
// '
//
// ๐ . ' , ₒ
// ₒ _______
// ____ .`_|___|_`. ____
// \ \ / / ₒ৹
// \ ' / ๐
// ₒ \/
// ₒ / \ ) (
// ( ₒ৹ ( ( )
// ) ) _ ) ) (
// ( ) ( ( ><_> ( ( ( )
// ) ) ( ( ) ) ) ) ) ) (
// ( ( ) ) ( ( ( ( ( ( )
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "./CID.sol";

struct CommentRequest {
uint feedId;
uint postId;
uint replyTo;
CID commentMetadata;
}
67 changes: 67 additions & 0 deletions contracts/models/PostRequest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// ,-,
// * . /.( .
// \|/ \ {
// . _ . , . -*- . `-`
// ,'-. * / \_ * / \_ /|\ * /\'__ *. *
// (____". / \ / \, __ . _/ / \ * . .
// . /\/\ /\/ :' __ \_ / \ _^/ ^/ `—./\ /\ .
// * _ / \/ \ _/ \-‘\/ ` \ /\ /.' ^_ \_ .’\\ /_/\ ,'-.
// /_\ /\ .- `. \/ \ /. / \ ;. _/ \ -. `_/ \/. \ _ (____". *
// . / \ / `-.__ ^ / .-'.--\ - \/ _ `--./ .-' `-/. \ / \ .
// / /. `. / / `. / ` .-' '-._ `._ /. \
// ~._,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'
// ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~~
// ~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~
// ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
// ๐
// _
// ₒ ><_>
// _______ __ _______
// .-' | _ "\ |" \ /" _ "| ๐
// '--./ / _.---. (. |_) :) || | (: ( \___)
// '-, (__..-` \ |: \/ |: | \/ \
// \ . | (| _ \\ |. | // \ ___
// `,.__. ,__.--/ |: |_) :) |\ | (: _( _|
// '._/_.'___.-` (_______/ |__\| \_______) ๐
//
// __ __ ___ __ __ __ ___ _______
// |" |/ \| "| /" | | "\ /""\ |" | /" "|
// ๐ |' / \: |(: (__) :) / \ || | (: ______)
// |: /' | \/ \/ /' /\ \ |: | ₒ \/ |
// \// /\' | // __ \\ // __' \ \ |___ // ___)_
// / / \\ |(: ( ) :) / / \\ \ ( \_|: \ (: "|
// |___/ \___| \__| |__/ (___/ \___) \_______) \_______)
// ₒ৹
// ___ __ _______ ________
// _ |" | ₒ /""\ | _ "\ /" )
// ><_> || | / \ (. |_) :) (: \___/
// |: | /' /\ \ |: \/ \___ \
// \ |___ // __' \ (| _ \\ __/ \\ \_____)\_____
// ( \_|: \ / / \\ \ |: |_) :) /" \ :) /--v____ __`<
// \_______) (___/ \___)(_______/ (_______/ )/
// '
//
// ๐ . ' , ₒ
// ₒ _______
// ____ .`_|___|_`. ____
// \ \ / / ₒ৹
// \ ' / ๐
// ₒ \/
// ₒ / \ ) (
// ( ₒ৹ ( ( )
// ) ) _ ) ) (
// ( ) ( ( ><_> ( ( ( )
// ) ) ( ( ) ) ) ) ) ) (
// ( ( ) ) ( ( ( ( ( ( )
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "./CID.sol";

struct PostRequest {
uint feedId;
CID postMetadata;
}
76 changes: 76 additions & 0 deletions contracts/models/ReactionRequests.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// ,-,
// * . /.( .
// \|/ \ {
// . _ . , . -*- . `-`
// ,'-. * / \_ * / \_ /|\ * /\'__ *. *
// (____". / \ / \, __ . _/ / \ * . .
// . /\/\ /\/ :' __ \_ / \ _^/ ^/ `—./\ /\ .
// * _ / \/ \ _/ \-‘\/ ` \ /\ /.' ^_ \_ .’\\ /_/\ ,'-.
// /_\ /\ .- `. \/ \ /. / \ ;. _/ \ -. `_/ \/. \ _ (____". *
// . / \ / `-.__ ^ / .-'.--\ - \/ _ `--./ .-' `-/. \ / \ .
// / /. `. / / `. / ` .-' '-._ `._ /. \
// ~._,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'2_,-'
// ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~~
// ~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~~~ ~~
// ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
// ๐
// _
// ₒ ><_>
// _______ __ _______
// .-' | _ "\ |" \ /" _ "| ๐
// '--./ / _.---. (. |_) :) || | (: ( \___)
// '-, (__..-` \ |: \/ |: | \/ \
// \ . | (| _ \\ |. | // \ ___
// `,.__. ,__.--/ |: |_) :) |\ | (: _( _|
// '._/_.'___.-` (_______/ |__\| \_______) ๐
//
// __ __ ___ __ __ __ ___ _______
// |" |/ \| "| /" | | "\ /""\ |" | /" "|
// ๐ |' / \: |(: (__) :) / \ || | (: ______)
// |: /' | \/ \/ /' /\ \ |: | ₒ \/ |
// \// /\' | // __ \\ // __' \ \ |___ // ___)_
// / / \\ |(: ( ) :) / / \\ \ ( \_|: \ (: "|
// |___/ \___| \__| |__/ (___/ \___) \_______) \_______)
// ₒ৹
// ___ __ _______ ________
// _ |" | ₒ /""\ | _ "\ /" )
// ><_> || | / \ (. |_) :) (: \___/
// |: | /' /\ \ |: \/ \___ \
// \ |___ // __' \ (| _ \\ __/ \\ \_____)\_____
// ( \_|: \ / / \\ \ |: |_) :) /" \ :) /--v____ __`<
// \_______) (___/ \___)(_______/ (_______/ )/
// '
//
// ๐ . ' , ₒ
// ₒ _______
// ____ .`_|___|_`. ____
// \ \ / / ₒ৹
// \ ' / ๐
// ₒ \/
// ₒ / \ ) (
// ( ₒ৹ ( ( )
// ) ) _ ) ) (
// ( ) ( ( ><_> ( ( ( )
// ) ) ( ( ) ) ) ) ) ) (
// ( ( ) ) ( ( ( ( ( ( )
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "./CID.sol";

struct AddReactionRequest {
uint feedId;
uint postId;
uint commentId;
uint8 reactionType;
}

struct RemoveReactionRequest {
uint feedId;
uint postId;
uint commentId;
uint reactionId;
}
2 changes: 1 addition & 1 deletion contracts/superclasses/KetlGuarded.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "../../node_modules/@big-whale-labs/ketl-attestation-token/contracts/KetlAttestation.sol";
import "@big-whale-labs/ketl-attestation-token/contracts/KetlAttestation.sol";

contract KetlGuarded is Initializable, OwnableUpgradeable {
KetlAttestation public attestationToken;
Expand Down
Loading

0 comments on commit 2078f85

Please sign in to comment.