Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ immunopass = "2KywXPJLebpRqAGDeWuQDEaReX3M951js7DorDCFtvRW"
url = "https://anchor.projectserum.com"

[provider]
cluster = "devnet"
cluster = "localnet"
wallet = "/home/rusiru/.config/solana/id.json"

[scripts]
Expand Down
2 changes: 1 addition & 1 deletion app/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const workspace = {
}

export const network = {
local: "https://api.devnet.solana.com",
local: "http://127.0.0.1:8899",
localnet: "http://127.0.0.1:8899",
testnet: "https://api.testnet.solana.com",
mainnet: "https://api.mainnet.solana.com",
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/doctor/DoctorDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default function DoctorDashboard(props) {
<TableRow>
<StyledTableCell>Date of Vaccination</StyledTableCell>
<StyledTableCell align="left">Vaccine</StyledTableCell>
<StyledTableCell align="left">Batch Number</StyledTableCell>
<StyledTableCell align="left">Vaccination Code</StyledTableCell>
<StyledTableCell align="left">Dosage</StyledTableCell>
<StyledTableCell align="left">Status</StyledTableCell>
<StyledTableCell align="left">Validate</StyledTableCell>
Expand Down
14 changes: 0 additions & 14 deletions app/src/pages/doctor/DoctorLogin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import DoctorDashboard from './DoctorDashboard';
import AdminDashboard from '../admin/AdminDashboard';
import { useNavigate } from 'react-router';




const wallets = [
getPhantomWallet(),
getSolflareWallet(),
Expand All @@ -18,20 +15,9 @@ const wallets = [

export function DoctorLogin() {



const wallet = useWallet();
const navigate = useNavigate();


// const navigate = useNavigate();

// useEffect(() => {
// if (wallet.connected) {
// navigate('/doctor/dashboard')
// }
// },[wallet.connected]);

if (!wallet.connected) {
return (
<div className="main-center-container text-center">
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/passport_holder/PassportHolderDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default function PassportHolderDashboard() {
<TableRow>
<StyledTableCell>Date of Vaccination</StyledTableCell>
<StyledTableCell align="left">Vaccine</StyledTableCell>
<StyledTableCell align="left">Batch Number</StyledTableCell>
<StyledTableCell align="left">Vaccination Code</StyledTableCell>
<StyledTableCell align="left">Dosage</StyledTableCell>
<StyledTableCell align="left">Status</StyledTableCell>
<StyledTableCell align="left">Validate</StyledTableCell>
Expand Down
7 changes: 0 additions & 7 deletions app/src/pages/passport_holder/PassportHolderLogin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ export function PassportHolderLogin() {

const wallet = useWallet();
const navigate = useNavigate();
// const navigate = useNavigate();

// useEffect(() => {
// if (wallet.connected) {
// navigate('/passport-holder/dashboard')
// }
// },[wallet.connected]);

if (!wallet.connected) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default function VaccinationCampDashboard() {
<TableRow>
<StyledTableCell>Date of Vaccination</StyledTableCell>
<StyledTableCell align="left">Vaccine</StyledTableCell>
<StyledTableCell align="left">Batch Number</StyledTableCell>
<StyledTableCell align="left">Vaccination Code</StyledTableCell>
<StyledTableCell align="left">Dosage</StyledTableCell>
<StyledTableCell align="left">Status</StyledTableCell>
<StyledTableCell align="left">Validate</StyledTableCell>
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/validation/ValidationDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default function ValidationDashboard() {
Vaccination Data
</div>
<form onSubmit={loadVaccinationRecord}>
<label className="">Vaccination Batch Code:</label>
<label className="">Vaccination Code:</label>
<div className="form-group row">
<div className="col-sm-12">
<input
Expand Down
15 changes: 9 additions & 6 deletions programs/immunopass/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare_id!("2KywXPJLebpRqAGDeWuQDEaReX3M951js7DorDCFtvRW");
pub mod immunopass {
use super::*;

// function to create/update a doctor
pub fn create_doctor(ctx: Context<CreateDoctor>, firstname: String, lastname: String, date_of_birth: String, license_number: String, licence_issued_date: String, licence_expiry_date: String, business_address: String, business_telephone: String, qualifications: String) -> ProgramResult {

let doctor: &mut Account<Doctor> = &mut ctx.accounts.doctor;
Expand Down Expand Up @@ -39,6 +40,7 @@ pub mod immunopass {
Ok(())
}

// function to create/update a vaccination camp
pub fn create_vaccination_camp(ctx: Context<CreateVaccinationCamp>, registration_number: String, name: String, phone: String, email: String, website: String, opening_times: String, address: String) -> ProgramResult {

let vaccination_camp: &mut Account<VaccinationCamp> = &mut ctx.accounts.vaccination_camp;
Expand Down Expand Up @@ -66,6 +68,7 @@ pub mod immunopass {
Ok(())
}

// function to create/update a passport holder
pub fn create_passport_holder(ctx: Context<CreatePassportHolder>, firstname: String, lastname: String, date_of_birth: String, gender: String, title: String, address: String, phone: String, place_of_birth: String, nic: String) -> ProgramResult {
let genders = vec!["FEMALE", "MALE", "OTHER"];

Expand All @@ -78,6 +81,7 @@ pub mod immunopass {
passport_holder.lastname = lastname;
passport_holder.date_of_birth = date_of_birth.parse().unwrap();

// check gender
if gender.is_empty() {
passport_holder.gender = "NOT_SPECIFIED".parse().unwrap();
} else if !genders.contains(&gender.to_uppercase().as_str()) {
Expand Down Expand Up @@ -106,6 +110,7 @@ pub mod immunopass {
Ok(())
}

// function to create a vaccination record
pub fn create_vaccination_record(ctx: Context<CreateVaccinationRecord>, vaccine: String, notes: String, age: String, weight: String, dosage: String, batch_number: String, doctor: Pubkey, vaccination_camp: Pubkey, passport_holder: Pubkey) -> ProgramResult {
let author: &Signer = &ctx.accounts.author;

Expand Down Expand Up @@ -179,6 +184,7 @@ pub mod immunopass {
Ok(())
}

// function to create a validation record
pub fn create_validation_record(ctx: Context<CreateValidationRecord>, record_type: String, record: Pubkey, validator_type: String, validator: Pubkey, status: String, notes: String) -> ProgramResult {

let validator_types = vec!["doctor", "vaccination_camp", "passport_holder"];
Expand All @@ -192,10 +198,7 @@ pub mod immunopass {
if validator.to_bytes().len() == 0 {
return Err(ErrorCode::ValidatorNotProvided.into());
}
// check if the validator is a valid type
// if validator != *author.key {
// return Err(ErrorCode::InvalidValidator.into());
// }

// check if validator type is valid
if !validator_types.contains(&validator_type.to_lowercase().as_str()) {
return Err(ErrorCode::ValidatorNotFound.into());
Expand Down Expand Up @@ -228,6 +231,7 @@ pub mod immunopass {
Ok(())
}

// function to check vaccination record validity
pub fn check_vaccination_record_validity(ctx: Context<VerifyVaccinationRecord>) -> ProgramResult {

let vaccination_record: &mut Account<VaccinationRecord> = &mut ctx.accounts.vaccination_record;
Expand All @@ -236,8 +240,7 @@ pub mod immunopass {
let vc_verification_record: &mut Account<ValidationRecord> = &mut ctx.accounts.vc_verification_record;
let ph_verification_record: &mut Account<ValidationRecord> = &mut ctx.accounts.ph_verification_record;



// check validity logic
if doc_verification_record.status == "invalid".to_uppercase() || vc_verification_record.status == "invalid".to_uppercase() || ph_verification_record.status == "invalid".to_uppercase() {
vaccination_record.status = "invalid".to_uppercase();
} else if doc_verification_record.status == "valid".to_uppercase() && vc_verification_record.status == "valid".to_uppercase() && ph_verification_record.status == "valid".to_uppercase() {
Expand Down