fix copayers

This commit is contained in:
Matias Alejo Garcia 2016-08-15 16:07:30 -03:00
commit 9e70821c4c
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
11 changed files with 392 additions and 315 deletions

View file

@ -1,31 +1,38 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="">
</div>
<div class="copayers content p20v" ng-controller="copayersController as copayers" ng-init="copayers.init()">
<div ng-show="!index.notAuthorized">
<ion-view ng-controller="copayersController">
<ion-nav-title>{{wallet.name}}</ion-nav-title>
<ion-nav-buttons side="primary">
<button class="button" href ui-sref="tabs.home">
<i class="ion-arrow-left-c"></i> Back
</button>
</ion-nav-buttons>
<ion-content delegate-handle="my-handle" overflow-scroll="true">
<div ng-show="!wallet.notAuthorized">
<h1 class="text-center" translate>Share this invitation with your copayers</h1>
<div ng-click="copayers.copySecret(index.walletSecret)" ng-class="{'enable_text_select': !index.isCordova}">
<div ng-click="copySecret()" ng-class="{'enable_text_select': !isCordova}">
<div class="text-center">
<qrcode size="220" error-correction-level="L" data="{{index.walletSecret}}"></qrcode>
<div ng-show="!index.walletSecret" style="position:relative; top:-226px; height:0px">
<qrcode size="220" error-correction-level="L" data="{{secret}}"></qrcode>
<div ng-show="!secret" style="position:relative; top:-226px; height:0px">
<div style="height:220px; width:220px; margin:auto; background: white">
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
</div>
</div>
<div class="secret" ng-show="!index.isCordova">
{{index.walletSecret || ('Loading...'|translate)}}
<div class="secret" ng-show="!isCordova">
{{secret || ('Loading...'|translate)}}
</div>
</div>
</div>
<div ng-show="index.walletSecret">
<div class="text-center m10t" ng-if="index.isCordova">
<div ng-show="secret">
<div class="text-center m10t" ng-if="isCordova">
<span class="button outline round dark-gray tiny m0"
ng-click="copayers.shareSecret(index.walletSecret)">
ng-click="shareSecret()">
<i class="fi-share"></i>
<span translate>Share invitation</span>
</span>
@ -35,28 +42,34 @@
<h4 class="size-14 p10h m10t">
<span translate>Waiting for copayers</span>
<span class="text-gray right">
[ <span translate>{{index.m}}-of-{{index.n}}</span> ]
[ <span translate>{{wallet.m}}-of-{{wallet.n}}</span> ]
</span>
</h4>
<div class="white line-b p10" ng-include="'views/includes/copayers.html'"></div>
<div ng-if="!index.isComplete" class="line-b p10 white size-12">
<div ng-if="!wallet.isComplete()" class="line-b p10 white size-12">
<i class="fi-loop m5r p10l"></i>
<span translate>Waiting...</span>
</div>
<div ng-if="wallet.isComplete()" class="line-b p10 white size-12" href>
<button class="button" href ui-sref="tabs.home">
<span translate>WALLET COMPLETE!</span>
</button>
</div>
</div>
<div class="m20b text-center" ng-show="index.notAuthorized">
<div class="m20b text-center" ng-show="wallet.notAuthorized">
<h1 translate>Wallet incomplete and broken</h1>
<h4 translate>Delete it and create a new one</h4>
</div>
<div class="text-center">
<button class="tiny round outline dark-gray warning" ng-click="copayers.deleteWallet()">
<button class="tiny round outline dark-gray warning" ng-click="deleteWallet()">
<i class="fi-trash"></i> <span translate>Cancel and delete the wallet</span>
</button>
</div>
</div>
</div>
</ion-content>
<div class="extra-margin-bottom"></div>
</div>
</ion-view>

View file

@ -15,7 +15,6 @@
{{item.m}}-of-{{item.n}}
</span>
<span class="badge badge-assertive" ng-show="!item.isComplete()" translate>
Incomplete
</span>

View file

