Skip to content

Commit

Permalink
2.6.3 various bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmdeklerk committed May 30, 2018
1 parent d8d4189 commit 8949d16
Show file tree
Hide file tree
Showing 13 changed files with 6,153 additions and 42 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.6.0
2.6.3
5 changes: 2 additions & 3 deletions app/index.html
Expand Up @@ -41,10 +41,9 @@
<link rel="stylesheet" href="styles/index.css">

<div layout="column" flex layout-fill class="application-content" ng-if="showApp">
<div layout="column" flex layout-fill hide-gt-xs layout-align="center center">
<p>This site is optimized for desktop/tablet use only.</p>
<div layout="column" flex layout-fill hide-gt-xs layout-align="start center" layout-padding class="mobile-notice">
<p>The HEAT desktop wallet is optimized for desktop/tablet use only.</p>
<p>Please check back later when our mobile apps (IOS/Android) have been released.</p>
<br>
<p><a href="http://heatledger.com">heatledger.com</a></p>
</div>
<div layout="row" flex layout-fill hide show-gt-xs>
Expand Down
20 changes: 11 additions & 9 deletions app/src/components/routes/ethereum/ethereum-account.ts
Expand Up @@ -176,15 +176,17 @@ class EthereumAccountComponent {
this.ethplorer.getAddressInfo(this.account).then(info => {
this.$scope.$evalAsync(()=>{
this.balanceUnconfirmed = info.ETH.balance;
this.erc20Tokens = info.tokens.map(token => {
let tokenInfo = this.ethplorer.tokenInfoCache[token.tokenInfo.address]
return {
balance: utils.formatQNT((token.balance+"")||"0", tokenInfo?tokenInfo.decimals:8),
symbol: token.tokenInfo.symbol,
name: token.tokenInfo.name,
id: ''
}
})
if (info.tokens) {
this.erc20Tokens = info.tokens.map(token => {
let tokenInfo = this.ethplorer.tokenInfoCache[token.tokenInfo.address]
return {
balance: utils.formatQNT((token.balance+"")||"0", tokenInfo?tokenInfo.decimals:8),
symbol: token.tokenInfo.symbol,
name: token.tokenInfo.name,
id: ''
}
})
}
})
})
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/components/routes/login.ts
Expand Up @@ -36,7 +36,7 @@ declare var saveAs: any;
<div layout="column" flex ng-if="!vm.page">
<div layout="row" layout-align="center center">
<md-button class="md-primary md-raised" ng-click="vm.page='signin'" aria-label="Sign in" ng-show="vm.localKeys.length">
<md-tooltip md-direction="bottom">Sign in with your pin</md-tooltip>
<md-tooltip md-direction="bottom">Sign in with your Password (or Pin Code)</md-tooltip>
Sign in
</md-button>
<md-button class="md-primary md-raised" ng-click="vm.page='create';vm.generateNewSecretPhrase()" aria-label="Create">
Expand All @@ -62,7 +62,7 @@ declare var saveAs: any;
</div>
<div layout="column" flex>
<md-input-container flex ng-show="vm.pageSigninAccount">
<label>Pin Code</label>
<label>Password (or Pin Code)</label>
<input ng-model="vm.pageSigninPincode" required name="pincode" maxlength="15">
</md-input-container>
</div>
Expand Down Expand Up @@ -101,7 +101,7 @@ declare var saveAs: any;
</div>
<div layout="column" flex>
<md-input-container flex>
<label>Pin Code (required, minumum 4 numbers)</label>
<label>Password (or Pin Code) (required)</label>
<input ng-model="vm.pageCreatePincode" required name="pincode" maxlength="15">
</md-input-container>
</div>
Expand Down Expand Up @@ -229,7 +229,7 @@ declare var saveAs: any;
</div>
<div layout="column" flex>
<md-input-container flex>
<label>Pin Code (required 4 numbers)</label>
<label>Password (or Pin Code) (required)</label>
<input ng-model="vm.pageAddPincode" required name="pincode" maxlength="5">
</md-input-container>
</div>
Expand Down Expand Up @@ -486,7 +486,7 @@ class LoginComponent {
}

isValidPincode(pincode) {
return /^\d{4,15}$/.test(pincode);
return /^[a-zA-Z0-9_.-]{4,15}$/.test(pincode);
}

generateNewSecretPhrase() {
Expand Down
14 changes: 12 additions & 2 deletions app/src/components/routes/server/server.ts
Expand Up @@ -28,6 +28,8 @@
<div layout="row" class="button-row">
<md-button class="start-stop" ng-show="!vm.server.isRunning" ng-click="vm.startServer()">Start Server</md-button>
<md-button class="start-stop md-primary" ng-show="vm.server.isRunning" ng-click="vm.stopServer()">Stop Server</md-button>
<md-button class="start-stop" ng-click="vm.showFolder()">Install Dir</md-button>
<md-switch ng-model="vm.connectedToLocalhost" aria-label="Choose API connection" ng-change="vm.connectToLocalhostChanged()">
<md-tooltip md-direction="top">
Connect client API to remotehost or to your local machine
Expand All @@ -46,6 +48,7 @@
<md-button ng-show="vm.user.unlocked&&!vm.isMining" ng-disabled="!vm.server.isReady" class="start-stop" ng-click="vm.startMining()">Start Mining</md-button>
<md-button ng-show="vm.user.unlocked&&vm.isMining" ng-disabled="!vm.server.isReady" class="start-stop md-primary" ng-click="vm.stopMining()">Stop Mining</md-button>
<a ng-show="!vm.user.unlocked" class="start-stop" href="#/login">Sign in to start mining</a>
</div>
<div layout="column" flex class="console" layout-fill>
<md-virtual-repeat-container md-top-index="vm.topIndex" flex layout-fill layout="column"
Expand All @@ -61,7 +64,7 @@
</div>
`
})
@Inject('$scope','server','heat','user','settings')
@Inject('$scope','server','heat','user','settings','$mdToast')
class ServerComponent {
private ROW_HEIGHT = 12; // must match the `server .console pre { height: 12px }` style rule above

Expand Down Expand Up @@ -91,7 +94,8 @@ class ServerComponent {
public server: ServerService,
private heat: HeatService,
private user: UserService,
private settings: SettingsService) {
private settings: SettingsService,
private $mdToast: angular.material.IToastService) {

if (user.unlocked) {
heat.subscriber.blockPushed({generator:user.account}, ()=>{this.updateMiningInfo()});
Expand Down Expand Up @@ -129,6 +133,10 @@ class ServerComponent {
this.remotehostDisplay = this.hostRemote.replace('https://','');
}

showFolder() {
require('electron').shell.showItemInFolder(this.server.getAppDir('.'))
}

/* md-virtual-repeat */
getItemAtIndex(index) {
return this.render(this.server.buffer[index]);
Expand Down Expand Up @@ -157,6 +165,8 @@ class ServerComponent {

startServer() {
this.server.startServer()
this.$mdToast.show(this.$mdToast.simple().textContent("In some cases you need to Start the server A SECOND TIME!\n"+
"Wheter that's the case is indicated at the end of the log output (the colored text with black background).").hideDelay(10000));
}

stopServer() {
Expand Down
84 changes: 65 additions & 19 deletions app/src/components/routes/wallet/wallet.ts
Expand Up @@ -81,14 +81,30 @@ class CurrencyAddressCreate {
still after an architectural change where we dont display the CREATE node anymore.
We'll be leaving it in place where all you need to do is set this.hidden=false to
have it displayed again. */
createAddress() {
createAddress(component: WalletComponent) {

// collect all CurrencyBalance of 'our' same currency type
let currencyBalances = this.parent.currencies.filter(c => c['isCurrencyBalance'] && c.name == this.name)

// if there is no address in use yet we use the first one
if (currencyBalances.length == 0) {
let nextAddress = this.wallet.addresses[0]
let newCurrencyBalance = new CurrencyBalance('Ethereum','ETH',nextAddress.address, nextAddress.privateKey)
component.rememberAdressCreated(this.parent.account, nextAddress.address)
newCurrencyBalance.visible = this.parent.expanded
this.parent.currencies.push(newCurrencyBalance)
this.flatten()
return true
}

// determine the first 'next' address based of the last currencyBalance displayed
let lastAddress = currencyBalances[currencyBalances.length -1]['address']

// when the last address is not yet used it should be used FIRST before we allow the creation of a new address
if (!currencyBalances[currencyBalances.length -1]['inUse']) {
return false
}

// look up the following address
for (let i=0; i<this.wallet.addresses.length; i++) {

Expand All @@ -101,13 +117,16 @@ class CurrencyAddressCreate {

let nextAddress = this.wallet.addresses[i+1]
let newCurrencyBalance = new CurrencyBalance('Ethereum','ETH',nextAddress.address, nextAddress.privateKey)
component.rememberAdressCreated(this.parent.account, nextAddress.address)
newCurrencyBalance.visible = this.parent.expanded
let index = this.parent.currencies.indexOf(currencyBalances[currencyBalances.length-1])+1
this.parent.currencies.splice(index, 0, newCurrencyBalance)
this.flatten()
return
return true
}
}

return false
}
}

Expand Down Expand Up @@ -188,8 +207,8 @@ class WalletEntry {
<!-- Create ETH Account -->
<md-button class="md-warn md-raised" ng-click="vm.createEthAccount($event)" aria-label="Create Account" ng-if="!vm.allLocked">
<md-tooltip md-direction="bottom">Create ETH Account</md-tooltip>
Create ETH Account
<md-tooltip md-direction="bottom">Create Eth Address</md-tooltip>
Create ETH Address
</md-button>
</div>
Expand Down Expand Up @@ -286,6 +305,7 @@ class WalletComponent {

entries:Array<WalletEntry|CurrencyBalance|TokenBalance> = []
walletEntries: Array<WalletEntry> = []
createdAddresses: {[key:string]:Array<string>} = {}

constructor(private $scope: angular.IScope,
private $q: angular.IQService,
Expand All @@ -302,6 +322,7 @@ class WalletComponent {
private user: UserService) {

this.initLocalKeyStore()
this.initCreatedAddresses()
}

initLocalKeyStore() {
Expand Down Expand Up @@ -330,6 +351,24 @@ class WalletComponent {
this.flatten()
}

initCreatedAddresses() {
for (let i=0; i<window.localStorage.length; i++) {
let key = window.localStorage.key(i)
let data = key.match(/eth-address-created:(.+):(.+)/)
if (data) {
let acc = data[1], addr = data[2]
this.createdAddresses[acc] = this.createdAddresses[acc] || []
this.createdAddresses[acc].push(addr)
}
}
}

rememberAdressCreated(account: string, ethAddress: string) {
this.createdAddresses[account] = this.createdAddresses[account] || []
this.createdAddresses[account].push(ethAddress)
window.localStorage.setItem(`eth-address-created:${account}:${ethAddress}`,"1")
}

/* Iterates down all children of walletEntries and flattens them into the entries list */
flatten() {
this.$scope.$evalAsync(() => {
Expand Down Expand Up @@ -391,7 +430,7 @@ class WalletComponent {
remove($event, entry:WalletEntry) {
dialogs.prompt($event, 'Remove Wallet Entry',
`This completely removes the wallet entry from your device.
Please enter your pin code to confirm you wish to remove this entry`, '').then(
Please enter your Password (or Pin Code) to confirm you wish to remove this entry`, '').then(
pin => {
if (pin == entry.pin) {
this.localKeyStore.remove(entry.account)
Expand All @@ -402,7 +441,7 @@ class WalletComponent {
}

unlock($event, selectedWalletEntry: WalletEntry) {
dialogs.prompt($event, 'Enter Password (or Pin)', 'Please enter your password (or pin code) to unlock', '').then(
dialogs.prompt($event, 'Enter Password (or Pin)', 'Please enter your Password (or Pin Code) to unlock', '').then(
pin => {
let count = 0
this.walletEntries.forEach(walletEntry => {
Expand Down Expand Up @@ -520,19 +559,23 @@ class WalletComponent {

let index = walletEntry.currencies.indexOf(ethCurrencyAddressLoading)
ethCurrencyAddressLoading.wallet.addresses.forEach(address => {
if (address.inUse) {
let wasCreated = (this.createdAddresses[walletEntry.account]||[]).indexOf(address.address) != -1
if (address.inUse || wasCreated) {
let ethCurrencyBalance = new CurrencyBalance('Ethereum','ETH',address.address, address.privateKey)
ethCurrencyBalance.balance = Number(address.balance+"").toFixed(18)
ethCurrencyBalance.visible = walletEntry.expanded
ethCurrencyBalance.inUse = wasCreated ? false : true
walletEntry.currencies.splice(index, 0, ethCurrencyBalance)
index++;

address.tokensBalances.forEach(balance => {
let tokenBalance = new TokenBalance(balance.name, balance.symbol, balance.address)
tokenBalance.balance = utils.commaFormat(balance.balance)
tokenBalance.visible = walletEntry.expanded
ethCurrencyBalance.tokens.push(tokenBalance)
})
if (address.tokensBalances) {
address.tokensBalances.forEach(balance => {
let tokenBalance = new TokenBalance(balance.name, balance.symbol, balance.address)
tokenBalance.balance = utils.commaFormat(balance.balance)
tokenBalance.visible = walletEntry.expanded
ethCurrencyBalance.tokens.push(tokenBalance)
})
}
}
})

Expand Down Expand Up @@ -678,15 +721,18 @@ class WalletComponent {
$mdDialog.cancel()
}

$scope['vm'].okButtonClick = function () {
$scope['vm'].okButtonClick = function ($event) {
let walletEntry = $scope['vm'].data.selectedWalletEntry
let success = false
if (walletEntry) {
let node = walletEntry.currencies.find(c => c.isCurrencyAddressCreate && c.name == 'Ethereum')
node.createAddress()
success = node.createAddress(self)
walletEntry.toggle(true)
}
$mdDialog.hide(null).then(() => {

if (!success) {
dialogs.alert($event, 'Unable to Create Address', 'Make sure you use the previous address first before you can create a new address')
}
})
}

Expand Down Expand Up @@ -774,8 +820,8 @@ class WalletComponent {
<md-input-container flex>
<textarea rows="3" flex ng-model="vm.data.selectedWalletEntry.secretPhrase" readonly ng-trim="false"
id="wallet-secret-textarea"
style="font-family:monospace; font-size:16px; font-weight: bold; color: white; border: 1px solid white"></textarea>
<span id="wallet-secret-textarea" style="display:none">{{vm.data.selectedWalletEntry.secretPhrase}}</span>
</md-input-container>
</div>
Expand All @@ -784,9 +830,9 @@ class WalletComponent {
</md-dialog-content>
<md-dialog-actions layout="row">
<span flex></span>
<md-button class="md-warn" ng-click="vm.cancelButtonClick()" aria-label="Cancel">Cancel</md-button>
<md-button class="md-warn" ng-click="vm.cancelButtonClick($event)" aria-label="Cancel">Cancel</md-button>
<md-button ng-disabled="!vm.data.selectedWalletEntry || !vm.data.selectedWalletEntry.unlocked || !vm.data.selectedWalletEntry.bip44Compatible"
class="md-primary" ng-click="vm.okButtonClick()" aria-label="OK">OK</md-button>
class="md-primary" ng-click="vm.okButtonClick($event)" aria-label="OK">OK</md-button>
</md-dialog-actions>
</form>
</md-dialog>
Expand Down
2 changes: 2 additions & 0 deletions app/src/dialogs/about.ts
Expand Up @@ -32,6 +32,8 @@ module dialogs {
<p><a href="#" ng-click="vm.goTo('main')">Go to MAIN NET</a></p>
<p><a href="#" ng-click="vm.goTo('test')">Go to TEST NET</a></p>
<p><a href="#" ng-click="vm.goTo('beta')">Go to BETA NET</a></p>
<br>
<p>Ethereum API <u>Powered by <a href="https://ethplorer.io">Ethplorer.io</a></u></p>
<!--
<p><button onclick="gtag_report_conversion_signup(undefined)">Signup Test</button></p>
<p><button onclick="gtag_report_conversion_bid(undefined, Date.now()+'')">Bid Test</button></p>
Expand Down
7 changes: 7 additions & 0 deletions app/src/services/ServerService.ts
Expand Up @@ -74,6 +74,13 @@ class ServerService extends EventEmitter {
}
}

getAppDir(dirName) {
var os = this.getOS();
var path = require('path');
let dir = path.join(__dirname,'..','heatledger', dirName);
return path.resolve(dir)
}

startServer() {
if (this.isRunning) {
throw new Error('Server starting or already up, check server.isRunning before calling this method');
Expand Down
4 changes: 3 additions & 1 deletion app/src/services/currencies/ETHCurrency.ts
Expand Up @@ -64,7 +64,9 @@ class ETHCurrency implements ICurrency {
this.pendingTransactions.add(address, data.txHash, timestamp)
},
err => {
dialogs.alert($event, 'Send Ether Error', 'There was an error sending this transaction: '+JSON.stringify(err))
if (err) {
dialogs.alert($event, 'Send Ether Error', 'There was an error sending this transaction: '+JSON.stringify(err))
}
}
)
}
Expand Down

0 comments on commit 8949d16

Please sign in to comment.