Merge pull request #59 from lbryio/redux-encryption-flow

Add encryption flow to redux
This commit is contained in:
Shawn Khameneh 2018-07-24 20:50:34 -05:00 committed by GitHub
commit b4fffe863d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 10760 additions and 119 deletions

529
dist/bundle.js vendored
View file

@ -46,34 +46,19 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@ -104,8 +89,8 @@ return /******/ (function(modules) { // webpackBootstrap
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectBlocks = exports.selectDraftTransactionError = exports.selectDraftTransactionAddress = exports.selectDraftTransactionAmount = exports.selectDraftTransaction = exports.selectGettingNewAddress = exports.selectReceiveAddress = exports.selectIsSendingSupport = exports.selectIsFetchingTransactions = exports.selectHasTransactions = exports.selectRecentTransactions = exports.selectTransactionItems = exports.selectTransactionsById = exports.selectBalance = exports.makeSelectBlockDate = exports.selectSearchBarFocused = exports.selectWunderBarAddress = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchValue = exports.selectSearchQuery = exports.makeSelectSearchUris = exports.selectSearchState = exports.selectNavLinks = exports.selectActiveHistoryEntry = exports.selectHistoryStack = exports.selectHistoryIndex = exports.selectIsForwardDisabled = exports.selectIsBackDisabled = exports.selectPathAfterAuth = exports.selectPageTitle = exports.selectHeaderLinks = exports.selectCurrentParams = exports.selectCurrentPage = exports.selectCurrentPath = exports.makeSelectCurrentParam = exports.computePageFromPath = exports.selectSearchDownloadUris = exports.selectTotalDownloadProgress = exports.selectDownloadingFileInfos = exports.selectFileInfosDownloaded = exports.selectUrisLoading = exports.selectDownloadingByOutpoint = exports.selectIsFetchingFileListDownloadedOrPublished = exports.selectIsFetchingFileList = exports.selectFileInfosByOutpoint = exports.makeSelectLoadingForUri = exports.makeSelectDownloadingForUri = exports.makeSelectFileInfoForUri = exports.selectFetchingCostInfo = exports.selectCostForCurrentPageUri = exports.selectAllCostInfoByUri = exports.makeSelectCostInfoForUri = exports.makeSelectFetchingCostInfoForUri = undefined;
exports.selectRewardContentClaimIds = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.makeSelectIsUriResolving = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForPage = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.makeSelectClaimForUri = exports.selectSnack = exports.selectNotificationProps = exports.selectNotification = exports.selectBlackListedOutpoints = exports.blacklistReducer = exports.walletReducer = exports.searchReducer = exports.notificationsReducer = exports.fileInfoReducer = exports.costInfoReducer = exports.claimsReducer = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = exports.doSendSupport = exports.doSetDraftTransactionAddress = exports.doSetDraftTransactionAmount = exports.doSendDraftTransaction = exports.doCheckAddressIsMine = exports.doGetNewAddress = exports.doFetchBlock = exports.doFetchTransactions = exports.doBalanceSubscribe = exports.doUpdateBalance = exports.doBlackListedOutpointsSubscribe = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doFetchCostInfoForUri = exports.doFetchRewardedContent = exports.doFetchTrendingUris = exports.doFetchFeaturedUris = exports.doResolveUri = exports.doResolveUris = exports.doAbandonClaim = exports.doFetchClaimListMine = exports.doFetchClaimCountByChannel = exports.doFetchClaimsByChannel = exports.doHideNotification = exports.doNotify = exports.convertToShareLink = exports.isNameValid = exports.isURIClaimable = exports.isURIValid = exports.normalizeURI = exports.buildURI = exports.parseURI = exports.regexAddress = exports.regexInvalidURI = exports.Lbryapi = exports.Lbry = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.MODALS = exports.ACTIONS = exports.Notification = undefined;
exports.selectWalletUnlockResult = exports.selectWalletUnlockSucceeded = exports.selectWalletUnlockPending = exports.selectWalletDecryptResult = exports.selectWalletDecryptSucceeded = exports.selectWalletDecryptPending = exports.selectWalletEncryptResult = exports.selectWalletEncryptSucceeded = exports.selectWalletEncryptPending = exports.selectWalletState = exports.selectWalletIsEncrypted = exports.selectBlocks = exports.selectDraftTransactionError = exports.selectDraftTransactionAddress = exports.selectDraftTransactionAmount = exports.selectDraftTransaction = exports.selectGettingNewAddress = exports.selectReceiveAddress = exports.selectIsSendingSupport = exports.selectIsFetchingTransactions = exports.selectHasTransactions = exports.selectRecentTransactions = exports.selectTransactionItems = exports.selectTransactionsById = exports.selectBalance = exports.makeSelectBlockDate = exports.selectSearchBarFocused = exports.selectWunderBarAddress = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchValue = exports.selectSearchQuery = exports.makeSelectSearchUris = exports.selectSearchState = exports.selectNavLinks = exports.selectActiveHistoryEntry = exports.selectHistoryStack = exports.selectHistoryIndex = exports.selectIsForwardDisabled = exports.selectIsBackDisabled = exports.selectPathAfterAuth = exports.selectPageTitle = exports.selectHeaderLinks = exports.selectCurrentParams = exports.selectCurrentPage = exports.selectCurrentPath = exports.makeSelectCurrentParam = exports.computePageFromPath = exports.selectSearchDownloadUris = exports.selectTotalDownloadProgress = exports.selectDownloadingFileInfos = exports.selectFileInfosDownloaded = exports.selectUrisLoading = exports.selectDownloadingByOutpoint = exports.selectIsFetchingFileListDownloadedOrPublished = exports.selectIsFetchingFileList = exports.selectFileInfosByOutpoint = exports.makeSelectLoadingForUri = exports.makeSelectDownloadingForUri = exports.makeSelectFileInfoForUri = exports.selectFetchingCostInfo = exports.selectCostForCurrentPageUri = exports.selectAllCostInfoByUri = exports.makeSelectCostInfoForUri = exports.makeSelectFetchingCostInfoForUri = exports.selectRewardContentClaimIds = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = undefined;
exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.makeSelectIsUriResolving = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForPage = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.makeSelectClaimForUri = exports.selectSnack = exports.selectNotificationProps = exports.selectNotification = exports.selectBlackListedOutpoints = exports.blacklistReducer = exports.walletReducer = exports.searchReducer = exports.notificationsReducer = exports.fileInfoReducer = exports.costInfoReducer = exports.claimsReducer = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = exports.doWalletStatus = exports.doWalletUnlock = exports.doWalletDecrypt = exports.doWalletEncrypt = exports.doSendSupport = exports.doSetDraftTransactionAddress = exports.doSetDraftTransactionAmount = exports.doSendDraftTransaction = exports.doCheckAddressIsMine = exports.doGetNewAddress = exports.doFetchBlock = exports.doFetchTransactions = exports.doBalanceSubscribe = exports.doUpdateBalance = exports.doBlackListedOutpointsSubscribe = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doFetchCostInfoForUri = exports.doFetchRewardedContent = exports.doFetchTrendingUris = exports.doFetchFeaturedUris = exports.doResolveUri = exports.doResolveUris = exports.doAbandonClaim = exports.doFetchClaimListMine = exports.doFetchClaimCountByChannel = exports.doFetchClaimsByChannel = exports.doHideNotification = exports.doNotify = exports.convertToShareLink = exports.isNameValid = exports.isURIClaimable = exports.isURIValid = exports.normalizeURI = exports.buildURI = exports.parseURI = exports.regexAddress = exports.regexInvalidURI = exports.Lbryapi = exports.Lbry = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.MODALS = exports.ACTIONS = exports.Notification = undefined;
var _Notification = __webpack_require__(1);
@ -373,6 +358,30 @@ Object.defineProperty(exports, 'doSendSupport', {
return _wallet.doSendSupport;
}
});
Object.defineProperty(exports, 'doWalletEncrypt', {
enumerable: true,
get: function get() {
return _wallet.doWalletEncrypt;
}
});
Object.defineProperty(exports, 'doWalletDecrypt', {
enumerable: true,
get: function get() {
return _wallet.doWalletDecrypt;
}
});
Object.defineProperty(exports, 'doWalletUnlock', {
enumerable: true,
get: function get() {
return _wallet.doWalletUnlock;
}
});
Object.defineProperty(exports, 'doWalletStatus', {
enumerable: true,
get: function get() {
return _wallet.doWalletStatus;
}
});
var _batchActions = __webpack_require__(19);
@ -1057,6 +1066,72 @@ Object.defineProperty(exports, 'selectBlocks', {
return _wallet3.selectBlocks;
}
});
Object.defineProperty(exports, 'selectWalletIsEncrypted', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletIsEncrypted;
}
});
Object.defineProperty(exports, 'selectWalletState', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletState;
}
});
Object.defineProperty(exports, 'selectWalletEncryptPending', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletEncryptPending;
}
});
Object.defineProperty(exports, 'selectWalletEncryptSucceeded', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletEncryptSucceeded;
}
});
Object.defineProperty(exports, 'selectWalletEncryptResult', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletEncryptResult;
}
});
Object.defineProperty(exports, 'selectWalletDecryptPending', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletDecryptPending;
}
});
Object.defineProperty(exports, 'selectWalletDecryptSucceeded', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletDecryptSucceeded;
}
});
Object.defineProperty(exports, 'selectWalletDecryptResult', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletDecryptResult;
}
});
Object.defineProperty(exports, 'selectWalletUnlockPending', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletUnlockPending;
}
});
Object.defineProperty(exports, 'selectWalletUnlockSucceeded', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletUnlockSucceeded;
}
});
Object.defineProperty(exports, 'selectWalletUnlockResult', {
enumerable: true,
get: function get() {
return _wallet3.selectWalletUnlockResult;
}
});
var _action_types = __webpack_require__(4);
@ -1485,6 +1560,21 @@ var FETCH_BLOCK_SUCCESS = exports.FETCH_BLOCK_SUCCESS = 'FETCH_BLOCK_SUCCESS';
var SUPPORT_TRANSACTION_STARTED = exports.SUPPORT_TRANSACTION_STARTED = 'SUPPORT_TRANSACTION_STARTED';
var SUPPORT_TRANSACTION_COMPLETED = exports.SUPPORT_TRANSACTION_COMPLETED = 'SUPPORT_TRANSACTION_COMPLETED';
var SUPPORT_TRANSACTION_FAILED = exports.SUPPORT_TRANSACTION_FAILED = 'SUPPORT_TRANSACTION_FAILED';
var WALLET_ENCRYPT_START = exports.WALLET_ENCRYPT_START = 'WALLET_ENCRYPT_START';
var WALLET_ENCRYPT_COMPLETED = exports.WALLET_ENCRYPT_COMPLETED = 'WALLET_ENCRYPT_COMPLETED';
var WALLET_ENCRYPT_FAILED = exports.WALLET_ENCRYPT_FAILED = 'WALLET_ENCRYPT_FAILED';
var WALLET_UNLOCK_START = exports.WALLET_UNLOCK_START = 'WALLET_UNLOCK_START';
var WALLET_UNLOCK_COMPLETED = exports.WALLET_UNLOCK_COMPLETED = 'WALLET_UNLOCK_COMPLETED';
var WALLET_UNLOCK_FAILED = exports.WALLET_UNLOCK_FAILED = 'WALLET_UNLOCK_FAILED';
var WALLET_DECRYPT_START = exports.WALLET_DECRYPT_START = 'WALLET_DECRYPT_START';
var WALLET_DECRYPT_COMPLETED = exports.WALLET_DECRYPT_COMPLETED = 'WALLET_DECRYPT_COMPLETED';
var WALLET_DECRYPT_FAILED = exports.WALLET_DECRYPT_FAILED = 'WALLET_DECRYPT_FAILED';
var WALLET_LOCK_START = exports.WALLET_LOCK_START = 'WALLET_LOCK_START';
var WALLET_LOCK_COMPLETED = exports.WALLET_LOCK_COMPLETED = 'WALLET_LOCK_COMPLETED';
var WALLET_LOCK_FAILED = exports.WALLET_LOCK_FAILED = 'WALLET_LOCK_FAILED';
var WALLET_STATUS_START = exports.WALLET_STATUS_START = 'WALLET_STATUS_START';
var WALLET_STATUS_COMPLETED = exports.WALLET_STATUS_COMPLETED = 'WALLET_STATUS_COMPLETED';
var WALLET_STATUS_FAILED = exports.WALLET_STATUS_FAILED = 'WALLET_STATUS_FAILED';
// Claims
var FETCH_FEATURED_CONTENT_STARTED = exports.FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
@ -2076,6 +2166,9 @@ Lbry.wallet_unlock = function () {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return daemonCallWithResult('wallet_unlock', params);
};
Lbry.wallet_lock = function () {
return daemonCallWithResult('wallet_lock', {});
};
// transactions
Lbry.transaction_list = function () {
@ -2379,26 +2472,26 @@ exports.default = lbryProxy;
/* 8 */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1, eval)("this");
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1, eval)("this");
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ }),
@ -4382,6 +4475,11 @@ exports.doSendDraftTransaction = doSendDraftTransaction;
exports.doSetDraftTransactionAmount = doSetDraftTransactionAmount;
exports.doSetDraftTransactionAddress = doSetDraftTransactionAddress;
exports.doSendSupport = doSendSupport;
exports.doWalletEncrypt = doWalletEncrypt;
exports.doWalletUnlock = doWalletUnlock;
exports.doWalletLock = doWalletLock;
exports.doWalletDecrypt = doWalletDecrypt;
exports.doWalletStatus = doWalletStatus;
var _action_types = __webpack_require__(4);
@ -4627,6 +4725,116 @@ function doSendSupport(amount, claimId, uri, successCallback, errorCallback) {
};
}
function doWalletEncrypt(newPassword) {
return function (dispatch) {
dispatch({
type: ACTIONS.WALLET_ENCRYPT_START
});
_lbry2.default.wallet_encrypt({ new_password: newPassword }).then(function (result) {
if (result === true) {
dispatch({
type: ACTIONS.WALLET_ENCRYPT_COMPLETED,
result: result
});
} else {
dispatch({
type: ACTIONS.WALLET_ENCRYPT_FAILED,
result: result
});
}
});
};
}
function doWalletUnlock(password) {
return function (dispatch) {
dispatch({
type: ACTIONS.WALLET_UNLOCK_START
});
_lbry2.default.wallet_unlock({ password: password }).then(function (result) {
if (result === true) {
dispatch({
type: ACTIONS.WALLET_UNLOCK_COMPLETED,
result: result
});
} else {
dispatch({
type: ACTIONS.WALLET_UNLOCK_FAILED,
result: result
});
}
});
};
}
function doWalletLock() {
return function (dispatch) {
dispatch({
type: ACTIONS.WALLET_LOCK_START
});
_lbry2.default.wallet_lock().then(function (result) {
if (result === true) {
dispatch({
type: ACTIONS.WALLET_LOCK_COMPLETED,
result: result
});
} else {
dispatch({
type: ACTIONS.WALLET_LOCK_FAILED,
result: result
});
}
});
};
}
function doWalletDecrypt() {
return function (dispatch) {
dispatch({
type: ACTIONS.WALLET_DECRYPT_START
});
_lbry2.default.wallet_decrypt().then(function (result) {
if (result === true) {
dispatch({
type: ACTIONS.WALLET_DECRYPT_COMPLETED,
result: result
});
} else {
dispatch({
type: ACTIONS.WALLET_DECRYPT_FAILED,
result: result
});
}
});
};
}
function doWalletStatus() {
return function (dispatch) {
dispatch({
type: ACTIONS.WALLET_STATUS_START
});
_lbry2.default.status().then(function (result) {
if (result && !result.error) {
dispatch({
type: ACTIONS.WALLET_STATUS_COMPLETED,
result: result
});
} else {
dispatch({
type: ACTIONS.WALLET_STATUS_FAILED,
result: result
});
}
});
};
}
/***/ }),
/* 29 */
/***/ (function(module, exports, __webpack_require__) {
@ -4637,7 +4845,7 @@ function doSendSupport(amount, claimId, uri, successCallback, errorCallback) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.makeSelectBlockDate = exports.selectBlocks = exports.selectDraftTransactionError = exports.selectDraftTransactionAddress = exports.selectDraftTransactionAmount = exports.selectDraftTransaction = exports.selectGettingNewAddress = exports.selectReceiveAddress = exports.selectIsSendingSupport = exports.selectIsFetchingTransactions = exports.selectHasTransactions = exports.selectRecentTransactions = exports.selectTransactionItems = exports.selectTransactionsById = exports.selectBalance = exports.selectState = undefined;
exports.makeSelectBlockDate = exports.selectBlocks = exports.selectDraftTransactionError = exports.selectDraftTransactionAddress = exports.selectDraftTransactionAmount = exports.selectDraftTransaction = exports.selectGettingNewAddress = exports.selectReceiveAddress = exports.selectIsSendingSupport = exports.selectIsFetchingTransactions = exports.selectHasTransactions = exports.selectRecentTransactions = exports.selectTransactionItems = exports.selectTransactionsById = exports.selectBalance = exports.selectWalletLockResult = exports.selectWalletLockSucceeded = exports.selectWalletLockPending = exports.selectWalletUnlockResult = exports.selectWalletUnlockSucceeded = exports.selectWalletUnlockPending = exports.selectWalletDecryptResult = exports.selectWalletDecryptSucceeded = exports.selectWalletDecryptPending = exports.selectWalletEncryptResult = exports.selectWalletEncryptSucceeded = exports.selectWalletEncryptPending = exports.selectWalletIsEncrypted = exports.selectWalletState = exports.selectState = undefined;
var _reselect = __webpack_require__(16);
@ -4653,6 +4861,60 @@ var selectState = exports.selectState = function selectState(state) {
return state.wallet || {};
};
var selectWalletState = exports.selectWalletState = selectState;
var selectWalletIsEncrypted = exports.selectWalletIsEncrypted = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletIsEncrypted;
});
var selectWalletEncryptPending = exports.selectWalletEncryptPending = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletEncryptPending;
});
var selectWalletEncryptSucceeded = exports.selectWalletEncryptSucceeded = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletEncryptSucceded;
});
var selectWalletEncryptResult = exports.selectWalletEncryptResult = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletEncryptResult;
});
var selectWalletDecryptPending = exports.selectWalletDecryptPending = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletDecryptPending;
});
var selectWalletDecryptSucceeded = exports.selectWalletDecryptSucceeded = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletDecryptSucceded;
});
var selectWalletDecryptResult = exports.selectWalletDecryptResult = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletDecryptResult;
});
var selectWalletUnlockPending = exports.selectWalletUnlockPending = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletUnlockPending;
});
var selectWalletUnlockSucceeded = exports.selectWalletUnlockSucceeded = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletUnlockSucceded;
});
var selectWalletUnlockResult = exports.selectWalletUnlockResult = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletUnlockResult;
});
var selectWalletLockPending = exports.selectWalletLockPending = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletLockPending;
});
var selectWalletLockSucceeded = exports.selectWalletLockSucceeded = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletLockSucceded;
});
var selectWalletLockResult = exports.selectWalletLockResult = (0, _reselect.createSelector)(selectState, function (state) {
return state.walletLockResult;
});
var selectBalance = exports.selectBalance = (0, _reselect.createSelector)(selectState, function (state) {
return state.balance;
});
@ -5545,6 +5807,9 @@ var PUBLISH = exports.PUBLISH = 'publish';
var SEARCH = exports.SEARCH = 'search';
var CONFIRM_TRANSACTION = exports.CONFIRM_TRANSACTION = 'confirm_transaction';
var CONFIRM_THUMBNAIL_UPLOAD = exports.CONFIRM_THUMBNAIL_UPLOAD = 'confirm_thumbnail_upload';
var WALLET_ENCRYPT = exports.WALLET_ENCRYPT = 'wallet_encrypt';
var WALLET_DECRYPT = exports.WALLET_DECRYPT = 'wallet_decrypt';
var WALLET_UNLOCK = exports.WALLET_UNLOCK = 'wallet_unlock';
/***/ }),
/* 37 */
@ -5729,6 +5994,35 @@ var buildDraftTransaction = function buildDraftTransaction() {
};
};
// TODO: Split into common success and failure types
// See details in https://github.com/lbryio/lbry/issues/1307
/*:: type ActionResult = {
result: any,
};*/
/*:: type WalletState = {
balance: any,
blocks: any,
transactions: any,
fetchingTransactions: boolean,
gettingNewAddress: boolean,
draftTransaction: any,
sendingSupport: boolean,
walletIsEncrypted: boolean,
walletEncryptPending: boolean,
walletEncryptSucceded: ?boolean,
walletEncryptResult: ?boolean,
walletDecryptPending: boolean,
walletDecryptSucceded: ?boolean,
walletDecryptResult: ?boolean,
walletUnlockPending: boolean,
walletUnlockSucceded: ?boolean,
walletUnlockResult: ?boolean,
walletLockPending: boolean,
walletLockSucceded: ?boolean,
walletLockResult: ?boolean,
}*/
var defaultState = {
balance: undefined,
blocks: {},
@ -5736,16 +6030,29 @@ var defaultState = {
fetchingTransactions: false,
gettingNewAddress: false,
draftTransaction: buildDraftTransaction(),
sendingSupport: false
sendingSupport: false,
walletIsEncrypted: false,
walletEncryptPending: false,
walletEncryptSucceded: null,
walletEncryptResult: null,
walletDecryptPending: false,
walletDecryptSucceded: null,
walletDecryptResult: null,
walletUnlockPending: false,
walletUnlockSucceded: null,
walletUnlockResult: null,
walletLockPending: false,
walletLockSucceded: null,
walletLockResult: null
};
reducers[ACTIONS.FETCH_TRANSACTIONS_STARTED] = function (state) {
reducers[ACTIONS.FETCH_TRANSACTIONS_STARTED] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
fetchingTransactions: true
});
};
reducers[ACTIONS.FETCH_TRANSACTIONS_COMPLETED] = function (state, action) {
reducers[ACTIONS.FETCH_TRANSACTIONS_COMPLETED] = function (state /*: WalletState*/, action) {
var byId = Object.assign({}, state.transactions);
var transactions = action.data.transactions;
@ -5761,13 +6068,13 @@ reducers[ACTIONS.FETCH_TRANSACTIONS_COMPLETED] = function (state, action) {
});
};
reducers[ACTIONS.GET_NEW_ADDRESS_STARTED] = function (state) {
reducers[ACTIONS.GET_NEW_ADDRESS_STARTED] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
gettingNewAddress: true
});
};
reducers[ACTIONS.GET_NEW_ADDRESS_COMPLETED] = function (state, action) {
reducers[ACTIONS.GET_NEW_ADDRESS_COMPLETED] = function (state /*: WalletState*/, action) {
var address = action.data.address;
// Say no to localStorage!
@ -5778,25 +6085,25 @@ reducers[ACTIONS.GET_NEW_ADDRESS_COMPLETED] = function (state, action) {
});
};
reducers[ACTIONS.UPDATE_BALANCE] = function (state, action) {
reducers[ACTIONS.UPDATE_BALANCE] = function (state /*: WalletState*/, action) {
return Object.assign({}, state, {
balance: action.data.balance
});
};
reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED] = function (state) {
reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
checkingAddressOwnership: true
});
};
reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_COMPLETED] = function (state) {
reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_COMPLETED] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
checkingAddressOwnership: false
});
};
reducers[ACTIONS.SET_DRAFT_TRANSACTION_AMOUNT] = function (state, action) {
reducers[ACTIONS.SET_DRAFT_TRANSACTION_AMOUNT] = function (state /*: WalletState*/, action) {
var oldDraft = state.draftTransaction;
var newDraft = Object.assign({}, oldDraft, {
amount: parseFloat(action.data.amount)
@ -5807,7 +6114,7 @@ reducers[ACTIONS.SET_DRAFT_TRANSACTION_AMOUNT] = function (state, action) {
});
};
reducers[ACTIONS.SET_DRAFT_TRANSACTION_ADDRESS] = function (state, action) {
reducers[ACTIONS.SET_DRAFT_TRANSACTION_ADDRESS] = function (state /*: WalletState*/, action) {
var oldDraft = state.draftTransaction;
var newDraft = Object.assign({}, oldDraft, {
address: action.data.address
@ -5818,7 +6125,7 @@ reducers[ACTIONS.SET_DRAFT_TRANSACTION_ADDRESS] = function (state, action) {
});
};
reducers[ACTIONS.SEND_TRANSACTION_STARTED] = function (state) {
reducers[ACTIONS.SEND_TRANSACTION_STARTED] = function (state /*: WalletState*/) {
var newDraftTransaction = Object.assign({}, state.draftTransaction, {
sending: true
});
@ -5828,13 +6135,13 @@ reducers[ACTIONS.SEND_TRANSACTION_STARTED] = function (state) {
});
};
reducers[ACTIONS.SEND_TRANSACTION_COMPLETED] = function (state) {
reducers[ACTIONS.SEND_TRANSACTION_COMPLETED] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
draftTransaction: buildDraftTransaction()
});
};
reducers[ACTIONS.SEND_TRANSACTION_FAILED] = function (state, action) {
reducers[ACTIONS.SEND_TRANSACTION_FAILED] = function (state /*: WalletState*/, action) {
var newDraftTransaction = Object.assign({}, state.draftTransaction, {
sending: false,
error: action.data.error
@ -5845,26 +6152,26 @@ reducers[ACTIONS.SEND_TRANSACTION_FAILED] = function (state, action) {
});
};
reducers[ACTIONS.SUPPORT_TRANSACTION_STARTED] = function (state) {
reducers[ACTIONS.SUPPORT_TRANSACTION_STARTED] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
sendingSupport: true
});
};
reducers[ACTIONS.SUPPORT_TRANSACTION_COMPLETED] = function (state) {
reducers[ACTIONS.SUPPORT_TRANSACTION_COMPLETED] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
sendingSupport: false
});
};
reducers[ACTIONS.SUPPORT_TRANSACTION_FAILED] = function (state, action) {
reducers[ACTIONS.SUPPORT_TRANSACTION_FAILED] = function (state /*: WalletState*/, action) {
return Object.assign({}, state, {
error: action.data.error,
sendingSupport: false
});
};
reducers[ACTIONS.FETCH_BLOCK_SUCCESS] = function (state, action) {
reducers[ACTIONS.FETCH_BLOCK_SUCCESS] = function (state /*: WalletState*/, action) {
var _action$data = action.data,
block = _action$data.block,
height = _action$data.block.height;
@ -5876,6 +6183,108 @@ reducers[ACTIONS.FETCH_BLOCK_SUCCESS] = function (state, action) {
return Object.assign({}, state, { blocks: blocks });
};
reducers[ACTIONS.WALLET_STATUS_COMPLETED] = function (state /*: WalletState*/, action) {
return Object.assign({}, state, {
walletIsEncrypted: !!action.result.wallet_is_encrypted
});
};
reducers[ACTIONS.WALLET_ENCRYPT_START] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
walletEncryptPending: true,
walletEncryptSucceded: null,
walletEncryptResult: null
});
};
reducers[ACTIONS.WALLET_ENCRYPT_COMPLETED] = function (state /*: WalletState*/, action /*: ActionResult*/) {
return Object.assign({}, state, {
walletEncryptPending: false,
walletEncryptSucceded: true,
walletEncryptResult: action.result
});
};
reducers[ACTIONS.WALLET_ENCRYPT_FAILED] = function (state /*: WalletState*/, action /*: ActionResult*/) {
return Object.assign({}, state, {
walletEncryptPending: false,
walletEncryptSucceded: false,
walletEncryptResult: action.result
});
};
reducers[ACTIONS.WALLET_DECRYPT_START] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
walletDecryptPending: true,
walletDecryptSucceded: null,
walletDecryptResult: null
});
};
reducers[ACTIONS.WALLET_DECRYPT_COMPLETED] = function (state /*: WalletState*/, action /*: ActionResult*/) {
return Object.assign({}, state, {
walletDecryptPending: false,
walletDecryptSucceded: true,
walletDecryptResult: action.result
});
};
reducers[ACTIONS.WALLET_DECRYPT_FAILED] = function (state /*: WalletState*/, action /*: ActionResult*/) {
return Object.assign({}, state, {
walletDecryptPending: false,
walletDecryptSucceded: false,
walletDecryptResult: action.result
});
};
reducers[ACTIONS.WALLET_UNLOCK_START] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
walletUnlockPending: true,
walletUnlockSucceded: null,
walletUnlockResult: null
});
};
reducers[ACTIONS.WALLET_UNLOCK_COMPLETED] = function (state /*: WalletState*/, action /*: ActionResult*/) {
return Object.assign({}, state, {
walletUnlockPending: false,
walletUnlockSucceded: true,
walletUnlockResult: action.result
});
};
reducers[ACTIONS.WALLET_UNLOCK_FAILED] = function (state /*: WalletState*/, action /*: ActionResult*/) {
return Object.assign({}, state, {
walletUnlockPending: false,
walletUnlockSucceded: false,
walletUnlockResult: action.result
});
};
reducers[ACTIONS.WALLET_LOCK_START] = function (state /*: WalletState*/) {
return Object.assign({}, state, {
walletLockPending: false,
walletLockSucceded: null,
walletLockResult: null
});
};
reducers[ACTIONS.WALLET_LOCK_COMPLETED] = function (state /*: WalletState*/, action /*: ActionResult*/) {
return Object.assign({}, state, {
walletLockPending: false,
walletLockSucceded: true,
walletLockResult: action.result
});
};
reducers[ACTIONS.WALLET_LOCK_FAILED] = function (state /*: WalletState*/, action /*: ActionResult*/) {
return Object.assign({}, state, {
walletLockPending: false,
walletLockSucceded: false,
walletLockResult: action.result
});
};
function walletReducer() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
var action = arguments[1];

