Skip to content

Commit

Permalink
1.8.2 (#47)
Browse files Browse the repository at this point in the history
* fix bug in send from KT account with old keystore file

* update send input validation

* update fee preview

* remove webauthn

* bump version

* fix batch estimate test
  • Loading branch information
klassare authored Aug 21, 2020
1 parent 719ab51 commit e81d7d5
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 93 deletions.
58 changes: 1 addition & 57 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kukai",
"version": "1.8.0",
"version": "1.8.2",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand All @@ -9,7 +9,7 @@
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"stage-ghpages-mainnet": "ng lint --fix && ng build --prod && angular-cli-ghpages --repo \"[email protected]:kukai-wallet/kukai-wallet.github.io.git\" --branch staging",
"stage-ghpages-mainnet": "ng lint --fix && ng build --prod && angular-cli-ghpages --repo \"[email protected]:kukai-wallet/wallet.git\" --branch staging",
"stage-ghpages-testnet": "ng lint --fix && ng build --prod && angular-cli-ghpages --repo \"[email protected]:kukai-wallet/testnet.git\" --branch staging",
"deploy-preview-version": "ng lint --fix && ng build --prod && angular-cli-ghpages --repo \"[email protected]:kukai-wallet/preview.git\" --branch master",
"deploy-beta-version": "ng lint --fix && ng build --prod && angular-cli-ghpages --repo \"[email protected]:kukai-wallet/beta.git\" --branch master"
Expand All @@ -27,7 +27,6 @@
"@angular/platform-browser-dynamic": "^9.1.1",
"@angular/router": "^9.1.1",
"@ledgerhq/hw-transport-u2f": "^5.19.0",
"@ledgerhq/hw-transport-webauthn": "^5.19.0",
"@ng-bootstrap/ng-bootstrap": "^5.1.0",
"@ngx-translate/core": "11.0.1",
"@ngx-translate/http-loader": "4.0.0",
Expand Down
3 changes: 3 additions & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Release notes
## 1.8.2
* Various bug fixes and improvements in the send modal
* Remove webauthn due to incompatability with Safari
## 1.8.1
* Add support for manager.tz undelegation
* Add error pages and fix routing
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/send/send.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <H1>Send tez</H1>
<p *ngIf="this.isMultipleDestinations"></p>
<p class="fee"><ng-container *ngIf="!getTotalBurn() ; else burn">Fee: </ng-container>
<ng-template #burn>Fee & storage cost: </ng-template>
{{ getTotalCost() }}</p>
{{ getTotalCost(true) }}</p>
</div>
<div class="group">
<label>From address</label>
Expand Down Expand Up @@ -59,13 +59,13 @@ <H1>Send tez</H1>
</div>
<div class="group">
<label>Fee</label>
<input type="text" class="text" placeholder={{this.defaultTransactionParams.fee.toString()}} [(ngModel)]="fee">
<input type="text" (input)="updateMaxAmount()" (paste)="updateMaxAmount()" class="text" placeholder={{this.defaultTransactionParams.fee.toString()}} [(ngModel)]="fee">
</div>
</div>
<div class="row-group">
<div class="group">
<label>Storage limit</label>
<input type="text" class="text" placeholder={{this.defaultTransactionParams.storage.toString()}} [(ngModel)]="storage">
<input type="text" (input)="updateMaxAmount()" (paste)="updateMaxAmount()" class="text" placeholder={{this.defaultTransactionParams.storage.toString()}} [(ngModel)]="storage">
</div>
<div class="group">
<label>Max storage cost</label>
Expand Down
32 changes: 18 additions & 14 deletions src/app/components/send/send.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class SendComponent implements OnInit {
this.messageService.startSpinner('Signing transaction...');
let keys;
try {
keys = await this.walletService.getKeys(pwd, this.activeAccount.address);
keys = await this.walletService.getKeys(pwd, this.activeAccount.pkh);
} catch {
this.messageService.stopSpinner();
}
Expand Down Expand Up @@ -220,19 +220,21 @@ export class SendComponent implements OnInit {
updateMaxAmount() {
if (this.sendMax) {
const max = this.maxToSend(this.activeAccount);
let maxAmount = '0';
if (max.length && max.slice(0, 1) !== '-') {
this.amount = max;
} else {
this.amount = '0';
maxAmount = max;
}
if (this.amount !== maxAmount) {
this.amount = maxAmount;
}
}
}
maxToSend(account: Account): string {
if (account && (account instanceof ImplicitAccount)) {
let accountBalance = Big(account.balanceXTZ).div(1000000);
accountBalance = accountBalance.minus(this.fee ? Number(this.fee) : this.defaultTransactionParams.fee);
accountBalance = accountBalance.minus(this.fee && Number(this.fee) ? Number(this.fee) : this.defaultTransactionParams.fee);
if (!this.isMultipleDestinations) {
accountBalance = accountBalance.minus(this.storage ? Number(this.storage) / 1000 : this.defaultTransactionParams.burn);
accountBalance = accountBalance.minus(this.storage && Number(this.storage) ? Number(this.storage) / 1000 : this.defaultTransactionParams.burn);
} else {
accountBalance = accountBalance.minus(this.defaultTransactionParams.burn);
}
Expand Down Expand Up @@ -454,6 +456,7 @@ export class SendComponent implements OnInit {
if (res) {
console.log(res);
this.defaultTransactionParams = res;
this.updateMaxAmount();
}
this.latestSimError = '';
this.formInvalid = '';
Expand All @@ -471,6 +474,7 @@ export class SendComponent implements OnInit {
this.latestSimError = prevSimError;
if (this.isMultipleDestinations ? !this.toMultipleDestinationsString : !this.toPkh) {
this.defaultTransactionParams = zeroTxParams;
this.updateMaxAmount();
this.prevEquiClass = '';
}
}
Expand Down Expand Up @@ -522,7 +526,7 @@ export class SendComponent implements OnInit {
if (!this.inputValidationService.address(toPkh) || toPkh === this.activeAccount.address) {
return this.translate.instant('SENDCOMPONENT.INVALIDRECEIVERADDRESS');
} else if (!this.inputValidationService.amount(amount) ||
(finalCheck && (amount === '0' || amount === ''))) {
(finalCheck && (((amount === '0') || amount === '') && (toPkh.slice(0, 3) !== 'KT1')))) {
return this.translate.instant('SENDCOMPONENT.INVALIDAMOUNT');
} else if (!this.inputValidationService.gas(this.gas)) {
return this.translate.instant('SENDCOMPONENT.INVALIDGASLIMIT');
Expand Down Expand Up @@ -583,22 +587,22 @@ export class SendComponent implements OnInit {
}
return totalSent.toString();
}
getTotalCost(): string {
getTotalCost(display: boolean = false): string {
const totalFee = Big(this.getTotalFee()).plus(Big(this.getTotalBurn())).toString();
setTimeout(() => {
this.updateMaxAmount();
}, 100);
if (display && totalFee === '0') {
return '-';
}
return totalFee;
}
getTotalFee(): number {
if (this.fee !== '') {
if (this.fee !== '' && Number(this.fee)) {
return Number(this.fee);
}
return Number(this.defaultTransactionParams.fee);
}
getTotalBurn(): number {
if (this.storage) {
return (Number(this.storage) * this.transactions.length) / 1000;
if (this.storage !== '' && Number(this.storage)) {
return Number(Big(this.storage).mul(this.transactions.length).div('1000').toString());
}
return Number(this.defaultTransactionParams.burn);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/estimate/estimate.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('EstimateService', () => {
gasLimit: 10287,
storageLimit: 257
}],
fee: 0.003988,
fee: 0.003991,
burn: 0.257,
gas: 11980,
storage: 86,
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/estimate/estimate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class EstimateService {
storageLimit: 60000
};
for (const tx of transactions) {
if (!invoke) {
if (tx.to.slice(0, 3) !== 'KT1') {
tx.amount = 0.000001;
}
tx.gasLimit = simulation.gasLimit;
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/import/import.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe('[ ImportService ]', () => {
describe('> Legacy v3', async () => {
beforeEach(() => {
spyOn(conseil, 'getContractAddresses').and.callFake(async function(address: string) {
if (address.slice(0,2) === 'tz') {
if (address.slice(0, 2) === 'tz') {
return ['KT1KwPDCVmkrXQ2ZKWhVAiiFzYxiXCEyhE7U'];
} else {
return [];
Expand Down
14 changes: 1 addition & 13 deletions src/app/services/ledger/ledger.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core';
import 'babel-polyfill';
import TransportU2F from '@ledgerhq/hw-transport-u2f';
import TransportWebAuthn from '@ledgerhq/hw-transport-webauthn';
import Tezos from '@obsidiansystems/hw-app-xtz';
import { OperationService } from '../operation/operation.service';
import { MessageService } from '../message/message.service';
Expand All @@ -14,9 +13,7 @@ export class LedgerService {
constructor(
private operationService: OperationService,
private messageService: MessageService
) {
this.setTransport();
}
) {}
async setTransport() {
if (!this.transport) {
console.log('Trying to use U2F for transport...');
Expand All @@ -27,15 +24,6 @@ export class LedgerService {
console.log('Couldn\'t use U2F for transport!');
}
}
if (!this.transport) {
console.log('Trying to use WebAuthn for transport...');
try {
this.transport = await TransportWebAuthn.create();
console.log('Transport is now set to use WebAuthn!');
} catch (e) {
console.log('Couldn\'t use WebAuthn for transport!');
}
}
}
async transportCheck() {
if (!this.transport) {
Expand Down

0 comments on commit e81d7d5

Please sign in to comment.