Skip to content

Commit

Permalink
access modifier fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anoushk1234 committed Jan 30, 2022
1 parent 4ef6e86 commit fc80237
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Mainnet Address
```
0xD9b5a4Efe3f6e43C3b437B495dDB8668A3a3258d
```
Storage contract address(beta)
Storage Mumbai address(beta)
```
0x2bBF7B77585af7e3F2a0542944e49B92186D0c29
0xEd38011305ff0dBCD75B39bb07295E9E6bff5BA6
```
87 changes: 67 additions & 20 deletions contracts/MetaStorage.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

contract MetaStorage {

contract MetaStorage {
struct EventData {
string title;
string image;
Expand All @@ -25,31 +24,66 @@ contract MetaStorage {

// Events

event childCreated(string title, uint256 fee, uint256 seats, string image, address eventHost, string description, string link, string date, address childAddress);

event TicketBought (address childContract, address buyer);

event HostCreated (address _hostAddress, string name, string image, string bio, string socialLinks);

event CreateNewFeature (address featuredEventContract);
event childCreated(
string title,
uint256 fee,
uint256 seats,
string image,
address eventHost,
string description,
string link,
string date,
address childAddress
);

event TicketBought(address childContract, address buyer);

event HostCreated(
address _hostAddress,
string name,
string image,
string bio,
string socialLinks
);

event CreateNewFeature(address featuredEventContract);

// Contract Storage

mapping(address => EventData[]) detailsMap;
mapping(address => EventData[]) detailsMap;
mapping(address => HostProfile) profileMap;
address[] featuredArray;
address[] admins = [0x28172273CC1E0395F3473EC6eD062B6fdFb15940, 0x0009f767298385f4Aa17EA1493562834657A2A5a];
modifier adminOnly {
address[] admins = [
0x28172273CC1E0395F3473EC6eD062B6fdFb15940,
0x0009f767298385f4Aa17EA1493562834657A2A5a
];
modifier adminOnly() {
require(msg.sender == admins[0] || msg.sender == admins[1]); //same as the if above
_; //tells that this modifier should be executed before the code
}

// Logic

function getEventDetails() public view returns (EventData[] memory _EventData) {
function getEventDetails()
public
view
returns (EventData[] memory _EventData)
{
return detailsMap[msg.sender];
}

function pushEventDetails(string memory title, uint256 fee, uint256 seats,uint256 occupiedSeats, string memory image, address eventHostAddress, string memory description, string memory link, string memory date, address child) public {
function pushEventDetails(
string memory title,
uint256 fee,
uint256 seats,
uint256 occupiedSeats,
string memory image,
address eventHostAddress,
string memory description,
string memory link,
string memory date,
address child
) public {
EventData memory _tempEventData = EventData(
title,
image,
Expand All @@ -63,15 +97,25 @@ contract MetaStorage {
eventHostAddress
);
detailsMap[eventHostAddress].push(_tempEventData);

emit childCreated(title, fee, seats, image, eventHostAddress, description, link, date, address(child));

emit childCreated(
title,
fee,
seats,
image,
eventHostAddress,
description,
link,
date,
address(child)
);
}

function emitTicketBuy(address _childContract, address _sender) public {
emit TicketBought(_childContract, _sender);
}

/* function isAdmin(address _address) public view returns (bool _isAdmin) {
/* function isAdmin(address _address) public view returns (bool _isAdmin) {
bool boolean = false;
Expand All @@ -92,7 +136,12 @@ contract MetaStorage {
emit CreateNewFeature(_event);
}

function addCreateHostProfile(string memory _name, string memory _image, string memory _bio, string memory _socialLinks) public {
function addCreateHostProfile(
string memory _name,
string memory _image,
string memory _bio,
string memory _socialLinks
) public {
HostProfile memory _tempProfile = HostProfile(
_name,
_image,
Expand All @@ -102,6 +151,4 @@ contract MetaStorage {
profileMap[msg.sender] = _tempProfile;
emit HostCreated(msg.sender, _name, _image, _bio, _socialLinks);
}

}
}
1 change: 1 addition & 0 deletions launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run mumbai-storage
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hardhat-project",
"scripts": {
"mumbai": "npx hardhat run --network mumbai scripts/deploy-metastorage.js"
"mumbai-storage": "npx hardhat run --network mumbai scripts/deploy-metastorage.js"
},
"dependencies": {
"@nomiclabs/hardhat-etherscan": "^2.1.8",
Expand Down

0 comments on commit fc80237

Please sign in to comment.