9849
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -34,6 +34,7 @@
"babel-eslint": "^8.0.3",
"babel-loader": "^7.1.4",
"babel-plugin-module-resolver": "^3.0.0",
"babel-plugin-transform-flow-comments": "^6.17.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.18.0",
"eslint": "^4.19.1",
@ -43,9 +44,9 @@
"eslint-plugin-flowtype": "^2.40.1",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-prettier": "^2.4.0",
"flow-babel-webpack-plugin": "^1.1.1",
"flow-bin": "^0.69.0",
"flow-typed": "^2.4.0",
"flow-typed": "^2.5.1",
"flow-webpack-plugin": "^1.2.0",
"husky": "^0.14.3",
"lint-staged": "^7.0.4",
"prettier": "^1.4.2",

View file

@ -42,6 +42,21 @@ export const FETCH_BLOCK_SUCCESS = 'FETCH_BLOCK_SUCCESS';
export const SUPPORT_TRANSACTION_STARTED = 'SUPPORT_TRANSACTION_STARTED';
export const SUPPORT_TRANSACTION_COMPLETED = 'SUPPORT_TRANSACTION_COMPLETED';
export const SUPPORT_TRANSACTION_FAILED = 'SUPPORT_TRANSACTION_FAILED';
export const WALLET_ENCRYPT_START = 'WALLET_ENCRYPT_START';
export const WALLET_ENCRYPT_COMPLETED = 'WALLET_ENCRYPT_COMPLETED';
export const WALLET_ENCRYPT_FAILED = 'WALLET_ENCRYPT_FAILED';
export const WALLET_UNLOCK_START = 'WALLET_UNLOCK_START';
export const WALLET_UNLOCK_COMPLETED = 'WALLET_UNLOCK_COMPLETED';
export const WALLET_UNLOCK_FAILED = 'WALLET_UNLOCK_FAILED';
export const WALLET_DECRYPT_START = 'WALLET_DECRYPT_START';
export const WALLET_DECRYPT_COMPLETED = 'WALLET_DECRYPT_COMPLETED';
export const WALLET_DECRYPT_FAILED = 'WALLET_DECRYPT_FAILED';
export const WALLET_LOCK_START = 'WALLET_LOCK_START';
export const WALLET_LOCK_COMPLETED = 'WALLET_LOCK_COMPLETED';
export const WALLET_LOCK_FAILED = 'WALLET_LOCK_FAILED';
export const WALLET_STATUS_START = 'WALLET_STATUS_START';
export const WALLET_STATUS_COMPLETED = 'WALLET_STATUS_COMPLETED';
export const WALLET_STATUS_FAILED = 'WALLET_STATUS_FAILED';
// Claims
export const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';

