Update Project list

This commit is contained in:
Vivek Teega 2020-07-03 14:12:58 +05:30
parent 76fc769bba
commit 92e63513f3

View File

@ -62,7 +62,10 @@
<!--<p>A fully responsive site template designed by <a href="https://html5up.net">HTML5 UP</a> and <!--<p>A fully responsive site template designed by <a href="https://html5up.net">HTML5 UP</a> and
released<br /> released<br />
for free under the <a href="https://html5up.net/license">Creative Commons</a> license.</p>--> for free under the <a href="https://html5up.net/license">Creative Commons</a> license.</p>-->
<p>Join the blockchain revolution by being part of RanchiMall's <br>World Class Internship projects, <br>curated under <a href="https://medium.com/ranchimall/ranchi-mall-internship-blockchain-contract-b00193fd188c" target="_blank">RanchiMall Internship Blockchain Contract</a></p> <p>Join the blockchain revolution by being part of RanchiMall's <br>World Class Internship projects,
<br>curated under <a
href="https://medium.com/ranchimall/ranchi-mall-internship-blockchain-contract-b00193fd188c"
target="_blank">RanchiMall Internship Blockchain Contract</a></p>
</div> </div>
</div> </div>
<nav> <nav>
@ -99,14 +102,9 @@
<article id="work"> <article id="work">
<h2 class="major">Projects</h2> <h2 class="major">Projects</h2>
<span class="image main"><img src="images/pic02.jpg" alt="" /></span> <span class="image main"><img src="images/pic02.jpg" alt="" /></span>
<p>Adipiscing magna sed dolor elit. Praesent eleifend dignissim arcu, at eleifend sapien imperdiet ac. <p>This is some random text which will be replaced with much more creative introduction to the Project List</p>
Aliquam erat volutpat. Praesent urna nisi, fringila lorem et vehicula lacinia quam. Integer <div id='projectlist'>
sollicitudin mauris nec lorem luctus ultrices.</p> </div>
<p>Nullam et orci eu lorem consequat tincidunt vivamus et sagittis libero. Mauris aliquet magna magna
sed nunc rhoncus pharetra. Pellentesque condimentum sem. In efficitur ligula tate urna. Maecenas
laoreet massa vel lacinia pellentesque lorem ipsum dolor. Nullam et orci eu lorem consequat
tincidunt. Vivamus et sagittis libero. Mauris aliquet magna magna sed nunc rhoncus amet feugiat
tempus.</p>
</article> </article>
<!-- About --> <!-- About -->
@ -430,8 +428,8 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
<ul class="icons"> <ul class="icons">
<li><a href="https://twitter.com/ranchimallFLO" target="_blank" class="icon brands fa-twitter"><span <li><a href="https://twitter.com/ranchimallFLO" target="_blank" class="icon brands fa-twitter"><span
class="label">Twitter</span></a></li> class="label">Twitter</span></a></li>
<li><a href="https://facebook.com/ranchimall/" target="_blank" <li><a href="https://facebook.com/ranchimall/" target="_blank" class="icon brands fa-facebook-f"><span
class="icon brands fa-facebook-f"><span class="label">Facebook</span></a></li> class="label">Facebook</span></a></li>
<!--<li><a href="#" class="icon brands fa-instagram"><span class="label">Instagram</span></a></li>--> <!--<li><a href="#" class="icon brands fa-instagram"><span class="label">Instagram</span></a></li>-->
<li><a href="https://github.com/ranchimall/" target="_blank" class="icon brands fa-github"><span <li><a href="https://github.com/ranchimall/" target="_blank" class="icon brands fa-github"><span
class="label">GitHub</span></a></li> class="label">GitHub</span></a></li>
@ -1166,7 +1164,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
entropyStr += window.location; entropyStr += window.location;
var entropyBytes = Crypto.SHA256(entropyStr, { asBytes: true }); var entropyBytes = Crypto.SHA256(entropyStr, { asBytes: true });
for (var i = 0 ; i < entropyBytes.length ; i++) { for (var i = 0; i < entropyBytes.length; i++) {
sr.seedInt8(entropyBytes[i]); sr.seedInt8(entropyBytes[i]);
} }
} }
@ -2868,7 +2866,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
// A "null" reducer // A "null" reducer
var NullExp = window.NullExp = function NullExp() {} var NullExp = window.NullExp = function NullExp() { }
NullExp.prototype.convert = function (x) { NullExp.prototype.convert = function (x) {
return x; return x;
}; };
@ -2959,7 +2957,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
(function () { (function () {
// Constructor function of Global EllipticCurve object // Constructor function of Global EllipticCurve object
var ec = window.EllipticCurve = function () {}; var ec = window.EllipticCurve = function () { };
// ---------------- // ----------------
// ECFieldElementFp constructor // ECFieldElementFp constructor
@ -3106,8 +3104,8 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
// No-operation padding, used for stream ciphers // No-operation padding, used for stream ciphers
C_pad.NoPadding = { C_pad.NoPadding = {
pad: function (cipher, message) {}, pad: function (cipher, message) { },
unpad: function (cipher, message) {} unpad: function (cipher, message) { }
}; };
// Zero Padding. // Zero Padding.
@ -4902,7 +4900,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
//bitTrx.js //bitTrx.js
(function () { (function () {
var bitjs = window.bitjs = function () {}; var bitjs = window.bitjs = function () { };
/* public vars */ /* public vars */
bitjs.pub = 0x23; // flochange - changed the prefix to FLO Mainnet PublicKey Prefix 0x23 bitjs.pub = 0x23; // flochange - changed the prefix to FLO Mainnet PublicKey Prefix 0x23
@ -5338,26 +5336,26 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
buffer = buffer.concat(scriptBytes); buffer = buffer.concat(scriptBytes);
} }
buffer = buffer.concat(bitjs.numToBytes(parseInt(this.locktime),4)); buffer = buffer.concat(bitjs.numToBytes(parseInt(this.locktime), 4));
flohex = ascii_to_hexa(this.floData); flohex = ascii_to_hexa(this.floData);
floDataCount = this.floData.length; floDataCount = this.floData.length;
//flochange -- creating unique data character count logic for floData. This string is prefixed before actual floData string in Raw Transaction //flochange -- creating unique data character count logic for floData. This string is prefixed before actual floData string in Raw Transaction
if (floDataCount <= 16) { if (floDataCount <= 16) {
floDataCountString = floDataCount.toString(16); floDataCountString = floDataCount.toString(16);
floDataCountString = "0"+ floDataCountString; floDataCountString = "0" + floDataCountString;
} else if (floDataCount < 253) { } else if (floDataCount < 253) {
floDataCountString = floDataCount.toString(16); floDataCountString = floDataCount.toString(16);
} else if (floDataCount <= 1023) { } else if (floDataCount <= 1023) {
floDataCountAdjusted = (floDataCount - 253) + parseInt("0xfd00fd"); floDataCountAdjusted = (floDataCount - 253) + parseInt("0xfd00fd");
floDataCountStringAdjusted = floDataCountAdjusted.toString(16); floDataCountStringAdjusted = floDataCountAdjusted.toString(16);
floDataCountString = floDataCountStringAdjusted.substr(0,2)+ floDataCountStringAdjusted.substr(4,2)+ floDataCountStringAdjusted.substr(2,2); floDataCountString = floDataCountStringAdjusted.substr(0, 2) + floDataCountStringAdjusted.substr(4, 2) + floDataCountStringAdjusted.substr(2, 2);
} else { } else {
floDataCountString = "Character Limit Exceeded"; floDataCountString = "Character Limit Exceeded";
} }
return Crypto.util.bytesToHex(buffer)+floDataCountString+flohex; // flochange -- Addition of floDataCountString and floData in serialization return Crypto.util.bytesToHex(buffer) + floDataCountString + flohex; // flochange -- Addition of floDataCountString and floData in serialization
} }
@ -5577,12 +5575,12 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
); );
//https://raw.github.com/bitcoinjs/bitcoinjs-lib/09e8c6e184d6501a0c2c59d73ca64db5c0d3eb95/src/address.js //https://raw.github.com/bitcoinjs/bitcoinjs-lib/09e8c6e184d6501a0c2c59d73ca64db5c0d3eb95/src/address.js
Bitcoin.Address = function (bytes) { Bitcoin.Address = function (bytes) {
if(floGlobals.blockchain == "FLO") if (floGlobals.blockchain == "FLO")
this.version = 0x23; // FLO mainnet public address this.version = 0x23; // FLO mainnet public address
else if(floGlobals.blockchain == "FLO_TEST") else if (floGlobals.blockchain == "FLO_TEST")
this.version = 0x73; // FLO testnet public address this.version = 0x73; // FLO testnet public address
if ("string" == typeof bytes) { if ("string" == typeof bytes) {
bytes = Bitcoin.Address.decodeString(bytes,this.version); bytes = Bitcoin.Address.decodeString(bytes, this.version);
} }
this.hash = bytes; this.hash = bytes;
}; };
@ -5612,7 +5610,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
/** /**
* Parse a Bitcoin address contained in a string. * Parse a Bitcoin address contained in a string.
*/ */
Bitcoin.Address.decodeString = function (string,version) { Bitcoin.Address.decodeString = function (string, version) {
var bytes = Bitcoin.Base58.decode(string); var bytes = Bitcoin.Base58.decode(string);
var hash = bytes.slice(0, 21); var hash = bytes.slice(0, 21);
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true }); var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
@ -5912,7 +5910,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
if (pubkey.getBitcoinAddress().toString() == address) { if (pubkey.getBitcoinAddress().toString() == address) {
return i; return i;
} }
} catch (e) {} } catch (e) { }
} }
throw "Unable to find valid recovery factor"; throw "Unable to find valid recovery factor";
} }
@ -6012,14 +6010,14 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
this.priv = BigInteger.fromByteArrayUnsigned(input); this.priv = BigInteger.fromByteArrayUnsigned(input);
} else if ("string" == typeof input) { } else if ("string" == typeof input) {
var bytes = null; var bytes = null;
try{ try {
// This part is edited for FLO. FLO WIF are always compressed WIF. FLO WIF (private key) starts with R for mainnet and c for testnet. // This part is edited for FLO. FLO WIF are always compressed WIF. FLO WIF (private key) starts with R for mainnet and c for testnet.
if(((floGlobals.blockchain == "FLO") && /^R[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(input)) || if (((floGlobals.blockchain == "FLO") && /^R[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(input)) ||
((floGlobals.blockchain == "FLO_TEST") && /^c[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(input))) { ((floGlobals.blockchain == "FLO_TEST") && /^c[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(input))) {
bytes = ECKey.decodeCompressedWalletImportFormat(input); bytes = ECKey.decodeCompressedWalletImportFormat(input);
this.compressed = true; this.compressed = true;
}else if (ECKey.isHexFormat(input)) { } else if (ECKey.isHexFormat(input)) {
bytes = Crypto.util.hexToBytes(input); bytes = Crypto.util.hexToBytes(input);
} }
@ -6070,9 +6068,9 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
} }
}; };
if(floGlobals.blockchain == "FLO") if (floGlobals.blockchain == "FLO")
ECKey.privateKeyPrefix = 0xA3; //(Bitcoin mainnet 0x80 testnet 0xEF) (FLO mainnet 0xA3 163 D) ECKey.privateKeyPrefix = 0xA3; //(Bitcoin mainnet 0x80 testnet 0xEF) (FLO mainnet 0xA3 163 D)
else if(floGlobals.blockchain == "FLO_TEST") else if (floGlobals.blockchain == "FLO_TEST")
ECKey.privateKeyPrefix = 0xEF; //FLO testnet ECKey.privateKeyPrefix = 0xEF; //FLO testnet
/** /**
@ -6415,10 +6413,10 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
return Crypto.SHA256(Crypto.SHA256(data, { asBytes: true }), { asBytes: true }); return Crypto.SHA256(Crypto.SHA256(data, { asBytes: true }), { asBytes: true });
}, },
// duck typing method // duck typing method
hasMethods: function(obj /*, method list as strings */){ hasMethods: function (obj /*, method list as strings */) {
var i = 1, methodName; var i = 1, methodName;
while((methodName = arguments[i++])){ while ((methodName = arguments[i++])) {
if(typeof obj[methodName] != 'function') { if (typeof obj[methodName] != 'function') {
return false; return false;
} }
} }
@ -6430,7 +6428,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
(function (ellipticCurveType) { (function (ellipticCurveType) {
//Defining Elliptic Encryption Object //Defining Elliptic Encryption Object
var ellipticEncryption = window.ellipticCurveEncryption = function () {}; var ellipticEncryption = window.ellipticCurveEncryption = function () { };
ellipticEncryption.rng = new SecureRandom(); ellipticEncryption.rng = new SecureRandom();
@ -7016,7 +7014,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
product = -1; // fix for a zero product term, after which the sum should be sum^0 = sum, not sum^1 product = -1; // fix for a zero product term, after which the sum should be sum^0 = sum, not sum^1
break; break;
} }
product = (product + config.logs[at ^ x[j]] - config.logs[x[i] ^ x[j]] + config.max /* to make sure it's not negative */ ) % product = (product + config.logs[at ^ x[j]] - config.logs[x[i] ^ x[j]] + config.max /* to make sure it's not negative */) %
config.max; config.max;
} }
@ -7153,7 +7151,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
findDifference(original, updatedObj) returns an object with the added, deleted and updated differences findDifference(original, updatedObj) returns an object with the added, deleted and updated differences
mergeRecurcive(original, diff) this will get you a new object that will merge all the changes between the old object and the new object mergeRecurcive(original, diff) this will get you a new object that will merge all the changes between the old object and the new object
*/ */
(function(){ (function () {
const isDate = d => d instanceof Date; const isDate = d => d instanceof Date;
const isEmpty = o => Object.keys(o).length === 0; const isEmpty = o => Object.keys(o).length === 0;
const isObject = o => o != null && typeof o === 'object'; const isObject = o => o != null && typeof o === 'object';
@ -7351,7 +7349,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
const mergeRecursive = (obj1, obj2) => { const mergeRecursive = (obj1, obj2) => {
for (var p in obj2) { for (var p in obj2) {
try { try {
if(obj2[p].constructor == Object) { if (obj2[p].constructor == Object) {
obj1[p] = mergeRecursive(obj1[p], obj2[p]); obj1[p] = mergeRecursive(obj1[p], obj2[p]);
} }
// Property in destination object set; update its value. // Property in destination object set; update its value.
@ -7364,7 +7362,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
obj1[p] = mergeRecursive(obj1[p], obj2[p]); obj1[p] = mergeRecursive(obj1[p], obj2[p]);
} }
}else{ } else {
obj1[p] = obj2[p]; obj1[p] = obj2[p];
} }
} catch (e) { } catch (e) {
@ -7406,23 +7404,25 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
} }
}); });
if(obj.constructor.toString().indexOf("Array") != -1) {obj = obj.filter(function (el) { if (obj.constructor.toString().indexOf("Array") != -1) {
obj = obj.filter(function (el) {
return el != null; return el != null;
});} });
}
return obj; return obj;
} }
/*obj is original object or array, diff is the output of findDifference */ /*obj is original object or array, diff is the output of findDifference */
window.mergeDifference = (obj,diff) => { window.mergeDifference = (obj, diff) => {
if(Object.keys(diff.updated).length !== 0) if (Object.keys(diff.updated).length !== 0)
obj = mergeRecursive(obj,diff.updated) obj = mergeRecursive(obj, diff.updated)
if(Object.keys(diff.deleted).length !== 0){ if (Object.keys(diff.deleted).length !== 0) {
obj = mergeRecursive(obj,diff.deleted) obj = mergeRecursive(obj, diff.deleted)
obj = cleanse(obj) obj = cleanse(obj)
} }
if(Object.keys(diff.added).length !== 0) if (Object.keys(diff.added).length !== 0)
obj = mergeRecursive(obj,diff.added) obj = mergeRecursive(obj, diff.added)
return obj return obj
} }
})(); })();
@ -7628,7 +7628,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
//Returns public-key from private-key //Returns public-key from private-key
getPubKeyHex: function (privateKeyHex) { getPubKeyHex: function (privateKeyHex) {
if(!privateKeyHex) if (!privateKeyHex)
return null; return null;
var key = new Bitcoin.ECKey(privateKeyHex); var key = new Bitcoin.ECKey(privateKeyHex);
if (key.priv == null) if (key.priv == null)
@ -7811,7 +7811,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
var change = utxoAmt - sendAmt - fee; var change = utxoAmt - sendAmt - fee;
if (change > 0) if (change > 0)
trx.addoutput(senderAddr, change); trx.addoutput(senderAddr, change);
trx.addflodata(floData.replace(/\n/g,' ')); trx.addflodata(floData.replace(/\n/g, ' '));
var signedTxHash = trx.sign(privKey, 1); var signedTxHash = trx.sign(privKey, 1);
this.broadcastTx(signedTxHash) this.broadcastTx(signedTxHash)
.then(txid => resolve(txid)) .then(txid => resolve(txid))
@ -7842,7 +7842,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
} }
} }
trx.addoutput(floID, utxoAmt - fee); trx.addoutput(floID, utxoAmt - fee);
trx.addflodata(floData.replace(/\n/g,' ')); trx.addflodata(floData.replace(/\n/g, ' '));
var signedTxHash = trx.sign(privKey, 1); var signedTxHash = trx.sign(privKey, 1);
this.broadcastTx(signedTxHash) this.broadcastTx(signedTxHash)
.then(txid => resolve(txid)) .then(txid => resolve(txid))
@ -7858,11 +7858,11 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
* @param {boolean} preserveRatio (optional) preserve ratio or equal contribution * @param {boolean} preserveRatio (optional) preserve ratio or equal contribution
* @return {Promise} * @return {Promise}
*/ */
writeDataMultiple: function (senderPrivKeys, data, receivers = [floGlobals.adminID], preserveRatio = true){ writeDataMultiple: function (senderPrivKeys, data, receivers = [floGlobals.adminID], preserveRatio = true) {
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 (!preserveRatio) {
let tmp = {}; let tmp = {};
let amount = (floGlobals.sendAmt * receivers.length) / senderPrivKeys.length; let amount = (floGlobals.sendAmt * receivers.length) / senderPrivKeys.length;
senderPrivKeys.forEach(key => tmp[key] = amount); senderPrivKeys.forEach(key => tmp[key] = amount);
@ -7895,7 +7895,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
let senders = {}, preserveRatio; let senders = {}, preserveRatio;
//check for argument validations //check for argument validations
try{ try {
let invalids = { let invalids = {
InvalidSenderPrivKeys: [], InvalidSenderPrivKeys: [],
InvalidSenderAmountFor: [], InvalidSenderAmountFor: [],
@ -7905,31 +7905,31 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
let inputVal = 0, outputVal = 0; let inputVal = 0, outputVal = 0;
//Validate sender privatekeys (and send amount if passed) //Validate sender privatekeys (and send amount if passed)
//conversion when only privateKeys are passed (preserveRatio mode) //conversion when only privateKeys are passed (preserveRatio mode)
if(Array.isArray(senderPrivKeys)){ if (Array.isArray(senderPrivKeys)) {
senderPrivKeys.forEach(key => { senderPrivKeys.forEach(key => {
try{ try {
if(!key) if (!key)
invalids.InvalidSenderPrivKeys.push(key); invalids.InvalidSenderPrivKeys.push(key);
else{ else {
let floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(key)); let floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(key));
senders[floID] = { senders[floID] = {
wif: key wif: key
} }
} }
}catch(error){ } catch (error) {
invalids.InvalidSenderPrivKeys.push(key) invalids.InvalidSenderPrivKeys.push(key)
} }
}) })
preserveRatio = true; preserveRatio = true;
} }
//conversion when privatekeys are passed with send amount //conversion when privatekeys are passed with send amount
else{ else {
for(let key in senderPrivKeys){ for (let key in senderPrivKeys) {
try{ try {
if(!key) if (!key)
invalids.InvalidSenderPrivKeys.push(key); invalids.InvalidSenderPrivKeys.push(key);
else{ else {
if(typeof senderPrivKeys[key] !== 'number' || senderPrivKeys[key] <= 0) if (typeof senderPrivKeys[key] !== 'number' || senderPrivKeys[key] <= 0)
invalids.InvalidSenderAmountFor.push(key) invalids.InvalidSenderAmountFor.push(key)
else else
inputVal += senderPrivKeys[key]; inputVal += senderPrivKeys[key];
@ -7939,7 +7939,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
coins: senderPrivKeys[key] coins: senderPrivKeys[key]
} }
} }
}catch(error){ } catch (error) {
invalids.InvalidSenderPrivKeys.push(key) invalids.InvalidSenderPrivKeys.push(key)
} }
} }
@ -7961,9 +7961,9 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
if (Object.keys(invalids).length) if (Object.keys(invalids).length)
return reject(invalids); return reject(invalids);
//Reject if given inputVal and outputVal are not equal //Reject if given inputVal and outputVal are not equal
if(!preserveRatio && inputVal != outputVal) if (!preserveRatio && inputVal != outputVal)
return reject(`Input Amount (${inputVal}) not equal to Output Amount (${outputVal})`) return reject(`Input Amount (${inputVal}) not equal to Output Amount (${outputVal})`)
}catch(error){ } catch (error) {
return reject(error) return reject(error)
} }
//Get balance of senders //Get balance of senders
@ -7975,7 +7975,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
totalFee = floGlobals.fee, totalFee = floGlobals.fee,
balance = {}; balance = {};
//Divide fee among sender if not for preserveRatio //Divide fee among sender if not for preserveRatio
if(!preserveRatio) if (!preserveRatio)
var dividedFee = totalFee / Object.keys(senders).length; var dividedFee = totalFee / Object.keys(senders).length;
//Check if balance of each sender is sufficient enough //Check if balance of each sender is sufficient enough
let insufficient = []; let insufficient = [];
@ -7986,7 +7986,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
totalBalance += balance[floID]; totalBalance += balance[floID];
} }
if (insufficient.length) if (insufficient.length)
return reject({InsufficientBalance: insufficient}) return reject({ InsufficientBalance: insufficient })
//Calculate totalSentAmount and check if totalBalance is sufficient //Calculate totalSentAmount and check if totalBalance is sufficient
let totalSendAmt = totalFee; let totalSendAmt = totalFee;
for (floID in receivers) for (floID in receivers)
@ -8003,7 +8003,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
for (floID in senders) { for (floID in senders) {
let utxos = results.shift(); let utxos = results.shift();
let sendAmt; let sendAmt;
if(preserveRatio){ if (preserveRatio) {
let ratio = (balance[floID] / totalBalance); let ratio = (balance[floID] / totalBalance);
sendAmt = totalSendAmt * ratio; sendAmt = totalSendAmt * ratio;
} else } else
@ -8027,7 +8027,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
} }
for (floID in receivers) for (floID in receivers)
trx.addoutput(floID, receivers[floID]); trx.addoutput(floID, receivers[floID]);
trx.addflodata(floData.replace(/\n/g,' ')); trx.addflodata(floData.replace(/\n/g, ' '));
for (let i = 0; i < wifSeq.length; i++) for (let i = 0; i < wifSeq.length; i++)
trx.signinput(i, wifSeq[i], 1); trx.signinput(i, wifSeq[i], 1);
var signedTxHash = trx.serialize(); var signedTxHash = trx.serialize();
@ -8099,7 +8099,7 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=1`).then(response => { this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=1`).then(response => {
var newItems = response.totalItems - options.ignoreOld; var newItems = response.totalItems - options.ignoreOld;
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=${newItems*2}`).then( this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=${newItems * 2}`).then(
response => { response => {
if (options.limit <= 0) if (options.limit <= 0)
options.limit = response.items.length; options.limit = response.items.length;
@ -9375,16 +9375,16 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
}) })
} }
const checkIfPinRequired = function(key){ const checkIfPinRequired = function (key) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if(key.length == 52) if (key.length == 52)
resolve(key) resolve(key)
else { else {
inputFn("PIN/Password").then(pwd => { inputFn("PIN/Password").then(pwd => {
try{ try {
let privKey = Crypto.AES.decrypt(key, pwd); let privKey = Crypto.AES.decrypt(key, pwd);
resolve(privKey) resolve(privKey)
}catch(error){ } catch (error) {
reject("Access Denied: Incorrect PIN/Password") reject("Access Denied: Incorrect PIN/Password")
} }
}).catch(error => reject("Access Denied: PIN/Password required")) }).catch(error => reject("Access Denied: PIN/Password required"))
@ -9395,12 +9395,12 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getPrivateKeyCredentials().then(key => { getPrivateKeyCredentials().then(key => {
checkIfPinRequired(key).then(privKey => { checkIfPinRequired(key).then(privKey => {
try{ try {
myPrivKey = privKey myPrivKey = privKey
myPubKey = floCrypto.getPubKeyHex(myPrivKey) myPubKey = floCrypto.getPubKeyHex(myPrivKey)
myFloID = floCrypto.getFloIDfromPubkeyHex(myPubKey) myFloID = floCrypto.getFloIDfromPubkeyHex(myPubKey)
resolve('Login Credentials loaded successful') resolve('Login Credentials loaded successful')
}catch(error){ } catch (error) {
reject("Corrupted Private Key") reject("Corrupted Private Key")
} }
}).catch(error => reject(error)) }).catch(error => reject(error))
@ -9499,17 +9499,17 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
}) })
}, },
securePrivKey: function(pwd){ securePrivKey: function (pwd) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let indexArr = localStorage.getItem(`${floGlobals.application}#privKey`) let indexArr = localStorage.getItem(`${floGlobals.application}#privKey`)
if(!indexArr) if (!indexArr)
return reject("PrivKey not found"); return reject("PrivKey not found");
indexArr = JSON.parse(indexArr) indexArr = JSON.parse(indexArr)
let encryptedKey = Crypto.AES.encrypt(myPrivKey, pwd); let encryptedKey = Crypto.AES.encrypt(myPrivKey, pwd);
let threshold = indexArr.length; let threshold = indexArr.length;
let shares = floCrypto.createShamirsSecretShares(encryptedKey, threshold, threshold) let shares = floCrypto.createShamirsSecretShares(encryptedKey, threshold, threshold)
let promises = []; let promises = [];
for(var i=0; i<threshold;i++) for (var i = 0; i < threshold; i++)
promises.push(compactIDB.writeData("credentials", shares[i], indexArr[i], floGlobals.application)); promises.push(compactIDB.writeData("credentials", shares[i], indexArr[i], floGlobals.application));
Promise.all(promises) Promise.all(promises)
.then(results => resolve("Private Key Secured")) .then(results => resolve("Private Key Secured"))
@ -9544,6 +9544,17 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
reactor.registerEvent("startUpErrorLog"); reactor.registerEvent("startUpErrorLog");
reactor.addEventListener("startUpErrorLog", log => console.error(log)) reactor.addEventListener("startUpErrorLog", log => console.error(log))
</script> </script>
<script>
async function loadRIBC(){
floCloudAPI.requestObjectData('RIBC', options = { senderIDs: false, receiverID: "FMeiptdJNtYQEtzyYAVNP8fjsDJ1i4EPfE", application: 'RIBC' })
}
</script>
<script id="onLoadStartUp"> <script id="onLoadStartUp">
function onLoadStartUp() { function onLoadStartUp() {
@ -9554,7 +9565,25 @@ print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
floDapps.launchStartUp().then(result => { floDapps.launchStartUp().then(result => {
console.log(result) console.log(result)
alert(`Welcome FLO_ID: ${myFloID}`) alert(`Welcome FLO_ID: ${myFloID}`)
//App functions.... //App functions....
loadRIBC()
.then(loadres => {
let projectDetails = floGlobals.appObjects.RIBC.projectDetails
let projectDetailsKeys = Object.keys(projectDetails)
console.log('hey im here')
let projectlistContainer = document.getElementById('projectlist')
for(let i=0; i<projectDetailsKeys.length; i++){
newHtml = `<h4>${projectDetails[projectDetailsKeys[i]].projectName}</h4>
<p>${projectDetails[projectDetailsKeys[i]].projectDescription}</p>`
projectlistContainer.innerHTML = projectlistContainer.innerHTML + newHtml
}
})
}).catch(error => console.error(error)) }).catch(error => console.error(error))
} }
</script> </script>