Git Product home page Git Product logo

daml-covid19's Introduction

DAML-Covid19

DAML implementation for Covid19 Use Cases -- Copyright (c) 2020 Rethink Ledgers LLC. All rights reserved.

Link to Google Doc for more information about the Covid19 Model using DAML

https://docs.google.com/document/d/1AdekheWp4MGCXcCUA7thlD_u6XDi-yA3HvEB288owJY/edit#

Installation instructions

Step1 : Building and installing DAML Postgress

  1. install DAML SDK (currently 1.14) For more information :https://docs.daml.com/getting-started/installation.html

  2. install Postgress for local persistance layer with daml For more information : Setup a new DB: 'test' Setup a Postgress User: 'Bart' with password: 'password'

    note: when you create a new daml file then 'delete database' and recreate it

  3. Build locally .dar file

     daml build
    
     note: if you are rebuilding, then deleted first your .daml and daml2js folders
    
  4. UX code generation:

     daml codegen js -o daml2js .daml/dist/Covid19-0.0.1.dar
    
  5. Change to ui-js directory

     Cd ui-js directory
    
  6. Install User interface code

     yarn install --force --frozen-lockfile
    

Step 2B : Deploying DAML with Initialization script

  1. DAML Script

     We created an onboarding script in /Scriptfile folder calledScriptExample.dam
    
  2. Run Script

     To initialize the network You can call: 
    
     daml script --dar .daml/dist/Covid19-0.0.1.dar --script-name ScriptExample:initializeFixed --ledger-host localhost --ledger-port 6865
    

Step 2A : Deploying DAML and UX in local environment

  1. Start DAML Sandbox in a new console window

     daml sandbox .daml/dist/Covid19-0.0.1.dar --ledgerid Covid19 --sql-backend-jdbcurl "jdbc:postgresql://localhost/test?user=Bart&password=password"
    
  2. Make Static Content sub-directory

     mkdir static-content
    
  3. Start JSON-API in a new console window

daml json-api --ledger-host localhost --ledger-port 6865 --http-port 7575 --max-inbound-message-size 4194304 --package-reload-interval 5s --application-id HTTP-JSON-API-Gateway --static-content "prefix=static,directory=./static-content" --access-token-file ./token/token --query-store-jdbc-config "driver=org.postgresql.Driver,url=jdbc:postgresql://localhost:5432/test?&ssl=false,user=Bart,password=password,createSchema=false"

This now links to token authorization file which can be found in ./token directory

The token file must include the correct JWT token

"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2RhbWwuY29tL2xlZGdlci1hcGkiOnsibGVkZ2VySWQiOiJDb3ZpZDE5IiwiYXBwbGljYXRpb25JZCI6ImZvb2JhciIsImFjdEFzIjpbIk9wZXJhdG9yIl0sInJlYWRBcyI6WyJPcGVyYXRvciJdfX0.JklciDh0-GzkvrPkSJ_H3sYX39LFU4C3uVWd7qsMPNo"

Note: In order to be able to retrieve filtered contracts through the JSON-API a new Schema must be created. To achieve this, execute the following command before making any transactions in the ledger

daml json-api --ledger-host localhost --ledger-port 6865 --http-port 7575 --max-inbound-message-size 4194304 --package-reload-interval 5s --application-id HTTP-JSON-API-Gateway --static-content "prefix=static,directory=./static-content" --access-token-file ./token/token --query-store-jdbc-config "driver=org.postgresql.Driver,url=jdbc:postgresql://localhost:5432/test?&ssl=false,user=Bart,password=password,createSchema=true"

After the command has completed, then you can start up the JSON-API the regular way:

daml json-api --ledger-host localhost --ledger-port 6865 --http-port 7575 --max-inbound-message-size 4194304 --package-reload-interval 5s --application-id HTTP-JSON-API-Gateway --static-content "prefix=static,directory=./static-content" --access-token-file ./token/token --query-store-jdbc-config "driver=org.postgresql.Driver,url=jdbc:postgresql://localhost:5432/test?&ssl=false,user=Bart,password=password,createSchema=false"

  1. Start Frontend and Backend solution in a new console window in ui-js directory

     cd ui-js
     
     Verify the authentication token in the following file scr/context/UserContext.js
     
                             "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2RhbWwuY29tL2xlZGdlci1hcGkiOnsibGVkZ2VySWQiOiJDb3ZpZDE5IiwiYXBwbGljYXRpb25JZCI6ImZvb2JhciIsImFjdEFzIjpbIk9wZXJhdG9yIl0sInJlYWRBcyI6WyJPcGVyYXRvciJdfX0.JklciDh0-GzkvrPkSJ_H3sYX39LFU4C3uVWd7qsMPNo"
    
     yarn run start
    
  2. Initiation of a Local Network

    The network can be initiate with pushing a JSON file via Postman

    1. Download and install Postman
    
    2. Authentication:
    
    bearer token :  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2RhbWwuY29tL2xlZGdlci1hcGkiOnsibGVkZ2VySWQiOiJDb3ZpZDE5IiwiYXBwbGljYXRpb25JZCI6ImZvb2JhciIsImFjdEFzIjpbIk9wZXJhdG9yIl0sInJlYWRBcyI6WyJPcGVyYXRvciJdfX0.JklciDh0-GzkvrPkSJ_H3sYX39LFU4C3uVWd7qsMPNo"
    
    3. Send Post instruction 
    
    POST localhost:7575/v1/create
    
    Body:
    
    {
             "templateId": "Main:Network",
             "payload": {
               "operator": "Operator"
             }
    }
    
    4. You can verify the Network via login in as "Operator" and navigating to the Network left NavBar
    

