Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet/dev #369

Merged
merged 5 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app-template/bitcoincom/appConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"windowsAppId": "804636ee-b017-4cad-8719-e58ac97ffa5c",
"pushSenderId": "1036948132229",
"description": "A Secure Bitcoin Wallet",
"version": "5.1.5",
"fullVersion": "5.1-rc4",
"androidVersion": "501500",
"version": "5.1.6",
"fullVersion": "5.1-rc5",
"androidVersion": "501600",
"_extraCSS": "",
"_enabledExtensions": {
"coinbase": false,
Expand Down
87 changes: 58 additions & 29 deletions src/js/controllers/amount.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,7 @@ angular

function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, sendFlowService, shapeshiftService, txFormatService, platformInfo, ongoingProcess, popupService, profileService, walletService, $window) {
var vm = this;

// Variables
vm.allowSend = false;
vm.altCurrencyList = [];
vm.alternativeAmount = '';
vm.alternativeUnit = '';
vm.amount = '0';
vm.availableFunds = '';
vm.canSendAllAvailableFunds = true;
vm.errorMessage = '';
// Use insufficient for logic, as when the amount is invalid, funds being
// either sufficent or insufficient doesn't make sense.
vm.fundsAreInsufficient = false;
vm.globalResult = '';
vm.isRequestingSpecificAmount = false;
vm.listComplete = false;
vm.lastUsedPopularList = [];
vm.maxAmount = 0;
vm.minAmount = 0;
vm.sendableFunds = '';
vm.showSendMaxButton = false;
vm.showSendLimitMaxButton = false;
vm.thirdParty = null;
vm.unit = '';


// Functions
vm.changeUnit = changeUnit;
vm.close = close;
Expand All @@ -46,7 +22,6 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
vm.removeDigit = removeDigit;
vm.save = save;
vm.sendMax = sendMax;


$scope.$on('$ionicView.beforeEnter', onBeforeEnter);
$scope.$on('$ionicView.leave', onLeave);
Expand Down Expand Up @@ -79,8 +54,55 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
satoshis: null
};

function onLeave() {
angular.element($window).off('keydown');
function initVariables() {
// Private variables
altCurrencyModal = null;
altUnitIndex = 0;
availableUnits = [];
canSendMax = true;
fiatCode;
isNW = platformInfo.isNW;
isAndroid = platformInfo.isAndroid;
isIos = platformInfo.isIOS;
lastUsedAltCurrencyList = [];
passthroughParams = {};
satToUnit;
transactionSendableAmount = {
crypto: '',
satoshis: null
};
unitDecimals;
unitIndex = 0;
unitToSatoshi;
useSendMax = false;
walletSpendableAmount = {
crypto: '',
satoshis: null
};

// Public variables
vm.allowSend = false;
vm.altCurrencyList = [];
vm.alternativeAmount = '';
vm.alternativeUnit = '';
vm.amount = '0';
vm.availableFunds = '';
vm.canSendAllAvailableFunds = true;
vm.errorMessage = '';
// Use insufficient for logic, as when the amount is invalid, funds being
// either sufficent or insufficient doesn't make sense.
vm.fundsAreInsufficient = false;
vm.globalResult = '';
vm.isRequestingSpecificAmount = false;
vm.listComplete = false;
vm.lastUsedPopularList = [];
vm.maxAmount = 0;
vm.minAmount = 0;
vm.sendableFunds = '';
vm.showSendMaxButton = false;
vm.showSendLimitMaxButton = false;
vm.thirdParty = null;
vm.unit = '';
}

function onBeforeEnter(event, data) {
Expand All @@ -89,12 +111,15 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
}



// Init before entering on this screen
initVariables();
initCurrencies();
// Then start

passthroughParams = sendFlowService.state.getClone();
console.log('amount onBeforeEnter after back sendflow ', passthroughParams);


// Init thirdParty, should be done for all the variable
vm.thirdParty = null;

Expand Down Expand Up @@ -223,6 +248,10 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
}
}

function onLeave() {
angular.element($window).off('keydown');
}

