floBlockchainAPI_v2.2.1 | floCloudAPI_v2.1.2a

(Bug fixes)
floBlockchainAPI v2.2.1
- Fixed: Unconfirmed transaction (propably dropped) causing new transaction not to be read in readData

floCloudAPI v2.1.2a
- Fixed: singleRequest not returning response correctly
- Fixed: afterTime optional parameter not added in requests
- Fixed: setStatus and requestStatus not working
This commit is contained in:
sairajzero 2022-03-08 02:19:15 +05:30
parent 85baa8e6e1
commit ecb4266a89

View File

@ -6982,7 +6982,7 @@
})(typeof global !== "undefined" ? global : window); })(typeof global !== "undefined" ? global : window);
</script> </script>
<script id="floBlockchainAPI" version="2.2.0"> <script id="floBlockchainAPI" version="2.2.1">
/* FLO Blockchain Operator to send/receive data from blockchain using API calls*/ /* FLO Blockchain Operator to send/receive data from blockchain using API calls*/
'use strict'; 'use strict';
(function(GLOBAL) { (function(GLOBAL) {
@ -7415,8 +7415,14 @@
if (options.limit <= 0) if (options.limit <= 0)
options.limit = response.items.length; options.limit = response.items.length;
var filteredData = []; var filteredData = [];
for (let i = 0; i < (response.totalItems - options.ignoreOld) && let numToRead = response.totalItems - options.ignoreOld,
filteredData.length < options.limit; i++) { unconfirmedCount = 0;
for (let i = 0; i < numToRead && filteredData.length < options.limit; i++) {
if (!response.items[i].confirmations) { //unconfirmed transactions
unconfirmedCount++;
numToRead++;
continue;
}
if (options.pattern) { if (options.pattern) {
try { try {
let jsonContent = JSON.parse(response.items[i].floData); let jsonContent = JSON.parse(response.items[i].floData);
@ -7476,7 +7482,7 @@
filteredData.push(response.items[i].floData); filteredData.push(response.items[i].floData);
} }
resolve({ resolve({
totalTxs: response.totalItems, totalTxs: response.totalItems - unconfirmedCount,
data: filteredData data: filteredData
}); });
}).catch(error => { }).catch(error => {
@ -7743,7 +7749,7 @@
} }
} }
</script> </script>
<script id="floCloudAPI" version="2.1.2"> <script id="floCloudAPI" version="2.1.2a">
/* FLO Cloud operations to send/request application data*/ /* FLO Cloud operations to send/request application data*/
const floCloudAPI = { const floCloudAPI = {
@ -7935,7 +7941,7 @@
else if (typeof data === "object" && data.method === "POST") else if (typeof data === "object" && data.method === "POST")
fetcher = fetch(sn_url, data); fetcher = fetch(sn_url, data);
fetcher.then(response => { fetcher.then(response => {
if (response.ok) if (response.ok || response.status === 400 || response.status === 500)
resolve(response); resolve(response);
else else
reject(response); reject(response);
@ -7975,13 +7981,13 @@
else else
data = new URLSearchParams(JSON.parse(JSON.stringify(data_obj))).toString(); data = new URLSearchParams(JSON.parse(JSON.stringify(data_obj))).toString();
this.fetch_ActiveAPI(floID, data).then(response => { this.fetch_ActiveAPI(floID, data).then(response => {
response.json() if (response.ok)
.then(result => resolve(this.objectifier(result))) response.json()
.catch(error => { .then(result => resolve(result))
response.text() .catch(error => reject(error))
.then(result => reject(result)) //Error Message from Node else response.text()
.catch(error => reject(error)) .then(result => reject(response.status + ": " + result)) //Error Message from Node
}) .catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))
}) })
}, },
@ -8009,6 +8015,7 @@
if ((!r.atVectorClock || r.atVectorClock == v) && if ((!r.atVectorClock || r.atVectorClock == v) &&
(r.atVectorClock || !r.lowerVectorClock || r.lowerVectorClock <= v) && (r.atVectorClock || !r.lowerVectorClock || r.lowerVectorClock <= v) &&
(r.atVectorClock || !r.upperVectorClock || r.upperVectorClock >= v) && (r.atVectorClock || !r.upperVectorClock || r.upperVectorClock >= v) &&
(!r.afterTime || r.afterTime < d.log_time) &&
r.application == d.application && r.application == d.application &&
r.receiverID == d.receiverID && r.receiverID == d.receiverID &&
(!r.comment || r.comment == d.comment) && (!r.comment || r.comment == d.comment) &&
@ -8050,7 +8057,7 @@
filterKey: function(type, options) { filterKey: function(type, options) {
return type + (options.comment ? ':' + options.comment : '') + return type + (options.comment ? ':' + options.comment : '') +
'|' + (options.receiverID || floGlobals.adminID) + '|' + (options.group || options.receiverID || floGlobals.adminID) +
'|' + (options.application || floGlobals.application); '|' + (options.application || floGlobals.application);
}, },
@ -8122,27 +8129,29 @@
floID: myFloID, floID: myFloID,
application: options.application || floGlobals.application, application: options.application || floGlobals.application,
time: Date.now(), time: Date.now(),
status: true,
pubKey: myPubKey pubKey: myPubKey
} }
let hashcontent = ["time", "application", "floID"].map(d => request[d]).join("|"); let hashcontent = ["time", "application", "floID"].map(d => request[d]).join("|");
request.sign = floCrypto.signData(hashcontent, myPrivKey); request.sign = floCrypto.signData(hashcontent, myPrivKey);
this.util.liveRequest(options.refID || floGlobals.adminID, callback) this.util.liveRequest(options.refID || floGlobals.adminID, request, callback)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)) .catch(error => reject(error))
}) })
}, },
//request status of floID(s) in trackList //request status of floID(s) in trackList
requestStatus: function(trackList, options) { requestStatus: function(trackList, options = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!Array.isArray(trackList)) if (!Array.isArray(trackList))
trackList = [trackList]; trackList = [trackList];
let callback = options.callback instanceof Function ? options.callback : (d, e) => console.debug(d, e); let callback = options.callback instanceof Function ? options.callback : (d, e) => console.debug(d, e);
let request = { let request = {
status: false,
application: options.application || floGlobals.application, application: options.application || floGlobals.application,
trackList: trackList trackList: trackList
} }
this.util.liveRequest(options.refID || floGlobals.adminID, callback) this.util.liveRequest(options.refID || floGlobals.adminID, request, callback)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)) .catch(error => reject(error))
}) })
@ -8182,6 +8191,7 @@
lowerVectorClock: options.lowerVectorClock || undefined, lowerVectorClock: options.lowerVectorClock || undefined,
upperVectorClock: options.upperVectorClock || undefined, upperVectorClock: options.upperVectorClock || undefined,
atVectorClock: options.atVectorClock || undefined, atVectorClock: options.atVectorClock || undefined,
afterTime: options.afterTime || undefined,
mostRecent: options.mostRecent || undefined, mostRecent: options.mostRecent || undefined,
} }