Step 2B : Deploying DAML to ProjectDable

  1. Deploy DAML Dar file to ProjectDable

     More instrictions can be found here: https://docs.projectdabl.com/quickstart/#home
    
  2. Generate new JWT Token for "Operator

     On the Managment Console create Operator as Party
     Select the JWT token for Operator
    
     Note: This token changes daily and therefore the new token needs to be updated daily in the source code
    
  3. Update the Token in the UserContext.js file

     // ProjectDable Token for Operator
        token  = <JWT Token Here>
    
  4. Build and zip up the UI code in ui-js directory

     yarn build
     zip -r ../covid19xxx-ui.zip build
    
  5. Upload and deploy the covid19xxx-ui.zip file to projectdable and the ledger

  6. Launch the browser based on the projectdable ledger link

     example: https://<ledger-id>.projectdabl.com/#/login
    
  7. Setup the initial Contract as Live Data

     Goto https://<ledger-id>.projectdabl.com/#/livedata
    
     Select Operator and a new Contract
    
     Select Newtork COntract with Operator = Operator
    
     Note : this creates the starting contract for the Network
    
  8. Login into

     https://<ledger-id>.projectdabl.com/#/login
    
     enter Operator as "Login" and Enter
     Navigate to the Network screen and you should see a first Contract in the list screen
    

3A Configuration for Local Node.js Trinsic Server

For any intgertaion with Trinsic you have 2 options: a locl Node.js server or a hosted AWS Node.js server on EC2

  1. Local Node.js Server the following local Node.js server files must be available

    ui-js/server.js ui-js/.env Note: This file will be provided seperatly ui-js/scr/AxiosClient.js baseURL: 'http://localhost:3002/'

  2. Validate that the Node.js server is stared locally

    in package.json the following entries must be available in "script"
    
    "start": "run-p server frontend",
    "server": "node server.js --exec nodemon",
    

    also can validate using ngrok.io where can be found upon startup of the node.js server

3B Configuration for Trinsic Server hosted on AWS

  1. AWS Server Note : local EC2 instance and Loadbalancer must be started

    Source Code can be found at https://github.com/bartcant/TrinsicServer

    The following configuration must be updated

    ui-js/scr/AxiosClient.js

     baseURL: 'https://daml-covid19.vcredserver.com/'
    

For quick reference on DAML:

https://digital-asset.github.io/daml-cheat-sheet/ https://docs.daml.com/1.1.1/ https://docs.daml.com/1.1.1/json-api/index.html

AWS Cognito

Set up Pool Id, App client id in ui-js/src/config.js

Init Script Running

daml script --dar .daml/dist/Covid19-0.0.1.dar --script-name ScriptExample:initializeFixed --ledger-host localhost --ledger-port 6865

python bot

Install Python 3.0 Install Poetry

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python

pip install -r requirements.txt

deployment bot

make setup

run bot

python python_bot/bot.py

daml-covid19's People

Contributors

bartcant avatar pangdeskpad avatar star123good avatar

Watchers

 avatar

daml-covid19's Issues

New feature : Retrieve Roletype from Ledger

During the login process the roletype from the logedin user must be retrieved from the ledger
Currently this is hardcoded in
usercontext.js

// Role is retrieved from party Name
const role = localStorage.getItem("daml.party",party)
localStorage.setItem("daml.role", role);

Instead it needs to be retrieved from ledger

Sample (Not verified code below)

const fetchUpdate = async () => {
      console.log("insidefetch");
      try {
        const contractResponse = await post('/v1/query', {
          body: {
            "templateIds": ["Main:CitizenInvitation"],
            "query" : {"citizen" : "Alice"}
                 }
         });
        
         const citizenContractResponse = await contractResponse.json();
         const assets = citizenContractResponse.contracts.map(c => c.payload.roletype);
         const roletype = JSON.stringify (assets);
         console.log ("Roletype : " + roletype);
        
      }
      catch(err) {
        alert("Something went wrong with roletype");
      }
    }; 

Current observation: the code for this appears to be skipped at this time

Also
current code in line 122 "query" : {"citizen" : "Alice"}
needs to be updated so that the "citizen" : 'logedin user'

New Feature: when Ledger.exercise function fails - catch and display error message

on Citizeninvite.js

Implement a feature when an ledger.exercise function fails then an error message is displayed

something like

/* try {
ledger.exercise(Main.CitizenInvitation.AcceptCitizenInvitation, curContractId, { operator, citizen, citizendetails, verifiablecredentials });
}
catch(e) {
console.error(e);
alert("Something went wrong");
} */

Dev Console Warning - Can't perform a React state update on an unmounted component.

Upon Exiting the application I get a new Warning message in the Dev console