function goBack() {
sendFlowService.router.goBack();
}
Expand Down
137 changes: 73 additions & 64 deletions src/js/controllers/review.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,6 @@ angular
function reviewController(addressbookService, externalLinkService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, clipboardService, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, ionicToast, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, sendFlowService, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) {
var vm = this;

vm.buttonText = '';
vm.destination = {
address: '',
balanceAmount: '',
balanceCurrency: '',
coin: '',
color: '',
currency: '',
currencyColor: '',
kind: '', // 'address', 'contact', 'wallet'
name: ''
};
vm.displayAddress = '';
vm.feeCrypto = '';
vm.feeFiat = '';
vm.fiatCurrency = '';
vm.feeIsHigh = false;
vm.feeLessThanACent = false;
vm.isCordova = platformInfo.isCordova;
vm.memo = '';
vm.notReadyMessage = '';
vm.origin = {
balanceAmount: '',
balanceCurrency: '',
currency: '',
currencyColor: '',
};
vm.originWallet = null;
vm.paymentExpired = false;
vm.personalNotePlaceholder = gettextCatalog.getString('Enter text here');
vm.primaryAmount = '';
vm.primaryCurrency = '';
vm.usingMerchantFee = false;
vm.readyToSend = false;
vm.remainingTimeStr = '';
vm.secondaryAmount = '';
vm.secondaryCurrency = '';
vm.sendingTitle = gettextCatalog.getString('You are sending');
vm.sendStatus = '';
vm.showAddress = true;
vm.thirdParty = null;
vm.wallet = null;
vm.memoExpanded = false;

// Functions
vm.goBack = goBack;
vm.onSuccessConfirm = onSuccessConfirm;
vm.onShareTransaction = onShareTransaction;

var sendFlowData;
var config = null;
var coin = '';
Expand All @@ -76,14 +27,85 @@ angular
var unitFromSat = 0;

var FEE_TOO_HIGH_LIMIT_PERCENTAGE = 15;

// Functions
vm.goBack = goBack;
vm.onSuccessConfirm = onSuccessConfirm;
vm.onShareTransaction = onShareTransaction;

function initVariables() {
// Private variables
sendFlowData;
config = null;
coin = '';
countDown = null;
defaults = {};
usingCustomFee = false;
usingMerchantFee = false;
destinationWalletId = '';
lastTxId = '';
originWalletId = '';
priceDisplayIsFiat = true;
satoshis = null;
toAddress = '';
tx = {};
txPayproData = null;
unitFromSat = 0;

// Public variables
vm.buttonText = '';
vm.destination = {
address: '',
balanceAmount: '',
balanceCurrency: '',
coin: '',
color: '',
currency: '',
currencyColor: '',
kind: '', // 'address', 'contact', 'wallet'
name: ''
};
vm.displayAddress = '';
vm.feeCrypto = '';
vm.feeFiat = '';
vm.fiatCurrency = '';
vm.feeIsHigh = false;
vm.feeLessThanACent = false;
vm.isCordova = platformInfo.isCordova;
vm.memo = '';
vm.notReadyMessage = '';
vm.origin = {
balanceAmount: '',
balanceCurrency: '',
currency: '',
currencyColor: '',
};
vm.originWallet = null;
vm.paymentExpired = false;
vm.personalNotePlaceholder = gettextCatalog.getString('Enter text here');
vm.primaryAmount = '';
vm.primaryCurrency = '';
vm.usingMerchantFee = false;
vm.readyToSend = false;
vm.remainingTimeStr = '';
vm.secondaryAmount = '';
vm.secondaryCurrency = '';
vm.sendingTitle = gettextCatalog.getString('You are sending');
vm.sendStatus = '';
vm.showAddress = true;
vm.thirdParty = null;
vm.wallet = null;
vm.memoExpanded = false;
}

$scope.$on("$ionicView.beforeEnter", onBeforeEnter);

function onBeforeEnter(event, data) {
$log.debug('reviewController onBeforeEnter sendflow ', sendFlowService.state);

// Reset from last time
vm.thirdParty = null;
// Init before entering on this screen
initVariables();
// Then start

defaults = configService.getDefaults();
sendFlowData = sendFlowService.state.getClone();
Expand Down Expand Up @@ -727,20 +749,7 @@ angular
$timeout(function onTimeout() {
$scope.$apply();
}, 10);

});

// setWalletSelector(tx.coin, tx.network, tx.amount, function(err) {
// if (err) {
// return exitWithError('Could not update wallets');
// }
//
// if (vm.wallets.length > 1) {
// vm.showWalletSelector();
// } else if (vm.wallets.length) {
// setWallet(vm.wallets[0], tx);
// }
// });
}

function showSendMaxWarning(wallet, sendMaxInfo) {
Expand Down
15 changes: 15 additions & 0 deletions src/js/controllers/wallet-selector.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ angular
var unitDecimals = 0;
var unitsFromSatoshis = 0;

//
// Needs to migrate $scope to vm.
//
function initVariables() {
// Private variables
fromWalletId = '';
priceDisplayAsFiat = false;
unitDecimals = 0;
unitsFromSatoshis = 0;
}

$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
$scope.$on("$ionicView.enter", onEnter);

Expand All @@ -20,6 +31,10 @@ angular
sendFlowService.state.pop();
}

// Init before entering on this screen
initVariables();
// Then start

$scope.params = sendFlowService.state.getClone();

console.log('walletSelector onBeforeEnter after back sendflow', $scope.params);
Expand Down
4 changes: 2 additions & 2 deletions src/js/directives/incomingDataMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ angular.module('copayApp.directives')
scope.type = "url";
} else if (scope.data.parsed.publicAddress) {
scope.type = "bitcoinAddress";
var prefix = scope.data.parsed.isTestnet ? 'bchtest:' : 'bitcoincash:';
scope.data.toAddress = (prefix + scope.data.parsed.publicAddress.cashAddr) || scope.data.parsed.publicAddress.legacy || scope.data.parsed.publicAddress.bitpay;
var prefix = scope.data.coin === 'bch' ? (scope.data.parsed.isTestnet ? 'bchtest:' : 'bitcoincash:') : '';
scope.data.toAddress = (scope.data.parsed.publicAddress.cashAddr ? prefix + scope.data.parsed.publicAddress.cashAddr : false) || scope.data.parsed.publicAddress.legacy || scope.data.parsed.publicAddress.bitpay;
} else {
scope.type = "text";
}
Expand Down