View file

@ -23,3 +23,6 @@ export const PUBLISH = 'publish';
export const SEARCH = 'search';
export const CONFIRM_TRANSACTION = 'confirm_transaction';
export const CONFIRM_THUMBNAIL_UPLOAD = 'confirm_thumbnail_upload';
export const WALLET_ENCRYPT = 'wallet_encrypt';
export const WALLET_DECRYPT = 'wallet_decrypt';
export const WALLET_UNLOCK = 'wallet_unlock';

View file

@ -71,6 +71,10 @@ export {
doSetDraftTransactionAmount,
doSetDraftTransactionAddress,
doSendSupport,
doWalletEncrypt,
doWalletDecrypt,
doWalletUnlock,
doWalletStatus,
} from 'redux/actions/wallet';
// utils
@ -202,4 +206,15 @@ export {
selectDraftTransactionAddress,
selectDraftTransactionError,
selectBlocks,
selectWalletIsEncrypted,
selectWalletState,
selectWalletEncryptPending,
selectWalletEncryptSucceeded,
selectWalletEncryptResult,
selectWalletDecryptPending,
selectWalletDecryptSucceeded,
selectWalletDecryptResult,
selectWalletUnlockPending,
selectWalletUnlockSucceeded,
selectWalletUnlockResult,
} from 'redux/selectors/wallet';

