-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create SustainableSupplyChainContract.py
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
sidra_chain_integration/contracts/SustainableSupplyChainContract.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from typing import Dict | ||
|
||
class SustainableSupplyChainContract: | ||
def __init__(self): | ||
self.suppliers: Dict[str, Dict[str, str]] = {} | ||
self.products: Dict[str, Dict[str, str]] = {} | ||
|
||
def register_supplier(self, supplier_id: str, name: str, location: str): | ||
# Register a new supplier | ||
self.suppliers[supplier_id] = { | ||
"name": name, | ||
"location": location, | ||
"products": [] | ||
} | ||
|
||
def add_product(self, supplier_id: str, product_id: str, product_name: str): | ||
# Add a product to a supplier | ||
if supplier_id not in self.suppliers: | ||
raise ValueError("Supplier not found") | ||
self.suppliers[supplier_id]["products"].append(product_id) | ||
self.products[product_id] = { | ||
"supplier_id": supplier_id, | ||
"product_name": product_name, | ||
"sustainability_certifications": [] | ||
} | ||
|
||
def add_sustainability_certification(self, product_id: str, certification: str): | ||
# Add a sustainability certification to a product | ||
if product_id not in self.products: | ||
raise ValueError("Product not found") | ||
self.products[product_id]["sustainability_certifications"].append(certification) | ||
|
||
def get_supplier_info(self, supplier_id: str): | ||
# Get the information of a supplier | ||
return self.suppliers.get(supplier_id, {}) | ||
|
||
def get_product_info(self, product_id: str): | ||
# Get the information of a product | ||
return self.products.get(product_id, {}) |