tracking-code-which-will-go-to-the-HEAD FLAMEAL Documentation Global

Global

Members

mongoose.Schema

# constant FBSchema

The schema of the food bank

View Source server/models/foodBanks.js, line 9

# constant fetchAddress

Function used to fetch the address from getData

View Source client/src/Web3/getData.js, line 78

# constant fetchContLastMonth

Function used to fetch the number of contributors who performed any tranasaction over last 30 days from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 165

# constant fetchData

Function used to fetch the web 3 elements from getData

View Source client/src/Web3/getData.js, line 60

# constant fetchDonPerMonth

Function used to fetch a map containing the last 12 months with the number of donations associated to each month from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 270

# constant fetchMetaState

A function to return the state of the MetaMask connection state.

View Source client/src/Web3/getWeb3.js, line 50

# constant fetchReceivers

Function used to fetch the number of receivers (occured in transactions where the address was declared as receiver) from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 180

# constant fetchReceiversLM

Function used to fetch the number of receivers (occured in transactions where the address was declared as receiver) over the last 30 days from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 195

# constant fetchRecMap

Function used to fetch a map containing the receivers with the number of transactions associated to each receiver from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 285

# constant fetchTopSenders

Function used to fetch the top senders from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 150

# constant fetchTotalSenders

Function used to fetch the number of senders from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 255

# constant fetchTotalUsers

Function used to fetch the number of unique users from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 240

# constant fetchTransactions

Function used to fetch transactions from getData

View Source client/src/Web3/getData.js, line 69

# constant fetchTransCount

Function used to fetch the number of transactions stored in the contract from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 210

# constant fetchTransLastMonth

Function used to fetch the number of transactions performed over last 30 days from the features object located in the extractFeatures function.

The processed data comes from the smart contract deployed on the blockchain network.

!IMPORTANT! If the the extractFeatures function is not called before calling this function, the data returned by this function will be outdated. (dating back to the last time the extractFeatures function was called)

View Source client/src/Web3/extractFeatures.js, line 225

mongoose.Schema

# constant UserSchema

The schema of the user account

View Source server/models/userAccount.js, line 8

Methods

# App() → {ReactComponent}

React functional component to display the application, wrapped in a router to point to the different pages

View Source client/src/App.js, line 19

the application component

ReactComponent

# authenticateUser(req, res)

Function used to authenticate the user by comparing the address provided with the address in the database.

If the function is called the nonce is changed regardless of whether the user is authenticated or not.

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/user.js, line 132

# checkStateFb() → {Object}

Function used to check if there is a saved state in session storage

View Source client/src/context/FoodBankContext.js, line 3

the state if there is one, else the initialState

Object

# checkStateUser() → {Object}

Function used to check if there is a saved state in session storage

View Source client/src/context/UserContext.js, line 3

the state if there is one, else the initialState

Object

# checkUser(address) → {Promise.<Object>}

Function used to check if the user exists in the database

Parameters:
Name Type Description
address String

the address of the user to be checked

View Source client/src/api/actions.js, line 30

a promise that resolves to the response from the database or rejects with an error

Promise.<Object>

# createfb(fbData) → {Promise.<Object>}

Function used to create a new foodbank in the database

Parameters:
Name Type Description
fbData Object

the data of the foodbank to be sent to the database

View Source client/src/api/actions.js, line 51

a promise that resolves to the response from the database or rejects with an error if the foodbank already exists

Promise.<Object>

# createFb(req, res)

Function used to create a food bank in the database

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/foodbank.js, line 34

# createUser(req, res)

Function used to create a user in the database.

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/user.js, line 86

# extractFeatures() → {Promise.<Object>}

Function to extract features from the smart contract deployed on the blockchain network using Web3. This function is called when the app is loaded and it prepares the data to be consumed by various components. The data is fetched by calling additional functions.

View Source client/src/Web3/extractFeatures.js, line 16

  • returns a promise that resolves to the features object or rejects with an error