View file

@ -79,6 +79,7 @@ Lbry.wallet_send = (params = {}) => daemonCallWithResult('wallet_send', params);
Lbry.wallet_encrypt = (params = {}) => daemonCallWithResult('wallet_encrypt', params);
Lbry.wallet_decrypt = () => daemonCallWithResult('wallet_decrypt', {});
Lbry.wallet_unlock = (params = {}) => daemonCallWithResult('wallet_unlock', params);
Lbry.wallet_lock = () => daemonCallWithResult('wallet_lock', {});
// transactions
Lbry.transaction_list = (params = {}) => daemonCallWithResult('transaction_list', params);
@ -128,7 +129,7 @@ Lbry.getMediaType = (contentType, extname) => {
return res === extname ? 'unknown' : res;
} else if (contentType) {
return /^[^/]+/.exec(contentType)[0];
}
}
return 'unknown';
};

View file

@ -242,3 +242,113 @@ export function doSendSupport(amount, claimId, uri, successCallback, errorCallba
}).then(success, error);
};
}
export function doWalletEncrypt(newPassword) {
return dispatch => {
dispatch({
type: ACTIONS.WALLET_ENCRYPT_START,
});
Lbry.wallet_encrypt({ new_password: newPassword }).then(result => {
if (result === true) {
dispatch({
type: ACTIONS.WALLET_ENCRYPT_COMPLETED,
result,
});
} else {
dispatch({
type: ACTIONS.WALLET_ENCRYPT_FAILED,
result,
});
}
});
};
}
export function doWalletUnlock(password) {
return dispatch => {
dispatch({
type: ACTIONS.WALLET_UNLOCK_START,
});
Lbry.wallet_unlock({ password }).then(result => {
if (result === true) {
dispatch({
type: ACTIONS.WALLET_UNLOCK_COMPLETED,
result,
});
} else {
dispatch({
type: ACTIONS.WALLET_UNLOCK_FAILED,
result,
});
}
});
};
}
export function doWalletLock() {
return dispatch => {
dispatch({
type: ACTIONS.WALLET_LOCK_START,
});
Lbry.wallet_lock().then(result => {
if (result === true) {
dispatch({
type: ACTIONS.WALLET_LOCK_COMPLETED,
result,
});
} else {
dispatch({
type: ACTIONS.WALLET_LOCK_FAILED,
result,
});
}
});
};
}
export function doWalletDecrypt() {
return dispatch => {
dispatch({
type: ACTIONS.WALLET_DECRYPT_START,
});
Lbry.wallet_decrypt().then(result => {
if (result === true) {
dispatch({
type: ACTIONS.WALLET_DECRYPT_COMPLETED,
result,
});
} else {
dispatch({
type: ACTIONS.WALLET_DECRYPT_FAILED,
result,
});
}
});
};
}
export function doWalletStatus() {
return dispatch => {
dispatch({
type: ACTIONS.WALLET_STATUS_START,
});
Lbry.status().then(result => {
if (result && !result.error) {
dispatch({
type: ACTIONS.WALLET_STATUS_COMPLETED,
result,
});
} else {
dispatch({
type: ACTIONS.WALLET_STATUS_FAILED,
result,
});
}
});
};
}

