Skip to content

Commit

Permalink
Staging (#12)
Browse files Browse the repository at this point in the history
* topbar

* offline signing option

* decode signed operation hash UI

* fix new data structure

* update api for operations

* Account table re-adjusted

* set up zeronet

* minor changes

* delegator pipe update

* truncatePipe

* time-ago pipe

* tooltips for app-activity

* add class for constants

* switch to betanet

* update betanet chain_id

* ActivityComponent revamped

* fix signed decoding

* move online signing warning

* tweak row padding

* minor UI fix

* minor fix

* small change buttons

* context-menu for electron

* fix TypeError at Menu.popup

* allow to unset delegate in integrity check

* code cleanup

* change walletService to public in home-page

* delegate UI fix

* minor text changes

* minor spelling

* spelling

* test of TranslateService

* fix account import bug

* update to betanet

* test code transferred to homePage and Language button

* homePageComponent and startComponent translated into fr

* 3 more components translated

* ru and jp json completed

* 6 components translated

* finishing translation

* translation completed

* fix electron issue

* update css for home-page component

* fix start component height

* lifecycle hook for 'Show help' btn

* top-bar-btn vertical aligned

* translation text

* update for zeronet

* first send modal modified

* update operation service for multiple transactions

* send modals 90% completed

* Fix Show More btn

* Show More btn in activityComponent

* more btn

* added portuguese

* jp updated

* Fee input added

* korean language added

* minor change

* version number

* fix translation race condition

* add support for multi-send in account

* add alphanet

* add total fee for multi-send

* randomize api server

* fix some translation race errors

* fix operations from api

* fix css heights

* fix roundoff error and update delegate-pipe + gas limit

* small fix activity component

* small fix delegator name
  • Loading branch information
klassare authored and Dee297 committed Oct 11, 2018
1 parent 09fccd3 commit 0978239
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 52 deletions.
31 changes: 27 additions & 4 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kukai",
"version": "1.2.0",
"version": "1.2.1",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand Down Expand Up @@ -39,6 +39,7 @@
"@types/crypto-js": "^3.1.39",
"aes-js": "^3.1.1",
"angular-cli-ghpages": "^0.5.2",
"big.js": "^5.1.2",
"bip39": "^2.4.0",
"bootstrap": "^4.0.0",
"bs58": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/activity/activity.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<!-- Amount -->
<td class="amount table-cell">
<ng-container *ngIf="transaction.amount">
{{ transaction.amount / 1000000 | number:'1.0' }} &#42793;
{{ transaction.amount / 1000000 | number:'1.0-6' }} &#42793;
</ng-container>
</td>

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/delegate/delegate.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h4 class="modal-title pull-left"> {{ 'DELEGATECOMPONENT.TITLE2' | translate }}
</div>
<div class="modal-body">
<p> {{ 'DELEGATECOMPONENT.ACCOUNT' | translate }} {{ activePkh }}
<BR> {{ 'DELEGATECOMPONENT.DELEGATE' | translate }} {{ toPkh }}
<BR> {{ 'DELEGATECOMPONENT.DELEGATE' | translate }} {{ toPkh | delegatorName }}
<BR> {{ 'DELEGATECOMPONENT.FEE' | translate }} {{ fee | number:'1.0' }}&#42793;
</p>
<div class="row">
Expand Down
1 change: 1 addition & 0 deletions src/app/components/delegate/delegate.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { WalletService } from '../../services/wallet.service';
import { CoordinatorService } from '../../services/coordinator.service';
import { OperationService } from '../../services/operation.service';
import { ExportService } from '../../services/export.service';
import { DelegatorNamePipe } from '../../pipes/delegator-name.pipe';

@Component({
selector: 'app-delegate',
Expand Down
6 changes: 4 additions & 2 deletions src/app/components/send/send.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ <h4 class="modal-title pull-left"> {{ 'SENDCOMPONENT.TITLE2' | translate }} </h4
<p>
{{ 'SENDCOMPONENT.FROM' | translate }} {{ activePkh }}
<BR>
<span *ngIf="isMultipleDestinations"> Total Sent: {{ totalAmount() | number:'1.0-6' }}&#42793; </span>
<span *ngIf="isMultipleDestinations"> Total Sent: {{ totalAmount() | number:'1.0-6' }}&#42793;
<BR> Total fee: {{ totalFee() | number:'1.0-6' }}&#42793;
</span>
<span *ngIf="!isMultipleDestinations">
{{ 'SENDCOMPONENT.TO' | translate }} {{ transactions[0].to }}
<BR> {{ 'SENDCOMPONENT.AMOUNT' | translate }} {{ transactions[0].amount | number:'1.0-6' }}&#42793;
<BR> Fee: {{ fee | number:'1.0-6' }}&#42793;
</span>
<BR> Total fee {{ totalFee() | number:'1.0-6' }}&#42793;
<BR><BR>
<!--
<ng-container *ngFor="let transaction of transactions">
Expand Down
1 change: 1 addition & 0 deletions src/app/components/send/send.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class SendComponent implements OnInit {
this.formInvalid = this.checkInput();
if (!this.formInvalid) {
if (!this.amount) { this.amount = '0'; }

if (!this.fee) { this.fee = '0'; }
if (!this.toMultipleDestinationsString) { this.toMultipleDestinationsString = ''; }
if (this.isMultipleDestinations) {
Expand Down
72 changes: 54 additions & 18 deletions src/app/pipes/delegator-name.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,72 @@ import { Pipe, PipeTransform } from '@angular/core';
})
export class DelegatorNamePipe implements PipeTransform {
map: Map<string, string> = new Map([
['tz1XQ7SRj4QQWjaeebNd8dFwuTrCot3GGDRF', 'Tz Baker'], // no longer listed
// ['tz1L5GqtsKbasq9yD4hvtGC7VprPXDPmeb9V', 'Tezos Bakes'], no longer active
['tz1TDSmoZXwVevLTEvKCTHWpomG76oC9S2fJ', 'Tezos Community'],
['tz1eEnQhbwf6trb8Q8mPb2RaPkNk2rN7BKi8', 'Cryptium Labs'],
['tz1abTjX2tjtMdaq5VCzkDtBnMSCFPW2oRPa', 'TEZ Rocket'],
['tz1NortRftucvAkD1J58L32EhSVrQEWJCEnB', 'Bake’n’Rolls'],
['tz1LLNkQK4UQV6QcFShiXJ2vT2ELw449MzAA', 'TezoSteam'],
['tz1bHzftcTKZMTZgLLtnrXydCm6UEqf4ivca', 'Tezos Vote'],
['tz1YTyvABUyhE7JHpxMVBVqjZnZM4ofMrWKE', 'Tezos Delegate EU'],
['tz1WCd2jm4uSt4vntk4vSuUWoZQGhLcDuR9q', 'Happy Tezos'],
['tz1LLNkQK4UQV6QcFShiXJ2vT2ELw449MzAA', 'TezoSteam'],
['tz1Xek93iSXXckyQ6aYLVS5Rr2tge2en7ZxS', 'XTZ Delegate'],
['tz1TcH4Nb3aHNDJ7CGZhU7jgAK1BkSP4Lxds', 'XTZ Antipodes'],
['tz1iLbZZ9uoRuVJCrZ9ZwiJMpfzhy3c67mav', 'AirBie'],
['tz1fZ767VDbqx4DeKiFswPSHh513f51mKEUZ', 'Tezos Bakery'],
['tz1YTyvABUyhE7JHpxMVBVqjZnZM4ofMrWKE', 'Tezos Delegate EU'],
['tz1UUgPwikRHW1mEyVZfGYy6QaxrY6Y7WaG5', 'Tez Patisserie'],
['tz1PesW5khQNhy4revu2ETvMtWPtuVyH2XkZ', 'Tz Dutch'],
['tz1WpeqFaBG9Jm73Dmgqamy8eF8NWLz9JCoY', 'Staking Facilities'],
['tz1L3vFD8mFzBaS8yLHFsd7qDJY1t276Dh8i', 'Zednode'],
['tz1iZEKy4LaAjnTmn2RuGDf2iqdAQKnRi8kY', 'Tezzigator'],
['tz1YKh8T79LAtWxX29N5VedCSmaZGw9LNVxQ', 'TezosBr'],
['tz1WCd2jm4uSt4vntk4vSuUWoZQGhLcDuR9q', 'Happy Tezos'],
['tz1hThMBD8jQjFt78heuCnKxJnJtQo9Ao25X', 'Tezos Chef'],
['tz3bEQoFCZEEfZMskefZ8q8e4eiHH1pssRax', 'Ceibo XTZ'], // Listing Error
['tz1Tnjaxk6tbAeC2TmMApPh8UsrEVQvhHvx5', 'Crypto Delegate'],
['tz1L3vFD8mFzBaS8yLHFsd7qDJY1t276Dh8i', 'Zednode'],
['tz1iLbZZ9uoRuVJCrZ9ZwiJMpfzhy3c67mav', 'AirBie'],
['tz1ZTG13gkvouxSANka3HG3uys8C5gu3DPXZ', 'Just a Baker'],
['tz1PYLN9TsKZHfn2GtrXnxkeGvahmYdBTG5v', 'Tezos Bakes'],
['tz1Zhv3RkfU2pHrmaiDyxp7kFZpZrUCu1CiF', 'TZBake'],
['tz3bEQoFCZEEfZMskefZ8q8e4eiHH1pssRax', 'Ceibo XTZ'],
['tz1YKh8T79LAtWxX29N5VedCSmaZGw9LNVxQ', 'TezosBr'],
['tz1VYQpZvjVhv1CdcENuCNWJQXu1TWBJ8KTD', 'Tezos Tokyo'],
['tz1PriNQyDC7d5ccPAD96ugujYy5YbdGLdQ5', 'Tezos Baker JP'],
['tz1Z1WwoqgRFbLE3YNdYRpCx44NSfiMJzeAG', 'Bakemon'],
['tz1bkg7rynMXVcjomoe3diB4URfv8GU2GAcw', 'tz Bank'],
['tz1Lhf4J9Qxoe3DZ2nfe8FGDnvVj7oKjnMY6', 'Tez Baker'], // Listing Error
['tz1YdCPrYbksK7HCoYKDyzgfXwY16Fy9rrGa', 'Norn Delegate'],
['tz1LesY3S4wfe15SNm1W3qJmQzWxLqVjTruH', 'Xtez.io'],
['tz1Tnjaxk6tbAeC2TmMApPh8UsrEVQvhHvx5', 'Crypto Delegate'],
['tz1RCFbB9GpALpsZtu6J58sb74dm8qe6XBzv', 'Staked'],
['tz1Yc6ATtfUJyDjHwJ8WoVL22sJueDenueke', 'TezDele Baker A'],
['tz1SdwBHocSrcuMFNLPUg4LPRfx9eaqjVUEL', 'TezDele Baker B'],
['tz1LBEKXaxQbd5Gtzbc1ATCwc3pppu81aWGc', 'Tez-Baking.com']
['tz1YvG6poSGhPLTdzbzCmqShMndzoyhyVg7J', 'Tezos Baking Club'],
['tz1Z1WwoqgRFbLE3YNdYRpCx44NSfiMJzeAG', 'Bakemon'],
['tz1iMAHAVpkCVegF9FLGWUpQQeiAHh4ffdLQ', 'Wetez Wallet'],
['tz1Lhf4J9Qxoe3DZ2nfe8FGDnvVj7oKjnMY6', 'Tez Baker'],
['tz1Suih9uWEnubDeqCTCEfueSCGWYohjyaA5', 'XTZ Black'],
['tz1eZwq8b5cvE2bPKokatLkVMzkxz24z3Don', 'You Loaf We Bake'],
['tz1hAYfexyzPGG6RhZZMpDvAHifubsbb6kgn', 'Tezos Suisse'],
['tz1S1Aew75hMrPUymqenKfHo8FspppXKpW7h', 'Tezos Aus'],
['tz1YdCPrYbksK7HCoYKDyzgfXwY16Fy9rrGa', 'Norn Delegate'],
['tz1SohptP53wDPZhzTWzDUFAUcWF6DMBpaJV', 'Hayek Lab'],
['tz1aRhFErGMgL57DYHMT1vYwv7PzsJN1chrk', 'Baked Tezos'],
['tz1b5ppWdFzLHV2i11WcvM7bYVQbQC4K6ZVM', 'TeZetetic'],
['tz1NqKH9D5HdfvoEQssMS5Up13CVypVxLA1k', 'Cypher Baker'],
['tz1PYLN9TsKZHfn2GtrXnxkeGvahmYdBTG5v', 'Tezos Bakes'],
['tz1Zhv3RkfU2pHrmaiDyxp7kFZpZrUCu1CiF', 'TZ Bake'],
['tz1Vd1rXpV8hTHbFXCXN3c3qzCsgcU5BZw1e', 'Tz Node'],
['tz1fP9PoNWMpAaiPcBEb1gqQTskUAFNDiWD4', 'Tezocracy'],
['tz1LBEKXaxQbd5Gtzbc1ATCwc3pppu81aWGc', 'Tez Baking'],
['tz1bkg7rynMXVcjomoe3diB4URfv8GU2GAcw', 'Tz Bank'],
['tz1Lh9jeLSWDHYy8AshvG2dpNQseDaHg7cms', 'Tezos Spanish'],
['tz1VHFxUuBhwopxC9YC9gm5s2MHBHLyCtvN1', 'Hyper Blocks Pro'],
['tz1WnfXMPaNTBmH7DBPwqCWs9cPDJdkGBTZ8', 'Tezos HODL'],
['tz1go7f6mEQfT2xX2LuHAqgnRGN6c2zHPf5c', 'Stakery'],
['tz1bakeKFwqmtLBzghw8CFnqFvRxLj849Vfg', 'Tez Milk'],
['tz1eFXLaCUcKbhXkLBGUGMGNY9tKHjWGG25V', 'Tezos Node Spain'],
['tz1ZQppA6UerMz5CJtGvZmmB6z8L9syq7ixu', 'First Block'],
['tz1QGZ3dD2YpRKZ4APeso6EXTeyCUUkw6MQC', 'Tezos BC'],
['tz1NXPdPC2DfyA5ohitnS6ryqrDKbFJeu5Nn', 'Tez Boss'],
['tz1Z3KCf8CLGAYfvVWPEr562jDDyWkwNF7sT', 'Hot Stake'],
['tz1KfEsrtDaA1sX7vdM4qmEPWuSytuqCDp5j', 'XTZ Master'],
['tz1TgvirXEwVJPg1cCrxT9zFubdzw7Ng6Ke9', 'Tezos Moon'],
['tz2LBtbMMvvguWQupgEmtfjtXy77cHgdr5TE', 'Tez Central'],
['tz1ZKi4VrDMEQpypn2NTn9pPbZL3xLRkETLA', 'XTZ Baker'],
['tz1MowoYvqgxhKToQMAmGgTtjfZcRfS733JY', 'Stake Bake'],
['tz1RV1MBbZMR68tacosb7Mwj6LkbPSUS1er1', 'Baking Tacos'],
['tz1aiYKXmSRckyJ9EybKmpVry373rfyngJU8', 'View Nodes'],
['tz1PeZx7FXy7QRuMREGXGxeipb24RsMMzUNe', 'Tezos Panda'],
['tz1bTArEJxjYZKdXsMwLWixtpTnXNq6EZydC', 'Stack Tezos'],
['tz1d6Fx42mYgVFnHUW8T8A7WBfJ6nD9pVok8', 'My Tezos Baking']
]);

transform(pkh: string): string {
Expand Down
35 changes: 11 additions & 24 deletions src/app/services/operation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Buffer } from 'buffer';
import * as libs from 'libsodium-wrappers';
import * as Bs58check from 'bs58check';
import * as bip39 from 'bip39';
import Big from 'big.js';

import { TranslateService } from '@ngx-translate/core'; // Multiple instances created ?

Expand Down Expand Up @@ -40,7 +41,7 @@ export class OperationService {
TZ: new Uint8Array([3, 99, 29]),
KT: new Uint8Array([2, 90, 121])
};
toMicro = 1000000;
microTez = new Big(1000000);
constructor(
private http: HttpClient,
private translate: TranslateService,
Expand All @@ -50,7 +51,6 @@ export class OperationService {
Returns an observable for the activation of an ICO identity
*/
activate(pkh: string, secret: string): Observable<any> {
console.log(pkh + ' : ' + secret);
return this.http.get(this.nodeURL + '/chains/main/blocks/head/hash', {})
.flatMap((hash: any) => {
const fop: any = {
Expand All @@ -72,7 +72,6 @@ export class OperationService {
return this.http.post(this.nodeURL + '/injection/operation',
JSON.stringify(sopbytes), httpOptions)
.flatMap((final: any) => {
console.log(JSON.stringify(final));
return this.opCheck(final);
});
});
Expand Down Expand Up @@ -106,27 +105,24 @@ export class OperationService {
originate(pkh: string, amount: number, fee: number = 0, keys: KeyPair): Observable<any> {
return this.http.get(this.nodeURL + '/chains/main/blocks/head/hash', {})
.flatMap((hash: string) => {
console.log(JSON.stringify(hash));
return this.http.get(this.nodeURL + '/chains/main/blocks/head/context/contracts/' + pkh + '/counter', {})
.flatMap((actions: number) => {
console.log('number: ' + actions);
return this.http.get(this.nodeURL + '/chains/main/blocks/head/context/contracts/' + pkh + '/manager_key', {})
.flatMap((manager: any) => {
console.log('managerKey: ' + JSON.stringify(manager));
let counter: number = Number(actions);
const fop: any = {
branch: hash,
contents: [
{
kind: 'origination',
source: pkh,
fee: (fee * this.toMicro).toString(),
fee: this.microTez.times(fee).toString(),
counter: (++counter).toString(),
gas_limit: '0',
storage_limit: '0',
managerPubkey: keys.pkh, // Mainnet
// manager_pubkey: keys.pkh, // Zeronet
balance: (amount * this.toMicro).toString(),
balance: this.microTez.times(amount).toString(),
spendable: true,
delegatable: true
}
Expand Down Expand Up @@ -181,11 +177,11 @@ export class OperationService {
fop.contents.push({
kind: 'transaction',
source: from,
fee: (fee * this.toMicro).toString(),
fee: this.microTez.times(fee).toString(),
counter: (++counter).toString(),
gas_limit: '200',
gas_limit: '127',
storage_limit: '0',
amount: (transactions[i].amount * this.toMicro).toString(),
amount: this.microTez.times(transactions[i].amount).toString(),
destination: transactions[i].to,
});
}
Expand All @@ -211,7 +207,7 @@ export class OperationService {
{
kind: 'delegation',
source: from,
fee: (fee * this.toMicro).toString(),
fee: this.microTez.times(fee).toString(),
counter: (++counter).toString(),
gas_limit: '0',
storage_limit: '0',
Expand Down Expand Up @@ -297,7 +293,6 @@ export class OperationService {
}
return this.http.post(this.nodeURL + '/chains/main/blocks/head/helpers/preapply/operations', [fop])
.flatMap((parsed: any) => {
console.log(JSON.stringify(parsed));
let newPkh = null;
for (let i = 0; i < parsed[0].contents.length; i++) {
if (parsed[0].contents[i].kind === 'origination') {
Expand All @@ -317,7 +312,6 @@ export class OperationService {
throw new Error(applied[0].contents[i].metadata.operation_result.errors[0].id);
}
}
console.log('applied part: ' + JSON.stringify(applied[0].contents[0].metadata.operation_result.status));
}
errHandler(error: any): Observable<any> {
if (error.error && error.error[0] && error.error[0].id) {
Expand Down Expand Up @@ -624,26 +618,19 @@ export class OperationService {
};
}
decodeContractId(hex: string): string {
console.log('hex: ' + hex);
if (hex.slice(0, 2) === '00') {
console.log('tz');
return this.decodePkh(hex.slice(2, 44));
} else if (hex.slice(0, 2) === '01') {
console.log('KT1');
return this.b58cencode(this.hex2buf(hex.slice(2, 42)), this.prefix.KT);
} else {
console.log('Unsupported tags');
throw new Error('TagError');
}
}
/*
Validate operation bytes
*/
validOpBytes(fop: any, opbytes: string): boolean {
console.log('Validating...');
const fop2: any = this.decodeOpBytes(opbytes);
console.log('1: ' + JSON.stringify(fop));
console.log('2: ' + JSON.stringify(fop2));
if (JSON.stringify(fop) === JSON.stringify(fop2)) {
return true; // Client and node agree the opbytes are correct!
}
Expand All @@ -670,7 +657,7 @@ export class OperationService {
destinationTmp = this.translate.instant('OPERATIONSERVICE.DESTINATION');
amountTmp = this.translate.instant('OPERATIONSERVICE.AMOUNT');
output.push(destinationTmp + ' ' + fop.contents[i].destination);
output.push(amountTmp + ' ' + (Number(fop.contents[i].amount) / this.toMicro).toString() + ' tez');
output.push(amountTmp + ' ' + Big(Number(fop.contents[i].amount)).div(this.microTez).toString() + ' tez');
// output.push('Destination: ' + fop.contents[i].destination);
// output.push('Amount: ' + (Number(fop.contents[i].amount) / this.toMicro).toString() + ' tez');
} else if (fop.contents[i].kind === 'origination') {
Expand All @@ -680,7 +667,7 @@ export class OperationService {
balanceTmp = this.translate.instant('OPERATIONSERVICE.BALANCE');
// output.push(managerTmp + ' ' + fop.contents[i].managerPubkey); // betanet
output.push(managerTmp + ' ' + fop.contents[i].manager_pubkey); // zeronet
output.push(balanceTmp + ' ' + (Number(fop.contents[i].balance) / this.toMicro).toString() + ' tez');
output.push(balanceTmp + ' ' + Big(Number(fop.contents[i].balance)).div(this.microTez).toString() + ' tez');
// output.push('Manager: ' + fop.contents[i].managerPubkey);
// output.push('Balance: ' + (Number(fop.contents[i].balance) / this.toMicro).toString() + ' tez');
} else if (fop.contents[i].kind === 'delegation') {
Expand All @@ -697,7 +684,7 @@ export class OperationService {

let feeTmp = '';
feeTmp = this.translate.instant('OPERATIONSERVICE.FEE');
output.push(feeTmp + ' ' + (Number(fop.contents[i].fee) / this.toMicro).toString() + ' tez');
output.push(feeTmp + ' ' + Big(Number(fop.contents[i].fee)).div(this.microTez).toString() + ' tez');
// output.push('Fee: ' + (Number(fop.contents[i].fee) / this.toMicro).toString() + ' tez');
if (i + 1 < fop.contents.length) {
output.push('');
Expand Down
2 changes: 1 addition & 1 deletion src/electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kukai",
"version": "1.2.0",
"version": "1.2.1",
"main": "main.js",
"scripts": {
"start": "electron ."
Expand Down

0 comments on commit 0978239

Please sign in to comment.