Skip to content

Latest commit

 

History

History
153 lines (113 loc) · 4.83 KB

README.md

File metadata and controls

153 lines (113 loc) · 4.83 KB

Cipher AI Vault Data Store Canister

Developer Grant

This is the Data Store canister for the Cipher AI Vault demo, responsible for securely storing and managing user data in stable memory.

Note: This demo is a proof of concept and not intended for production use. It was developed as part of a Developer Grant from the DFINITY Foundation.

Table of Contents

Prerequisites

Ensure you have the following installed:

  • DFX
  • Node.js
  • Azle development kit

For setup assistance, refer to:

Getting Started

  1. Clone the Cipher AI Vault repository if you haven't already:

    git clone https://github.com/supaIC/Cipher-AI-Vault.git
    cd Cipher-AI-Vault/data-store
  2. Install packages:

    npm install

    Note: The default canister name is 'backend'. You can change it by modifying the dfx.json file's canister section. If you modify it and plan to deploy on the mainnet, make sure you also edit the canister_ids.json file.

Building and Deployment

  1. Build the canister:

    npm run build

    Note: If you're running Azle for the first time or have switched versions, it will install necessary components. This may take 5-15 minutes depending on your system.

  2. Deploy the canister:

    dfx canister install backend --wasm target/wasm32-unknown-unknown/release/backend.wasm.gz --mode reinstall -y

    For mainnet deployment, add --network ic after canister in the command.

Useful Test Commands

Replace principal with your actual principal ID in the following commands.

Authorization and Management

  1. Check Authorization:

    dfx canister --network ic call backend isAuthorized
  2. Reset Canister Data:

    dfx canister --network ic call backend resetCanister
  3. Delete User Data (authorized users only):

    dfx canister --network ic call backend deleteUserData '( "principal" )'

Queries

  1. Check if Data Map is Empty:

    dfx canister --network ic call backend isDataMapEmpty
  2. Fetch All User Data:

    dfx canister --network ic call backend getAllUserData
  3. Fetch Data for a Single User:

    dfx canister --network ic call backend getSingleUser '( "principal" )'
  4. Fetch File Data for a User's File:

    dfx canister --network ic call backend getFileData '( "principal", "file-12345" )'
  5. Check if a User Exists:

    dfx canister --network ic call backend doesUserExist '( "principal" )'

Updates

  1. Create a New User Entry:

    dfx canister --network ic call backend createUserEntry
  2. Add a File to User:

    dfx canister --network ic call backend addFileToUser '( "principal", record { fileID = "file-12345"; fileName = "Project Plan"; fileData = vec { record { id = "1"; name = "First Entry"; description = "Details of first entry" } } } )'
  3. Update File for User:

    dfx canister --network ic call backend updateFileForUser '( "principal", record { fileID = "file-12345"; fileName = "Updated Project Plan"; fileData = vec { record { id = "1"; name = "Updated Entry"; description = "Updated details" } } } )'
  4. Remove a File from User:

    dfx canister --network ic call backend removeFileFromUser '( "principal", "file-12345" )'
  5. Add Data to a File for a User:

    dfx canister --network ic call backend addDataToFile '( "principal", "file-12345", record { id = "2"; name = "Second Entry"; description = "Details of second entry" } )'
  6. Update Data for a File for a User:

    dfx canister --network ic call backend updateDataForFile '( "principal", "file-12345", record { id = "1"; name = "Updated Entry"; description = "Updated details of first entry" } )'

Example Mock Values

  • User Principal: "principal"
  • File ID: "file-12345"
  • File Name: "Project Plan" / "Updated Project Plan"
  • Data Entries:
    • record { id = "1"; name = "First Entry"; description = "Details of first entry" }
    • record { id = "2"; name = "Second Entry"; description = "Details of second entry" }

Replace these mock values with your specific testing data as needed.