Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet setup #2

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Binary file modified .DS_Store
Binary file not shown.
37 changes: 37 additions & 0 deletions alembic/versions/4630d4638c08_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""empty message

Revision ID: 4630d4638c08
Revises:
Create Date: 2024-10-20 00:29:32.624225

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel

# revision identifiers, used by Alembic.
revision: str = '4630d4638c08'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('organisation',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('location', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('encoded_wallet', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('organisation')
# ### end Alembic commands ###
24 changes: 24 additions & 0 deletions disasterResAlloc/backend/-- SQLite.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- SQLite
-- Step 1: Delete all existing data
DELETE FROM organisation;

-- Step 3: Insert new data with IDs from 0 to 9
INSERT INTO organisation (id, name, location, email, encoded_wallet, created, updated, seed, cause, disaster, image, balance)
VALUES
(0, 'International Red Cross Honduras', 'Honduras', '', 'rM9PyNnSe5CGfjEY6t8VgF4TiVoVHmpnNW', '2024-10-19 17:10:13.441232', NULL, NULL, 'The International Red Cross in Honduras focuses on vector control and community health education to combat the spread of dengue. It also provides medical supplies and supports overwhelmed healthcare facilities.', 'Dengue Outbreak', 'https://www.icrc.org/sites/default/files/styles/desktop_full/public/document_new/image_plus_list/portada_honduras.jpg.webp?itok=1rRdfkzZ', 0),

(1, 'Palestine Children''s Relief Fund', 'Gaza', '[email protected]', 'rpquhZW7Qcwgnsuhgh96s8UnSkzuycL1Ls', '2024-10-19 17:10:13.441232', NULL, NULL, 'PCRF specializes in offering medical care to children and families affected by the ongoing crisis. The organization focuses on providing urgent medical supplies, clean water, food, and long-term mental health support. PCRF also manages programs to help children in Gaza access specialized surgeries and healthcare unavailable locally.', 'Genocide', 'https://i.ytimg.com/vi/5-C1YnFQPOg/maxresdefault.jpg', 0),

(2, 'National Unit for Disaster Risk Management', 'Colombia', 'n/a', 'rKSV8SdzMYN2unLDdV8prmaDwgi6Qpcaho', '2024-10-20 10:11:17', NULL, 'n/a', 'The National Unit for Disaster Risk Management (UNGRD) in Colombia coordinates evacuation plans and monitors volcanic activity to protect residents. It collaborates with the Geological Service of Colombia for early warning systems.', 'Puracé Volcano', 'https://i0.wp.com/www.thenonmad.com/wp-content/uploads/2018/03/Purace-31.jpg?fit=1600%2C1200&ssl=1', 0),

(3, 'Armenian Red Cross Society', 'Armenia', 'n/a', 'ra4D3C4jHpoFkuxcrDFMWdb8agWeYrxKya', '2024-10-20 10:11:17', NULL, 'n/a', 'The Armenian Red Cross Society provides flood victims with essential supplies such as food, water, and shelter. It also runs community preparedness programs to mitigate future flood risks.', 'Flash Floods', 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSyaeKFZag0kKt9FeLYtB7m0zBsQIKToW419w&s', 0),

(4, 'BRAC', 'Bangladesh', 'n/a', 'rGJhZtWni3Qz2gsiv4S26mJzbswWGLJe9o', '2024-10-20 10:11:17', NULL, 'n/a', 'BRAC supports displaced families by providing emergency shelters, food packages, and healthcare during tropical cyclones. They also run long-term recovery programs focused on rebuilding livelihoods.', 'Tropical Cyclone Remal', 'https://www.economist.com/img/b/1280/720/90/sites/default/files/images/2019/09/articles/main/20190907_irp003.jpg', 0),

(5, 'Bangladesh Red Crescent Society', 'Bangladesh', 'n/a', 'rhaTCwALyM1iyAARNVNFgxWNvdmFVMSFNg', '2024-10-20 10:11:17', NULL, 'n/a', 'The Bangladesh Red Crescent Society offers medical assistance and disaster relief to cyclone-affected areas. It helps set up mobile clinics and works on restoring clean water supplies.', 'Tropical Cyclone Remal', 'https://redcross.eu/uploads/files/Latest%20News/EUAV%20Interview%20with%20Margherita/IMG_4.JPG', 0),

(6, 'UN World Food Programme', 'Southern Africa', 'n/a', 'rQpNWAbZhKbAkrBtog5qMwvQojiv2XGUNF', '2024-10-20 10:11:17', NULL, 'n/a', 'The UN World Food Programme (WFP) addresses food insecurity caused by drought, distributing emergency food supplies and running nutrition programs to combat malnutrition.', 'Drought', 'https://www.wfp.org/sites/default/files/2024-03/WF121663_UGA_20200707_WFP-Hugh_Rutherford_5079.jpg', 0),

(7, 'Red Cross Botswana', 'Botswana', 'n/a', 'rJbZQ8KjWgrp8Pf32PofRmoqg6Lm76xG87', '2024-10-20 10:11:17', NULL, 'n/a', 'The Red Cross in Botswana provides drought-affected communities with water, food, and hygiene supplies. It also supports farmers with sustainable agricultural practices to build long-term resilience.', 'Drought', 'https://www.botswanaredcross.org.bw/images/2022/09/19/disaster-management.jpg', 0),

(8, 'Care International', 'Papua New Guinea', 'n/a', 'rniWcikeHyzkUbHvHVqnNrTEw7XJK21bSa', '2024-10-20 10:11:17', NULL, 'n/a', 'Care International provides emergency assistance to communities affected by landslides and floods, including shelter, clean water, and sanitation. They also work on disaster preparedness and climate resilience programs.', 'Landslides and Floods', 'https://www.care-international.org/sites/default/files/styles/og_image/public/2022-04/Papua%20New%20Guinea_Classroom%20teaching_RS47722_180725_PNG_PKS_StTheresaES_JH_560.jpg?h=8d256a69&itok=_PgYSfHl', 0);
3 changes: 3 additions & 0 deletions disasterResAlloc/backend/-- SQLite3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- SQLite
DELETE FROM organisation
WHERE id <= 27;
12 changes: 0 additions & 12 deletions disasterResAlloc/backend/organisations.py

This file was deleted.

155 changes: 155 additions & 0 deletions disasterResAlloc/backend/wallet_hard_coded.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import sqlite3
from datetime import datetime
import asyncio

from ..components.wallet import create_multiple_wallets # Adjust the import based on your project structure

async def main():
"""
Main function to generate 9 wallet addresses and print their classic addresses.
"""
# Generate 9 wallets
wallets = await create_multiple_wallets(9)

# Print the classic addresses
for idx, wallet in enumerate(wallets, start=1):
print(f"{wallet['classicAddress']}")

if __name__ == "__main__":
import asyncio
asyncio.run(main())

# async def generate_wallets():
# """
# Generates wallets and inserts their data into the 'organisation' table.
# """

# # List of organizations with their details
# org_data = [
# {
# "name": "International Red Cross Honduras",
# "location": "Honduras",
# "email": "[email protected]",
# "cause": "The International Red Cross in Honduras focuses on vector control and community health education to combat the spread of dengue. It also provides medical supplies and supports overwhelmed healthcare facilities.",
# "disaster": "Dengue Outbreak",
# "image": "https://www.icrc.org/sites/default/files/styles/desktop_full/public/document_new/image_plus_list/portada_honduras.jpg.webp?itok=1rRdfkzZ",
# },
# {
# "name": "Palestine Children’s Relief Fund",
# "location": "Gaza",
# "email": "[email protected]",
# "cause": "PCRF specializes in offering medical care to children and families affected by the ongoing crisis. The organization focuses on providing urgent medical supplies, clean water, food, and long-term mental health support. PCRF also manages programs to help children in Gaza access specialized surgeries and healthcare unavailable locally.",
# "disaster": "Genocide",
# "image": "https://i.ytimg.com/vi/5-C1YnFQPOg/maxresdefault.jpg",
# },
# {
# "name": "National Unit for Disaster Risk Management",
# "location": "Colombia",
# "email": "n/a",
# "cause": "The National Unit for Disaster Risk Management (UNGRD) in Colombia coordinates evacuation plans and monitors volcanic activity to protect residents. It collaborates with the Geological Service of Colombia for early warning systems.",
# "disaster": "Puracé Volcano",
# "image": "https://i0.wp.com/www.thenonmad.com/wp-content/uploads/2018/03/Purace-31.jpg?fit=1600%2C1200&ssl=1",
# },
# {
# "name": "Armenian Red Cross Society",
# "location": "Armenia",
# "email": "n/a",
# "cause": "The Armenian Red Cross Society provides flood victims with essential supplies such as food, water, and shelter. It also runs community preparedness programs to mitigate future flood risks.",
# "disaster": "Flash Floods",
# "image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSyaeKFZag0kKt9FeLYtB7m0zBsQIKToW419w&s",
# },
# # Add the remaining organizations with their details...
# {
# "name": "BRAC",
# "location": "Bangladesh",
# "email": "n/a",
# "cause": "BRAC supports displaced families by providing emergency shelters, food packages, and healthcare during tropical cyclones. They also run long-term recovery programs focused on rebuilding livelihoods.",
# "disaster": "Tropical Cyclone Remal",
# "image": "https://www.economist.com/img/b/1280/720/90/sites/default/files/images/2019/09/articles/main/20190907_irp003.jpg",
# },
# {
# "name": "Bangladesh Red Crescent Society",
# "location": "Bangladesh",
# "email": "n/a",
# "cause": "The Bangladesh Red Crescent Society offers medical assistance and disaster relief to cyclone-affected areas. It helps set up mobile clinics and works on restoring clean water supplies.",
# "disaster": "Tropical Cyclone Remal",
# "image": "https://redcross.eu/uploads/files/Latest%20News/EUAV%20Interview%20with%20Margherita/IMG_4.JPG",
# },
# {
# "name": "UN World Food Programme",
# "location": "Southern Africa",
# "email": "n/a",
# "cause": "The UN World Food Programme (WFP) addresses food insecurity caused by drought, distributing emergency food supplies and running nutrition programs to combat malnutrition.",
# "disaster": "Drought",
# "image": "https://www.wfp.org/sites/default/files/2024-03/WF121663_UGA_20200707_WFP-Hugh_Rutherford_5079.jpg",
# },
# {
# "name": "Red Cross Botswana",
# "location": "Botswana",
# "email": "n/a",
# "cause": "The Red Cross in Botswana provides drought-affected communities with water, food, and hygiene supplies. It also supports farmers with sustainable agricultural practices to build long-term resilience.",
# "disaster": "Drought",
# "image": "https://www.botswanaredcross.org.bw/images/2022/09/19/disaster-management.jpg",
# },
# {
# "name": "Care International",
# "location": "Multiple Locations",
# "email": "n/a",
# "cause": "Care International works globally to fight poverty and provide disaster relief, with programs focusing on emergency response, health, education, and economic development.",
# "disaster": "Various",
# "image": "https://www.care-international.org/sites/default/files/styles/gallery_image/public/2022-02/CI_Fistula_Sunday.jpg",
# }
# ]

# # Generate wallets
# wallets = await create_multiple_wallets(len(org_data)) # Ensure this function returns wallet objects with 'classicAddress' and optionally 'seed'

# # Set 'amount' to 0 and assign organization details to each wallet
# for wallet, org in zip(wallets, org_data):
# wallet['amount'] = 0
# wallet['name'] = org['name']
# wallet['location'] = org['location']
# wallet['email'] = org['email']
# wallet['cause'] = org['cause']
# wallet['disaster'] = org['disaster']
# wallet['image'] = org['image']
# # Set the 'created' date
# wallet['created'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# # Include the 'seed' if it's part of the wallet data
# wallet['seed'] = wallet.get('seed', None)

# # Connect to your SQLite database
# conn = sqlite3.connect('your_database.db') # Replace with your actual database path
# cursor = conn.cursor()

# try:
# # Insert each wallet into the 'organisation' table
# for wallet in wallets:
# cursor.execute("""
# INSERT INTO organisation (name, location, email, encoded_wallet, balance, created, seed, cause, disaster, image)
# VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# """, (
# wallet['name'],
# wallet['location'],
# wallet['email'],
# wallet['classicAddress'],
# wallet['amount'],
# wallet['created'],
# wallet['seed'],
# wallet['cause'],
# wallet['disaster'],
# wallet['image']
# ))
# # Commit the transaction
# conn.commit()
# print("Wallets have been inserted into the database.")
# except sqlite3.Error as e:
# print(f"An error occurred: {e}")
# conn.rollback()
# finally:
# # Close the database connection
# conn.close()

# if __name__ == "__main__":
# asyncio.run(generate_wallets())

3 changes: 3 additions & 0 deletions disasterResAlloc/components/navbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def menu_item(text: str, url: str) -> rx.Component:
("About", menu_item_icon("book-open")),
("Profile", menu_item_icon("user")),
("Settings", menu_item_icon("settings")),
("Wallet", menu_item_icon("settings")),
menu_item_icon("layout-dashboard"),
),
rx.text(text, size="4", weight="regular"),
Expand Down Expand Up @@ -113,10 +114,12 @@ def menu_button() -> rx.Component:
"/about",
"/profile",
"/settings",
"/wallet",
]

# Get the decorated pages.
pages = get_decorated_pages()
pages.append({"route": "/wallet", "title": "Wallet"})

# Include all pages even if they are not in the ordered_page_routes.
ordered_pages = sorted(
Expand Down
7 changes: 5 additions & 2 deletions disasterResAlloc/components/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ def sidebar_item(text: str, url: str) -> rx.Component:
rx.match(
text,
("Overview", sidebar_item_icon("home")),
("Table", sidebar_item_icon("table-2")),
("Wallet", sidebar_item_icon("table-2")),
("About", sidebar_item_icon("book-open")),
("Profile", sidebar_item_icon("user")),
("Organisations", sidebar_item_icon("users")),
("Settings", sidebar_item_icon("settings")),
("Wallet", sidebar_item_icon("settings")), # Add an icon for Wallet here
sidebar_item_icon("layout-dashboard"),
),
rx.text(text, size="3", weight="regular"),
Expand Down Expand Up @@ -134,14 +135,16 @@ def sidebar() -> rx.Component:
# The ordered page routes.
ordered_page_routes = [
"/",
"/table",
"/wallet",
"/about",
"/profile",
"/settings",
"/wallet", # Add the wallet route here
]

# Get the decorated pages.
pages = get_decorated_pages()
pages.append({"route": "/wallet", "title": "Wallet"})

# Include all pages even if they are not in the ordered_page_routes.
ordered_pages = sorted(
Expand Down
Loading