Skip to content

Commit

Permalink
Bugfix & set loyaltyContractAddress while adding shop
Browse files Browse the repository at this point in the history
  • Loading branch information
taskooh committed Aug 24, 2024
1 parent 3422893 commit 3a26343
Show file tree
Hide file tree
Showing 8 changed files with 478 additions and 27 deletions.
18 changes: 13 additions & 5 deletions contracts/BookingContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ contract BookingContract {
uint256 storeId;
string storeName;
address storeAdmin;
address loyaltyLogicContract;
}

struct Reservation {
Expand All @@ -23,7 +24,8 @@ contract BookingContract {

modifier onlyStoreAdmin(uint256 storeId) {
require(
msg.sender == stores[storeId].storeAdmin,
msg.sender == stores[storeId].storeAdmin ||
msg.sender == stores[storeId].loyaltyLogicContract,
"Only store admin can call this function"
);
_;
Expand All @@ -32,15 +34,21 @@ contract BookingContract {
modifier onlyStoreAdminByReservation(uint256 reservationId) {
require(
msg.sender ==
stores[reservations[reservationId].storeId].storeAdmin,
stores[reservations[reservationId].storeId].storeAdmin ||
msg.sender ==
stores[reservations[reservationId].storeId]
.loyaltyLogicContract,
"Only store admin can call this function"
);
_;
}

function addStore(string calldata storeName) external {
function addStore(
string calldata storeName,
address loyaltyLogicContract
) external {
uint256 len = stores.length;
stores.push(Store(len, storeName, msg.sender));
stores.push(Store(len, storeName, msg.sender, loyaltyLogicContract));
emit StoreAdded(len, storeName, msg.sender);
}

Expand Down Expand Up @@ -74,7 +82,7 @@ contract BookingContract {
uint256 _currentDeposit,
uint256 _serviceFee,
bool _paid
) external {
) external onlyStoreAdminByReservation(_reservationId) {
reservations[_reservationId] = Reservation({
storeId: _storeId,
customer: _customer,
Expand Down
Loading

0 comments on commit 3a26343

Please sign in to comment.