Use default account for sending transactions (#5588)

* Add default account for Wallet Creation

* Use default account by default, save current used account

* Fix tests
This commit is contained in:
Nicolas Gotchac
2017-05-16 16:38:16 +02:00
committed by Gav Wood
parent 48ddd8b312
commit 8642300d74
7 changed files with 70 additions and 7 deletions

View File

@@ -16,6 +16,38 @@
import WalletsUtils from '~/util/wallets';
/**
* The sender is by default (when the UI loads) the
* default dapp address. It can then be modified when
* sending transactions....
*/
let currentSender = '';
let hasCurrentSenderChanged = false;
export function getSender () {
currentSender;
}
export function loadSender (api) {
// If the current sender has been changed
// then don't bother checking changes of the
// default sender
if (hasCurrentSenderChanged) {
return Promise.resolve(currentSender);
}
return api.parity.getNewDappsDefaultAddress()
.then((defaultAccount) => {
currentSender = defaultAccount;
return defaultAccount;
});
}
export function setSender (sender) {
currentSender = sender;
hasCurrentSenderChanged = true;
}
export function trackRequest (api, options, statusCallback) {
const { requestId, transactionHash } = options;
const txHashPromise = transactionHash