Skip to content

Commit

Permalink
Fixed verifyCaller calls
Browse files Browse the repository at this point in the history
  • Loading branch information
scheuclu committed Feb 24, 2022
1 parent b883daa commit d10a3b9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions project-6/contracts/coffeebase/SupplyChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '../coffeeaccesscontrol/RetailerRole.sol';
import '../coffeeaccesscontrol/ConsumerRole.sol';

contract SupplyChain is FarmerRole,DistributorRole,RetailerRole,ConsumerRole {
//contract SupplyChain is FarmerRole {

// Define 'owner'
address owner;
Expand Down Expand Up @@ -199,7 +198,7 @@ contract SupplyChain is FarmerRole,DistributorRole,RetailerRole,ConsumerRole {
// Define a function 'processtItem' that allows a farmer to mark an item 'Processed'
// Call modifier to check if upc has passed previous supply chain stage
// Call modifier to verify caller of this function
function processItem(uint _upc) verifyCaller(msg.sender) harvested(_upc) onlyFarmer public {
function processItem(uint _upc) verifyCaller(items[_upc].originFarmerID) harvested(_upc) onlyFarmer public {
// Update the appropriate fields
items[_upc].itemState = State.Processed;

Expand All @@ -210,7 +209,7 @@ contract SupplyChain is FarmerRole,DistributorRole,RetailerRole,ConsumerRole {
// Define a function 'packItem' that allows a farmer to mark an item 'Packed'
// Call modifier to check if upc has passed previous supply chain stage
// Call modifier to verify caller of this function
function packItem(uint _upc) verifyCaller(msg.sender) processed(_upc) onlyFarmer public {
function packItem(uint _upc) verifyCaller(items[_upc].originFarmerID) processed(_upc) onlyFarmer public {
// Update the appropriate fields
items[_upc].itemState = State.Packed;

Expand All @@ -221,7 +220,7 @@ contract SupplyChain is FarmerRole,DistributorRole,RetailerRole,ConsumerRole {
// Define a function 'sellItem' that allows a farmer to mark an item 'ForSale'
// Call modifier to check if upc has passed previous supply chain stage
// Call modifier to verify caller of this function
function sellItem(uint _upc, uint _price) verifyCaller(msg.sender) packed(_upc) onlyFarmer public {
function sellItem(uint _upc, uint _price) verifyCaller(items[_upc].originFarmerID) packed(_upc) onlyFarmer public {
// Update the appropriate fields
items[_upc].itemState = State.ForSale;
items[_upc].productPrice = _price;
Expand Down Expand Up @@ -255,7 +254,7 @@ contract SupplyChain is FarmerRole,DistributorRole,RetailerRole,ConsumerRole {
// Use the above modifers to check if the item is sold
// Call modifier to check if upc has passed previous supply chain stage
// Call modifier to verify caller of this function
function shipItem(uint _upc) verifyCaller(msg.sender) sold(_upc) public onlyDistributor {
function shipItem(uint _upc) verifyCaller(items[_upc].distributorID) sold(_upc) public onlyDistributor {
// Update the appropriate fields
items[_upc].itemState = State.Shipped;

Expand Down

0 comments on commit d10a3b9

Please sign in to comment.