Promise.<Object>

# FBProvider(children)

The provider to be used to handle the global state of foodbanks to be used in any component of the application

Parameters:
Name Type Description
children ReactComponent

the children provider will be wrapped around

See:

View Source client/src/context/FoodBankContext.js, line 72

# fbReducers(state, action) → {Object}

The reducer function used to interact with the global state of foodbanks

Parameters:
Name Type Description
state Object

the passed state

action String

the action to be performed

See:

View Source client/src/context/FoodBankContext.js, line 24

if the action is not recognised

Error

the new state

Object

# fetchInventory(req, res)

Function used to fetch the inventory of a user in the database.

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/user.js, line 69

# findUser(req, res)

Function used to find a user in the database based on the address.

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/user.js, line 21

# generateNonce() → {String}

Function used to generate a unique nonce to be asssigned to a user in the database. The nonce is a 16 character string containing upper and lower case letters and numbers.

View Source server/controllers/user.js, line 4

a uniquely generated nonce

String

# getData() → {Promise.<object>}

Function used to extract the elements needed from the web 3 instance

View Source client/src/Web3/getData.js, line 14

the promise that resolves to the web3Elements object or rejects with an error

Promise.<object>

# getfb() → {Promise.<Object>}

Function used to fetch all the foodbanks from the database

View Source client/src/api/actions.js, line 93

a promise that resolves to the response from the database with all the foobanks found or rejects with an error

Promise.<Object>

# getFoodBanks(res)

Function used to fetch the food banks from the database

Parameters:
Name Type Description
res Object

the response object from the server

View Source server/controllers/foodbank.js, line 3

# getOneFb(req, res)

Function used to fetch one food bank from the database

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/foodbank.js, line 18

# getWeb3() → {Promise.<Web3>}

Function the fetch the web 3 instance based on the enviroment the application is opened in.

!IMPORTANT: If using a local provider (e.g. ganache-cli, truffle), make sure to update the address in the provider variable

View Source client/src/Web3/getWeb3.js, line 4

The promise that resolves to the web 3 instance or rejects with an error

Promise.<Web3>

# getWeb3Http() → {Promise.<object>}

Function used to fetch the web 3 elements from a http rpc provider regardless of browser instance

!IMPORTANT: If using a local provider (e.g. ganache-cli, truffle), make sure to update the address in the provider variable

View Source client/src/Web3/getWeb3Http.js, line 4

the promise that resolves to the web3Elements object or rejects with an error

Promise.<object>

# LoginLogic() → {function}

The function used to handle the Web3 authentication logic using MetaMask

!IMPORTANT! The user must use MetaMask for the function to work as it is entirely dependent on the fetchData function

View Source client/src/components/Login/LoginLogic.js, line 10

handleLogin the function to be called when authentication is attempted

function

# loginUser(req, res)

Function used to login the user and compare the address provided with the address in the database.

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/user.js, line 113

# sendData(addressIn, contentIn) → {object|null}

Function to send the data to initaite the transaction on blockchain

  • The page will be refreshed after each transaction attempt to avoid the user to send the same data twice and refresh the web3 instance
  • If the transaction is succesfull it will generate an alert with the transaction hash
Parameters:
Name Type Description
addressIn String

the address of the receiver

contentIn String

the content of the transaction (the goods)

View Source client/src/Web3/sendData.js, line 3

the transaction error object or null if the transaction was successful

object | null

# StateProvider(children)

The provider to be used to handle the global state of the user to be used in any component of the application

Parameters:
Name Type Description
children ReactComponent

the children provider will be wrapped around

See:

View Source client/src/context/UserContext.js, line 82

# updateFb(fbData) → {Promise.<Object>}

Function used to update the foodbank's data in the database

Parameters:
Name Type Description
fbData Object

the data of the foodbank to be sent to the database

View Source client/src/api/actions.js, line 72

