floBlockchainAPI v2.4.4

- Updated writeDataMultiple: use options (bool: preserveRatio, float: sendAmt)
- Updated default values to reduce flo spent during tx
This commit is contained in:
sairajzero 2023-03-20 19:44:52 +05:30
parent b16473f982
commit 0ab284b41b
2 changed files with 8 additions and 9 deletions

View File

@ -1,4 +1,4 @@
(function (EXPORTS) { //floBlockchainAPI v2.4.3 (function (EXPORTS) { //floBlockchainAPI v2.4.4
/* 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';
const floBlockchainAPI = EXPORTS; const floBlockchainAPI = EXPORTS;
@ -9,9 +9,9 @@
FLO: ['https://flosight.duckdns.org/', 'https://flosight.ranchimall.net/'], FLO: ['https://flosight.duckdns.org/', 'https://flosight.ranchimall.net/'],
FLO_TEST: ['https://testnet-flosight.duckdns.org', 'https://testnet.flocha.in/'] FLO_TEST: ['https://testnet-flosight.duckdns.org', 'https://testnet.flocha.in/']
}, },
sendAmt: 0.001, sendAmt: 0.0003,
fee: 0.0005, fee: 0.0002,
minChangeAmt: 0.0005, minChangeAmt: 0.0002,
receiverID: floGlobals.adminID receiverID: floGlobals.adminID
}; };
@ -261,11 +261,11 @@
* @param {boolean} preserveRatio (optional) preserve ratio or equal contribution * @param {boolean} preserveRatio (optional) preserve ratio or equal contribution
* @return {Promise} * @return {Promise}
*/ */
floBlockchainAPI.writeDataMultiple = function (senderPrivKeys, data, receivers = [DEFAULT.receiverID], preserveRatio = true) { floBlockchainAPI.writeDataMultiple = function (senderPrivKeys, data, receivers = [DEFAULT.receiverID], options = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!Array.isArray(senderPrivKeys)) if (!Array.isArray(senderPrivKeys))
return reject("Invalid senderPrivKeys: SenderPrivKeys must be Array"); return reject("Invalid senderPrivKeys: SenderPrivKeys must be Array");
if (!preserveRatio) { if (options.preserveRatio === false) {
let tmp = {}; let tmp = {};
let amount = (DEFAULT.sendAmt * receivers.length) / senderPrivKeys.length; let amount = (DEFAULT.sendAmt * receivers.length) / senderPrivKeys.length;
senderPrivKeys.forEach(key => tmp[key] = amount); senderPrivKeys.forEach(key => tmp[key] = amount);
@ -275,7 +275,7 @@
return reject("Invalid receivers: Receivers must be Array"); return reject("Invalid receivers: Receivers must be Array");
else { else {
let tmp = {}; let tmp = {};
let amount = DEFAULT.sendAmt; let amount = options.sendAmt || DEFAULT.sendAmt;
receivers.forEach(floID => tmp[floID] = amount); receivers.forEach(floID => tmp[floID] = amount);
receivers = tmp receivers = tmp
} }

View File

@ -1,4 +1,4 @@
(function (EXPORTS) { //floCrypto v2.3.6 (function (EXPORTS) { //floCrypto v2.3.6a
/* FLO Crypto Operators */ /* FLO Crypto Operators */
'use strict'; 'use strict';
const floCrypto = EXPORTS; const floCrypto = EXPORTS;
@ -155,7 +155,6 @@
hashID: { hashID: {
value: (str) => { value: (str) => {
let bytes = ripemd160(Crypto.SHA256(str, { asBytes: true }), { asBytes: true }); let bytes = ripemd160(Crypto.SHA256(str, { asBytes: true }), { asBytes: true });
console.debug(bytes);
bytes.unshift(bitjs.pub); bytes.unshift(bitjs.pub);
var hash = Crypto.SHA256(Crypto.SHA256(bytes, { var hash = Crypto.SHA256(Crypto.SHA256(bytes, {
asBytes: true asBytes: true