diff --git a/src/pages/home/home.html b/src/pages/home/home.html
index e7e2672a3..a31ed6f60 100644
--- a/src/pages/home/home.html
+++ b/src/pages/home/home.html
@@ -5,4 +5,12 @@
+
+
+ {{wallet.credentials.walletName}} {{wallet.credentials.m}}-{{wallet.credentials.n}}
+
+
+ {{wallet.credentials.coin}} - {{wallet.credentials.walletId}}
+
+
diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts
index 3bd1fcf34..d14554de2 100644
--- a/src/pages/home/home.ts
+++ b/src/pages/home/home.ts
@@ -1,16 +1,23 @@
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
+import { ProfileProvider } from '../../providers/profile/profile';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
+ public wallets;
- constructor(public navCtrl: NavController) {
+ constructor(
+ public navCtrl: NavController,
+ private profile: ProfileProvider
+ ) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad HomePage');
+ this.wallets = this.profile.bind();
+ console.log('[home.ts:20]',this.wallets); //TODO
}
}
diff --git a/src/providers/bwc/bwc.ts b/src/providers/bwc/bwc.ts
index 5dd162a64..5d544767e 100644
--- a/src/providers/bwc/bwc.ts
+++ b/src/providers/bwc/bwc.ts
@@ -1,18 +1,15 @@
import { Injectable } from '@angular/core';
-//import * as BWC from 'bitcore-wallet-client';
+import * as BWC from 'bitcore-wallet-client';
@Injectable()
export class BwcProvider {
- /*
public buildTx = BWC.buildTx;
public parseSecret = BWC.parseSecret;
public Client = BWC;
- */
constructor() {
console.log('Hello BwcProvider Provider');
}
- /*
getBitcore() {
return BWC.Bitcore;
}
@@ -43,6 +40,5 @@ export class BwcProvider {
bwc.import(walletData, opts);
return bwc;
}
- */
}
diff --git a/src/providers/profile/profile.ts b/src/providers/profile/profile.ts
index a4d9b63d2..84fb1ef18 100644
--- a/src/providers/profile/profile.ts
+++ b/src/providers/profile/profile.ts
@@ -1,9 +1,11 @@
import { Injectable } from '@angular/core';
+import { Events } from 'ionic-angular';
import * as moment from 'moment';
import * as _ from 'lodash';
import { PersistenceProvider } from '../persistence/persistence';
import { ConfigProvider } from '../config/config';
import { BwcProvider } from '../bwc/bwc';
+import { WalletProvider } from '../wallet/wallet';
interface Profile {
version: string;
@@ -32,6 +34,8 @@ export class ProfileProvider {
public profile: Profile;
constructor(
+ public events: Events,
+ private wallet: WalletProvider,
private persistence: PersistenceProvider,
private config: ConfigProvider,
private bwc: BwcProvider
@@ -42,6 +46,7 @@ export class ProfileProvider {
get() {
return new Promise((resolve, reject) => {
this.persistence.getProfile().then((profile: any) => {
+ this.profile = profile;
resolve(profile);
}, (error) => {
reject(error);
@@ -52,42 +57,24 @@ export class ProfileProvider {
create() {
this.profile = new Profile();
- console.log('[profile.ts:33]', this.profile); //TODO
-
this.persistence.storeNewProfile(this.profile).then(() => {
- // bindProfile (this.profile)
+ // TODO: bind?
}, (error) => {
- // Todo: error?
+ // TODO: error?
});
}
- bind(profile: Profile) {
- let l = profile.credentials.length;
- let i = 0;
- let totalBound = 0;
+ bind() {
+ let l = this.profile.credentials.length;
+ let wallets = new Array();
- if (!l) return;
+ if (!l) return wallets;
+ let credentials = this.profile.credentials;
- _.each(profile.credentials, function(credentials) {
- this.bindWallet(credentials, function(err, bound) {
- i++;
- totalBound += bound;
- if (i == l) {
- console.log('Bound ' + totalBound + ' out of ' + l + ' wallets');
- return;
- }
- });
+ _.each(credentials, (credential) => {
+ wallets.push(this.wallet.bind(credential));
});
- }
-
- bindWallet(credentials) {
- let defaults = this.config.get();
-
- /*
- let client = this.bwc.getClient(JSON.stringify(credentials), {
- bwsurl: defaults['bws']['url'],
- });
- */
+ return wallets;
}
}
diff --git a/src/providers/wallet/wallet.ts b/src/providers/wallet/wallet.ts
index 78ea8d7c2..04df4dda5 100644
--- a/src/providers/wallet/wallet.ts
+++ b/src/providers/wallet/wallet.ts
@@ -1,10 +1,83 @@
import { Injectable } from '@angular/core';
-@Injectable()
-export class WalletProvider {
+import { PlatformProvider } from '../platform/platform';
+import { ConfigProvider } from '../config/config';
+import { BwcProvider } from '../bwc/bwc';
- constructor() {
- console.log('Hello WalletService Provider');
+// TODO: create interface
+interface Wallet {
+ baseUrl: string;
+ credentials: Object;
+ doNotVerifyPayPro: boolean;
+ logLevel: string;
+ payProHttp: string;
+ request: Function;
+ supportStaffWalletId: string;
+ timeout: Number;
+}
+
+class Wallet implements Wallet {
+ constructor(
+ public baseUrl: string = '1.0.0',
+ ) {
+ // Nothing to do
+ }
+
+}
+
+const UPDATE_PERIOD = 15;
+
+@Injectable()
+export class WalletProvider {
+ public wallet: Object = new Object();
+
+ constructor(
+ private platform: PlatformProvider,
+ private config: ConfigProvider,
+ private bwc: BwcProvider
+ ) {
+ console.log('Hello WalletService Provider');
+ }
+
+ bind(credential) {
+ let defaults = this.config.get();
+
+ let wallet = this.bwc.getClient(JSON.stringify(credential), {
+ bwsurl: defaults['bws']['url'],
+ });
+ return wallet;
+ }
+
+ bindClient(wallet, opts?) {
+ opts = opts || {};
+ let walletId = wallet.credentials.walletId;
+
+ //root.updateWalletSettings(wallet);
+ this.wallet[walletId] = wallet;
+
+ /*
+ _needsBackup(wallet, function(val) {
+ wallet.needsBackup = val;
+ });
+
+ _balanceIsHidden(wallet, function(val) {
+ wallet.balanceHidden = val;
+ });
+ */
+
+ this.wallet[walletId].initialize({
+ notificationIncludeOwn: true,
+ }, function(err) {
+ if (err) {
+ console.log('Could not init notifications err:', err);
+ return;
+ }
+ this.wallet[walletId].setNotificationsInterval(UPDATE_PERIOD);
+ this.wallet[walletId].openWallet(function(err) {
+ if (wallet.status !== true)
+ console.log('Wallet + ' + walletId + ' status:' + wallet.status)
+ });
+ });
}
}