Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
chore: merge develop into master (#363)
Browse files Browse the repository at this point in the history
* refactor: qr-code regex (#298)

* feat: add top wallets list (#312)

* fix: show keyboard on ios (#297)

* refactor: use the activeDelegates number provided by the network (#336)

* refactor: 51 delegate limit  to activeDelegates limit

* changes

* fix: update `activeDelegates` on node configuration response

* test: fix type

* test: fix trailing whitespace

* fix: update the wallet in the correct profile (#339)

* chore: fix some punctuation mistakes (#340)

* chore: bump to 1.4.3 (#342)

* chore: use organization-wide GitHub Configuration (#343)

* chore: update ark-ts to change the peer config endpoint (#344)

* refactor: display the remote error message when it exists

* chore: bump to 1.4.4

* perf: clear intervals when navigating to another page

* fix: get fees for 7 days instead of 30

* fix: avoid bignumber error when typing decimals

* fix: display zero balance in the wallets list

* fix: continue updating current wallet when navigating to others pages

* fix: do not hang the app while finding a good peer

* refactor: migrate to v2 api (#350)

* refactor: migrate to v2 api

* fix: fetch and post transactions

* feat: handle enter key when manually importing wallet (#354)

* refactor: use activeDelegates provided by network (#355)

* refactor: use activeDelegates provided by network

* fix: use StoredNetwork instead of Network

* fix: handle transaction amount as a string (#356)

* fix: handle transaction amount as a string

* fix: handle NaN on equivalent amount in fiat

* fix: change the send amount only on blur

* fix: lint

* fix: typo preminned to premined (#357)

* chore: bump to 1.5.0 (#359)
  • Loading branch information
luciorubeens committed Jul 12, 2019
1 parent 76b9cd5 commit a8ad876
Show file tree
Hide file tree
Showing 21 changed files with 3,280 additions and 2,991 deletions.
2 changes: 1 addition & 1 deletion config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ark.wallet.mobile" version="1.4.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="io.ark.wallet.mobile" version="1.5.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Ark Mobile</name>
<description>ARK</description>
<author email="lucio@ark.io" href="http://ark.io/">Ark Ecosystem</author>
Expand Down
5,790 changes: 2,914 additions & 2,876 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "ark-mobile",
"version": "1.4.4",
"version": "1.5.0",
"author": {
"name": "Lucio Rubens",
"email": "luciorubeens@gmail.com",
Expand Down Expand Up @@ -60,7 +60,7 @@
"@ngx-translate/http-loader": "2.0.0",
"android-versions": "^1.3.0",
"angular2-qrcode": "^2.0.1",
"ark-ts": "^0.3.19",
"ark-ts": "^0.4.0",
"arkjs": "github:arkecosystem/ark-js#master",
"bcryptjs": "^2.4.3",
"bignumber.js": "^6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/app/app.constants.ts
@@ -1,5 +1,5 @@
// BLOCKCHAIN
export const BLOCKCHAIN_PREMINNED = 125000000;
export const BLOCKCHAIN_PREMINED = 125000000;

// WALLET
export const ARKTOSHI_DP = 8;
Expand Down Expand Up @@ -47,4 +47,4 @@ export const PIN_ATTEMPTS_TIMEOUT_MILLISECONDS = 30 * 1000;
export const PRIVACY_POLICY_URL = 'https://ark.io/PrivacyPolicy.txt';
export const URI_QRCODE_SCHEME_PREFIX = 'ark:';
export const NUM_ACTIVE_DELEGATES = 51;
export const TOP_WALLETS_TO_FETCH = 100;
export const TOP_WALLETS_TO_FETCH = 50;
1 change: 1 addition & 0 deletions src/components/amount/amount.html
Expand Up @@ -14,6 +14,7 @@
name="amount"
[(ngModel)]="amount"
(input)="onInputToken()"
(blur)="onBlurToken()"
[placeholder]="tokenPlaceholder">
</ion-input>
</ion-item>
Expand Down
14 changes: 12 additions & 2 deletions src/components/amount/amount.ts
Expand Up @@ -53,14 +53,24 @@ export class AmountComponent implements OnInit {
public onInputToken() {
const precision = this.marketCurrency.code === 'btc' ? 8 : 2;
try {
this.amount = Number((new BigNumber(this.amount.toString())).toFixed(constants.ARKTOSHI_DP));
this.amountEquivalent = +(this.amount * this.marketCurrency.price).toFixed(precision);
const amount = Number((new BigNumber(this.amount.toString())).toFixed(constants.ARKTOSHI_DP));
const amountEquivalent = +(amount * this.marketCurrency.price).toFixed(precision);
this.amountEquivalent = amountEquivalent;
} catch {
return;
}
this.hasChanged();
}

public onBlurToken() {
try {
this.amount = Number(new BigNumber(this.amount).toFixed(constants.ARKTOSHI_DP));
} catch {
this.amount = 0;
}
this.onInputToken();
}

public onInputFiat() {
this.amount = +(this.amountEquivalent / this.marketCurrency.price).toFixed(8);
this.hasChanged();
Expand Down
12 changes: 10 additions & 2 deletions src/models/transaction.ts
@@ -1,5 +1,6 @@
import BigNumber from 'bignumber.js';
import moment from 'moment';
import { Transaction as TransactionModel, TransactionType } from 'ark-ts/model';
import arkConfig from 'ark-ts/config';

import { MarketCurrency, MarketHistory, MarketTicker } from '@models/market';

Expand Down Expand Up @@ -47,6 +48,8 @@ export class Transaction extends TransactionModel {
}

this.date = new Date(this.getTimestamp() * 1000);
this.amount = new BigNumber(input['amount']).toNumber();
this.fee = new BigNumber(input['fee']).toNumber();
delete self.network;

return self;
Expand All @@ -69,11 +72,16 @@ export class Transaction extends TransactionModel {
price = currency ? currency.price : 0;
} else {
price = market.getPriceByDate(marketCurrency.code, this.date);

if (!price) {
price = market.getPriceByDate(marketCurrency.code, moment(this.date).subtract(1, 'd').toDate());
}
}

const amount = ArkUtility.arktoshiToArk(this.getAmount(), true);
const raw = amount * price;

return amount * price;
return isNaN(raw) ? 0 : raw;
}

getTimestamp() {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/delegates/delegates.html
Expand Up @@ -38,7 +38,7 @@
<ion-col col-2 text-center><span class="rate">{{ delegate?.rate }}</span></ion-col>
<ion-col col-8>
<span class="username">{{ delegate?.username }}</span>
<ion-badge item-end *ngIf="isSameDelegate(delegate?.publicKey)" color="danger">{{ 'DELEGATES_PAGE.VOTED' | translate | lowercase }}</ion-badge>
<ion-badge *ngIf="isSameDelegate(delegate?.publicKey)" color="danger">{{ 'DELEGATES_PAGE.VOTED' | translate | lowercase }}</ion-badge>
</ion-col>
<ion-col col-2 text-center><span class="percentage">{{ (delegate?.approval).toFixed(2) }}%</span></ion-col>
</ion-row>
Expand Down
22 changes: 11 additions & 11 deletions src/pages/delegates/delegates.ts
Expand Up @@ -5,9 +5,10 @@ import { Subject } from 'rxjs/Subject';
import { ArkApiProvider } from '@providers/ark-api/ark-api';
import { UserDataProvider } from '@providers/user-data/user-data';
import { ToastProvider } from '@providers/toast/toast';
import { Delegate, Network, VoteType, TransactionVote } from 'ark-ts';
import { Delegate, VoteType, TransactionVote } from 'ark-ts';

import { Wallet, WalletKeys } from '@models/model';
import { StoredNetwork } from '@models/stored-network';

import * as constants from '@app/app.constants';
import { PinCodeComponent } from '@components/pin-code/pin-code';
Expand All @@ -32,10 +33,10 @@ export class DelegatesPage implements OnDestroy {
public standByDelegates: Delegate[];

public supply = 0;
public preMinned: number = constants.BLOCKCHAIN_PREMINNED;
public preMined: number = constants.BLOCKCHAIN_PREMINED;

public rankStatus = 'active';
public currentNetwork: Network;
public currentNetwork: StoredNetwork;
public slides: string[] = [
'active',
'standBy',
Expand Down Expand Up @@ -99,7 +100,7 @@ export class DelegatesPage implements OnDestroy {
}

getTotalForged() {
const forged = this.supply === 0 ? 0 : this.supply - this.preMinned;
const forged = this.supply === 0 ? 0 : this.supply - this.preMined;

return forged;
}
Expand All @@ -121,20 +122,19 @@ export class DelegatesPage implements OnDestroy {
delegatePublicKey: this.selectedDelegate.publicKey,
passphrase: keys.key,
secondPassphrase: keys.secondKey,
fee: this.selectedFee,
type,
};

this.arkApiProvider.api.transaction.createVote(data).subscribe((transaction) => {
transaction.fee = this.selectedFee; // The transaction will be re-signed
this.arkApiProvider.transactionBuilder.createVote(data).subscribe((transaction) => {
this.confirmTransaction.open(transaction, keys);
});
}

private fetchCurrentVote() {
if (!this.currentWallet) { return; }

this.arkApiProvider.api.account
.votes({ address: this.currentWallet.address })
this.arkApiProvider.client.getWalletVotes(this.currentWallet.address)
.takeUntil(this.unsubscriber$)
.subscribe((data) => {
if (data.success && data.delegates.length > 0) {
Expand All @@ -160,14 +160,14 @@ export class DelegatesPage implements OnDestroy {
this.zone.runOutsideAngular(() => {
this.arkApiProvider.delegates.subscribe((data) => this.zone.run(() => {
this.delegates = data;
this.activeDelegates = this.delegates.slice(0, constants.NUM_ACTIVE_DELEGATES);
this.standByDelegates = this.delegates.slice(constants.NUM_ACTIVE_DELEGATES, this.delegates.length);
this.activeDelegates = this.delegates.slice(0, this.currentNetwork.activeDelegates);
this.standByDelegates = this.delegates.slice(this.currentNetwork.activeDelegates, this.delegates.length);
}));
});

this.onUpdateDelegates();
this.fetchCurrentVote();
this.arkApiProvider.fetchDelegates(constants.NUM_ACTIVE_DELEGATES * 2).subscribe();
this.arkApiProvider.fetchDelegates(this.currentNetwork.activeDelegates * 2).subscribe();
}

ngOnDestroy() {
Expand Down
14 changes: 0 additions & 14 deletions src/pages/network-status/network-status.html
Expand Up @@ -21,27 +21,13 @@ <h4 item-content class="content">
</ion-label>
</ion-item>

<ion-item>
<ion-label stacked>
<p ion-text>{{ 'NETWORKS_PAGE.DELAY' | translate }}</p>
<h4 item-content class="content">{{ currentPeer?.delay }}</h4>
</ion-label>
</ion-item>

<ion-item>
<ion-label stacked>
<p ion-text>{{ 'NETWORKS_PAGE.HEIGHT' | translate }}</p>
<h4 item-content class="content">{{ currentPeer?.height }}</h4>
</ion-label>
</ion-item>

<ion-item>
<ion-label stacked>
<p ion-text>{{ 'STATUS' | translate }}</p>
<h4 item-content class="content">{{ currentPeer?.status }}</h4>
</ion-label>
</ion-item>

<ion-item>
<ion-label stacked>
<p ion-text>{{ 'NETWORKS_PAGE.VERSION' | translate }}</p>
Expand Down
31 changes: 21 additions & 10 deletions src/pages/network-status/network-status.ts
Expand Up @@ -10,7 +10,6 @@ import { ArkApiProvider } from '@providers/ark-api/ark-api';

import { Network, Peer } from 'ark-ts';

import * as constants from '@app/app.constants';
import { TranslateService } from '@ngx-translate/core';
import { ToastProvider } from '@providers/toast/toast';

Expand Down Expand Up @@ -74,14 +73,25 @@ export class NetworkStatusPage implements OnDestroy {
}

private refreshData() {
this.arkApiProvider.api.peer.get(this.currentPeer.ip, this.currentPeer.port)
.takeUntil(this.unsubscriber$)
.do((response) => {
if (response.success) {
this.zone.run(() => this.currentPeer = response.peer);
}
})
.subscribe();
this.arkApiProvider.client.getPeerConfig(this.currentPeer.ip, this.currentNetwork.p2pPort)
.takeUntil(this.unsubscriber$)
.subscribe((response) => {
if (response) {
this.zone.run(() => {
this.currentPeer.version = response.data.version;
});
}
});

this.arkApiProvider.client.getPeerSyncing(this.getPeerUrl())
.takeUntil(this.unsubscriber$)
.subscribe((response) => {
if (response) {
this.zone.run(() => {
this.currentPeer.height = response.height;
});
}
});
}

private onUpdatePeer() {
Expand All @@ -92,6 +102,7 @@ export class NetworkStatusPage implements OnDestroy {
this.translateService.get('NETWORKS_PAGE.PEER_SUCCESSFULLY_CHANGED')
.subscribe((translate) => this.toastProvider.success(translate));
this.zone.run(() => this.currentPeer = peer);
this.refreshData();
}).subscribe();
}

Expand All @@ -101,7 +112,7 @@ export class NetworkStatusPage implements OnDestroy {

this.refreshIntervalListener = setInterval(() => {
this.refreshData();
}, constants.WALLET_REFRESH_TRANSACTIONS_MILLISECONDS);
}, 30 * 1000);
}

ngOnDestroy() {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/transaction/transaction-send/transaction-send.ts
Expand Up @@ -267,11 +267,11 @@ export class TransactionSendPage implements OnInit {
passphrase: result.keys.key,
secondPassphrase: result.keys.secondKey,
recipientId: this.transaction.recipientAddress,
fee: this.fee
};

this.arkApiProvider.api.transaction.createTransaction(data).subscribe((transaction) => {
this.arkApiProvider.transactionBuilder.createTransaction(data).subscribe((transaction) => {
// The transaction will be signed again;
transaction.fee = this.fee;
this.confirmTransaction.open(transaction, result.keys, result.checkerResult);
}, () => {
this.toastProvider.error('TRANSACTIONS_PAGE.CREATE_TRANSACTION_ERROR');
Expand Down
24 changes: 10 additions & 14 deletions src/pages/wallet/wallet-dashboard/wallet-dashboard.ts
Expand Up @@ -350,13 +350,13 @@ export class WalletDashboardPage implements OnInit, OnDestroy {
passphrase: keys.key,
secondPassphrase: keys.secondKey,
username: this.newDelegateName,
fee: this.newDelegateFee,
publicKey
};

this.arkApiProvider.api.transaction.createDelegate(transaction)
this.arkApiProvider.transactionBuilder.createDelegate(transaction)
.takeUntil(this.unsubscriber$)
.subscribe((data) => {
data.fee = this.newDelegateFee;
this.confirmTransaction.open(data, keys);
});
}
Expand All @@ -373,12 +373,12 @@ export class WalletDashboardPage implements OnInit, OnDestroy {
private createSignature(keys: WalletKeys) {
keys.secondPassphrase = this.newSecondPassphrase;

this.arkApiProvider.api.transaction
.createSignature(keys.key, keys.secondPassphrase)
.takeUntil(this.unsubscriber$)
.subscribe((data) => {
this.confirmTransaction.open(data, keys);
});
this.arkApiProvider.transactionBuilder
.createSignature(keys.key, keys.secondPassphrase)
.takeUntil(this.unsubscriber$)
.subscribe((data) => {
this.confirmTransaction.open(data, keys);
});
}

private saveWallet() {
Expand All @@ -392,11 +392,7 @@ export class WalletDashboardPage implements OnInit, OnDestroy {

private refreshTransactions(save: boolean = true, loader?: Loading|Refresher) {
this.zone.runOutsideAngular(() => {
this.arkApiProvider.api.transaction.list({
recipientId: this.address,
senderId: this.address,
orderBy: 'timestamp:desc',
})
this.arkApiProvider.client.getTransactionList(this.address)
.finally(() => this.zone.run(() => {
if (loader) {
if (loader instanceof Loading) {
Expand Down Expand Up @@ -424,7 +420,7 @@ export class WalletDashboardPage implements OnInit, OnDestroy {
}

private refreshAccount() {
this.arkApiProvider.api.account.get({address: this.address}).takeUntil(this.unsubscriber$).subscribe((response) => {
this.arkApiProvider.client.getWallet(this.address).takeUntil(this.unsubscriber$).subscribe((response) => {
if (response.success) {
this.wallet.deserialize(response.account);
this.saveWallet();
Expand Down
Expand Up @@ -13,9 +13,11 @@
{{ (useAddress ? 'WALLETS_PAGE.ENTER_ADDRESS' : 'WALLETS_PAGE.ENTER_SECRET_PASSPHRASE') | translate }}
</ion-label>
<ion-input *ngIf="useAddress || !hidePassphrase" #inputAddressOrPassphrase name="addressOrPassphrase" rows="2" [ngModel]="addressOrPassphrase"
(ngModelChange)="addressOrPassphraseChange($event)" formControlName="controlAddressOrPassphrase" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" required></ion-input>
(ngModelChange)="addressOrPassphraseChange($event)" formControlName="controlAddressOrPassphrase" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
(keyup.enter)="handleKeyEnter()" required></ion-input>
<ion-input *ngIf="!useAddress && hidePassphrase" #inputPassphraseHidden name="passphraseHidden" rows="2" [ngModel]="passphraseHidden"
(ngModelChange)="passphraseHiddenChange($event)" [ngModelOptions]="{standalone: true}" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" required></ion-input>
(ngModelChange)="passphraseHiddenChange($event)" [ngModelOptions]="{standalone: true}" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
(keyup.enter)="handleKeyEnter()" required></ion-input>
<button *ngIf="!useAddress" ion-button clear item-end (click)='showHidePassphrase()' style="height:100%;">
<ion-icon *ngIf="!hidePassphrase" name="eye" style="font-size:200%;"></ion-icon>
<ion-icon *ngIf="hidePassphrase" name="eye-off" style="font-size:200%;"></ion-icon>
Expand Down
7 changes: 7 additions & 0 deletions src/pages/wallet/wallet-import-manual/wallet-import-manual.ts
Expand Up @@ -39,6 +39,7 @@ export class WalletManualImportPage extends BaseWalletImport {

@ViewChild('inputAddressOrPassphrase') inputAddressOrPassphrase;
@ViewChild('inputPassphraseHidden') inputPassphraseHidden;
@ViewChild('importWalletManual') importWalletManual: HTMLFormElement;

constructor(
navParams: NavParams,
Expand All @@ -65,6 +66,12 @@ export class WalletManualImportPage extends BaseWalletImport {
this.initFormValidation();
}

handleKeyEnter() {
if (this.importWalletManual.form.valid && !this.submitted) {
this.submitForm();
}
}

submitForm() {
this.submitted = true;
this.import(this.useAddress ? this.addressOrPassphrase : null,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/wallet/wallet-import/wallet-import.base.ts
Expand Up @@ -62,8 +62,7 @@ export abstract class BaseWalletImport {

let newWallet = new Wallet(!privateKey);

this.arkApiProvider.api.account
.get({ address })
this.arkApiProvider.client.getWallet(address)
.finally(() => {
if (!privateKey) {
this.addWallet(newWallet);
Expand Down

0 comments on commit a8ad876

Please sign in to comment.