Merge pull request #2 from cmgustavo/ref/design-02
[Amazon] Adds support multisign. Common widget to select wallet
This commit is contained in:
commit
77e0d26f82
4 changed files with 60 additions and 96 deletions
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<ion-content ng-controller="amazonController as amazon" ng-init="amazon.init()">
|
||||
|
||||
<div class="text-center" ng-show="network == 'testnet'">
|
||||
<div class="box-notification warning" ng-show="network == 'testnet'">
|
||||
Sandbox version. Only for testing purpose
|
||||
</div>
|
||||
|
||||
|
|
@ -40,8 +40,10 @@
|
|||
</a>
|
||||
</div>
|
||||
|
||||
<h4 class="padding">Your cards</h4>
|
||||
<div class="list card">
|
||||
<div class="card">
|
||||
<div class="item item-divider">
|
||||
Your cards
|
||||
</div>
|
||||
<div ng-repeat="(id, item) in giftCards | orderObjectBy:'date':true track by $index"
|
||||
ng-click="amazon.openCardModal(item)"
|
||||
class="item item-avatar">
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@
|
|||
|
||||
<div ng-show="!buy.giftCard">
|
||||
|
||||
<div class="assertive" ng-show="buy.error" ng-click="buy.error = null">
|
||||
<div class="box-notification error" ng-show="buy.error" ng-click="buy.error = null">
|
||||
{{buy.error}}
|
||||
<div class="m10t size-12" ng-show="buy.errorInfo">
|
||||
<div ng-show="buy.errorInfo">
|
||||
There was an error when trying to buy gift card, but the funds were sent to BitPay Invoice. Please, contact
|
||||
BitPay to refund your bitcoin
|
||||
<div class="p10 m10t">
|
||||
<div>
|
||||
Amount: {{buy.errorInfo.amount}} {{buy.errorInfo.currency}}<br>
|
||||
BitPay Invoice ID: {{buy.errorInfo.invoiceId}}.
|
||||
</div>
|
||||
|
|
@ -53,23 +53,11 @@
|
|||
|
||||
</label>
|
||||
|
||||
|
||||
<label class="item item-input item-stacked-label">
|
||||
<span class="input-label">Pay From Copay Wallet</span>
|
||||
<input type="text"
|
||||
id="address"
|
||||
name="address"
|
||||
ng-disabled="buy.selectedWalletId"
|
||||
ng-attr-placeholder="{{'Choose your source wallet'}}"
|
||||
ng-model="buy.selectedWalletName" required>
|
||||
<a on-tap="openWalletsModal(buy.allWallets)" class="button button-light">
|
||||
<i class="icon ion-folder size-18"></i>
|
||||
</a>
|
||||
</label>
|
||||
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
|
||||
</div>
|
||||
|
||||
<button class="button button-block"
|
||||
ng-disabled="!buy.selectedWalletId || !fiat"
|
||||
ng-disabled="!fiat"
|
||||
type="submit"
|
||||
value="Buy now">
|
||||
Buy now
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
var self = this;
|
||||
var wallet;
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, w) {
|
||||
if (lodash.isEmpty(w)) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
wallet = w;
|
||||
$log.debug('Wallet changed: ' + w.name);
|
||||
});
|
||||
|
||||
$scope.openExternalLink = function(url, target) {
|
||||
if (platformInfo.isNW) {
|
||||
nodeWebkit.openExternalLink(url);
|
||||
|
|
@ -17,53 +26,18 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
|
||||
this.init = function() {
|
||||
var network = amazonService.getEnvironment();
|
||||
self.allWallets = profileService.getWallets({
|
||||
$scope.wallets = profileService.getWallets({
|
||||
network: network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
|
||||
wallet = self.allWallets[0];
|
||||
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = wallet.credentials.walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
|
||||
$scope.type = 'SELL';
|
||||
$scope.wallets = wallets;
|
||||
$scope.self = self;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
}).then(function(modal) {
|
||||
$scope.walletsModal = modal;
|
||||
$scope.walletsModal.show();
|
||||
});
|
||||
|
||||
$scope.$on('walletSelected', function(ev, walletId) {
|
||||
$timeout(function() {
|
||||
wallet = profileService.getClient(walletId);
|
||||
self.selectedWalletId = walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
});
|
||||
};
|
||||
|
||||
this.createTx = function() {
|
||||
self.error = null;
|
||||
self.errorInfo = null;
|
||||
|
||||
if (lodash.isEmpty(wallet)) return;
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
self.error = bwcError.msg('MISSING_PRIVATE_KEY');
|
||||
|
|
@ -73,7 +47,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
var dataSrc = {
|
||||
currency: 'USD',
|
||||
amount: $scope.fiat,
|
||||
uuid: self.selectedWalletId
|
||||
uuid: wallet.id
|
||||
};
|
||||
var outputs = [];
|
||||
var config = configService.getSync();
|
||||
|
|
@ -241,7 +215,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
$log.debug("Saving new gift card with status: " + newData.status);
|
||||
|
||||
self.giftCard = newData;
|
||||
if (newData.status == 'PENDING') $state.transitionTo('amazon');
|
||||
if (newData.status == 'PENDING') $state.transitionTo('amazon.main');
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
|
|
@ -278,18 +252,24 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
});
|
||||
return bwcError.cb(err, null, cb);
|
||||
}
|
||||
walletService.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) {
|
||||
if (err) {
|
||||
$log.debug(err);
|
||||
walletService.removeTx(wallet, broadcastedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
return bwcError.cb(err, null, cb);
|
||||
}
|
||||
if (signedTxp.status == 'accepted') {
|
||||
walletService.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) {
|
||||
if (err) {
|
||||
$log.debug(err);
|
||||
walletService.removeTx(wallet, broadcastedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
return bwcError.cb(err, null, cb);
|
||||
}
|
||||
$timeout(function() {
|
||||
return cb(null, broadcastedTxp);
|
||||
}, 5000);
|
||||
});
|
||||
} else {
|
||||
$timeout(function() {
|
||||
return cb(null, broadcastedTxp);
|
||||
return cb(null, signedTxp);
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -81,32 +81,26 @@ h3.title {
|
|||
}
|
||||
|
||||
.box-notification {
|
||||
position: relative;
|
||||
font-size: 12px;
|
||||
padding: 0.5rem;
|
||||
border-radius: 2px;
|
||||
background: #FFFFFF;
|
||||
.box-icon {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
color: white;
|
||||
background-color: #1ABC9C;
|
||||
padding: 0 0.5rem;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
height: 100%;
|
||||
i {
|
||||
position: relative;
|
||||
top: 10%;
|
||||
display: block;
|
||||
}
|
||||
&.error {
|
||||
background-color: #ED4A43;
|
||||
}
|
||||
&.secondary {
|
||||
background-color: #3498DB;
|
||||
}
|
||||
border: 1px solid;
|
||||
margin-bottom: 20px;
|
||||
a {
|
||||
color: #fff;
|
||||
}
|
||||
&.notice {
|
||||
border-color: #b2b2b2;
|
||||
background-color: #f8f8f8;
|
||||
color: #444;
|
||||
}
|
||||
&.warning {
|
||||
border-color: #e6b500;
|
||||
background-color: #ffc900;
|
||||
color: #fff;
|
||||
}
|
||||
&.error {
|
||||
background-color: #ef473a;
|
||||
border-color: #e42112;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -878,7 +872,7 @@ input[type=file] {
|
|||
}
|
||||
|
||||
.wallets {
|
||||
height: 105px;
|
||||
height: 90px;
|
||||
}
|
||||
/*
|
||||
* Calculator
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue