Skip to content

Commit

Permalink
v1.0.0-RC48-MB
Browse files Browse the repository at this point in the history
  • Loading branch information
MButcho committed Jul 17, 2020
1 parent b2f9844 commit c838eb2
Show file tree
Hide file tree
Showing 16 changed files with 442 additions and 191 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ https://support.ledger.com/hc/en-us/articles/115005165269-Connection-issues-with
wget -q -O - https://raw.githubusercontent.com/LedgerHQ/udev-rules/master/add_udev_rules.sh | sudo bash
```

todo:
Any donation to ELA address EUSMsck3svNiacva9LfwrLfbvNnUU27z77 or mbutcho (CryptoName) is much appreciated.

### Thank you and enjoy!
8 changes: 4 additions & 4 deletions docs/build-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ npm ls node-gyp


# to auto build a releases
git commit -am v1.0.0-RC47-MB;
git tag v1.0.0-RC47-MB;
git commit -am v1.0.0-RC48-MB;
git tag v1.0.0-RC48-MB;
git push;
git push --tags;

## to delete release tags
git push --delete origin v1.0.0-RC47-MB;
git tag -d v1.0.0-RC47-MB;
git push --delete origin v1.0.0-RC48-MB;
git tag -d v1.0.0-RC48-MB;
git pull;
git push;
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elastos-light-wallet",
"version": "v1.0.0-RC47-MB",
"version": "v1.0.0-RC48-MB",
"description": "elastos light wallet",
"productName": "Elastos Light Wallet",
"main": "index.js",
Expand Down
101 changes: 60 additions & 41 deletions scripts/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ let cryptoNameELAAddress = '';
let requests = [];
let urls = [];

let loadedfiatList = false;
let loadedCurrenciesList = false;
let parsedFiatList = [];
let parsedCryptoList = [];

/** functions */
const init = (_GuiToggles) => {
Expand Down Expand Up @@ -257,11 +258,11 @@ const getRestService = () => {
};

const setRestService = (ix) => {
currentNetworkIx = ix;
if (ix === 99) {
restService = currentNodeURL;
currentNetworkIx = ix;
if (ix == 99) {
restService = currentNodeURL;
} else {
restService = REST_SERVICES[ix].url;
restService = REST_SERVICES[ix].url;
}
};

Expand Down Expand Up @@ -417,7 +418,7 @@ const pollForData = () => {
//requestRssFeed();
//requestFee();
//requestFeeAccount();
if (!loadedfiatList) { // load once
if (!loadedCurrenciesList) { // load once
CoinGecko.requestCurrencies();
CoinGecko.getCurrencies();
}
Expand Down Expand Up @@ -508,7 +509,7 @@ const getJson = (url, readyCallback, errorCallback) => {
xhttp.responseType = 'text';
xhttp.open('GET', url, true);
requests.push(xhttp);
urls.push(url);
urls.push("Start:"+getCurrentDateTime()+" URL:"+url);
xhttp.send();
};

Expand Down Expand Up @@ -561,21 +562,21 @@ const requestBlockchainData = (_userRequest) => {
requestUnspentTransactionOutputs();
requestBlockchainState();

/*
if (refreshCandiatesFlag) {
}*/

CoinGecko.requestPriceData();

if (_userRequest) reloadProducersAndVotes(_userRequest);
};

const reloadProducersAndVotes = (_userRequest) => {
if (_userRequest) {
clearParsedProducerList();
clearParsedCandidateVoteList();
loadedProducerList = false;
loadedVotes = false;
requestListOfProducers(_userRequest);
requestListOfCandidateVotes();
}
};
requestListOfProducers(_userRequest);
requestListOfCandidateVotes();
}

const getPublicKeyFromMnemonic = (_saveWallet) => {
useLedgerFlag = false;
Expand Down Expand Up @@ -1280,9 +1281,9 @@ const requestListOfProducersReadyCallback = (response, _userRequest) => {

const requestListOfProducers = (_userRequest) => {
if (_userRequest) {
producerListStatus = 'Refreshing Producers, Please Wait';
producerListStatus = 'Refreshing Producers, please wait ...';
} else {
producerListStatus = 'Loading Producers, Please Wait';
producerListStatus = 'Loading Producers, please wait ...';
}
const txUrl = `${getRestService()}/api/v1/dpos/rank/height/0?state=active`;
//mainConsole.log(getCurrentDateTime(), 'requestListOfProducers');
Expand Down Expand Up @@ -1413,7 +1414,7 @@ const requestListOfCandidateVotesReadyCallback = (response) => {

const requestListOfCandidateVotes = () => {
if (address !== undefined) {
candidateVoteListStatus = 'Loading Votes, Please Wait';
candidateVoteListStatus = 'Loading Votes, please wait ...';

const txUrl = `${getRestService()}/api/v1/dpos/address/${address}?pageSize=1&pageNum=1`;
// mainConsole.log('requestListOfCandidateVotes', txUrl);
Expand All @@ -1434,7 +1435,15 @@ const sendVoteTx = () => {
}

if (parsedProducerList.producersCandidateCount === 0) {
bannerStatus = 'No Candidates Selected.';
bannerStatus = 'No candidates selected.';
bannerClass = 'bg_red color_white banner-look';
GuiToggles.showAllBanners(false);
renderApp();
return;
}

if (parsedProducerList.producersCandidateCount > 36) {
bannerStatus = 'Too many candidates selected ['+parsedProducerList.producersCandidateCount+'].';
bannerClass = 'bg_red color_white banner-look';
GuiToggles.showAllBanners(false);
renderApp();
Expand Down Expand Up @@ -1493,7 +1502,7 @@ const sendVoteTx = () => {
candidateVoteListStatus += ' please confirm tx on ledger.';
LedgerComm.sign(encodedUnsignedTx, sendVoteLedgerCallback);
} else {
bannerStatus = `UTXOs have not been retrieved yet, please wait.`;
bannerStatus = `UTXOs have not been retrieved yet, please wait ...`;
bannerClass = 'landing-btnbg color_white banner-look';
GuiToggles.showAllBanners(false);
renderApp();
Expand Down Expand Up @@ -1580,7 +1589,7 @@ const sendVoteReadyCallback = (transactionJson) => {
} else {
candidateVoteListStatus = `Voting transaction successful.`;
GuiToggles.showHome();
bannerStatus = candidateVoteListStatus;
bannerStatus = `Voting transaction successful.`;
bannerClass = 'bg_green color_white banner-look';
requestTransactionHistory();
GuiToggles.showAllBanners(true);
Expand Down Expand Up @@ -1839,11 +1848,11 @@ const listRequests = () => {
} else {
otherRequests.push(urls[i]);
}
mainConsole.log(getCurrentDateTime(), request.readyState, urls[i]);
console.log(getCurrentDateTime(), "State:"+request.readyState, urls[i]);
i++;
});
//mainConsole.log(getCurrentDateTime(), "Requests:", requests.length, "Urls:", urls.length);
mainConsole.log(getCurrentDateTime(), "Aborted Requests:", abortedRequests.length, "Running Requests:", runningRequests.length, "Finished Requests:", finishedRequests.length, "Other Requests:", otherRequests.length);
console.log(getCurrentDateTime(), "Aborted Requests:", abortedRequests.length, "Running Requests:", runningRequests.length, "Finished Requests:", finishedRequests.length, "Other Requests:", otherRequests.length);
}

const clearRequests = () => {
Expand Down Expand Up @@ -1949,10 +1958,6 @@ const clearGlobalData = () => {
//mainConsole.log('SUCCESS clearGlobalData');
};

const resetConfigData = () => {
resetConfigInitialized();
};

const getLedgerDeviceInfo = () => {
return ledgerDeviceInfo;
};
Expand All @@ -1969,7 +1974,7 @@ const getELABalance = () => {
return '?';
};

const getFiatBalance = () => {
const getCurrencyBalance = () => {
const data = CoinGecko.getPriceData();
if (data) {
const elastos = data.elastos;
Expand All @@ -1985,23 +1990,27 @@ const getFiatBalance = () => {
return '?';
};

const parseFiatList = () => {
const parseCurrencyList = () => {
const currenciesList = CoinGecko.getCurrencies();
if (currenciesList && !loadedfiatList) {
if (currenciesList && !loadedCurrenciesList) {
parsedFiatList = [];
parsedCryptoList = [];
let obj = JSON.parse(JSON.stringify(currenciesList.rates));
let keysArray = Object.keys(obj);
for (let i = 0; i < keysArray.length; i++) {
var key = keysArray[i];
var value = obj[key];
if (value.type === "fiat") {
parsedFiatList.push(key);
} else if (value.type === "crypto") {
parsedCryptoList.push(key);
}
}
loadedfiatList = true;
loadedCurrenciesList = true;
parsedFiatList = parsedFiatList.sort();
parsedCryptoList = parsedCryptoList.sort();
renderApp();
GuiUtils.setValue('userCurrency',currentCurrency);
GuiUtils.setValue('userCurrency', currentCurrency.toUpperCase());
} else {
parsedFiatList.push("usd");
}
Expand All @@ -2011,6 +2020,10 @@ const getParsedFiatList = () => {
return parsedFiatList;
}

const getParsedCryptoList = () => {
return parsedCryptoList;
}

const getAddress = () => {
return address;
};
Expand Down Expand Up @@ -2423,6 +2436,10 @@ const getDefaultWalletPath = () => {
return defaultWalletPath;
}

const getDefaultNetworkIx = () => {
return defaultNetworkIx;
}

const getCurrentNodeURL = () => {
return currentNodeURL;
}
Expand All @@ -2436,7 +2453,7 @@ const getCurrentCurrency = () => {
}

const setCurrentCurrency = (_currency) => {
currentCurrency = _currency;
currentCurrency = _currency.toLowerCase();
CoinGecko.requestPriceData();
}

Expand Down Expand Up @@ -2465,9 +2482,9 @@ const readConfigFile = () => {
});

if (configCurrency.length > 0) {
currentCurrency = configCurrency;
currentCurrency = configCurrency.toLowerCase();
} else {
currentCurrency = defaultCurrency;
currentCurrency = defaultCurrency.toLowerCase();
}
currentNodeURL = configNodeURL;
if (currentNodeURL.length > 0) {
Expand Down Expand Up @@ -2501,7 +2518,7 @@ const readConfigFile = () => {

const updateConfigFile = (updateCurrency, updateNetworkIx, updateNodeURL, updateWalletPath, updateShowBalance, updateAdvancedFeatures) => {
let updateConfigContent = '';
updateConfigContent += "currency="+updateCurrency+"\nnetworkIx="+updateNetworkIx+"\nnodeURL="+updateNodeURL+"\nwalletPath="+updateWalletPath+"\nshowBalance="+updateShowBalance+"\nadvancedFeatures="+updateAdvancedFeatures;
updateConfigContent += "currency="+updateCurrency.toLowerCase()+"\nnetworkIx="+updateNetworkIx+"\nnodeURL="+updateNodeURL+"\nwalletPath="+updateWalletPath+"\nshowBalance="+updateShowBalance+"\nadvancedFeatures="+updateAdvancedFeatures;
if (developMode) updateConfigContent +="\ndevelopMode="+developMode;
fs.writeFile(configFilePath, updateConfigContent, "utf8", (err) => {
if (err) throw err;
Expand Down Expand Up @@ -2642,7 +2659,7 @@ const getTotalUTXOs = () => {
}

const getMaxUTXOsPerTX = () => {
if (isLedgerConnected) {
if (useLedgerFlag) {
return LEDGER_UTXO_CONSOLIDATE_COUNT;
} else {
return MAX_UTXO_CONSOLIDATE_COUNT;
Expand Down Expand Up @@ -2728,7 +2745,7 @@ exports.getPublicKeyFromMnemonic = getPublicKeyFromMnemonic;
exports.getPublicKeyFromPrivateKey = getPublicKeyFromPrivateKey;
exports.getAddress = getAddress;
exports.getELABalance = getELABalance;
exports.getFiatBalance = getFiatBalance;
exports.getCurrencyBalance = getCurrencyBalance;
exports.getParsedProducerList = getParsedProducerList;
exports.getProducerListStatus = getProducerListStatus;
exports.getParsedTransactionHistory = getParsedTransactionHistory;
Expand Down Expand Up @@ -2768,6 +2785,7 @@ exports.copyPrivateKeyToClipboard = copyPrivateKeyToClipboard;
exports.copyAddressToClipboard = copyAddressToClipboard;
/* Producers & Candidates */
//exports.setRefreshCandiatesFlag = setRefreshCandiatesFlag;
exports.reloadProducersAndVotes = reloadProducersAndVotes;
exports.requestListOfProducers = requestListOfProducers;
exports.requestListOfCandidateVotes = requestListOfCandidateVotes;
exports.verifyLedgerBanner = verifyLedgerBanner;
Expand Down Expand Up @@ -2799,11 +2817,10 @@ exports.getLoggedIn = getLoggedIn;
exports.getWalletNameLogin = getWalletNameLogin;
exports.getWalletNameCreate = getWalletNameCreate;
/* config */
exports.resetConfigInitialized = resetConfigInitialized;
//exports.resetConfigInitialized = resetConfigInitialized;
exports.createConfigFile = createConfigFile;
exports.readConfigFile = readConfigFile;
exports.updateConfigFile = updateConfigFile;
exports.resetConfigData = resetConfigData;
exports.getConfigNetworkIx = getConfigNetworkIx;
exports.getConfigNodeURL = getConfigNodeURL;
exports.getConfigCurrency = getConfigCurrency;
Expand All @@ -2824,6 +2841,7 @@ exports.getCurrentAdvancedFeatures = getCurrentAdvancedFeatures;
exports.setCurrentAdvancedFeatures = setCurrentAdvancedFeatures;
/* default */
exports.getDefaultWalletPath = getDefaultWalletPath;
exports.getDefaultNetworkIx = getDefaultNetworkIx;
/* consolidate */
exports.consolidateUTXOs = consolidateUTXOs;
exports.showConsolidateButton = showConsolidateButton;
Expand All @@ -2848,5 +2866,6 @@ exports.clearRequests = clearRequests;
exports.listRequests = listRequests;
exports.writeSendData = writeSendData;
exports.getJson = getJson;
exports.parseFiatList = parseFiatList;
exports.getParsedFiatList = getParsedFiatList;
exports.parseCurrencyList = parseCurrencyList;
exports.getParsedFiatList = getParsedFiatList;
exports.getParsedCryptoList = getParsedCryptoList;
4 changes: 2 additions & 2 deletions scripts/CoinGecko.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const init = (_App) => {
};

const requestPriceData = () => {
const url = 'https://api.coingecko.com/api/v3/simple/price?ids=elastos&vs_currencies='+App.getCurrentCurrency();
const url = 'https://api.coingecko.com/api/v3/simple/price?ids=elastos&vs_currencies='+App.getCurrentCurrency().toLowerCase();
//console.log(url);
App.getJson(url, requestPriceDataReadyCallback, requestPriceDataErrorCallback);
};
Expand All @@ -33,7 +33,7 @@ const requestCurrencies = () => {
const requestCurrenciesReadyCallback = (response) => {
//console.log("Loaded requestCurrenciesReadyCallback");
currencies = response;
App.parseFiatList();
App.parseCurrencyList();
}

const requestCurrenciesErrorCallback = (response) => {
Expand Down
1 change: 1 addition & 0 deletions scripts/GuiToggles.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const showHome = () => {
//app.setRefreshCandiatesFlag(true);
hideEverything();
//app.clearSendData();
app.reloadProducersAndVotes(false);
show('home');
show('homeMenuOpen');
show('version');
Expand Down
10 changes: 10 additions & 0 deletions scripts/GuiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ const getChecked = (id) => {
return get(id).checked;
};

const setPlaceholder = (id, value) => {
get(id).placeholder = value;
};

const getPlaceholder = (id) => {
return get(id).placeholder;
};

const hide = (id) => {
get(id).style = 'display:none;';
};
Expand All @@ -37,5 +45,7 @@ exports.setValue = setValue;
exports.getValue = getValue;
exports.setChecked = setChecked;
exports.getChecked = getChecked;
exports.setPlaceholder = setPlaceholder;
exports.getPlaceholder = getPlaceholder;
exports.hide = hide;
exports.show = show;
Loading

0 comments on commit c838eb2

Please sign in to comment.