@ -1,230 +1,234 @@
<div ng-controller="walletDetailsController">
<div class="onGoingProcess" ng-show="wallet.updating">
<div class="onGoingProcess-content" ng-style="{'background-color':wallet.color}">
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
<ion-view ng-controller="walletDetailsController">
<ion-nav-title>{{wallet.name}}</ion-nav-title>
<ion-nav-buttons side="primary">
<button class="button" href ui-sref="tabs.home">
<i class="ion-arrow-left-c"></i> Back
</button>
</ion-nav-buttons>
<ion-content delegate-handle="my-handle" overflow-scroll="true">
<div ng-show="!wallet">
No Wallet
<a href ui-sref="tabs.home" class="button">
Go home
</a>
</div>
<div ng-show="!wallet.isComplete()">
Wallet Incomplete.
<a href ui-sref="copayers({'walletId': wallet.id})" class="button">
Wait for Copayers
</a>
</div>
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
<div ng-style="{'background-color':wallet.color}" class="amount">
<div ng-if="!wallet.notAuthorized && !wallet.updating">
<div class="m20t" ng-show="wallet.updateError" ng-click='update()'>
<span class="size-12 db m10b">{{wallet.updateError|translate}}</span>
<button class="outline white tiny round" translate>Tap to retry</button>
</div>
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='wallet.retryScan()'>
<span translate>Scan status finished with error</span>
<br><span translate>Tap to retry</span>
</div>
<div ng-click='wallet.updateAll({triggerTxUpdate: true})' ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && !wallet.hideBalance" on-hold="hideToggle()">
<strong class="size-36">{{wallet.totalBalanceStr}}</strong>
<div class="size-14" ng-if="wallet.totalBalanceAlternative">{{wallet.totalBalanceAlternative}} {{wallet.alternativeIsoCode}}</div>
<div class="size-14" ng-if="wallet.pendingAmount">
<span translate>Pending Confirmation</span>: {{wallet.pendingAmountStr}}
</div>
</div>
<div ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && wallet.shouldHideBalance" on-hold="wallet.hideToggle()">
<strong class="size-24" translate>[Balance Hidden]</strong>
<div class="size-14" translate>
Tap and hold to show
</div>
</div>
</div>
<div ng-if="wallet.updating">
<div class="size-36">
<strong>...</strong>
</div>
</div>
</div> <!-- amount -->
<div class="wallet-info">
<span ng-include="'views/includes/walletInfo.html'"></span>
</div>
<span translate>Updating Wallet...</span>
</div>
</div>
</div> <!-- oh -->
<div class="oh">
<div class="p60b" ng-show="wallet && wallet.isComplete()">
<div class="oh pr m20t" ng-show="wallet.incorrectDerivation">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
WARNING: Key derivation is not working on this device/wallet. Actions cannot be performed on this wallet.
</span>
</div>
</div>
<div class="oh pr m20t" ng-show="wallet.notAuthorized && !wallet.updating">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
WARNING: Wallet not registered
</span>
</div>
<div class="text-center text-gray m15r m15l" translate>
This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information.
</div>
<div class="text-center m10t ">
<span class="button outline round dark-gray tiny"
ng-click="wallet.recreate()">
<span translate>Recreate</span>
</span>
</div>
</div>
<div id="walletHome" class="walletHome">
<ion-content delegate-handle="my-handle" overflow-scroll="true">
<div class="oh pr">
<div ng-style="{'background-color':wallet.color}" class="amount">
<div ng-if="!wallet.notAuthorized && !wallet.updating">
<div class="release size-12" ng-show="newRelease" ng-click="$root.openExternalLink('https://github.com/bitpay/copay/releases/latest')">
<span>{{newRelease}}</span><i class="icon-arrow-right3 right size-18"></i>
</div>
<div class="size-14 m10b" ng-if="wallet.totalBalanceAlternative">{{wallet.name}}</div>
<div ng-if="wallet.txps[0]">
<h4 ng-show="wallet.requiresMultipleSignatures" class="title m0" translate>Payment Proposals</h4>
<h4 ng-show="!wallet.requiresMultipleSignatures" class="title m0" translate>Unsent transactions</h4>
<div ng-repeat="tx in wallet.txps">
<div ng-include="wallet.txTemplateUrl"></div>
</div>
<div class="m15t" ng-show="wallet.updateError" ng-click='update()'>
<span class="size-12 db m10b">{{wallet.updateError|translate}}</span>
<button class="outline white tiny round" translate>Tap to retry</button>
</div>
<div class="text-gray text-center size-12 p10t"
ng-show="wallet.lockedBalanceSat">
<span translate>Total Locked Balance</span>:
<b>{{wallet.lockedBalanceStr}} </b>
<span> {{wallet.lockedBalanceAlternative}}
{{wallet.alternativeIsoCode}} </span>
</div>
</div>
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='wallet.retryScan()'>
<span translate>Scan status finished with error</span>
<br><span translate>Tap to retry</span>
</div>
<!-- Activity -->
<h4 class="title" ng-click="wallet.startSearch(); openSearchModal()" ng-show="!wallet.notAuthorized">
<span translate>Activity</span>
<i class="dib m5l size-16 pointer fi-magnifying-glass"></i>
</h4>
<div ng-click='wallet.updateAll({triggerTxUpdate: true})' ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && !wallet.hideBalance" on-hold="hideToggle()">
<strong class="size-36">{{wallet.totalBalanceStr}}</strong>
<div class="size-14" ng-if="wallet.totalBalanceAlternative">{{wallet.totalBalanceAlternative}} {{wallet.alternativeIsoCode}}</div>
<div class="size-14" ng-if="wallet.pendingAmount">
<span translate>Pending Confirmation</span>: {{wallet.pendingAmountStr}}
</div>
</div>
<div class="oh pr m20t text-gray size-12 text-center"
ng-show="!wallet.loadingWallet && !wallet.txHistory[0] && !wallet.updatingTxHistory && !wallet.txHistoryError && !wallet.updateError && !wallet.notAuthorized"
translate>No transactions yet ZZZZ {{wallet.totalBalanceStr}}
</div>
<div ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && wallet.shouldHideBalance" on-hold="wallet.hideToggle()">
<strong class="size-24" translate>[Balance Hidden]</strong>
<div class="size-14" translate>
Tap and hold to show
</div>
</div>
<div class="oh pr" ng-show="(wallet.txHistory[0] || wallet.txProgress > 5) && !wallet.notAuthorized">
<div ng-show="wallet.updatingTxHistory && wallet.txProgress > 5">
<div class="row p20 text-center">
<div class="columns large-12 medium-12 small-12 m10b">
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
</div>
<div ng-if="wallet.updating">
<div class="size-36">
<strong>...</strong>
</div>
</div>
</div> <!-- amount -->
<div class="wallet-info">
<span ng-include="'views/includes/walletInfo.html'"></span>
</div>
</div> <!-- oh -->
<div class="p60b">
<div class="oh pr m20t" ng-show="wallet.incorrectDerivation">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
WARNING: Key derivation is not working on this device/wallet. Actions cannot be performed on this wallet.
</span>
<div class="size-12 text-gray m20t">
<div translate>{{wallet.txProgress}} transactions downloaded</div>
<div translate>Updating transaction history. Please stand by.</div>
</div>
</div>
<div class="oh pr m20t" ng-show="wallet.notAuthorized && !wallet.updating">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
WARNING: Wallet not registered
</span>
</div>
<div class="text-center text-gray m15r m15l" translate>
This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information.
</div>
<div class="text-center m10t ">
<span class="button outline round dark-gray tiny"
ng-click="wallet.recreate()">
<span translate>Recreate</span>
</span>
</div>
</div>
<div class="release size-12" ng-show="newRelease" ng-click="$root.openExternalLink('https://github.com/bitpay/copay/releases/latest')">
<span>{{newRelease}}</span><i class="icon-arrow-right3 right size-18"></i>
</div>
<div ng-if="wallet.txps[0]">
<h4 ng-show="wallet.requiresMultipleSignatures" class="title m0" translate>Payment Proposals</h4>
<h4 ng-show="!wallet.requiresMultipleSignatures" class="title m0" translate>Unsent transactions</h4>
<div ng-repeat="tx in wallet.txps">
<div ng-include="wallet.txTemplateUrl"></div>
</div>
<div class="text-gray text-center size-12 p10t"
ng-show="wallet.lockedBalanceSat">
<span translate>Total Locked Balance</span>:
<b>{{wallet.lockedBalanceStr}} </b>
<span> {{wallet.lockedBalanceAlternative}}
{{wallet.alternativeIsoCode}} </span>
</div>
</div>
<!-- Activity -->
<h4 class="title" ng-click="wallet.startSearch(); openSearchModal()" ng-show="!wallet.notAuthorized">
<span translate>Activity</span>
<i class="dib m5l size-16 pointer fi-magnifying-glass"></i>
</h4>
<div class="oh pr m20t text-gray size-12 text-center"
ng-show="!wallet.loadingWallet && !wallet.txHistory[0] && !wallet.updatingTxHistory && !wallet.txHistoryError && !wallet.updateError && !wallet.notAuthorized"
translate>No transactions yet ZZZZ {{wallet.totalBalanceStr}}
</div>
<div class="oh pr" ng-show="(wallet.txHistory[0] || wallet.txProgress > 5) && !wallet.notAuthorized">
<div ng-show="wallet.updatingTxHistory && wallet.txProgress > 5">
<div class="row p20 text-center">
<div class="columns large-12 medium-12 small-12 m10b">
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
</div>
<div class="size-12 text-gray m20t">
<div translate>{{wallet.txProgress}} transactions downloaded</div>
<div translate>Updating transaction history. Please stand by.</div>
</div>
</div>
</div>
<div ng-if="wallet.txHistory[0] && wallet.updatingTxHistory && wallet.newTx" class="row collapse last-transactions-content animated fadeInDown">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">
<img src="img/icon-new.svg" width="40">
</div>
<div class="m10t" style="background:#eee; width: 8em; margin-left: 52px; line-height:0.6em">
<span>&nbsp;</span>
</div>
<div style="margin-top:5px; background:#eee; width: 6em; margin-left: 52px; line-height:0.6em">
<span>&nbsp;</span>
</div>
</div>
</div>
<div ng-repeat="btx in wallet.txHistory track by btx.txid"
ng-click="openTxModal(btx)"
class="row collapse last-transactions-content">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">
<img src="img/icon-receive-history.svg" alt="sync" width="40" ng-show="btx.action == 'received'">
<img src="img/icon-sent-history.svg" alt="sync" width="40" ng-show="btx.action == 'sent'">
<img src="img/icon-moved.svg" alt="sync" width="40" ng-show="btx.action == 'moved'">
</div>
<div class="m10t">
<span ng-show="btx.action == 'received'">
<span class="ellipsis">
<span ng-if="btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.note.body" translate> Received</span>
</span>
</span>
<span ng-show="btx.action == 'sent'">
<span class="ellipsis">
<span ng-if="btx.message">{{btx.message}}</span>
<span ng-if="!btx.message && btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.message && !btx.note.body && wallet.addressbook[btx.addressTo]">{{wallet.addressbook[btx.addressTo]}}</span>
<span ng-if="!btx.message && !btx.note.body && !wallet.addressbook[btx.addressTo]" translate> Sent</span>
</span>
</span>
<span ng-show="btx.action == 'moved'">
<span class="ellipsis">
<span ng-if="btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.note.body" translate>Moved</span>
</span>
</span>
<span class="label tu warning radius" ng-show="btx.action == 'invalid'" translate>Invalid</span>
</div>
</div>
<div class="large-5 medium-5 small-5 columns text-right" >
<span class="size-16" ng-class="{'text-bold': btx.recent}">
<span ng-if="btx.action == 'received'">+</span>
<span ng-if="btx.action == 'sent'">-</span>
<span class="size-12" ng-if="btx.action == 'invalid'" translate>
(possible double spend)
</span>
<span ng-if="btx.action != 'invalid'">
{{btx.amountStr}}
</span>
</span>
<div class="size-12 text-gray">
<time ng-if="btx.time">{{btx.time * 1000 | amTimeAgo}}</time>
<span translate class="text-warning"
ng-show="!btx.time && (!btx.confirmations || btx.confirmations == 0)">
Unconfirmed
</span>
</div>
</div>
<div class="large-1 medium-1 small-1 columns text-right m10t">
<i class="icon-arrow-right3 size-18"></i>
</div>
</div>
<div class="row m20t text-center" ng-show="wallet.historyRendering && !wallet.ching">
<div class="columns large-12 medium-12 small-12">
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
</div>
</div>
<ion-infinite-scroll
ng-if="historyShowMore"
on-infinite="showMore()"
distance="1%">
</ion-infinite-scroll>
</div>
</div>
</ion-content>
<div class="extra-margin-bottom"></div>
</div> <!-- END WalletHome -->
</div>
</div>
<div ng-if="wallet.txHistory[0] && wallet.updatingTxHistory && wallet.newTx" class="row collapse last-transactions-content animated fadeInDown">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">
<img src="img/icon-new.svg" width="40">
</div>
<div class="m10t" style="background:#eee; width: 8em; margin-left: 52px; line-height:0.6em">
<span>&nbsp;</span>
</div>
<div style="margin-top:5px; background:#eee; width: 6em; margin-left: 52px; line-height:0.6em">
<span>&nbsp;</span>
</div>
</div>
</div>
<div ng-repeat="btx in wallet.txHistory track by btx.txid"
ng-click="openTxModal(btx)"
class="row collapse last-transactions-content">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">
<img src="img/icon-receive-history.svg" alt="sync" width="40" ng-show="btx.action == 'received'">
<img src="img/icon-sent-history.svg" alt="sync" width="40" ng-show="btx.action == 'sent'">
<img src="img/icon-moved.svg" alt="sync" width="40" ng-show="btx.action == 'moved'">
</div>
<div class="m10t">
<span ng-show="btx.action == 'received'">
<span class="ellipsis">
<span ng-if="btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.note.body" translate> Received</span>
</span>
</span>
<span ng-show="btx.action == 'sent'">
<span class="ellipsis">
<span ng-if="btx.message">{{btx.message}}</span>
<span ng-if="!btx.message && btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.message && !btx.note.body && wallet.addressbook[btx.addressTo]">{{wallet.addressbook[btx.addressTo]}}</span>
<span ng-if="!btx.message && !btx.note.body && !wallet.addressbook[btx.addressTo]" translate> Sent</span>
</span>
</span>
<span ng-show="btx.action == 'moved'">
<span class="ellipsis">
<span ng-if="btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.note.body" translate>Moved</span>
</span>
</span>
<span class="label tu warning radius" ng-show="btx.action == 'invalid'" translate>Invalid</span>
</div>
</div>
<div class="large-5 medium-5 small-5 columns text-right" >
<span class="size-16" ng-class="{'text-bold': btx.recent}">
<span ng-if="btx.action == 'received'">+</span>
<span ng-if="btx.action == 'sent'">-</span>
<span class="size-12" ng-if="btx.action == 'invalid'" translate>
(possible double spend)
</span>
<span ng-if="btx.action != 'invalid'">
{{btx.amountStr}}
</span>
</span>
<div class="size-12 text-gray">
<time ng-if="btx.time">{{btx.time * 1000 | amTimeAgo}}</time>
<span translate class="text-warning"
ng-show="!btx.time && (!btx.confirmations || btx.confirmations == 0)">
Unconfirmed
</span>
</div>
</div>
<div class="large-1 medium-1 small-1 columns text-right m10t">
<i class="icon-arrow-right3 size-18"></i>
</div>
</div>
<div class="row m20t text-center" ng-show="wallet.historyRendering && !wallet.ching">
<div class="columns large-12 medium-12 small-12">
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
</div>
</div>
<ion-infinite-scroll
ng-if="historyShowMore"
on-infinite="showMore()"
distance="1%">
</ion-infinite-scroll>
</div>
</div>
</ion-content>
</ion-view>

