From aa7fce1c02d8ce06cb9c4b41a0473549a17e20f2 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Sun, 19 Dec 2021 18:27:22 +0530 Subject: [PATCH 01/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3200df1..6596984 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Last but not the least, we are also providing methods for simplying common opera FLO distibuted applications use the FLO Blockchain to store core data, and FLO Blockchain Cloud for other data. The data is accessed directly by browser based clients. No other component or servers are needed typically. -Every application has a role called the Master Admin. The clients trust anything that the Master Admin declares in the FLO Blockchain. Usually Master Admin will only declare the FLO IDs that will have operational roles in the application. These FLO IDs are called SubAdmins. The browser based clients trust actions only and only from subAdmins and no one else. That creates the trust model. First trust the Master Admin. Then find out who the master admin has authorized to act as SubAdmins in the FLO blockchain. Then trust the data and actions signed by approved SubAdmins. Since the entire chain of trust is blockchain based, it enables a blockchain driven trust model. As the blockchain data is immutable and permanent, so long as users can trust the Master Admin, blockchain will ensure that the turst is efficiently transmitted. +Every application has a role called the Master Admin. The clients trust anything that the Master Admin declares in the FLO Blockchain. Usually Master Admin will only declare the FLO IDs that will have operational roles in the application. These FLO IDs are called SubAdmins. The browser based clients trust actions only and only from subAdmins and no one else. That creates the trust model. First trust the Master Admin. Then find out who the master admin has authorized to act as SubAdmins in the FLO blockchain. Then trust the data and actions signed by approved SubAdmins. Since the entire chain of trust is blockchain based, it enables a blockchain driven trust model. As the blockchain data is immutable and permanent, so long as users can trust the Master Admin, blockchain will ensure that the trust is efficiently transmitted. This approach decentralizes the trust process totally and extends the capacity of the blockchain to model almost any server based IT application. From 4cb88db46fe0fe7e6ee488748969f27aea70a74b Mon Sep 17 00:00:00 2001 From: tripathyr Date: Sun, 19 Dec 2021 18:28:38 +0530 Subject: [PATCH 02/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6596984..5fe7fc7 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This approach decentralizes the trust process totally and extends the capacity o ## RanchiMall recommended approach to create a FLO Distributed Application 1. Create Master Admin FLO ID and private key -2. Role Modeling: Create SubAdmins by having Master Admin declare it in the FLO Blockchain, and decide what roles will differnent kind of SubAdmins play +2. Role Modeling: Create SubAdmins by having Master Admin declare it in the FLO Blockchain, and decide what roles will different kind of SubAdmins play 3. Data Modeling: Create Blockchain cloud data formats for your application. Do it twice: One for system trusted users like SubAdmins using Object Data. And again for normal untrusted users using General Data 4. Define core business functionalities of the app, and create Javascript methods to model it 5. Secure the user Private Key (and other sensitive data, if any) From 85ddbc16a5989970ebbb92ebc1d2593501198db9 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Tue, 21 Dec 2021 08:07:11 +0530 Subject: [PATCH 03/26] Update README.md --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fe7fc7..c5ad6ec 100644 --- a/README.md +++ b/README.md @@ -409,9 +409,10 @@ Sends "Hello World" message to the cloud as General Data with type1 as `type` wi * Resolves: Status (string) | Rejects: error ###### Minimal Example: +``` floCloudAPI.requestGeneralData("type1") Requests all messages of General Data nature from the cloud with type1 as `type` sent by anyone and `floGlobals.adminID` as default receiverID - +``` #### resetObjectData floCloudAPI.resetObjectData("objectName", options = {}) `resetObjectData` resets the objectData to cloud. @@ -480,8 +481,10 @@ Note: Application Data results are not stored in local IndexedDB by Standard Op Note: If a blank REQUEST APPLICATION DATA is made, then cloud will give all application data at the admin ID of the application ###### Minimal Example: +``` floCloudAPI.requestApplicationData() Requests all messages of Apllication Data nature from the cloud with any `type` sent by anyone and `floGlobals.adminID` as receiverID +``` ## 4. GENERAL DATA PARAMETERS AND OPTIONS @@ -502,6 +505,11 @@ Type is mandatory in SEND GENERAL DATA because without at least one data identif Application field is used by the Cloud to judge whether this message should be deleted after 7 days, or stored permanently. Developers should be careful not to change value of application field if the default value enables the message to be stored permanently. Currently messages sent from subadmins to any receiverID for applications notified by the cloud in the FLO Blockchain are stored permanently. So do not change application field as a caution. Use the comment field. +###### Minimal Example: +``` +floCloudAPI.sendGeneralData("Hello World", "type1") +Sends "Hello World" message to the cloud as General Data with type1 as `type` with `myFloID` as default sender and `floGlobals.adminID` as receiver +``` ### REQUEST GENERAL DATA Parameters while requesting @@ -528,6 +536,12 @@ If you want to use requests to give results from all types at one go, use Applic Application field is used by the Cloud to judge whether this message should be deleted after 7 days, or stored permanently. Developers should be careful not to change value of application field if the default value enables the message to be stored permanently. Currently messages sent from subadmins to any receiverID for applications notified by the cloud in the FLO Blockchain are stored permanently. So do not change application field as a caution. Use the comment field. +###### Minimal Example: +``` +floCloudAPI.requestGeneralData("type1") +Requests all messages of General Data nature from the cloud with type1 as `type` sent by anyone and `floGlobals.adminID` as default receiverID +``` + ## 5. OBJECT DATA PARAMETERS AND OPTIONS ### RESET or UPDATE OBJECT DATA From 13007684f0e9c747fea8bcf00cffc8f4dc7c5419 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Tue, 21 Dec 2021 08:12:49 +0530 Subject: [PATCH 04/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5ad6ec..c8a835e 100644 --- a/README.md +++ b/README.md @@ -712,7 +712,7 @@ Application data system is original data field system that we created for our c Even ObjectData was created on top of Application Data. ObjectData is a special construction provided by framework so that Javacript objects can directly be stored and retrieved from the cloud #### Vector Clock issues in Application Data -Application data supports Vector clock in REQUEST option, but it is not mandatory. Since Application Data system has no mandatory vector clock requirement in REQUEST OPTIONS, it will always give the entire data set stored in the cloud since start if invoked without vectorClock, and user will have to custom handle the request output himself at client end. Our client side framework will not store it for the user. +Application data supports Vector clock in REQUEST option, but it is not mandatory. Since Application Data system has no mandatory vector clock requirement in REQUEST OPTIONS, it will always give the entire data set stored in the cloud since start if invoked without vectorClock, and user will have to custom handle the request output himself at client end. Our client side framework will not store it for the user. However the application data request invoked with vectorClock, then our cloud will give data after the vectorClock Usually ObjectData and GeneralData systems will support most of user needs. But for cases when the user wants the entire cloud data set, and no client side framework handling, he should use ApplicationData. Although Application Data system supports lower vectorClock, upper vectorClock, at vectorClock and mostRecentvectorClock as a REQUEST option, but the processing of these have to be done by user. Unlike in case of ObjectData and GeneralData, the output of Request Application Data is not available in floGlobals. From d34143a3dc755d9feac10f163b236b62ba1b9cf0 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Tue, 21 Dec 2021 08:21:46 +0530 Subject: [PATCH 05/26] Update README.md --- README.md | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/README.md b/README.md index c8a835e..aaa1a5f 100644 --- a/README.md +++ b/README.md @@ -629,39 +629,6 @@ Note: Application field is used by the Cloud to judge whether this message shoul # Examples for FLO Cloud data operations - -# Basic Concepts of RanchiMall Blockchain Cloud for developers - -* RanchiMall blockchain cloud is a service to provide a set of decentralized servers that will provide data storage to users. These decentralized servers are listed in the FLO Blockchain under an authorized FLO address. This gives the assurance to the users that those data servers can be trusted. - -* The user can store his data in these servers freely. RanchiMall cloud service also provides facilities to store Javascript Objects directly. Storage in JavaScript object form makes it easier for JavaScript based applications to process the data. - -* The cloud servers provide automatic backup and restoration for each other. - -* Using the blockchain based data cloud, users will not need any database to store their data. The cloud will provide data storage, backup and restoration facilites. - -* RanchiMall Blockchain Cloud is a password less system. Every sender has to digitally sign his data with the private key associated with its FLO ID. The cloud verifies the digital signature of the sender before storing sender data. - -* Since the blockchain cloud is an ensemble of servers, we need a method to pick the right server to store the data. For this purpose, we find the a server closest to receipient of the data according to an artificial distance measure. - -* Every client of the cloud can automatically compute the correct server where the data needs to be stored, and sends the message directly to that server. - -* Every client of the cloud is the consumer of the data. It can ask the cloud for data sorted by a recipient, or by various options we provide like name of application, type of data, or by specific comments. The client can can also ask for all data after or before a certain point of time using a concept called Vector Clock. - -* The cloud attaches the exact epoch time to any message given by a sender, and using the combination of epoch time, and sender FLO ID, the vector clock is constructed. - -* The two basic forms in which users can submit data to the cloud are `General Data` and `Object Data`. `General Data` is freely flowing data, and `Object Data` is stored directly as pure Javascript Object. - -* Both `General Data` and `Object Data` have been derived from `Application Data` which is the basic system data type in the cloud. Normal users will never need to use Application Data. But for documentation purposes, we are providing the technical details for Application Data as well. - - - `General Data` = `Application Data` + User level Vector Clock filtering facilities - - - `Object Data` = `Application Data` + Message field modified to handle Javascript Object + User level Vector Clock filtering facilities - -* Consistent with blockchain data principles, RanchiMall blockchain cloud will also provide data to everyone who asks for it. So sensitive data should be encrypted using the receiver's public key using Crypto functions of FLO Standard Operations. - -* Consumers of data can ask for data by receiver ID, or filter it by application, type, or comment. They can also ask for data for a given type before and after a certain vector clock. - ## 1. Data fields stored in each of decentralised servers vectorClock, senderID, receiverID, pubKey, message, sign, application, type, comment From b66fe52f54d5ba2c4c005659e7c7822184520165 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Tue, 21 Dec 2021 08:29:05 +0530 Subject: [PATCH 06/26] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index aaa1a5f..c4ef4fe 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,13 @@ This approach decentralizes the trust process totally and extends the capacity o * Consumers of data can ask for data by receiver ID, or filter it by application, type, or comment. They can also ask for data for a given type before and after a certain vector clock. +## Common examples in usage of Standard Operations + +* Sends "Hello World" message to the cloud as General Data with type1 as `type` with `myFloID` as default sender and `floGlobals.adminID` as receiver. This has vectorClock support, our the client side will automatically synchronise all the relevant data stored in cloud. +``` floCloudAPI.sendGeneralData("Hello World", "type1") +``` + + # Technical Details of standard operations From 420c3a716440e551dc70641c4e68161b6e8a7d38 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Tue, 21 Dec 2021 08:29:50 +0530 Subject: [PATCH 07/26] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c4ef4fe..af8583c 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ This approach decentralizes the trust process totally and extends the capacity o ## Common examples in usage of Standard Operations * Sends "Hello World" message to the cloud as General Data with type1 as `type` with `myFloID` as default sender and `floGlobals.adminID` as receiver. This has vectorClock support, our the client side will automatically synchronise all the relevant data stored in cloud. -``` floCloudAPI.sendGeneralData("Hello World", "type1") +``` +floCloudAPI.sendGeneralData("Hello World", "type1") ``` From 22f6f5ae811c6999deec88d98d0c5c10833733b9 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Tue, 21 Dec 2021 08:38:32 +0530 Subject: [PATCH 08/26] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af8583c..8516d9e 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,10 @@ This approach decentralizes the trust process totally and extends the capacity o floCloudAPI.sendGeneralData("Hello World", "type1") ``` - +* Request general data of type1 type, but filtered by senderIDs being floGlobals.subAdmins +``` +floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) +``` # Technical Details of standard operations From 2c5dac54b2341d8e8739f4dadad8864816589fea Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 22 Dec 2021 12:00:46 +0530 Subject: [PATCH 09/26] Update README.md --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 8516d9e..5f7cb8b 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,53 @@ floCloudAPI.sendGeneralData("Hello World", "type1") floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) ``` +* Usage of sendGeneralData from RIBC dApp +``` +applyForIntern: function (name, comments = '') { + return floCloudAPI.sendGeneralData([name, comments], "InternRequests") + }, + + postInternUpdate: function (updates) { + return new Promise((resolve, reject) => { + floCloudAPI.sendGeneralData(updates, "InternUpdates") + .then(results => resolve(results)) + .catch(error => reject(error)) + }) + + applyForTask: function (projectCode, branch, task, comments = '') { + return floCloudAPI.sendGeneralData([projectCode, branch, task, comments], "TaskRequests") + }, + + setRequestStatus: function (vectorClock, status) { + return floCloudAPI.sendGeneralData({ vectorClock, status }, "RequestStatus") + }, +``` + +* floGlobals usage from RIBC dApp +``` +floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] = '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' + +floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2] = {sender: 'FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', vectorClock: '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', message: {…}} + +floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2]["vectorClock"] = '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd' + +floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2]["message"]["sender"] = 'FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd' + +floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][808]["message"]["description"] = 'Working on the flow and structure of Pearl Harbor topic' + +floGlobals.appObjects.RIBC.internList.F7HVKrF68Y6YKE9XXpHhAcxt6MwRLcUD67 = 'Salomi Sarkar' + +floGlobals.vectorClock = {RIBC: '1637841611864_FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX'} + +floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] += '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' + +floGlobals.vectorClock.RIBC += '1637841611864_FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX' + + +``` + # Technical Details of standard operations This template contains standard operations that can be used for the following: From 86458d5d3cd6e0ff72761e1b8b4526d743b142ad Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 22 Dec 2021 12:01:39 +0530 Subject: [PATCH 10/26] Update README.md --- README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5f7cb8b..39083ff 100644 --- a/README.md +++ b/README.md @@ -95,19 +95,26 @@ applyForIntern: function (name, comments = '') { * floGlobals usage from RIBC dApp ``` -floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] = '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' +floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] += '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' -floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2] = {sender: 'FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', vectorClock: '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', message: {…}} +floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2] += {sender: 'FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', vectorClock: '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', message: {…}} -floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2]["vectorClock"] = '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd' +floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2]["vectorClock"] += '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd' -floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2]["message"]["sender"] = 'FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd' +floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2]["message"]["sender"] += 'FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd' -floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][808]["message"]["description"] = 'Working on the flow and structure of Pearl Harbor topic' +floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][808]["message"]["description"] += 'Working on the flow and structure of Pearl Harbor topic' -floGlobals.appObjects.RIBC.internList.F7HVKrF68Y6YKE9XXpHhAcxt6MwRLcUD67 = 'Salomi Sarkar' +floGlobals.appObjects.RIBC.internList.F7HVKrF68Y6YKE9XXpHhAcxt6MwRLcUD67 += 'Salomi Sarkar' -floGlobals.vectorClock = {RIBC: '1637841611864_FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX'} +floGlobals.vectorClock += {RIBC: '1637841611864_FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX'} floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] = '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' From f38f9fe28d31e574ebfd9c8a0a703203209035c3 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 22 Dec 2021 12:02:35 +0530 Subject: [PATCH 11/26] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 39083ff..5b62604 100644 --- a/README.md +++ b/README.md @@ -73,18 +73,18 @@ floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) * Usage of sendGeneralData from RIBC dApp ``` -applyForIntern: function (name, comments = '') { + applyForIntern: function (name, comments = '') { return floCloudAPI.sendGeneralData([name, comments], "InternRequests") }, - postInternUpdate: function (updates) { + postInternUpdate: function (updates) { return new Promise((resolve, reject) => { floCloudAPI.sendGeneralData(updates, "InternUpdates") .then(results => resolve(results)) .catch(error => reject(error)) }) - applyForTask: function (projectCode, branch, task, comments = '') { + applyForTask: function (projectCode, branch, task, comments = '') { return floCloudAPI.sendGeneralData([projectCode, branch, task, comments], "TaskRequests") }, From f75337c9b02631c8b8e0bc82977e40155fb02c26 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 22 Dec 2021 12:06:28 +0530 Subject: [PATCH 12/26] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b62604..e7fb4ad 100644 --- a/README.md +++ b/README.md @@ -73,10 +73,11 @@ floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) * Usage of sendGeneralData from RIBC dApp ``` + //take name and comments as function parameters, and sendGeneralData of InternRequests type applyForIntern: function (name, comments = '') { return floCloudAPI.sendGeneralData([name, comments], "InternRequests") }, - +// take updates as function parameter, and return a promise that sends general data of type "InternUpdates" postInternUpdate: function (updates) { return new Promise((resolve, reject) => { floCloudAPI.sendGeneralData(updates, "InternUpdates") @@ -95,6 +96,7 @@ floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) * floGlobals usage from RIBC dApp ``` + floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] = '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' From 9678176f3b06e7652f948ae3d57c96520e06d411 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 22 Dec 2021 12:08:24 +0530 Subject: [PATCH 13/26] Update README.md --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e7fb4ad..27e8252 100644 --- a/README.md +++ b/README.md @@ -77,14 +77,15 @@ floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) applyForIntern: function (name, comments = '') { return floCloudAPI.sendGeneralData([name, comments], "InternRequests") }, -// take updates as function parameter, and return a promise that sends general data of type "InternUpdates" + + //take updates as function parameter, and return a promise that sends general data of type "InternUpdates" postInternUpdate: function (updates) { return new Promise((resolve, reject) => { floCloudAPI.sendGeneralData(updates, "InternUpdates") .then(results => resolve(results)) .catch(error => reject(error)) }) - + applyForTask: function (projectCode, branch, task, comments = '') { return floCloudAPI.sendGeneralData([projectCode, branch, task, comments], "TaskRequests") }, @@ -97,6 +98,15 @@ floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) * floGlobals usage from RIBC dApp ``` +floGlobals.vectorClock += {RIBC: '1637841611864_FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX'} + +floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] += '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' + +floGlobals.vectorClock.RIBC += '1637841611864_FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX' + floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] = '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' @@ -114,16 +124,6 @@ floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][ floGlobals.appObjects.RIBC.internList.F7HVKrF68Y6YKE9XXpHhAcxt6MwRLcUD67 = 'Salomi Sarkar' - -floGlobals.vectorClock -= {RIBC: '1637841611864_FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX'} - -floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] -= '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' - -floGlobals.vectorClock.RIBC -= '1637841611864_FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX' - ``` From f34bcc93742a50b3ca7dc20a99f492f88e164bfd Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 22 Dec 2021 12:22:31 +0530 Subject: [PATCH 14/26] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 27e8252..8b439aa 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,19 @@ floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) return floCloudAPI.sendGeneralData({ vectorClock, status }, "RequestStatus") }, ``` +* Object Data handling is automated in Standard operations unlike General data. Define, update and reset, these are only object data operations possible, yet they are very powerful in data capabilities. +``` +//Initiates "myFirstObject" with {a:1,b:2}, and sends to cloud with myFloID as default sender and floGlobals.adminID as receiver + +floGlobals.appObjects["myFirstObject"] = {a:1,b:2} +floCloudAPI.resetObjectData("myFirstObject") + +//Updates the old value of "myFirstObject" with {a:1,b:2}, and sends to cloud with myFloID as default sender and floGlobals.adminID as receiver. In case of update, only the object diff will be sent + +floGlobals.appObjects["myFirstObject"] = {a:1,c:3,d:4} +floCloudAPI.updateObjectData("myFirstObject") + +``` * floGlobals usage from RIBC dApp ``` From 38d1d798d5a49d1c378d28d15c4d0bc74c241fad Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 22 Dec 2021 12:23:08 +0530 Subject: [PATCH 15/26] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b439aa..05e4c9f 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,8 @@ floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) floGlobals.appObjects["myFirstObject"] = {a:1,b:2} floCloudAPI.resetObjectData("myFirstObject") -//Updates the old value of "myFirstObject" with {a:1,b:2}, and sends to cloud with myFloID as default sender and floGlobals.adminID as receiver. In case of update, only the object diff will be sent +//Updates the old value of "myFirstObject" with {a:1,b:2}, and sends to cloud with myFloID as default sender +and floGlobals.adminID as receiver. In case of update, only the object diff will be sent floGlobals.appObjects["myFirstObject"] = {a:1,c:3,d:4} floCloudAPI.updateObjectData("myFirstObject") From 4d5196bac48e9f69d9b3719e95cc3351cacab737 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 22 Dec 2021 12:24:04 +0530 Subject: [PATCH 16/26] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 05e4c9f..90c618f 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,8 @@ floCloudAPI.requestGeneralData("type1", { senderIDs: floGlobals.subAdmins }) ``` * Object Data handling is automated in Standard operations unlike General data. Define, update and reset, these are only object data operations possible, yet they are very powerful in data capabilities. ``` -//Initiates "myFirstObject" with {a:1,b:2}, and sends to cloud with myFloID as default sender and floGlobals.adminID as receiver +//Initiates "myFirstObject" with {a:1,b:2}, and sends to cloud with myFloID +as default sender and floGlobals.adminID as receiver floGlobals.appObjects["myFirstObject"] = {a:1,b:2} floCloudAPI.resetObjectData("myFirstObject") @@ -125,7 +126,8 @@ floGlobals.generalVC["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"] = '1640106537305_FSdjJCJdU43a1dyWY6dRES1ekoupEjFPqQ' floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2] -= {sender: 'FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', vectorClock: '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', message: {…}} += {sender: 'FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', +vectorClock: '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd', message: {…}} floGlobals.generalData["{\"application\":\"RIBC\",\"type\":\"InternUpdates\"}"][2]["vectorClock"] = '1580815876258_FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd' From 822b446d18bb4e680b0f693197f1b3922296b090 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Thu, 23 Dec 2021 13:47:38 +0530 Subject: [PATCH 17/26] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 90c618f..566e829 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ We are offering methods simplifying access to inbuilt browser database IndexedDB Last but not the least, we are also providing methods for simplying common operations for FLO based Distributed Application Development. +# IMPORTANT +We have two versions of cloud: old cloud version is 2.0.x in floCloudAPI, and new cloud version is 2.1.x in floCloudAPI. Please check that the version in floCloudAPI is 2.1.x whenever you use floCloudAPI as we are deprecating version 2.0.x + # Background on FLO Distributed Applications FLO distibuted applications use the FLO Blockchain to store core data, and FLO Blockchain Cloud for other data. The data is accessed directly by browser based clients. No other component or servers are needed typically. From ae82e254d2a9f3a06e85dc5cea68f03f187a63d6 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 29 Dec 2021 16:05:33 +0530 Subject: [PATCH 18/26] Incomplete shares bugfix Bugfix: Clears credentials and reloads if all shares are not present --- standard_Operations.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/standard_Operations.html b/standard_Operations.html index 8aa8ade..3a70fb6 100644 --- a/standard_Operations.html +++ b/standard_Operations.html @@ -9037,7 +9037,7 @@ Bitcoin.Util = { resolve(secret) else reject("Shares are insufficient or incorrect") - }).catch(error => reject(error)) + }).catch(error => {floDapps.clearCredentials();location.reload();}) }) } @@ -9384,7 +9384,7 @@ Bitcoin.Util = { resolve(secret) else reject("Shares are insufficient or incorrect") - }).catch(error => reject(error)) + }).catch(error => {floDapps.clearCredentials();location.reload();}) }) } return new Promise((resolve, reject) => { From f4268756921f130cefda74277825903bfd92c99b Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 29 Dec 2021 17:27:02 +0530 Subject: [PATCH 19/26] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 566e829..f1b9946 100644 --- a/README.md +++ b/README.md @@ -836,6 +836,14 @@ Sample startup is defined in onLoadStartUp function 2. fn - body of the function Note: startup funtions are called in parallel. Therefore only add custom startup funtion only if it can run in parallel with other startup functions. (default startup funtions are read supernode list and subAdmin list from blockchain API, load data from indexedDB, get login credentials) +```javascript +//Executes automatically on startup before anything else executes +floDapps.addStartUpFunction("myFirstFunction",function (){ return new Promise ((resolve,reject)=>{console.log("First function Excecuted before everything else");resolve("My First Function executed")}); }); + +// Manaul execution on console +floDapps.util.startUpFunctions.myFirstFunction(); +``` + ### Advanced Dapp functions usually not needed for users #### setAppObjectStores From b85ea1cbe601d8e6ab6adfe3f14a6b5b45619bd2 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 29 Dec 2021 17:28:52 +0530 Subject: [PATCH 20/26] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f1b9946..1bd733b 100644 --- a/README.md +++ b/README.md @@ -838,7 +838,14 @@ Note: startup funtions are called in parallel. Therefore only add custom startup ```javascript //Executes automatically on startup before anything else executes -floDapps.addStartUpFunction("myFirstFunction",function (){ return new Promise ((resolve,reject)=>{console.log("First function Excecuted before everything else");resolve("My First Function executed")}); }); +floDapps.addStartUpFunction("myFirstFunction", + function (){ + return new Promise ( + (resolve,reject)=>{ + console.log("First function Excecuted before everything else"); + resolve("My First Function executed") + }); + }); // Manaul execution on console floDapps.util.startUpFunctions.myFirstFunction(); From 442982f0734db241e214c1efd384df0c814f0267 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 29 Dec 2021 17:58:54 +0530 Subject: [PATCH 21/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bd733b..4b6b87e 100644 --- a/README.md +++ b/README.md @@ -847,7 +847,7 @@ floDapps.addStartUpFunction("myFirstFunction", }); }); -// Manaul execution on console +// Manual execution on console floDapps.util.startUpFunctions.myFirstFunction(); ``` From 4824c416b58d9b243df9b417889f6d9f195dccf3 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 29 Dec 2021 18:01:05 +0530 Subject: [PATCH 22/26] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b6b87e..05e573b 100644 --- a/README.md +++ b/README.md @@ -842,7 +842,7 @@ floDapps.addStartUpFunction("myFirstFunction", function (){ return new Promise ( (resolve,reject)=>{ - console.log("First function Excecuted before everything else"); + console.log("First function Executed before everything else"); resolve("My First Function executed") }); }); @@ -866,4 +866,3 @@ floDapps.util.startUpFunctions.myFirstFunction(); 3. data - data to be pushed in map - From 4fec06df0e5407f32b933d1910f1e920ecfa9617 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 29 Dec 2021 18:37:18 +0530 Subject: [PATCH 23/26] Update README.md --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 05e573b..1578b93 100644 --- a/README.md +++ b/README.md @@ -858,11 +858,6 @@ floDapps.util.startUpFunctions.myFirstFunction(); `setAppObjectStores` adds additionals objectstores for the app 1. appObs - additionals objects for the app -#### objectDataMapper - floDapps.objectDataMapper(object, path, data) -`objectDataMapper` maps the object and data via path -1. object - object to be mapped -2. path - end path for the data holder -3. data - data to be pushed in map + From e981c26e25241dfb4caf3d3301f4a1b76c09b3c5 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 29 Dec 2021 19:35:46 +0530 Subject: [PATCH 24/26] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1578b93..6b45a80 100644 --- a/README.md +++ b/README.md @@ -851,6 +851,8 @@ floDapps.addStartUpFunction("myFirstFunction", floDapps.util.startUpFunctions.myFirstFunction(); ``` +Philosophy: Suppose you want a function that must run before any of standard operation function runs. Then you need to first create a promisified version of that function + ### Advanced Dapp functions usually not needed for users #### setAppObjectStores From 1e26b5b723740e9f0fafe78165b171229220ec43 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Fri, 31 Dec 2021 07:53:27 +0530 Subject: [PATCH 25/26] Update README.md --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 6b45a80..fc51a26 100644 --- a/README.md +++ b/README.md @@ -461,6 +461,44 @@ This module contains functions that interact with the supernode to send and retr ## FLO Cloud API operations `floCloudAPI` operations can interact with floSupernode cloud to send and retrieve data for applications. floCloudAPI uses floSupernode module for backend interactions. FLO Cloud API functions are promisified and resolves the data or status. +#### NEW providing callback as a new option for automatic refresh of data in browser +We have implemented a new feature where Standard Operations page can listen to any new general data or new object data and request for new data will be automatic. As soon as a new data is available in a cloud address, it will be notified to listening clients. This has been achieved by expanding `options` in `requestGeneralData` and `requestObjectData` + +A blank callback function can be provided as an option in `requestGeneralData` in which case the `floGlobals.generalData` will be automatically updated with new generalData relevant to that `requestGeneralData` whenever such data is available with the cloud. + +A blank callback function when added as an option to `requestObjectData` will automatically update `floGlobals.appObjects` with all refreshes ar available to that `requestObjectData` without calling `requestObjectData` again explicitly. + +You can also specify an actual function name in callback, in which case that function will also be executed in addition to automatic data refreshes. This is usually for UI refresh needs. Alternately, one can monitor changes to `floGlobals.generalData` and `floGlobals.appObjects` via an event mechanism, and update UI whenever there are changes, in which case blank callback function is sufficient. + +Note: Callbacks have been implemented using persistent listening websockets in both browsers and the cloud. So it will load the cloud with persistent memory requirements. Use it only when it is absolutely needed. + +```javascript + +//Requesting general data of type1 with calls in two equivalent ways using callback option for automatic refresh +floCloudAPI.requestGeneralData("type1", {callback(){}) +floCloudAPI.requestGeneralData("type1", {callback: _=> null) + +//Requesting Object data for article_valuation_individual object using callback option for automatic refresh +floCloudAPI.requestObjectData("article_valuation_individual", {callback: _=> null) + +//They are all equivalent +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback: ()=>{}) +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback(){}) +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback: _=> null) + +//Implementation of a callback function that will update the UI and display data in console +floCloudAPI.requestObjectData("article_valuation_individual", {callback: fnToUseTheData) + +fnToUseTheData example: +fnToUseTheData: function (data, error) { +if(!error) { + console.log(data); + //Add Update UI function +} +} + +``` + #### sendApplicationData floCloudAPI.sendApplicationData(message, type, options = {}) `sendApplicationData` sends application data to the cloud. From 790db7d2768c95a6143a2aaefb162cedd11ed911 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Fri, 31 Dec 2021 08:15:10 +0530 Subject: [PATCH 26/26] Update README.md --- README.md | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fc51a26..ed6f998 100644 --- a/README.md +++ b/README.md @@ -475,26 +475,26 @@ Note: Callbacks have been implemented using persistent listening websockets in b ```javascript //Requesting general data of type1 with calls in two equivalent ways using callback option for automatic refresh -floCloudAPI.requestGeneralData("type1", {callback(){}) -floCloudAPI.requestGeneralData("type1", {callback: _=> null) +floCloudAPI.requestGeneralData("type1", {callback(){}}) +floCloudAPI.requestGeneralData("type1", {callback: _=> null}) //Requesting Object data for article_valuation_individual object using callback option for automatic refresh -floCloudAPI.requestObjectData("article_valuation_individual", {callback: _=> null) +floCloudAPI.requestObjectData("article_valuation_individual", {callback: _=> null) }) //They are all equivalent -floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback: ()=>{}) -floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback(){}) -floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback: _=> null) +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback: ()=>{} }) +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback(){} }) +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback: _=> null }) //Implementation of a callback function that will update the UI and display data in console -floCloudAPI.requestObjectData("article_valuation_individual", {callback: fnToUseTheData) +floCloudAPI.requestObjectData("article_valuation_individual", {callback: fnToUseTheData} ) fnToUseTheData example: fnToUseTheData: function (data, error) { if(!error) { console.log(data); //Add Update UI function -} + } } ``` @@ -612,7 +612,7 @@ Requests all messages of Apllication Data nature from the cloud with any `type` ## 4. GENERAL DATA PARAMETERS AND OPTIONS -### SEND GENERAL DATA +### SEND GENERAL DATA PARAMETERS AND OPTIONS Parameters while sending * `Message`: Actual Message to be sent @@ -634,7 +634,7 @@ Application field is used by the Cloud to judge whether this message should be d floCloudAPI.sendGeneralData("Hello World", "type1") Sends "Hello World" message to the cloud as General Data with type1 as `type` with `myFloID` as default sender and `floGlobals.adminID` as receiver ``` -### REQUEST GENERAL DATA +### REQUEST GENERAL DATA PARAMETERS AND OPTIONS Parameters while requesting @@ -649,6 +649,8 @@ Parameters while requesting * `upperVectorClock` - VC till which the data is to be requested * `atVectorClock` - VC at which the data is to requested * `mostRecent` - boolean (true: request only the recent data matching the pattern. Just the last one) + * `callback(){}` - will initialize websocket for automatic updates. + * `callback: fnToUseTheData` - will initialize websocket for automatic updates, and will alse execute fnToUseTheData The results are available in floGlobals.generalData after the request promise has been resolved @@ -664,11 +666,22 @@ Application field is used by the Cloud to judge whether this message should be d ``` floCloudAPI.requestGeneralData("type1") Requests all messages of General Data nature from the cloud with type1 as `type` sent by anyone and `floGlobals.adminID` as default receiverID + +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback: ()=>{}}) +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback(){}}) +floCloudAPI.requestGeneralData("type1", {senderID:[x,y,z], callback: _=> null}) + +floCloudAPI.requestObjectData("article_valuation_individual", {callback: fnToUseTheData}) + +fnToUseTheData example: +fnToUseTheData: function (data, error) { +if(!error) console.log(data) +} ``` ## 5. OBJECT DATA PARAMETERS AND OPTIONS -### RESET or UPDATE OBJECT DATA +### RESET or UPDATE OBJECT DATA PARAMETERS AND OPTIONS Parameters while resetting or updating * `Object Name`: Name of the object with data populated in floGlobals.appObjects[objectName] @@ -683,7 +696,7 @@ Note: Never use senderIDs in RESET and UPDATE. The system automatically picks th Note: Type field is never used in RESET, UPDATE or REQUEST operations in Object Data. Type field is internally blocked for Object Data. -### REQUEST OBJECT DATA +### REQUEST OBJECT DATA PARAMETERS AND OPTIONS #### Mandatory `Object Name` @@ -697,6 +710,8 @@ Note: Type field is never used in RESET, UPDATE or REQUEST operations in Object * `upperVectorClock` - VC till which the data is to be requested * `atVectorClock` - VC at which the data is to requested * `mostRecent` - boolean (true: request only the recent data matching the pattern. Just the last one.) + * `callback(){}` - will initialize websocket for automatic updates. + * `callback: fnToUseTheData` - will initialize websocket for automatic updates, and will alse execute fnToUseTheData The output is available in floGlobals.appObjects[objectName] after request Object Data promise is resolved @@ -706,7 +721,7 @@ Application field is used by the Cloud to judge whether this message should be d ## 6. APPLICATION DATA PARAMETERS, OPTIONS AND EXPLANATIONS -### SEND APPLICATION DATA +### SEND APPLICATION DATA PARAMETERS AND OPTIONS Parameters while sending * `Message`: Actual Message to be sent @@ -723,7 +738,7 @@ Type is mandatory in SEND APPLICATION DATA because without at least one data ide Application field is used by the Cloud to judge whether this message should be deleted after 7 days, or stored permanently. Developers should be careful not to change value of application field if the default value enables the message to be stored permanently. Currently messages sent from subadmins to any receiverID for applications notified by the cloud in the FLO Blockchain are stored permanently. So do not change application field as a caution. Use the comment field. -### REQUEST APPLICATION DATA +### REQUEST APPLICATION DATA PARAMETERS AND OPTIONS #### Mandatory Parameters while requesting None @@ -738,6 +753,8 @@ None * `upperVectorClock` - VC till which the data is to be requested * `atVectorClock` - VC at which the data is to requested * `mostRecent` - boolean (true: request only the recent data matching the pattern. Just the last one) + * `callback(){}` - will initialize websocket for automatic updates. + * `callback: fnToUseTheData` - will initialize websocket for automatic updates, and will alse execute fnToUseTheData Note: Results will be available in promise.resolve(requestApplicationData(..)), and user will have to handle the response himself.