-
{{ vin.addr }} {{ vin.value + ' BTC' }}
+
{{ vin.addr }} {{ currency.getConversion(vin.value) }}
-
Confirmations {{vin.confirmations}}
+
Confirmations {{vin.confirmations}}
scriptSig
@@ -44,10 +44,10 @@
-
+
-
+
@@ -62,7 +62,7 @@
- {{ vout.value + ' BTC' }}
+ {{ currency.getConversion(vout.value) }}
(S)
(U)
@@ -73,11 +73,11 @@
- Fee {{ tx.fees + ' BTC' }}
+ Fee {{ currency.getConversion(tx.fees) }}
{{ tx.confirmations }} Confirmations
- {{ tx.valueOut + ' BTC' }}
+ {{ currency.getConversion(tx.valueOut) }}
diff --git a/app/src/components/transaction/transaction.ts b/app/src/components/transaction/transaction.ts
index 074ee97..b01a7bb 100644
--- a/app/src/components/transaction/transaction.ts
+++ b/app/src/components/transaction/transaction.ts
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { Input } from '@angular/core';
import { NavController } from 'ionic-angular';
+import { CurrencyProvider } from '../../providers/currency/currency';
/**
* Generated class for the TransactionComponent component.
@@ -17,7 +18,7 @@ export class TransactionComponent {
public expanded: boolean = false;
@Input() public tx: any = {};
- constructor(private navCtrl: NavController) {
+ constructor(private navCtrl: NavController, public currency: CurrencyProvider) {
}
public getAddress(vout: any): string {
diff --git a/app/src/pages/address/address.html b/app/src/pages/address/address.html
index 9e441f5..752120a 100644
--- a/app/src/pages/address/address.html
+++ b/app/src/pages/address/address.html
@@ -5,27 +5,27 @@
Address
Address {{ address.addrStr }}
- {{ address.balance }} BTC
+ {{ currency.getConversion(address.balance) }}
Summary
-
+
Total Received
- {{ address.totalReceived }} BTC
+ {{ currency.getConversion(address.totalReceived) }}
Total Sent
- {{ address.totalSent }} BTC
+ {{ currency.getConversion(address.totalSent) }}
Final Balance
- {{ address.balance }} BTC
+ {{ currency.getConversion(address.balance) }}
diff --git a/app/src/pages/address/address.ts b/app/src/pages/address/address.ts
index e392a33..459f4de 100644
--- a/app/src/pages/address/address.ts
+++ b/app/src/pages/address/address.ts
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Http } from '@angular/http';
import { ApiProvider } from '../../providers/api/api';
+import { CurrencyProvider } from '../../providers/currency/currency';
/**
* Generated class for the AddressPage page.
@@ -23,7 +24,7 @@ export class AddressPage {
private addrStr: string;
public address: any = {};
- constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http, private api: ApiProvider) {
+ constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http, private api: ApiProvider, public currency: CurrencyProvider) {
this.addrStr = navParams.get('addrStr');
}
diff --git a/app/src/pages/block-detail/block-detail.html b/app/src/pages/block-detail/block-detail.html
index 354ef77..daa0444 100644
--- a/app/src/pages/block-detail/block-detail.html
+++ b/app/src/pages/block-detail/block-detail.html
@@ -8,9 +8,9 @@
Summary
-
+
- Number of Transactions
+ Number of Transactions
{{ block.tx.length }}
@@ -24,7 +24,7 @@
Block Reward
- {{ block.reward + ' BTC' }}
+ {{ currency.getConversion(block.reward) }}
diff --git a/app/src/pages/block-detail/block-detail.ts b/app/src/pages/block-detail/block-detail.ts
index 66053d5..95bdaf8 100644
--- a/app/src/pages/block-detail/block-detail.ts
+++ b/app/src/pages/block-detail/block-detail.ts
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Http } from '@angular/http';
import { ApiProvider } from '../../providers/api/api';
+import { CurrencyProvider } from '../../providers/currency/currency';
/**
* Generated class for the BlockDetailPage page.
@@ -25,9 +26,11 @@ export class BlockDetailPage {
tx: []
};
- constructor(public navCtrl: NavController, private http: Http, public navParams: NavParams, private api: ApiProvider) {
+ constructor(public navCtrl: NavController, private http: Http, public navParams: NavParams, private api: ApiProvider, public currency: CurrencyProvider) {
this.blockHash = navParams.get('blockHash');
+ }
+ public ionViewDidLoad(): void {
this.http.get(this.api.apiPrefix + 'block/' + this.blockHash).subscribe(
(data) => {
this.block = JSON.parse(data['_body']);
@@ -40,10 +43,6 @@ export class BlockDetailPage {
);
}
- public ionViewWillLeave(): void {
- this.loading = true;
- }
-
public goToPreviousBlock(): void {
this.navCtrl.push('block-detail', {
'blockHash': this.block.previousblockhash
diff --git a/app/src/pages/transaction/transaction.html b/app/src/pages/transaction/transaction.html
index 26a1663..bed9bd1 100644
--- a/app/src/pages/transaction/transaction.html
+++ b/app/src/pages/transaction/transaction.html
@@ -8,7 +8,7 @@
Summary
-
+
Size
diff --git a/app/src/pipes/split/split.ts b/app/src/pipes/split/split.ts
index ab08efd..1f2e7ca 100644
--- a/app/src/pipes/split/split.ts
+++ b/app/src/pipes/split/split.ts
@@ -15,7 +15,6 @@ export class SplitPipe implements PipeTransform {
*/
public transform(value: string, delimiter: string): Array {
let array: Array = value.split(delimiter);
- console.log('split is', array);
return array;
}
}
diff --git a/app/src/providers/currency/currency.spec.ts b/app/src/providers/currency/currency.spec.ts
index d1ef863..02fa17a 100644
--- a/app/src/providers/currency/currency.spec.ts
+++ b/app/src/providers/currency/currency.spec.ts
@@ -2,9 +2,10 @@
import { TestBed, ComponentFixture, inject } from '@angular/core/testing';
import { HttpModule } from '@angular/http';
import { CurrencyProvider } from './currency';
+import { ApiProvider } from '../api/api';
describe('CurrencyProvider', () => {
- let currency;
+ let currency: CurrencyProvider;
beforeEach(() => {
TestBed.configureTestingModule({
@@ -12,6 +13,7 @@ describe('CurrencyProvider', () => {
HttpModule
],
providers: [
+ ApiProvider,
CurrencyProvider
]
});
@@ -47,7 +49,7 @@ describe('CurrencyProvider', () => {
});
it('rounds float using specified number of decimal places', () => {
- let aFloat = 4.32943;
+ let aFloat: number = 4.32943;
expect(currency.roundFloat(aFloat, 2)).toBe(4.33);
expect(currency.roundFloat(aFloat, 3)).toBe(4.329);
@@ -66,7 +68,7 @@ describe('CurrencyProvider', () => {
});
it('gets proper conversion after changing currency', () => {
- let aFloat = 12345.09876543;
+ let aFloat: number = 12345.09876543;
expect(currency.getConversion(aFloat)).toBe('12345.09876543 BTC');
currency.setCurrency('mBTC');
diff --git a/app/src/providers/currency/currency.ts b/app/src/providers/currency/currency.ts
index fe6f412..b3f571b 100644
--- a/app/src/providers/currency/currency.ts
+++ b/app/src/providers/currency/currency.ts
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
+import { ApiProvider } from '../../providers/api/api';
import 'rxjs/add/operator/map';
/*
@@ -11,16 +12,18 @@ import 'rxjs/add/operator/map';
@Injectable()
export class CurrencyProvider {
- private defaultCurrency: string;
- private currencySymbol: string;
- private factor: number = 1;
+ public defaultCurrency: string;
+ public currencySymbol: string;
+ public factor: number = 1;
+ private bitstamp: number;
+ private loading: boolean;
- constructor(public http: Http) {
+ constructor(public http: Http, private api: ApiProvider) {
this.defaultCurrency = 'BTC';
this.currencySymbol = this.defaultCurrency;
}
- private roundFloat(aFloat: number, decimalPlaces: number): number {
+ public roundFloat(aFloat: number, decimalPlaces: number): number {
return Math.round(aFloat * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces);
}
@@ -50,12 +53,17 @@ export class CurrencyProvider {
localStorage.setItem('insight-currency', currency);
if (currency === 'USD') {
- // TODO Replace this with call
- /*
- Currency.get({}, function(res) {
- $rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp;
- });
- */
+ this.http.get(this.api.apiPrefix + 'currency').subscribe(
+ (data) => {
+ let currencyParsed: any = JSON.parse(data['_body']);
+ this.factor = this.bitstamp = currencyParsed.data.bitstamp;
+ this.loading = false;
+ },
+ (err) => {
+ console.log('err is', err);
+ this.loading = false;
+ }
+ );
} else if (currency === 'mBTC') {
this.factor = 1000;
} else if (currency === 'bits') {
diff --git a/app/src/test.ts b/app/src/test.ts
index 5a0cc78..c317506 100644
--- a/app/src/test.ts
+++ b/app/src/test.ts
@@ -17,7 +17,9 @@ import { ConfigMock, PlatformMock } from './mocks';
import { BlocksServiceMock } from './services/mocks';
import { BlocksService } from './services';
import { ApiProvider } from './providers/api/api';
+import { CurrencyProvider } from './providers/currency/currency';
import { HeadNavComponentModule } from './components/head-nav/head-nav.module';
+import { ActionSheetController } from 'ionic-angular';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any;
@@ -63,7 +65,9 @@ export class TestUtils {
{provide: Platform, useClass: PlatformMock},
{provide: Config, useClass: ConfigMock},
{provide: BlocksService, useClass: BlocksServiceMock},
- ApiProvider
+ ApiProvider,
+ CurrencyProvider,
+ ActionSheetController
],
imports: [
FormsModule,