View file

@ -1,3 +1,4 @@
// @flow
import * as ACTIONS from 'constants/action_types';
const reducers = {};
@ -6,6 +7,36 @@ const buildDraftTransaction = () => ({
address: undefined,
});
// TODO: Split into common success and failure types
// See details in https://github.com/lbryio/lbry/issues/1307
type ActionResult = {
type: any,
result: any,
};
type WalletState = {
balance: any,
blocks: any,
transactions: any,
fetchingTransactions: boolean,
gettingNewAddress: boolean,
draftTransaction: any,
sendingSupport: boolean,
walletIsEncrypted: boolean,
walletEncryptPending: boolean,
walletEncryptSucceded: ?boolean,
walletEncryptResult: ?boolean,
walletDecryptPending: boolean,
walletDecryptSucceded: ?boolean,
walletDecryptResult: ?boolean,
walletUnlockPending: boolean,
walletUnlockSucceded: ?boolean,
walletUnlockResult: ?boolean,
walletLockPending: boolean,
walletLockSucceded: ?boolean,
walletLockResult: ?boolean,
};
const defaultState = {
balance: undefined,
blocks: {},
@ -14,14 +45,27 @@ const defaultState = {
gettingNewAddress: false,
draftTransaction: buildDraftTransaction(),
sendingSupport: false,
walletIsEncrypted: false,
walletEncryptPending: false,
walletEncryptSucceded: null,
walletEncryptResult: null,
walletDecryptPending: false,
walletDecryptSucceded: null,
walletDecryptResult: null,
walletUnlockPending: false,
walletUnlockSucceded: null,
walletUnlockResult: null,
walletLockPending: false,
walletLockSucceded: null,
walletLockResult: null,
};
reducers[ACTIONS.FETCH_TRANSACTIONS_STARTED] = state =>
reducers[ACTIONS.FETCH_TRANSACTIONS_STARTED] = (state: WalletState) =>
Object.assign({}, state, {
fetchingTransactions: true,
});
reducers[ACTIONS.FETCH_TRANSACTIONS_COMPLETED] = (state, action) => {
reducers[ACTIONS.FETCH_TRANSACTIONS_COMPLETED] = (state: WalletState, action) => {
const byId = Object.assign({}, state.transactions);
const { transactions } = action.data;
@ -36,12 +80,12 @@ reducers[ACTIONS.FETCH_TRANSACTIONS_COMPLETED] = (state, action) => {
});
};
reducers[ACTIONS.GET_NEW_ADDRESS_STARTED] = state =>
reducers[ACTIONS.GET_NEW_ADDRESS_STARTED] = (state: WalletState) =>
Object.assign({}, state, {
gettingNewAddress: true,
});
reducers[ACTIONS.GET_NEW_ADDRESS_COMPLETED] = (state, action) => {
reducers[ACTIONS.GET_NEW_ADDRESS_COMPLETED] = (state: WalletState, action) => {
const { address } = action.data;
// Say no to localStorage!
@ -51,22 +95,22 @@ reducers[ACTIONS.GET_NEW_ADDRESS_COMPLETED] = (state, action) => {
});
};
reducers[ACTIONS.UPDATE_BALANCE] = (state, action) =>
reducers[ACTIONS.UPDATE_BALANCE] = (state: WalletState, action) =>
Object.assign({}, state, {
balance: action.data.balance,
});
reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED] = state =>
reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED] = (state: WalletState) =>
Object.assign({}, state, {
checkingAddressOwnership: true,
});
reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_COMPLETED] = state =>
reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_COMPLETED] = (state: WalletState) =>
Object.assign({}, state, {
checkingAddressOwnership: false,
});
reducers[ACTIONS.SET_DRAFT_TRANSACTION_AMOUNT] = (state, action) => {
reducers[ACTIONS.SET_DRAFT_TRANSACTION_AMOUNT] = (state: WalletState, action) => {
const oldDraft = state.draftTransaction;
const newDraft = Object.assign({}, oldDraft, {
amount: parseFloat(action.data.amount),
@ -77,7 +121,7 @@ reducers[ACTIONS.SET_DRAFT_TRANSACTION_AMOUNT] = (state, action) => {
});
};
reducers[ACTIONS.SET_DRAFT_TRANSACTION_ADDRESS] = (state, action) => {
reducers[ACTIONS.SET_DRAFT_TRANSACTION_ADDRESS] = (state: WalletState, action) => {
const oldDraft = state.draftTransaction;
const newDraft = Object.assign({}, oldDraft, {
address: action.data.address,
@ -88,7 +132,7 @@ reducers[ACTIONS.SET_DRAFT_TRANSACTION_ADDRESS] = (state, action) => {
});
};
reducers[ACTIONS.SEND_TRANSACTION_STARTED] = state => {
reducers[ACTIONS.SEND_TRANSACTION_STARTED] = (state: WalletState) => {
const newDraftTransaction = Object.assign({}, state.draftTransaction, {
sending: true,
});
@ -98,12 +142,12 @@ reducers[ACTIONS.SEND_TRANSACTION_STARTED] = state => {
});
};
reducers[ACTIONS.SEND_TRANSACTION_COMPLETED] = state =>
reducers[ACTIONS.SEND_TRANSACTION_COMPLETED] = (state: WalletState) =>
Object.assign({}, state, {
draftTransaction: buildDraftTransaction(),
});
reducers[ACTIONS.SEND_TRANSACTION_FAILED] = (state, action) => {
reducers[ACTIONS.SEND_TRANSACTION_FAILED] = (state: WalletState, action) => {
const newDraftTransaction = Object.assign({}, state.draftTransaction, {
sending: false,
error: action.data.error,
@ -114,24 +158,27 @@ reducers[ACTIONS.SEND_TRANSACTION_FAILED] = (state, action) => {
});
};
reducers[ACTIONS.SUPPORT_TRANSACTION_STARTED] = state =>
reducers[ACTIONS.SUPPORT_TRANSACTION_STARTED] = (state: WalletState) =>
Object.assign({}, state, {
sendingSupport: true,
});
reducers[ACTIONS.SUPPORT_TRANSACTION_COMPLETED] = state =>
reducers[ACTIONS.SUPPORT_TRANSACTION_COMPLETED] = (state: WalletState) =>
Object.assign({}, state, {
sendingSupport: false,
});
reducers[ACTIONS.SUPPORT_TRANSACTION_FAILED] = (state, action) =>
reducers[ACTIONS.SUPPORT_TRANSACTION_FAILED] = (state: WalletState, action) =>
Object.assign({}, state, {
error: action.data.error,
sendingSupport: false,
});
reducers[ACTIONS.FETCH_BLOCK_SUCCESS] = (state, action) => {
const { block, block: { height } } = action.data;
reducers[ACTIONS.FETCH_BLOCK_SUCCESS] = (state: WalletState, action) => {
const {
block,
block: { height },
} = action.data;
const blocks = Object.assign({}, state.blocks);
blocks[height] = block;
@ -139,6 +186,95 @@ reducers[ACTIONS.FETCH_BLOCK_SUCCESS] = (state, action) => {
return Object.assign({}, state, { blocks });
};
reducers[ACTIONS.WALLET_STATUS_COMPLETED] = (state: WalletState, action) =>
Object.assign({}, state, {
walletIsEncrypted: !!action.result.wallet_is_encrypted,
});
reducers[ACTIONS.WALLET_ENCRYPT_START] = (state: WalletState) =>
Object.assign({}, state, {
walletEncryptPending: true,
walletEncryptSucceded: null,
walletEncryptResult: null,
});
reducers[ACTIONS.WALLET_ENCRYPT_COMPLETED] = (state: WalletState, action: ActionResult) =>
Object.assign({}, state, {
walletEncryptPending: false,
walletEncryptSucceded: true,
walletEncryptResult: action.result,
});
reducers[ACTIONS.WALLET_ENCRYPT_FAILED] = (state: WalletState, action: ActionResult) =>
Object.assign({}, state, {
walletEncryptPending: false,
walletEncryptSucceded: false,
walletEncryptResult: action.result,
});
reducers[ACTIONS.WALLET_DECRYPT_START] = (state: WalletState) =>
Object.assign({}, state, {
walletDecryptPending: true,
walletDecryptSucceded: null,
walletDecryptResult: null,
});
reducers[ACTIONS.WALLET_DECRYPT_COMPLETED] = (state: WalletState, action: ActionResult) =>
Object.assign({}, state, {
walletDecryptPending: false,
walletDecryptSucceded: true,
walletDecryptResult: action.result,
});
reducers[ACTIONS.WALLET_DECRYPT_FAILED] = (state: WalletState, action: ActionResult) =>
Object.assign({}, state, {
walletDecryptPending: false,
walletDecryptSucceded: false,
walletDecryptResult: action.result,
});
reducers[ACTIONS.WALLET_UNLOCK_START] = (state: WalletState) =>
Object.assign({}, state, {
walletUnlockPending: true,
walletUnlockSucceded: null,
walletUnlockResult: null,
});
reducers[ACTIONS.WALLET_UNLOCK_COMPLETED] = (state: WalletState, action: ActionResult) =>
Object.assign({}, state, {
walletUnlockPending: false,
walletUnlockSucceded: true,
walletUnlockResult: action.result,
});
reducers[ACTIONS.WALLET_UNLOCK_FAILED] = (state: WalletState, action: ActionResult) =>
Object.assign({}, state, {
walletUnlockPending: false,
walletUnlockSucceded: false,
walletUnlockResult: action.result,
});
reducers[ACTIONS.WALLET_LOCK_START] = (state: WalletState) =>
Object.assign({}, state, {
walletLockPending: false,
walletLockSucceded: null,
walletLockResult: null,
});
reducers[ACTIONS.WALLET_LOCK_COMPLETED] = (state: WalletState, action: ActionResult) =>
Object.assign({}, state, {
walletLockPending: false,
walletLockSucceded: true,
walletLockResult: action.result,
});
reducers[ACTIONS.WALLET_LOCK_FAILED] = (state: WalletState, action: ActionResult) =>
Object.assign({}, state, {
walletLockPending: false,
walletLockSucceded: false,
walletLockResult: action.result,
});
export function walletReducer(state = defaultState, action) {
const handler = reducers[action.type];
if (handler) return handler(state, action);

View file

@ -3,6 +3,70 @@ import * as TRANSACTIONS from 'constants/transaction_types';
export const selectState = state => state.wallet || {};
export const selectWalletState = selectState;
export const selectWalletIsEncrypted = createSelector(
selectState,
state => state.walletIsEncrypted
);
export const selectWalletEncryptPending = createSelector(
selectState,
state => state.walletEncryptPending
);
export const selectWalletEncryptSucceeded = createSelector(
selectState,
state => state.walletEncryptSucceded
);
export const selectWalletEncryptResult = createSelector(
selectState,
state => state.walletEncryptResult
);
export const selectWalletDecryptPending = createSelector(
selectState,
state => state.walletDecryptPending
);
export const selectWalletDecryptSucceeded = createSelector(
selectState,
state => state.walletDecryptSucceded
);
export const selectWalletDecryptResult = createSelector(
selectState,
state => state.walletDecryptResult
);
export const selectWalletUnlockPending = createSelector(
selectState,
state => state.walletUnlockPending
);
export const selectWalletUnlockSucceeded = createSelector(
selectState,
state => state.walletUnlockSucceded
);
export const selectWalletUnlockResult = createSelector(
selectState,
state => state.walletUnlockResult
);
export const selectWalletLockPending = createSelector(
selectState,
state => state.walletLockPending
);
export const selectWalletLockSucceeded = createSelector(
selectState,
state => state.walletLockSucceded
);
export const selectWalletLockResult = createSelector(selectState, state => state.walletLockResult);
export const selectBalance = createSelector(selectState, state => state.balance);
export const selectTransactionsById = createSelector(selectState, state => state.transactions);
@ -66,7 +130,7 @@ export const selectTransactionItems = createSelector(selectTransactionsById, byI
txid,
date: tx.timestamp ? new Date(Number(tx.timestamp) * 1000) : null,
amount,
fee: amount < 0 ? (-1 * tx.fee) / append.length : 0,
fee: amount < 0 ? -1 * tx.fee / append.length : 0,
claim_id: item.claim_id,
claim_name: item.claim_name,
type: item.type || TRANSACTIONS.SPEND,

View file

@ -1,6 +1,7 @@
/* eslint-disable import/no-commonjs */
const path = require('path');
const FlowBabelWebpackPlugin = require('flow-babel-webpack-plugin');
//const FlowBabelWebpackPlugin = require('flow-babel-webpack-plugin');
const FlowWebpackPlugin = require('flow-webpack-plugin')
module.exports = {
mode: 'none',
@ -22,5 +23,5 @@ module.exports = {
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
},
plugins: [new FlowBabelWebpackPlugin()],
plugins: [new FlowWebpackPlugin()],
};

109
yarn.lock
View file

@ -99,6 +99,19 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"
"@octokit/rest@^15.2.6":
version "15.9.4"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-15.9.4.tgz#c6cf0f483275d9c798b18419b7c9d417493bb70f"
dependencies:
before-after-hook "^1.1.0"
btoa-lite "^1.0.0"
debug "^3.1.0"
http-proxy-agent "^2.1.0"
https-proxy-agent "^2.2.0"
lodash "^4.17.4"
node-fetch "^2.1.1"
url-template "^2.0.8"
"@sindresorhus/is@^0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
@ -248,6 +261,12 @@ acorn@^5.0.0, acorn@^5.3.0, acorn@^5.5.0:
version "5.5.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.5.3.tgz#f473dd47e0277a08e28e9bec5aeeb04751f0b8c9"
agent-base@4, agent-base@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9"
dependencies:
es6-promisify "^5.0.0"
ajv-keywords@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"
@ -1153,6 +1172,10 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"
before-after-hook@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-1.1.0.tgz#83165e15a59460d13702cb8febd6a1807896db5a"
big-integer@^1.6.17:
version "1.6.28"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.28.tgz#8cef0fda3ccde8759c2c66efcfacc35aea658283"
@ -1303,6 +1326,10 @@ browserslist@^2.1.2:
caniuse-lite "^1.0.30000792"
electron-to-chromium "^1.3.30"
btoa-lite@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337"
buffer-from@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531"
@ -1828,15 +1855,15 @@ dateformat@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
debug@3.1.0, debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
ms "2.0.0"
debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"
@ -2070,6 +2097,16 @@ error@^7.0.2:
string-template "~0.2.1"
xtend "~4.0.0"
es6-promise@^4.0.3:
version "4.2.4"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29"
es6-promisify@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
dependencies:
es6-promise "^4.0.3"
escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@ -2504,18 +2541,6 @@ flat-cache@^1.2.1:
graceful-fs "^4.1.2"
write "^0.2.1"
flow-babel-webpack-plugin@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/flow-babel-webpack-plugin/-/flow-babel-webpack-plugin-1.1.1.tgz#7dd41110b96045eab8d8af6df48883310de54e91"
dependencies:
babel-plugin-transform-flow-comments "^6.17.0"
flow-bin ">=0.44.2 <1"
lodash.merge "^4.6.0"
"flow-bin@>=0.44.2 <1":
version "0.72.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.72.0.tgz#12051180fb2db7ccb728fefe67c77e955e92a44d"
flow-bin@^0.69.0:
version "0.69.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.69.0.tgz#053159a684a6051fcbf0b71a2eb19a9679082da6"
@ -2524,14 +2549,14 @@ flow-parser@^0.*:
version "0.72.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.72.0.tgz#6c8041e76ac7d0be1a71ce29c00cd1435fb6013c"
flow-typed@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/flow-typed/-/flow-typed-2.4.0.tgz#3d2f48cf85df29df3bca6745b623726496ff4788"
flow-typed@^2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/flow-typed/-/flow-typed-2.5.1.tgz#0ff565cc94d2af8c557744ba364b6f14726a6b9f"
dependencies:
"@octokit/rest" "^15.2.6"
babel-polyfill "^6.26.0"
colors "^1.1.2"
fs-extra "^5.0.0"
github "0.2.4"
glob "^7.1.2"
got "^7.1.0"
md5 "^2.1.0"
@ -2544,6 +2569,10 @@ flow-typed@^2.4.0:
which "^1.3.0"
yargs "^4.2.0"
flow-webpack-plugin@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/flow-webpack-plugin/-/flow-webpack-plugin-1.2.0.tgz#1958821d16135028e391cad5ee2f3a4fa78197ec"
flush-write-stream@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.0.3.tgz#c5d586ef38af6097650b49bc41b55fabb19f35bd"
@ -2689,12 +2718,6 @@ github-username@^4.0.0:
dependencies:
gh-got "^6.0.0"
github@0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/github/-/github-0.2.4.tgz#24fa7f0e13fa11b946af91134c51982a91ce538b"
dependencies:
mime "^1.2.11"
glob-all@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/glob-all/-/glob-all-3.1.0.tgz#8913ddfb5ee1ac7812656241b03d5217c64b02ab"
@ -2981,6 +3004,13 @@ http-cache-semantics@3.8.1:
version "3.8.1"
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2"
http-proxy-agent@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405"
dependencies:
agent-base "4"
debug "3.1.0"
http-signature@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1"
@ -2993,6 +3023,13 @@ https-browserify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
https-proxy-agent@^2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0"
dependencies:
agent-base "^4.1.0"
debug "^3.1.0"
husky@^0.14.3:
version "0.14.3"
resolved "https://registry.yarnpkg.com/husky/-/husky-0.14.3.tgz#c69ed74e2d2779769a17ba8399b54ce0b63c12c3"
@ -3896,10 +3933,6 @@ lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
lodash.merge@^4.6.0:
version "4.6.1"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54"
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
@ -4085,10 +4118,6 @@ mime-types@^2.1.12, mime-types@~2.1.17:
dependencies:
mime-db "~1.33.0"
mime@^1.2.11:
version "1.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
@ -4237,6 +4266,10 @@ node-dir@0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.8.tgz#55fb8deb699070707fb67f91a460f0448294c77d"
node-fetch@^2.1.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.2.0.tgz#4ee79bde909262f9775f731e3656d0db55ced5b5"
"node-libs-browser@^1.0.0 || ^2.0.0", node-libs-browser@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.1.0.tgz#5f94263d404f6e44767d726901fff05478d600df"
@ -5909,6 +5942,10 @@ url-parse-lax@^3.0.0:
dependencies:
prepend-http "^2.0.0"
url-template@^2.0.8:
version "2.0.8"
resolved "https://registry.yarnpkg.com/url-template/-/url-template-2.0.8.tgz#fc565a3cccbff7730c775f5641f9555791439f21"
url-to-options@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9"