a promise that resolves to the response from the database or rejects with an error

Promise.<Object>

# updateFB(req, res)

Function used to update one food bank in the database

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/foodbank.js, line 60

# updateInventory(items, address) → {Promise.<Object>}

Function used to handle the update of user's inventory in the database

Parameters:
Name Type Description
items Array.<Object>

array of items to be sent to the database

address String

the address of the user holding the items

View Source client/src/api/actions.js, line 5

a promise that resolves to the response from the database or rejects with an error

Promise.<Object>

# updateUser(req, res)

Function used to update the inventory of a user in the database.

Parameters:
Name Type Description
req Object

the request object from the front end

res Object

the response object from the server

View Source server/controllers/user.js, line 44

# useEdit(validate) → {Object}

The function used to handle the logic of the EditFoodBank component makes the api call to update the foodbank using the updateFb function makes the api call to create a new foodbank using the createfb function

Parameters:
Name Type Description
validate function

the function to validate the input

View Source client/src/components/EditFoodBank/useEdit.js, line 6

the object containing the functions and data to be used in the main component

Object

# useForm(callback, validate) → {Object}

The function the handle the logic of the transfer form and the validation of the data before attepmting to submit the transaction to the blockchain

Parameters:
Name Type Description
callback function

the callback function used to fetch the submission state from the parent component

validate function

the function to validate the inputs

View Source client/src/components/TransferForm/useForm.js, line 9

the functions required by the TransferFill component

Object

# useHorizontalScroll() → {RefObject}

The function used to enable horisontal scrolling on the showcase component

View Source client/src/components/Showcase/useSideScroll.js, line 3

the refrence to be used in the component

RefObject

# useList(validate)

Holds the functions needed during user interaction i.e. adding, deleting.. and makes api call to update the list if the used is logged in.

Parameters:
Name Type Description
validate function

the function used to validate the inputs of the form

View Source client/src/components/List/useList.js, line 10

the functions needed during filling with the item list and the error list

# userReducers(state, action) → {Object}

The reducer function used to interact with the state

Parameters:
Name Type Description
state Object

the passed state

action String

the action to be performed

See:

View Source client/src/context/UserContext.js, line 28

if the action is not recognised

Error

the new state

Object

# useSearch(error) → {function|Array|Boolean|Boolean}

The function to hadle the logic behind the search transaction feature. The data is fetched by calling the getWeb3Http and extracting all the transactions from the response

Parameters:
Name Type Description
error String

the error generated after the validation of the input

View Source client/src/components/SearchTransaction/useSearch.js, line 4

handleSearch - the function that handles the search transaction

function

results - the array of the results of the search

Array

isFetching - the boolean that indicates if the search is being executed

Boolean

found - the boolean that indicates if the search was successful

Boolean

# validateEdit(values)

Function used to validate the input of the edit foodbank form EditFoodBank

Parameters:
Name Type Description
values Object

the values to be validated

View Source client/src/components/EditFoodBank/validateEdit.js, line 1

an array of errors

# validateInfo(values) → {Array}

Function used to validate the input of the list form from the ListFill component

Parameters:
Name Type Description
values Object

the input to be validated

View Source client/src/components/TransferForm/validateInfo.js, line 1

the array of errors found

Array

# validateInput(value) → {Array}

Function used to validate the input of the list form from the ListFill component

Parameters:
Name Type Description
value Object

the input to be validated

View Source client/src/components/List/validateList.js, line 1

  • the array of errors found
Array

# validateRegister(values) → {Array}

Function used to validate the user input of the register form

Parameters:
Name Type Description
values Object

the values to be validated

View Source client/src/components/Login/validateRegister.js, line 1

the array of errors found

Array

# validateSearch(value)

Function to validate the input of the search field

Parameters:
Name Type Description
value Object

the input to be validated

View Source client/src/components/SearchTransaction/validateSearch.js, line 1