View file

@ -1,9 +1,9 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, go, notification, platformInfo, gettext, gettextCatalog) {
function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, go, notification, platformInfo, gettext, gettextCatalog, $stateParams, $state) {
var self = this;
var isCordova = platformInfo.isCordova;
$scope.isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid;
@ -12,20 +12,6 @@ angular.module('copayApp.controllers').controller('copayersController',
var cancel_msg = gettextCatalog.getString('Cancel');
var confirm_msg = gettextCatalog.getString('Confirm');
// Note that this is ONLY triggered when the page is opened
// IF a wallet is incomplete and copay is at /#copayers
// and the user switch to an other complete wallet
// THIS IS NOT TRIGGERED.
//
self.init = function() {
var fc = profileService.focusedClient;
if (fc.isComplete()) {
$log.debug('Wallet Complete...redirecting')
go.walletHome();
return;
}
};
var _modalDeleteWallet = function() {
$scope.title = delete_msg;
$scope.accept_msg = accept_msg;
@ -66,9 +52,9 @@ angular.module('copayApp.controllers').controller('copayersController',
});
};
self.deleteWallet = function() {
$scope.deleteWallet = function() {
var fc = profileService.focusedClient;
if (isCordova) {
if ($scope.isCordova) {
navigator.notification.confirm(
delete_msg,
function(buttonIndex) {
@ -83,15 +69,15 @@ angular.module('copayApp.controllers').controller('copayersController',
}
};
self.copySecret = function(secret) {
if (isCordova) {
$scope.copySecret = function() {
if ($scope.isCordova) {
window.cordova.plugins.clipboard.copy(secret);
window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
}
};
self.shareSecret = function(secret) {
if (isCordova) {
$scope.shareSecret = function() {
if ($scope.isCordova) {
var message = gettextCatalog.getString('Join my Copay wallet. Here is the invitation code: {{secret}} You can download Copay for your phone or desktop at https://copay.io', {
secret: secret
});
@ -99,4 +85,19 @@ angular.module('copayApp.controllers').controller('copayersController',
}
};
});
if (!$stateParams.walletId) {
$log.debug('No wallet provided...back to home');
return $state.transitionTo('tabs.home')
}
var wallet = profileService.getWallet($stateParams.walletId);
var secret = wallet.status.wallet.secret;
try {
secret = wallet.status.wallet.secret;
} catch (e) {};
$scope.wallet = wallet;
$scope.secret = secret;
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('createController',
function($scope, $rootScope, $timeout, $log, lodash, go, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess) {
function($scope, $rootScope, $timeout, $log, lodash, go, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService) {
var isChromeApp = platformInfo.isChromeApp;
var isCordova = platformInfo.isCordova;
@ -166,7 +166,7 @@ angular.module('copayApp.controllers').controller('createController',
ongoingProcess.set('creatingWallet', true);
$timeout(function() {
profileService.createWallet(opts, function(err) {
profileService.createWallet(opts, function(err, wallet) {
ongoingProcess.set('creatingWallet', false);
if (err) {
$log.warn(err);
@ -176,13 +176,19 @@ angular.module('copayApp.controllers').controller('createController',
});
return;
}
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
if (self.seedSourceId == 'set') {
$timeout(function() {
$rootScope.$emit('Local/BackupDone');
}, 1);
}
go.walletHome();
go.walletHome();
});
}, 100);
}

View file

@ -95,15 +95,21 @@ angular.module('copayApp.controllers').controller('importController',
opts.password = null;
$timeout(function() {
profileService.importWallet(str2, opts, function(err, walletId) {
profileService.importWallet(str2, opts, function(err, wallet) {
ongoingProcess.set('importingWallet', false);
if (err) {
$scope.error = err;
} else {
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
return;
}
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
}, 100);
};
@ -111,7 +117,7 @@ angular.module('copayApp.controllers').controller('importController',
var _importExtendedPrivateKey = function(xPrivKey, opts) {
ongoingProcess.set('importingWallet', true);
$timeout(function() {
profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, walletId) {
profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, wallet) {
ongoingProcess.set('importingWallet', false);
if (err) {
if (err instanceof errors.NOT_AUTHORIZED) {
@ -124,7 +130,12 @@ angular.module('copayApp.controllers').controller('importController',
});
}
$rootScope.$emit('Local/WalletImported', walletId);
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
@ -157,7 +168,7 @@ angular.module('copayApp.controllers').controller('importController',
ongoingProcess.set('importingWallet', true);
$timeout(function() {
profileService.importMnemonic(words, opts, function(err, walletId) {
profileService.importMnemonic(words, opts, function(err, wallet) {
ongoingProcess.set('importingWallet', false);
if (err) {
@ -171,7 +182,11 @@ angular.module('copayApp.controllers').controller('importController',
});
}
$rootScope.$emit('Local/WalletImported', walletId);
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
@ -293,7 +308,7 @@ angular.module('copayApp.controllers').controller('importController',
ongoingProcess.set('importingWallet', true);
$log.debug('Import opts', lopts);
profileService.importExtendedPublicKey(lopts, function(err, walletId) {
profileService.importExtendedPublicKey(lopts, function(err, wallet) {
ongoingProcess.set('importingWallet', false);
if (err) {
$scope.error = err;
@ -301,7 +316,12 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
@ -366,7 +386,7 @@ angular.module('copayApp.controllers').controller('importController',
ongoingProcess.set('importingWallet', true);
$log.debug('Import opts', lopts);
profileService.importExtendedPublicKey(lopts, function(err, walletId) {
profileService.importExtendedPublicKey(lopts, function(err, wallet) {
ongoingProcess.set('importingWallet', false);
if (err) {
$scope.error = err;
@ -374,7 +394,12 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});

View file

@ -128,13 +128,18 @@ angular.module('copayApp.controllers').controller('joinController',
this._join = function(opts) {
ongoingProcess.set('joiningWallet', true);
$timeout(function() {
profileService.joinWallet(opts, function(err) {
profileService.joinWallet(opts, function(err, wallet) {
ongoingProcess.set('joiningWallet', false);
if (err) {
self.error = err;
$rootScope.$apply();
return;
}
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
go.walletHome();
});
}, 100);

View file

@ -1,9 +1,8 @@
'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $stateParams, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService ) {
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService) {
console.log('[walletDetails.js.5]', $stateParams); //TODO
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid;
@ -32,7 +31,7 @@ console.log('[walletDetails.js.5]', $stateParams); //TODO
ret.countDown = null;
ret.sendMaxInfo = {};
ret.showAlternative = false;
$scope.openSearchModal = function() {
var fc = profileService.focusedClient;
$scope.color = fc.backgroundColor;
@ -63,14 +62,32 @@ console.log('[walletDetails.js.5]', $stateParams); //TODO
};
$scope.update = function() {
console.log('[walletDetails.js.65:update:] TODO'); //TODO
// {triggerTxUpdate: true}
walletService.updateStatus(wallet, {
force: true
}, function(err, status) {
if (err) {} // TODO
});
};
$scope.hideToggle = function() {
console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO
console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO
};
$scope.wallet = profileService.getWallet($stateParams.walletId);
console.log('[walletDetails.js.66]',$scope.wallet); //TODO
if (!$stateParams.walletId) {
$log.debug('No wallet provided... using the first one');
$stateParams.walletId = profileService.getWallets({
onlyComplete: true
})[0].id;
}
var wallet = profileService.getWallet($stateParams.walletId);
$scope.wallet = wallet;
if (wallet) {
walletService.updateStatus(wallet, {}, function(err, status) {
if (err) {} // TODO
});
}
});

View file

@ -161,8 +161,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
})
.state('unsupported', {
url: '/unsupported',
@ -223,11 +223,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('copayers', {
url: '/copayers',
needProfile: true,
cache: false,
views: {
'main': {
templateUrl: 'views/copayers.html'
},
}
},
params: {
walletId: null,
},
})
.state('preferences', {
url: '/preferences',

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services')
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, bitcore, platformInfo, walletService) {
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, bitcore, platformInfo, $ionicHistory) {
var isChromeApp = platformInfo.isChromeApp;
@ -95,6 +95,9 @@ angular.module('copayApp.services')
client.on('notification', function(n) {
$log.debug('BWC Notification:', n);
$ionicHistory.clearCache();
notificationService.newBWCNotification(n,
walletId, client.credentials.walletName);
@ -401,7 +404,7 @@ angular.module('copayApp.services')
doCreateWallet(opts, function(err, walletClient, secret) {
if (err) return cb(err);
root.addAndBindWalletClient(walletClient, {
addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl
}, cb);
});
@ -433,7 +436,7 @@ angular.module('copayApp.services')
walletClient.joinWallet(opts.secret, opts.myName || 'me', {}, function(err) {
if (err) return bwcError.cb(err, gettext('Could not join wallet'), cb);
root.addAndBindWalletClient(walletClient, {
addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl
}, cb);
});
@ -496,7 +499,7 @@ angular.module('copayApp.services')
}
// Adds and bind a new client to the profile
root.addAndBindWalletClient = function(client, opts, cb) {
var addAndBindWalletClient = function(client, opts, cb) {
if (!client || !client.credentials)
return cb(gettext('Could not access wallet'));
@ -530,19 +533,14 @@ angular.module('copayApp.services')
});
};
walletService.updateRemotePreferences(client, {}, function() {
$log.debug('Remote preferences saved for:' + walletId)
});
saveBwsUrl(function() {
root.setAndStoreFocus(walletId, function() {
storageService.storeProfile(root.profile, function(err) {
var config = configService.getSync();
if (config.pushNotifications.enabled)
pushNotificationsService.enableNotifications(root.wallet);
return cb(err, walletId);
return cb(err, walletClient);
});
});
});
};
@ -584,13 +582,13 @@ angular.module('copayApp.services')
var addressBook = str.addressBook || {};
root.addAndBindWalletClient(walletClient, {
addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl
}, function(err, walletId) {
if (err) return cb(err);
root.setMetaData(walletClient, addressBook, function(error) {
if (error) $log.warn(error);
return cb(err, walletId);
return cb(err, walletClient);
});
});
};
@ -607,7 +605,7 @@ angular.module('copayApp.services')
return bwcError.cb(err, gettext('Could not import'), cb);
}
root.addAndBindWalletClient(walletClient, {
addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl
}, cb);
});
@ -638,7 +636,7 @@ angular.module('copayApp.services')
return bwcError.cb(err, gettext('Could not import'), cb);
}
root.addAndBindWalletClient(walletClient, {
addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl
}, cb);
});
@ -661,7 +659,7 @@ angular.module('copayApp.services')
return bwcError.cb(err, gettext('Could not import'), cb);
}
root.addAndBindWalletClient(walletClient, {
addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl
}, cb);
});
@ -745,28 +743,5 @@ angular.module('copayApp.services')
return lodash.sortBy(ret, 'name');
};
root.needsBackup = function(client, cb) {
if (!walletService.needsBackup(client))
return cb(false);
storageService.getBackupFlag(client.credentials.walletId, function(err, val) {
if (err) $log.error(err);
if (val) return cb(false);
return cb(true);
});
};
root.isReady = function(client, cb) {
if (!client.isComplete())
return cb('WALLET_NOT_COMPLETE');
root.needsBackup(client, function(needsBackup) {
if (needsBackup)
return cb('WALLET_NEEDS_BACKUP');
return cb();
});
};
return root;
});

View file

@ -61,7 +61,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
});
};
root.needsBackup = function(wallet) {
root.requiresBackup = function(wallet) {
if (wallet.isPrivKeyExternal()) return false;
if (!wallet.credentials.mnemonic) return false;
if (wallet.credentials.network == 'testnet') return false;
@ -69,6 +69,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
return true;
};
root.needsBackup = function(wallet, cb) {
if (!walletService.requiresBackup(wallet))
return cb(false);
storageService.getBackupFlag(wallet.credentials.walletId, function(err, val) {
if (err) $log.error(err);
if (val) return cb(false);
return cb(true);
});
};
var _walletStatusHash = function(walletStatus) {
var bal;
if (walletStatus) {
@ -90,6 +102,9 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
$log.warn('TODO');
return; // TODO!!!
if (err instanceof errors.NOT_AUTHORIZED) {
console.log('[walletService.js.93] TODO NOT AUTH'); //TODO
// TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
self.notAuthorized = true;
go.walletHome();
} else if (err instanceof errors.NOT_FOUND) {
@ -815,5 +830,18 @@ console.log('[walletService.js.786:wallet:]',wallet, forceNew); //TODO
};
root.isReady = function(wallet, cb) {
if (!wallet.isComplete())
return cb('WALLET_NOT_COMPLETE');
root.needsBackup(wallet, function(needsBackup) {
if (needsBackup)
return cb('WALLET_NEEDS_BACKUP');
return cb();
});
};
return root;
});