DeBio Network is a decentralized anonymous-first platform for medical and bioinformatics data. It uses blockchain technology as the immutable transaction ledger to support its processes.
Follow these steps to get started with our Backgorund Worker
All Node.js versions 14.0.0
above are compatible with our Backgorund Worker.
$ npm install
Start the development server with detailed logging:
npm run start:dev
Build for production environments:
npm run build
Execute tests:
npm run test
First, install Docker and Docker Compose.
Then run the following command to start a Backgorund Worker server using Docker Compose.
./.maintain/docker/create-network.sh
./.maintain/docker/start-docker-compose.sh
Server running on http://127.0.0.1:3001.
When this application is execute, SubstrateController
will called and run onApplicationBootstrap
to start listening event from substrate node.
In onApplicationBootstrap
only have one line code await this.substrateService.startListen();
this line will execute await this.syncBlock();
to sync event substrate from last block (last block before service is shutdown) to current block, after sync old block, service will start to listen event and sync current block.
Event from Lab Pallet. This event send data lab with this structure.
LabInfo {
box_public_key: String;
name: string;
email: string;
phone_number: string;
website: string;
country: string;
region: string;
city: string;
address: string;
latitude?: string;
longitude?: string;
profile_image?: string;
}
enum LabVerificationStatus {
Unverified = "Unverified",
Verified = "Verified",
Rejected = "Rejected",
Revoked = "Revoked",
}
Lab {
accountId: string;
services: string[];
certifications: string[];
verificationStatus: LabVerificationStatus;
info: LabInfo;
}
Execute LabRegisteredCommand
and called LabRegisteredHandler
.
Execute LabUpdatedCommand
and called LabUpdatedHandler
.
Execute LabDeregisteredCommand
and called LabDeregisteredHandler
.
Execute LabUpdateVerificationStatusCommand
and called LabUpdateVerificationStatusHandler
.
Event from Orders Pallets. This event send data orders with this structure.
enum OrderStatus {
Unpaid = "Unpaid",
Paid = "Paid",
Fulfilled = "Fulfilled",
Refunded = "Refunded",
Cancelled = "Cancelled",
Failed = "Failed",
}
enum Currency {
DAI = "DAI",
ETH = "ETH",
}
Price {
component: string;
value: string;
}
Orders {
id: string;
serviceId: string;
customerId: string;
customerBoxPublicKey: string;
sellerId: string;
dnaSampleTrackingId: string;
currency: Currency;
prices: Price[];
additionalPrices: Price[];
orderFlow: ServiceFlow;
status: OrderStatus;
createdAt: string;
updatedAt: string;
}
Execute OrderCreatedCommand
and called OrderCreatedHandler
.
Execute OrderPaidCommand
and called OrderPaidHandler
.
Execute OrderFulfilledCommand
and called OrderFulfilledHandler
.
Execute OrderRefundedCommand
and called OrderRefundedHandler
.
Execute OrderCancelledCommand
and called OrderCancelledHandler
.
Execute OrderFailedCommand
and called OrderFailedHandler
.
Event from Services Pallets. This event send data services with this structure.
ServiceInfo {
name: string;
prices_by_currency: PriceByCurrency[];
expected_duration: string;
category: string;
description: string;
dna_collection_process?: string;
test_result_sample: string;
long_description?: string;
image?: string;
}
enum ServiceFlow {
RequestTest = "RequestTest",
StakingRequestService = "StakingRequestService"
}
Service {
id: string;
ownerId: string;
info: ServiceInfo;
serviceFlow: ServiceFlow;
}
Execute ServiceCreatedCommand
and called ServiceCreatedHandler
.
Execute ServiceUpdatedCommand
and called ServiceUpdatedHandler
.
Execute ServiceDeletedCommand
and called ServiceDeletedHandler
.
Event from Genetic Testing Pallets. This event send data data staked with this structure.
DataStaked {
from: string;
hashDataBounty: string;
orderId: string;
}
Execute DataStakedCommand
and called DataStakedHandler
.
Event from Service Request Pallets. This event send data request, service invoice, and claim request with this structure.
enum RequestStatus {
Open = "Open",
WaitingForUnstaked = "WaitingForUnstaked",
Unstaked = "Unstaked",
Claimed = "Claimed",
Processed = "Processed",
Finalized = "Finalized"
}
Request {
hash: string;
requester_address: string;
lab_address: string;
country: string;
region: string;
city: string;
service_category: string;
staking_amount: string;
status: RequestStatus;
created_at: string;
updated_at: string;
unstaked_at: string;
}
ServiceInvoice {
requestHash: string;
orderId: string;
serviceId: string;
customerAddress: string;
sellerAddress: string;
dnaSampleTrackingId: string;
testingPrice: string;
qcPrice: string;
payAmount: string;
}
ClaimRequestModel {
requestHash: string;
labAddress: string;
serviceId: string;
testingPrice: string;
qcPrice: string;
}
Execute CreateServiceRequestCommand
and called CreateServiceRequestHandler
.
Execute ClaimedServiceRequestCommand
and called ClaimedServiceRequestHandler
.
Execute ProcessedServiceRequestCommand
and called ProcessedServiceRequestHandler
.
Execute FinalizedServiceRequestCommand
and called FinalizedServiceRequestHandler
.
Execute UnstakedServiceRequestCommand
and called UnstakedServiceRequestHandler
.
Execute UnstakedWaitingServiceRequestCommand
and called UnstakedWaitingServiceRequestHandler
.
Event from Certifications Pallets. This event send data certification with this structure.
Info {
title: string;
issuer: string;
month: string;
year: string;
description: string;
supporting_document: string;
}
Certification {
id: string;
owner_id: string;
info: Info
}
Execute CertificationCreatedCommand
and called CertificationCreatedHandler
.
Execute CertificationUpdatedCommand
and called CertificationUpdatedHandler
.
Execute CertificationDeletedCommand
and called CertificationDeletedHandler
.