image

[DOM] Password field is not contained in a form: (More info: https://goo.gl/9p2vKq) <input aria-invalid=​"false" id=​"password" placeholder=​"Password" type=​"password" class=​"MuiInputBase-input MuiInput-input makeStyles-textField-393" value>​
Network.js:68 333333333
index.js:1 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
in Network (created by Context.Consumer)
in Route (at Layout.js:53)
in Switch (at Layout.js:51)
in div (at Layout.js:45)
in div (at Layout.js:41)
in DamlLedger (at Layout.js:40)
in Layout (created by Context.Consumer)
in withRouter(Layout) (created by Context.Consumer)
in Route (at App.js:97)
in PrivateRoute (at App.js:57)
console. @ index.js:1
overrideMethod @ react_devtools_backend.js:2273
printWarning @ react-dom.development.js:88
error @ react-dom.development.js:60
warnAboutUpdateOnUnmountedFiberInDEV @ react-dom.development.js:23161
scheduleUpdateOnFiber @ react-dom.development.js:21169
dispatchAction @ react-dom.development.js:15660
removeSuccessMsg @ Network.js:69
(anonymous) @ Network.js:84
setTimeout (async)
(anonymous) @ Network.js:84
Promise.then (async)
exerciseInviteParty @ Network.js:82
onClick @ Network.js:160
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:306
executeDispatch @ react-dom.development.js:389
executeDispatchesInOrder @ react-dom.development.js:414
executeDispatchesAndRelease @ react-dom.development.js:3278
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:3287
forEachAccumulated @ react-dom.development.js:3259
runEventsInBatch @ react-dom.development.js:3304
runExtractedPluginEventsInBatch @ react-dom.development.js:3514
handleTopLevel @ react-dom.development.js:3558
batchedEventUpdates$1 @ react-dom.development.js:21871
batchedEventUpdates @ react-dom.development.js:795
dispatchEventForLegacyPluginEventSystem @ react-dom.development.js:3568
attemptToDispatchEvent @ react-dom.development.js:4267
dispatchEvent @ react-dom.development.js:4189
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
discreteUpdates$1 @ react-dom.development.js:21887
discreteUpdates @ react-dom.development.js:806
dispatchDiscreteEvent @ react-dom.development.js:4168

Create Credential Connection based on value "accept_vcoremail"

for the citizen registration process (citizeninvite/Citizeninvite.js) a value is set by the user "accept_vcoremail" upon the registration
If this data element is "vc" (Verifiable credential) then the registration process allows the user access to the (citizen/Citizenconnection.js) page for creating the Verifiable Credentials connections.
If this data element is "email" then process for registration is not navigating to citizen/Citizenconnection,js page

Verifiable credentials are received twice

I researched an issue with the team from Trinsic about the verifiable credentials that are generated from the covid19test.js and Testlist.js page

After investigation, the front-end code is NOT generating 2 requests to api/issue and api/immunityvc
Instead the issue API does not receive a response, which may cause the re-try automatically

More investigation required on what is causing this issue

New Feature: Adding Auth Aware Navbar and Header

For 2 types of users (hardcoded users):

  1. Alice
  2. AtriumHealth

Requirements:

  1. Change the display of certain Nav Bar items.
    eg. for Alice only show "CitizenInvite" and "TestRequest"
    eg.for AtriumHealth show "ClinicInvite" , "TestAppointment", "Covid19Test"
  2. Some Nav Bar items will always be displayed independent of the user ( eg. "Default")
  3. For the 2 types of Users change the Stylesheet so the background color is different after login
    eg. for Alice : papayawhip | #FFEFD5 | rgb(255,239,213)
    for AtriumHealth Powder blue / #b0e0e6
  4. for the 2 types of Users change the Header
    for Alice : change "DAML App Template" to "Citizen Portal"
    for AtriumHealth : change "DAML App Template" to "HealthClinic Portal"

system does not allow to go to Citizenalias

on citizeninvite.js

There is an error after the ledger.exercise has been executed

ledger.exercise(Main.CitizenInvitation.AcceptCitizenInvitation, curContractId, { operator, citizen, citizendetails, verifiablecredentials })
.then(() => {
dispatch(conductclick({
citizen: citizen,
contractId: curContractId,
avcore: citizendetails.accept_vcoremail
}));

  history.push("/app/citizenalias");
})

it shows the following error
ncaught (in promise) Error: Trying to look up template f32b3f9461e4639a7825aa66243a0311432827f8596c295b6f687f43a2ed0f95:Main:CitizenRole.
at Object.push../node_modules/@daml/types/index.js.exports.lookupTemplate (index.js:30)
at index.js:83
at decoder.ts:795
at andThen (result.ts:130)
at Decoder.decode (decoder.ts:795)
at Decoder.decode (decoder.ts:312)
at Decoder.decode (decoder.ts:501)
at decodeValue_1 (decoder.ts:371)
at decoder.ts:375
at Array.reduce ()
at Decoder.decode (decoder.ts:373)
at Decoder.decode (decoder.ts:312)
at Decoder.run (decoder.ts:716)
at Ledger. (index.js:369)
at step (index.js:44)
at Object.next (index.js:25)
at fulfilled (index.js:16)
push../node_modules/@daml/types/index.js.exports.lookupTemplate @ index.js:30
(anonymous) @ index.js:83
(anonymous) @ decoder.ts:795
andThen @ result.ts:130
(anonymous) @ decoder.ts:795
(anonymous) @ decoder.ts:312
(anonymous) @ decoder.ts:501
decodeValue_1 @ decoder.ts:371
(anonymous) @ decoder.ts:375
(anonymous) @ decoder.ts:373
(anonymous) @ decoder.ts:312
Decoder.run @ decoder.ts:716
(anonymous) @ index.js:369
step @ index.js:44
(anonymous) @ index.js:25
fulfilled @ index.js:16
Promise.then (async)
exerciseCitizenAccept @ Citizeninvite.js:110
onClick @ Citizeninvite.js:249
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:306
executeDispatch @ react-dom.development.js:389
executeDispatchesInOrder @ react-dom.development.js:414
executeDispatchesAndRelease @ react-dom.development.js:3278
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:3287
forEachAccumulated @ react-dom.development.js:3259
runEventsInBatch @ react-dom.development.js:3304
runExtractedPluginEventsInBatch @ react-dom.development.js:3514
handleTopLevel @ react-dom.development.js:3558
batchedEventUpdates$1 @ react-dom.development.js:21871
batchedEventUpdates @ react-dom.development.js:795
dispatchEventForLegacyPluginEventSystem @ react-dom.development.js:3568
attemptToDispatchEvent @ react-dom.development.js:4267
dispatchEvent @ react-dom.development.js:4189
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
discreteUpdates$1 @ react-dom.development.js:21887
discreteUpdates @ react-dom.development.js:806
dispatchDiscreteEvent @ react-dom.development.js:4168

Cancel button for citizenconnection

on citizenconnection.js there are currently 2 buttons

'Create Connection' and "Cancel"

Requirements

  1. align these buttons next to each other like in other Modals. Currently they display on top of each other
  2. Show Text above the Buttons
    " Create a Verifiable Connection"
    " for more information, check the How-To below"
  3. update the style so these buttons have the same style format like any other button
  4. Overall (All Buttons) change the style of the Button to "rectangular blue button with white text"
  5. When Cancel is clicked, show alert " No Verifiable Connection is created. Please update your details to received your test results via email"

New Feature: Supply VC for Testdata when Citizendetails .vcoremail = vc

Upon the completion of the Covid19Test information and storing it into DAML
the following process below is valid if Citizendetails .vcoremail = vc
If Citizendetails.vcoremail = email then a message is created a "the Covid19Test result information is sent via email to the email address on file"

if vcoremail = vc then See below

after Covid19test.js
ledger.exercise(Main.TestAppointment.Covid19TestAppointment, curContractId, {covid19testdata, statehealth, citizen, healthclinic});

Then also send an VC via the Trinisic API

For this you need the ConnectionID stored in the "VerifiableCredentials"
and execute the following Trinsic API code

(Sample code from streetcred_submission.js)

onIssue = () => {
const CovidResult = {
testdate: this.state.testdate,
healthclinic: this.state.healthclinic,
citizen: this.state.citizen,
statehealth: this.state.statehealth,
testtype: this.state.testtype,
testnumber: this.state.testnumber,
testresult: this.state.testresult,
locationstate: this.state.locationstate

    }
    console.log(CovidResult)
    console.log("start Axios here")
    axios.post('/api/issue', CovidResult).then((response) => {
        console.log(response);
    });

}

Note: The actual sending of the VC is done in server.js

app.post('/api/issue', cors(), async function (req, res) {
const attribs = JSON.stringify(req.body);
console.log("attribs in app.post" + attribs);
const connectid = cache.get("alice");

// In the line above instead of cache.get("alice")
we now need the connectionid as stored in DAML {Main.CitizenRole.Verifiablecredentionals.connectionid

console.log()
console.log ("We are starting the credentials part");
    let param_obj = JSON.parse(attribs);
    let params = {
        credentialOfferParameters: {
            definitionId: process.env.CRED_DEF_ID,
            connectionId: connectid,
            automaticIssuance: true,
            credentialValues: {
                "testdate": param_obj["testdate"],
                "healthclinic": param_obj["healthclinic"],
                "citizen": param_obj["citizen"],
                "statehealth": param_obj["statehealth"],
                "testtype": param_obj["testtype"],
                "testnumber": param_obj["testnumber"],
                "testresult": param_obj["testresult"],
                "locationstate": param_obj["locationstate"]
            }
        }
    }
    console.log("Client.createCredential");
    await client.createCredential(params);

});

New Feature: Store ConnectionId, holder-did, issuer-did

Note: sign-up at trinsic.id to download and install the mobile app.
Also this will give you access to the API documentation

upon the successful connection creation with StreetCred/Trinsic, store the details from the connection in the
DAML Template "CitizenInvitation
data VerifiableCredentials = VerifiableCredentials
with
connectionid : Text
holder_did : Text
issuer_did : Text

Reference : Citizenconnection.js

additional notes

in server.js a Trinsic connection is created by the following code

app.post('/api/connection', cors(), async function (req, res) {
const invite = await getInvite();
cache.add("alice", invite.connectionId);
console.log("Cache invite.connectionId : " + invite.connectionId);
res.status(200).send({ invite_url: invite.invitation, connectid : invite.connectionId });

});

const getInvite = async () => {
try {
return await client.createConnection({
connectionInvitationParameters: {}
});
} catch (e) {
console.log ("Get invite problem");
console.log(e.message || e.toString());
}
}

This sends an API request for a connectionid
as per the following format
https://app.swaggerhub.com/apis-docs/Trinsic/Credentials/v1#/Connections/CreateConnection

The response is as follows:

200 success

{
"connectionId": "string",
"name": "string",
"imageUrl": "string",
"myDid": "string",
"theirDid": "string",
"myKey": "string",
"theirKey": "string",
"state": "Invited",
"invitation": "string",
"invitationUrl": "string",
"endpoint": {
"did": "string",
"verkey": [
"string"
],
"uri": "string"
},
"createdAtUtc": "2020-07-08T01:46:01.234Z",
"multiParty": true
}

The requirement is to store the following data elements
connectionid
mydid
theirdid

in the following DAML template CitizenRole

ledger.exercise(Main.CitizenRole.SetVerifableCredentials, curContractId, { citizen, verifiablecredentials })

verifiablecredentials are defined as
{ "connectionid" : "Text", (=connectionid)
"holder_did": "Text", (=mydid)
'issuer_did": "Text" (=theirdid)
}

Dev Console Warning -

image

When accessing the Test Request page I get the following warning

onloadwff.js:71 Uncaught Error: Extension context invalidated.
at onloadwff.js:71
at Object.makeRequest (onloadwff.js:71)
at p (onloadwff.js:71)
at Object.sendRequest (onloadwff.js:71)
at Object.requestFunction (onloadwff.js:71)
at Object.processTextSubmit (onloadwff.js:71)
at S (onloadwff.js:71)
at responseHandler (onloadwff.js:71)
at n (onloadwff.js:71)

hippa_accept value is not reflected based on the Checkbox Value in the Form

in Citizeninvite.js

the value of
citizendetails.hippa_accept is currently hardcoded to "True"

const [citizendetails, setConductForm] = React.useState({
    idtype: '',
    ssn: '',
    did: '',
    firstname: '',
    lastname: '',
    email:'',
    accept_vcoremail: '',
    hippa_accept: 'True',
    insurance_id: ''
  });

The value needs to be derived from the Form

<FormControlLabel
       control={
         <Checkbox
                checked={state.checkedA} onChange={handleChange} name="accepthippa"
                value={citizendetails.hippa_accept}
          />
          }
         label="AcceptHippa"
     />

Dev Console Warning - Failed Prop Type

image

Login as : Operator
Go to Network
Click Button Setup Parties

Then Warning message appears

index.js:1 Warning: Failed prop type: Invalid prop autoWidth of type string supplied to ForwardRef(Select), expected boolean.
in ForwardRef(Select) (created by WithStyles(ForwardRef(Select)))
in WithStyles(ForwardRef(Select)) (at Network.js:146)
in div (created by ForwardRef(FormControl))
in ForwardRef(FormControl) (created by WithStyles(ForwardRef(FormControl)))
in WithStyles(ForwardRef(FormControl)) (at Network.js:144)
in div (created by ForwardRef(DialogContent))
in ForwardRef(DialogContent) (created by WithStyles(ForwardRef(DialogContent)))
in WithStyles(ForwardRef(DialogContent)) (at Network.js:126)
in div (created by ForwardRef(Paper))
in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
in WithStyles(ForwardRef(Paper)) (created by ForwardRef(Dialog))
in div (created by Transition)
in Transition (created by ForwardRef(Fade))
in ForwardRef(Fade) (created by Unstable_TrapFocus)
in Unstable_TrapFocus (created by ForwardRef(Modal))
in div (created by ForwardRef(Modal))
in ForwardRef(Portal) (created by ForwardRef(Modal))
in ForwardRef(Modal) (created by ForwardRef(Dialog))
in ForwardRef(Dialog) (created by WithStyles(ForwardRef(Dialog)))
in WithStyles(ForwardRef(Dialog)) (at Network.js:119)
in div (at Network.js:117)
in div (at Network.js:102)
in Network (created by Context.Consumer)
in Route (at Layout.js:67)
in Switch (at Layout.js:51)
in div (at Layout.js:45)
in div (at Layout.js:41)
in DamlLedger (at Layout.js:40)
in Layout (created by Context.Consumer)
in withRouter(Layout) (created by Context.Consumer)
in Route (at App.js:97)
in PrivateRoute (at App.js:57)
in Switch (at App.js:50)
in Router (created by HashRouter)
in HashRouter (at App.js:49)
in Provider (at App.js:48)
in ThemeProvider (at App.js:47)
in App (at src/index.js:14)
in UserProvider (at src/index.js:12)
in LayoutProvider (at src/index.js:11)
console. @ index.js:1
overrideMethod @ react_devtools_backend.js:2273
printWarning @ checkPropTypes.js:20
checkPropTypes @ checkPropTypes.js:82
validatePropTypes @ react.development.js:1714
createElementWithValidation @ react.development.js:1813
WithStyles @ withStyles.js:79
renderWithHooks @ react-dom.development.js:14803
updateForwardRef @ react-dom.development.js:16816
beginWork @ react-dom.development.js:18645
beginWork$1 @ react-dom.development.js:23179
performUnitOfWork @ react-dom.development.js:22154
workLoopSync @ react-dom.development.js:22130
performSyncWorkOnRoot @ react-dom.development.js:21756
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
discreteUpdates$1 @ react-dom.development.js:21893
discreteUpdates @ react-dom.development.js:806
dispatchDiscreteEvent @ react-dom.development.js:4168
index.js:1 Warning: Failed prop type: Invalid prop autoWidth of type string supplied to ForwardRef(SelectInput), expected boolean.
in ForwardRef(SelectInput) (created by ForwardRef(InputBase))
in ForwardRef(InputBase) (created by WithStyles(ForwardRef(InputBase)))
in WithStyles(ForwardRef(InputBase)) (created by ForwardRef(Input))
in ForwardRef(Input) (created by WithStyles(ForwardRef(Input)))
in WithStyles(ForwardRef(Input)) (created by ForwardRef(Select))
in ForwardRef(Select) (created by WithStyles(ForwardRef(Select)))
in WithStyles(ForwardRef(Select)) (at Network.js:146)
in div (created by ForwardRef(FormControl))
in ForwardRef(FormControl) (created by WithStyles(ForwardRef(FormControl)))
in WithStyles(ForwardRef(FormControl)) (at Network.js:144)
in div (created by ForwardRef(DialogContent))
in ForwardRef(DialogContent) (created by WithStyles(ForwardRef(DialogContent)))
in WithStyles(ForwardRef(DialogContent)) (at Network.js:126)
in div (created by ForwardRef(Paper))
in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
in WithStyles(ForwardRef(Paper)) (created by ForwardRef(Dialog))
in div (created by Transition)
in Transition (created by ForwardRef(Fade))
in ForwardRef(Fade) (created by Unstable_TrapFocus)
in Unstable_TrapFocus (created by ForwardRef(Modal))
in div (created by ForwardRef(Modal))
in ForwardRef(Portal) (created by ForwardRef(Modal))
in ForwardRef(Modal) (created by ForwardRef(Dialog))
in ForwardRef(Dialog) (created by WithStyles(ForwardRef(Dialog)))
in WithStyles(ForwardRef(Dialog)) (at Network.js:119)
in div (at Network.js:117)
in div (at Network.js:102)
in Network (created by Context.Consumer)
in Route (at Layout.js:67)
in Switch (at Layout.js:51)
in div (at Layout.js:45)
in div (at Layout.js:41)
in DamlLedger (at Layout.js:40)
in Layout (created by Context.Consumer)
in withRouter(Layout) (created by Context.Consumer)
in Route (at App.js:97)
in PrivateRoute (at App.js:57)
in Switch (at App.js:50)
in Router (created by HashRouter)
in HashRouter (at App.js:49)
in Provider (at App.js:48)
in ThemeProvider (at App.js:47)
in App (at src/index.js:14)
in UserProvider (at src/index.js:12)
in LayoutProvider (at src/index.js:11)
console. @ index.js:1
overrideMethod @ react_devtools_backend.js:2273
printWarning @ checkPropTypes.js:20
checkPropTypes @ checkPropTypes.js:82
validatePropTypes @ react.development.js:1714
createElementWithValidation @ react.development.js:1813
InputBase @ InputBase.js:434
renderWithHooks @ react-dom.development.js:14803
updateForwardRef @ react-dom.development.js:16816
beginWork @ react-dom.development.js:18645
beginWork$1 @ react-dom.development.js:23179
performUnitOfWork @ react-dom.development.js:22154
workLoopSync @ react-dom.development.js:22130
performSyncWorkOnRoot @ react-dom.development.js:21756
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
discreteUpdates$1 @ react-dom.development.js:21893
discreteUpdates @ react-dom.development.js:806
dispatchDiscreteEvent @ react-dom.development.js:4168

New Feature: Retrieve Ledgerdata for Citizendetails and update with new information via Form

for Updatecitizendetails.js

Displays the details of the Citizen in a list. By clicking the "Update" button, the system brings up the Form with the details of "Citizendetails" displayed in the Form Format (as )

Upon submission the updated details for "citizendetails" are submitted to the ledger via the ledger.exercise function

(Note... This later part may still have some bugs as I working through the DAML coding and testing)

Python Bot for updating TestResult from "Pending" to "Negative"

scenario

Precondition:

  1. Citizen (Alice) has requested CovidTest with HealthClinic

  2. Testing for Covid Appointment has been scheduled

  3. Novant Healthclinic logs in

  4. Go to Covid19Test

  5. Selects DAML contract for Alice

  6. Enter the information and submits "TestResult" is "Pending"
    Note : This will trigger a Verifiable Credential to Alice Mobile phone

New requirement

a Python Bot initiates an automatic Update to the Covid19Test Contract and updates the "TestResult" to "Negative"
The phyton code triggers a new "DAML Choice" on the Covid19Test Contract

Something like this

nonconsuming UpdateCovid19Test : ContractId Covid19Test
       with
        newcovid19testdata : Covid19testdata
       
       do  
         archive self
         create this with covid19testdata = newcovid19testdata

Please note that all the Covid19Testdata stays the same, except testresult is updated to "Negative"

  testdate : Date      
  healthclinic: Party 
  citizen: Party
  statehealth: Party
  testtype: Text
  testnumber: Int
  testresult: Testresult
  locationstate: Locationstate
   deriving (Eq, Show)

After the DAML contract is updated, this should now trigger a second Verifiable Credential with the updated TestResult

Resolve Dev Console warning messages

a few cleanups are required in the code . These issues are shown as warning messages in the development console upon starting the system

webpackHotDevClient.js:138 ./src/pages/citizeninvite/Citizenalias.js
  Line 13:8:   'axiosClient' is defined but never used                      no-unused-vars
  Line 20:10:  'conductclick' is defined but never used                     no-unused-vars
  Line 43:9:   'handleConductModalOpen' is assigned a value but never used  no-unused-vars
printWarnings @ webpackHotDevClient.js:138
handleWarnings @ webpackHotDevClient.js:143
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:210
webpackHotDevClient.js:138 ./src/pages/covid19test/Covid19test_alt.js
  Line 18:9:  'ledger' is assigned a value but never used  no-unused-vars
printWarnings @ webpackHotDevClient.js:138
handleWarnings @ webpackHotDevClient.js:143
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:210
webpackHotDevClient.js:138 ./src/components/Header/Header.js
  Line 23:3:  Expected a default case  default-case
printWarnings @ webpackHotDevClient.js:138
handleWarnings @ webpackHotDevClient.js:143
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:210
webpackHotDevClient.js:138 ./src/pages/citizeninvite/Citizeninvite.js
  Line 28:10:  'Party' is defined but never used                        no-unused-vars
  Line 56:17:  'setConductAlias' is assigned a value but never used     no-unused-vars
  Line 60:33:  'setConductVC' is assigned a value but never used        no-unused-vars
  Line 73:9:   'handleOptionChange' is assigned a value but never used  no-unused-vars
printWarnings @ webpackHotDevClient.js:138
handleWarnings @ webpackHotDevClient.js:143
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:210
webpackHotDevClient.js:138 ./src/context/UserContext.js
  Line 2:10:   'createToken' is defined but never used                no-unused-vars
  Line 99:9:   'fetchPublicToken' is assigned a value but never used  no-unused-vars
  Line 112:9:  'failedStatus' is assigned a value but never used      no-unused-vars
printWarnings @ webpackHotDevClient.js:138
handleWarnings @ webpackHotDevClient.js:143
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:210
webpackHotDevClient.js:132 There were more warnings in other files.
You can find a complete log in the terminal.
printWarnings @ webpackHotDevClient.js:132
handleWarnings @ webpackHotDevClient.js:143
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:210

More warnings maybe available on the server console

New User setup on Network page results in error

Steps:

  1. Logon with Operator
  2. Go to Network Page
  3. Select setup new Parties - ex. Fred
  4. Enter information

Results " Party is invallid"

Here is the console log

operator :Operator
Network.js:79 cid: 00df4dff50cd3c50024e4f5a6b34e5008a57dd823e8cc80d28c8c481f39ceba260
Network.js:82 party: Fred role Citizen
Network.js:90 [exerciseInviteParty] cognito regiter success skip coginto
Network.js:116 Party Registered: Fredwith the following roletype :Citizen
Network.js:101 error: Error: Trying to look up template 8a9718d89133027a9099c1016790ef122bc66a41bd1bb26aa41cd0fb6e99926b:Main:PartyInvitation.

Onboarding Process enhancements using AWS Cognito - Local Environment

This issue replaces and updates issue #56

Steps to follow to do for Local Development environment

  1. Initialize users (Parties) using DAML Script

To onboard hundreds or thousands of users we need a script type onboarding process
This could be accomplished using DAML Initialization Scripts

A reference for this can be found here : https://docs.daml.com/daml-script/index.html#using-daml-script-for-ledger-initialization

The "initialization Parties" script will look something like this

{-# LANGUAGE ApplicativeDo #-}

initializeFixed : Script ()
initializeFixed = do
operator <- allocatePartyWithHint "Operator" (PartyIdHint "Operator")
citizen <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
citizen<- allocatePartyWithHint "Bob" (PartyIdHint "Bob")
healthclinic <- allocatePartyWithHint "Novant" (PartyIdHint "Novant")
statehealth <- allocatePartyWithHint "Statehealth" (PartyIdHint "Statehealth")
insurance <- allocatePartyWithHint "Insurance" (PartyIdHint "Insurance")
let parties = LedgerParties{..}
initialize parties

daml script --dar .daml/dist/script-example-0.0.1.dar --script-name ScriptExample:initializeFixed --ledger-host localhost --ledger-port 6865

  1. Script for Setting up the initial "Network" Contract

This uses the same script concept as above and replaces the previous Postman process for the Initial Network creation
"
It will use something like ... "createCmd Network" instruction

  1. Once these Parties are initialized on the Network and the Network contract is created then the Operator logs in manually and goes to the Network tab and onboard the users

He enters "Alice" as a Citizen, "Bob" as a Citizen, "Novant as a Healthclinic, etc and onboards them on the Network
Note: This establishes each party with a specific Role

  1. Go to AWS Cognito and AWS Admin sets up al lUsers (eg. Alice, Bob, Novant, NCHealth, etc) in the AWS Cognito Pool
    or alternatively imports a list of users
    https://us-east-2.console.aws.amazon.com/cognito/users/?region=us-east-2#/pool/us-east-2_BAoMJofNU/import?_k=hydm6k

Note: I changed the settings for only Administrators to setup the users
image

  1. When the user (eg. Alice) logs in for the first time with a temporary password setup by the administrator, this password is authenticated by AWS Cognito and it recognizes that it is a first logon.
    The system will then ask her to setup a new password in accordance with the rules within Cognito (eg. minimum 6 characters, both letters and numbers)

New Feature: Network.js allows Operator to set different role type for each Party

Split the functionality to currently available on Network,js into a function where the
Party is assigned a Role. The different options (dropdown) are

  1. Citizen
  2. Health clinic
  3. State health agency
  4. Insurance Company

Also include the option to set an Alias (as per the

DAML Template Role will have the following data elements

  1. Party
  2. Role ( see above)

Key Party

signatory : operator
observer: All other Roles

User Authentication for Project Dable with AWS Cognito Server

In order to improve the authentication I like to propose to let all authentication be done by AWS Cognito service

Here are a few links that may help with the design and implementation

https://aws.amazon.com/cognito/

https://teachmyselfcloud.com/post/aws-amplify-cognito.html

Alternatively, We could Oauth and the service provided by https://auth0.com/

https://daml.com/daml-driven/easy-authentication-for-your-distributed-app-with-daml-and-auth0/

New Feature : Style change based on 3 or more roles

Currently the style changes and headers are implemented based on 2 values
"Alice" and "Atriumhealth"

See code line 38 in Header.js
<AppBar position="fixed" className={userState.role === 'Alice' ? classes.appBarAlice : classes.appBarAtriumHealth}>

This needs to be expanded to 3 or more different styles.

Unable to accept Citizeninvite

Steps:

  1. Logon as Alice
  2. go to "Citizen Invite"
  3. Click Accept Invitation
  4. Fill in all the details in the pop-up and click "Register"

I encounter the following failure

image

Dropdown with available HealtClinic Parties

Login in as a Citizen (eg Alice)
Go to Create Test
On this page change the entry-box for HealthClinic to a Dropdown with all available HealthClinics setup in the system

This will require a call back to the DAML code to retrieve all Parties that are identified with Role = "HealthClinic"

Dev Console Warning - <p> cannot appear as a descendant of <p>

index.js:1 Warning: validateDOMNesting(...):

cannot appear as a descendant of

.
in p (at Citizenconnection.js:40)
in div (at Citizenconnection.js:39)
in p (created by ForwardRef(Typography))
in ForwardRef(Typography) (created by WithStyles(ForwardRef(Typography)))
in WithStyles(ForwardRef(Typography)) (at Citizenconnection.js:200)
in div (created by Transition)
in div (created by Transition)
in div (created by Transition)
in Transition (created by ForwardRef(Collapse))
in ForwardRef(Collapse) (created by WithStyles(ForwardRef(Collapse)))
in WithStyles(ForwardRef(Collapse)) (created by ForwardRef(StepContent))
in div (created by ForwardRef(StepContent))
in ForwardRef(StepContent) (created by WithStyles(ForwardRef(StepContent)))
in WithStyles(ForwardRef(StepContent)) (at Citizenconnection.js:199)
in div (created by ForwardRef(Step))
in ForwardRef(Step) (created by WithStyles(ForwardRef(Step)))
in WithStyles(ForwardRef(Step)) (at Citizenconnection.js:197)
in div (created by ForwardRef(Paper))
in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
in WithStyles(ForwardRef(Paper)) (created by ForwardRef(Stepper))
in ForwardRef(Stepper) (created by WithStyles(ForwardRef(Stepper)))
in WithStyles(ForwardRef(Stepper)) (at Citizenconnection.js:195)
in div (at Citizenconnection.js:192)
in div (at Citizenconnection.js:164)
in CitizenConnection (created by ConnectFunction)
in ConnectFunction (created by Context.Consumer)
in Route (at Layout.js:59)
in Switch (at Layout.js:51)
in div (at Layout.js:45)
in div (at Layout.js:41)
in DamlLedger (at Layout.js:40)
in Layout (created by Context.Consumer)
in withRouter(Layout) (created by Context.Consumer)
in Route (at App.js:97)
in PrivateRoute (at App.js:57)
in Switch (at App.js:50)
in Router (created by HashRouter)
in HashRouter (at App.js:49)
in Provider (at App.js:48)
in ThemeProvider (at App.js:47)
in App (at src/index.js:14)
in UserProvider (at src/index.js:12)
in LayoutProvider (at src/index.js:11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.