diff --git a/dist/bundle.es.js b/dist/bundle.es.js index ae3251f..3f149e2 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -44,6 +44,7 @@ const GET_NEW_ADDRESS_COMPLETED = 'GET_NEW_ADDRESS_COMPLETED'; const FETCH_TRANSACTIONS_STARTED = 'FETCH_TRANSACTIONS_STARTED'; const FETCH_TRANSACTIONS_COMPLETED = 'FETCH_TRANSACTIONS_COMPLETED'; const UPDATE_BALANCE = 'UPDATE_BALANCE'; +const UPDATE_TOTAL_BALANCE = 'UPDATE_TOTAL_BALANCE'; const CHECK_ADDRESS_IS_MINE_STARTED = 'CHECK_ADDRESS_IS_MINE_STARTED'; const CHECK_ADDRESS_IS_MINE_COMPLETED = 'CHECK_ADDRESS_IS_MINE_COMPLETED'; const SEND_TRANSACTION_STARTED = 'SEND_TRANSACTION_STARTED'; @@ -69,6 +70,8 @@ const WALLET_STATUS_START = 'WALLET_STATUS_START'; const WALLET_STATUS_COMPLETED = 'WALLET_STATUS_COMPLETED'; const SET_TRANSACTION_LIST_FILTER = 'SET_TRANSACTION_LIST_FILTER'; const UPDATE_CURRENT_HEIGHT = 'UPDATE_CURRENT_HEIGHT'; +const SET_DRAFT_TRANSACTION_AMOUNT = 'SET_DRAFT_TRANSACTION_AMOUNT'; +const SET_DRAFT_TRANSACTION_ADDRESS = 'SET_DRAFT_TRANSACTION_ADDRESS'; // Claims const RESOLVE_URIS_STARTED = 'RESOLVE_URIS_STARTED'; @@ -215,15 +218,13 @@ const DO_PREPARE_EDIT = 'DO_PREPARE_EDIT'; const CREATE_NOTIFICATION = 'CREATE_NOTIFICATION'; const EDIT_NOTIFICATION = 'EDIT_NOTIFICATION'; const DELETE_NOTIFICATION = 'DELETE_NOTIFICATION'; +const DISMISS_NOTIFICATION = 'DISMISS_NOTIFICATION'; const CREATE_TOAST = 'CREATE_TOAST'; const DISMISS_TOAST = 'DISMISS_TOAST'; const CREATE_ERROR = 'CREATE_ERROR'; const DISMISS_ERROR = 'DISMISS_ERROR'; -const SET_DRAFT_TRANSACTION_AMOUNT = 'SET_DRAFT_TRANSACTION_AMOUNT'; -const SET_DRAFT_TRANSACTION_ADDRESS = 'SET_DRAFT_TRANSACTION_ADDRESS'; const FETCH_DATE = 'FETCH_DATE'; -const DISMISS_NOTIFICATION = 'DISMISS_NOTIFICATION'; var action_types = /*#__PURE__*/Object.freeze({ WINDOW_FOCUSED: WINDOW_FOCUSED, @@ -256,6 +257,7 @@ var action_types = /*#__PURE__*/Object.freeze({ FETCH_TRANSACTIONS_STARTED: FETCH_TRANSACTIONS_STARTED, FETCH_TRANSACTIONS_COMPLETED: FETCH_TRANSACTIONS_COMPLETED, UPDATE_BALANCE: UPDATE_BALANCE, + UPDATE_TOTAL_BALANCE: UPDATE_TOTAL_BALANCE, CHECK_ADDRESS_IS_MINE_STARTED: CHECK_ADDRESS_IS_MINE_STARTED, CHECK_ADDRESS_IS_MINE_COMPLETED: CHECK_ADDRESS_IS_MINE_COMPLETED, SEND_TRANSACTION_STARTED: SEND_TRANSACTION_STARTED, @@ -281,6 +283,8 @@ var action_types = /*#__PURE__*/Object.freeze({ WALLET_STATUS_COMPLETED: WALLET_STATUS_COMPLETED, SET_TRANSACTION_LIST_FILTER: SET_TRANSACTION_LIST_FILTER, UPDATE_CURRENT_HEIGHT: UPDATE_CURRENT_HEIGHT, + SET_DRAFT_TRANSACTION_AMOUNT: SET_DRAFT_TRANSACTION_AMOUNT, + SET_DRAFT_TRANSACTION_ADDRESS: SET_DRAFT_TRANSACTION_ADDRESS, RESOLVE_URIS_STARTED: RESOLVE_URIS_STARTED, RESOLVE_URIS_COMPLETED: RESOLVE_URIS_COMPLETED, FETCH_CHANNEL_CLAIMS_STARTED: FETCH_CHANNEL_CLAIMS_STARTED, @@ -405,14 +409,12 @@ var action_types = /*#__PURE__*/Object.freeze({ CREATE_NOTIFICATION: CREATE_NOTIFICATION, EDIT_NOTIFICATION: EDIT_NOTIFICATION, DELETE_NOTIFICATION: DELETE_NOTIFICATION, + DISMISS_NOTIFICATION: DISMISS_NOTIFICATION, CREATE_TOAST: CREATE_TOAST, DISMISS_TOAST: DISMISS_TOAST, CREATE_ERROR: CREATE_ERROR, DISMISS_ERROR: DISMISS_ERROR, - SET_DRAFT_TRANSACTION_AMOUNT: SET_DRAFT_TRANSACTION_AMOUNT, - SET_DRAFT_TRANSACTION_ADDRESS: SET_DRAFT_TRANSACTION_ADDRESS, - FETCH_DATE: FETCH_DATE, - DISMISS_NOTIFICATION: DISMISS_NOTIFICATION + FETCH_DATE: FETCH_DATE }); const API_DOWN = 'apiDown'; @@ -651,6 +653,10 @@ Lbry.claim_tip = (params = {}) => daemonCallWithResult('claim_tip', params); Lbry.transaction_list = (params = {}) => daemonCallWithResult('transaction_list', params); Lbry.utxo_release = (params = {}) => daemonCallWithResult('utxo_release', params); +// sync +Lbry.sync_hash = (params = {}) => daemonCallWithResult('sync_hash', params); +Lbry.sync_apply = (params = {}) => daemonCallWithResult('sync_apply', params); + Lbry.connectPromise = null; Lbry.connect = () => { if (Lbry.connectPromise === null) { @@ -1376,6 +1382,8 @@ const selectWalletLockResult = reselect.createSelector(selectState$2, state => s const selectBalance = reselect.createSelector(selectState$2, state => state.balance); +const selectTotalBalance = reselect.createSelector(selectState$2, state => state.totalBalance); + const selectTransactionsById = reselect.createSelector(selectState$2, state => state.transactions); const selectTransactionItems = reselect.createSelector(selectTransactionsById, byId => { @@ -1534,7 +1542,6 @@ function doUpdateBalance() { } = getState(); lbryProxy.account_balance().then(balanceAsString => { const balance = parseFloat(balanceAsString); - if (balanceInStore !== balance) { dispatch({ type: UPDATE_BALANCE, @@ -1547,6 +1554,27 @@ function doUpdateBalance() { }; } +function doUpdateTotalBalance() { + return (dispatch, getState) => { + const { + wallet: { totalBalance: totalBalanceInStore } + } = getState(); + lbryProxy.account_list().then(accountList => { + const { lbc_mainnet: accounts } = accountList; + const totalSatoshis = accounts.length === 1 ? accounts[0].satoshis : accounts.reduce((a, b) => a.satoshis + b.satoshis); + const totalBalance = (Number.isNaN(totalSatoshis) ? 0 : totalSatoshis) / Math.pow(10, 8); + if (totalBalanceInStore !== totalBalance) { + dispatch({ + type: UPDATE_TOTAL_BALANCE, + data: { + totalBalance + } + }); + } + }); + }; +} + function doBalanceSubscribe() { return dispatch => { dispatch(doUpdateBalance()); @@ -1554,6 +1582,13 @@ function doBalanceSubscribe() { }; } +function doTotalBalanceSubscribe() { + return dispatch => { + dispatch(doUpdateTotalBalance()); + setInterval(() => dispatch(doUpdateTotalBalance()), 5000); + }; +} + function doFetchTransactions() { return dispatch => { dispatch({ @@ -3022,6 +3057,7 @@ const buildDraftTransaction = () => ({ const defaultState$4 = { balance: undefined, + totalBalance: undefined, blocks: {}, latestBlock: undefined, transactions: {}, @@ -3082,6 +3118,10 @@ reducers$2[UPDATE_BALANCE] = (state, action) => Object.assign({}, state, { balance: action.data.balance }); +reducers$2[UPDATE_TOTAL_BALANCE] = (state, action) => Object.assign({}, state, { + totalBalance: action.data.totalBalance +}); + reducers$2[CHECK_ADDRESS_IS_MINE_STARTED] = state => Object.assign({}, state, { checkingAddressOwnership: true }); @@ -3355,10 +3395,12 @@ exports.doSetDraftTransactionAmount = doSetDraftTransactionAmount; exports.doSetFileListSort = doSetFileListSort; exports.doSetTransactionListFilter = doSetTransactionListFilter; exports.doToast = doToast; +exports.doTotalBalanceSubscribe = doTotalBalanceSubscribe; exports.doUpdateBalance = doUpdateBalance; exports.doUpdateBlockHeight = doUpdateBlockHeight; exports.doUpdateSearchOptions = doUpdateSearchOptions; exports.doUpdateSearchQuery = doUpdateSearchQuery; +exports.doUpdateTotalBalance = doUpdateTotalBalance; exports.doWalletDecrypt = doWalletDecrypt; exports.doWalletEncrypt = doWalletEncrypt; exports.doWalletStatus = doWalletStatus; @@ -3452,6 +3494,7 @@ exports.selectSearchSuggestions = selectSearchSuggestions; exports.selectSearchUrisByQuery = selectSearchUrisByQuery; exports.selectSearchValue = selectSearchValue; exports.selectToast = selectToast; +exports.selectTotalBalance = selectTotalBalance; exports.selectTotalDownloadProgress = selectTotalDownloadProgress; exports.selectTransactionItems = selectTransactionItems; exports.selectTransactionListFilter = selectTransactionListFilter; diff --git a/dist/bundle.js b/dist/bundle.js index 3608960..f2d5996 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -89,8 +89,8 @@ return /******/ (function(modules) { // webpackBootstrap Object.defineProperty(exports, "__esModule", { value: true }); -exports.selectTransactionListFilter = 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.makeSelectQueryWithOptions = exports.selectSearchSuggestions = exports.selectSearchBarFocused = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchOptions = exports.selectSearchValue = exports.makeSelectSearchUris = exports.selectSearchState = exports.selectFileListPublishedSort = exports.selectFileListDownloadedSort = 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.selectCurrentChannelPage = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = undefined; -exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.selectPendingById = exports.makeSelectClaimsInChannelForCurrentPageState = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.makeSelectChannelForClaimUri = exports.makeSelectFirstRecommendedFileForUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.makeSelectIsUriResolving = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForPage = exports.makeSelectFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.makeSelectClaimForUri = exports.selectError = exports.selectToast = exports.makeSelectContentPositionForUri = exports.contentReducer = exports.walletReducer = exports.searchReducer = exports.notificationsReducer = exports.fileInfoReducer = exports.claimsReducer = exports.creditsToString = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = exports.doUpdateBlockHeight = exports.doSetTransactionListFilter = exports.doWalletStatus = exports.doWalletUnlock = exports.doWalletDecrypt = exports.doWalletEncrypt = exports.doSendTip = exports.doSetDraftTransactionAddress = exports.doSetDraftTransactionAmount = exports.doSendDraftTransaction = exports.doCheckAddressIsMine = exports.doGetNewAddress = exports.doFetchBlock = exports.doFetchTransactions = exports.doBalanceSubscribe = exports.doUpdateBalance = exports.savePosition = exports.doUpdateSearchOptions = exports.setSearchApi = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doSetFileListSort = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doResolveUri = exports.doResolveUris = exports.doAbandonClaim = exports.doFetchClaimListMine = exports.doFetchClaimCountByChannel = exports.doFetchClaimsByChannel = exports.doDismissError = exports.doError = exports.doDismissToast = exports.doToast = exports.convertToShareLink = exports.isNameValid = exports.isURIClaimable = exports.isURIValid = exports.normalizeURI = exports.buildURI = exports.parseURI = exports.regexAddress = exports.regexInvalidURI = exports.Lbry = exports.PAGES = exports.SORT_OPTIONS = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_OPTIONS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.ACTIONS = undefined; +exports.selectTransactionListFilter = 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.selectTotalBalance = exports.selectBalance = exports.makeSelectBlockDate = exports.makeSelectQueryWithOptions = exports.selectSearchSuggestions = exports.selectSearchBarFocused = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchOptions = exports.selectSearchValue = exports.makeSelectSearchUris = exports.selectSearchState = exports.selectFileListPublishedSort = exports.selectFileListDownloadedSort = 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.selectCurrentChannelPage = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = undefined; +exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.selectPendingById = exports.makeSelectClaimsInChannelForCurrentPageState = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.makeSelectChannelForClaimUri = exports.makeSelectFirstRecommendedFileForUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.makeSelectIsUriResolving = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForPage = exports.makeSelectFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.makeSelectClaimForUri = exports.selectError = exports.selectToast = exports.makeSelectContentPositionForUri = exports.contentReducer = exports.walletReducer = exports.searchReducer = exports.notificationsReducer = exports.fileInfoReducer = exports.claimsReducer = exports.creditsToString = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = exports.doUpdateBlockHeight = exports.doSetTransactionListFilter = exports.doWalletStatus = exports.doWalletUnlock = exports.doWalletDecrypt = exports.doWalletEncrypt = exports.doSendTip = exports.doSetDraftTransactionAddress = exports.doSetDraftTransactionAmount = exports.doSendDraftTransaction = exports.doCheckAddressIsMine = exports.doGetNewAddress = exports.doFetchBlock = exports.doFetchTransactions = exports.doTotalBalanceSubscribe = exports.doUpdateTotalBalance = exports.doBalanceSubscribe = exports.doUpdateBalance = exports.savePosition = exports.doUpdateSearchOptions = exports.setSearchApi = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doSetFileListSort = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doResolveUri = exports.doResolveUris = exports.doAbandonClaim = exports.doFetchClaimListMine = exports.doFetchClaimCountByChannel = exports.doFetchClaimsByChannel = exports.doDismissError = exports.doError = exports.doDismissToast = exports.doToast = exports.convertToShareLink = exports.isNameValid = exports.isURIClaimable = exports.isURIValid = exports.normalizeURI = exports.buildURI = exports.parseURI = exports.regexAddress = exports.regexInvalidURI = exports.Lbry = exports.PAGES = exports.SORT_OPTIONS = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_OPTIONS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.ACTIONS = undefined; var _lbryURI = __webpack_require__(1); @@ -304,6 +304,18 @@ Object.defineProperty(exports, 'doBalanceSubscribe', { return _wallet.doBalanceSubscribe; } }); +Object.defineProperty(exports, 'doUpdateTotalBalance', { + enumerable: true, + get: function get() { + return _wallet.doUpdateTotalBalance; + } +}); +Object.defineProperty(exports, 'doTotalBalanceSubscribe', { + enumerable: true, + get: function get() { + return _wallet.doTotalBalanceSubscribe; + } +}); Object.defineProperty(exports, 'doFetchTransactions', { enumerable: true, get: function get() { @@ -895,6 +907,12 @@ Object.defineProperty(exports, 'selectBalance', { return _wallet3.selectBalance; } }); +Object.defineProperty(exports, 'selectTotalBalance', { + enumerable: true, + get: function get() { + return _wallet3.selectTotalBalance; + } +}); Object.defineProperty(exports, 'selectTransactionsById', { enumerable: true, get: function get() { @@ -1081,7 +1099,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } // types -//export { Toast } from 'types/Notification'; +// export { Toast } from 'types/Notification'; // constants exports.ACTIONS = ACTIONS; @@ -1126,27 +1144,27 @@ var claimIdMaxLength = 40; var regexInvalidURI = exports.regexInvalidURI = /[^A-Za-z0-9-]/g; var regexAddress = exports.regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/; -/** - * Parses a LBRY name into its component parts. Throws errors with user-friendly - * messages for invalid names. - * - * N.B. that "name" indicates the value in the name position of the URI. For - * claims for channel content, this will actually be the channel name, and - * the content name is in the path (e.g. lbry://@channel/content) - * - * In most situations, you'll want to use the contentName and channelName keys - * and ignore the name key. - * - * Returns a dictionary with keys: - * - name (string): The value in the "name" position in the URI. Note that this - * could be either content name or channel name; see above. - * - path (string, if persent) - * - claimSequence (int, if present) - * - bidPosition (int, if present) - * - claimId (string, if present) - * - isChannel (boolean) - * - contentName (string): For anon claims, the name; for channel claims, the path - * - channelName (string, if present): Channel name without @ +/** + * Parses a LBRY name into its component parts. Throws errors with user-friendly + * messages for invalid names. + * + * N.B. that "name" indicates the value in the name position of the URI. For + * claims for channel content, this will actually be the channel name, and + * the content name is in the path (e.g. lbry://@channel/content) + * + * In most situations, you'll want to use the contentName and channelName keys + * and ignore the name key. + * + * Returns a dictionary with keys: + * - name (string): The value in the "name" position in the URI. Note that this + * could be either content name or channel name; see above. + * - path (string, if persent) + * - claimSequence (int, if present) + * - bidPosition (int, if present) + * - claimId (string, if present) + * - isChannel (boolean) + * - contentName (string): For anon claims, the name; for channel claims, the path + * - channelName (string, if present): Channel name without @ */ function parseURI(URI) { var requireProto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; @@ -1254,10 +1272,10 @@ function parseURI(URI) { }, contentName ? { contentName: contentName } : {}, channelName ? { channelName: channelName } : {}, claimSequence ? { claimSequence: parseInt(claimSequence, 10) } : {}, bidPosition ? { bidPosition: parseInt(bidPosition, 10) } : {}, claimId ? { claimId: claimId } : {}, path ? { path: path } : {}); } -/** - * Takes an object in the same format returned by parse() and builds a URI. - * - * The channelName key will accept names with or without the @ prefix. +/** + * Takes an object in the same format returned by parse() and builds a URI. + * + * The channelName key will accept names with or without the @ prefix. */ function buildURI(URIObj) { var includeProto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; @@ -1454,6 +1472,7 @@ var GET_NEW_ADDRESS_COMPLETED = exports.GET_NEW_ADDRESS_COMPLETED = 'GET_NEW_ADD var FETCH_TRANSACTIONS_STARTED = exports.FETCH_TRANSACTIONS_STARTED = 'FETCH_TRANSACTIONS_STARTED'; var FETCH_TRANSACTIONS_COMPLETED = exports.FETCH_TRANSACTIONS_COMPLETED = 'FETCH_TRANSACTIONS_COMPLETED'; var UPDATE_BALANCE = exports.UPDATE_BALANCE = 'UPDATE_BALANCE'; +var UPDATE_TOTAL_BALANCE = exports.UPDATE_TOTAL_BALANCE = 'UPDATE_TOTAL_BALANCE'; var CHECK_ADDRESS_IS_MINE_STARTED = exports.CHECK_ADDRESS_IS_MINE_STARTED = 'CHECK_ADDRESS_IS_MINE_STARTED'; var CHECK_ADDRESS_IS_MINE_COMPLETED = exports.CHECK_ADDRESS_IS_MINE_COMPLETED = 'CHECK_ADDRESS_IS_MINE_COMPLETED'; var SEND_TRANSACTION_STARTED = exports.SEND_TRANSACTION_STARTED = 'SEND_TRANSACTION_STARTED'; @@ -1479,6 +1498,8 @@ var WALLET_STATUS_START = exports.WALLET_STATUS_START = 'WALLET_STATUS_START'; var WALLET_STATUS_COMPLETED = exports.WALLET_STATUS_COMPLETED = 'WALLET_STATUS_COMPLETED'; var SET_TRANSACTION_LIST_FILTER = exports.SET_TRANSACTION_LIST_FILTER = 'SET_TRANSACTION_LIST_FILTER'; var UPDATE_CURRENT_HEIGHT = exports.UPDATE_CURRENT_HEIGHT = 'UPDATE_CURRENT_HEIGHT'; +var SET_DRAFT_TRANSACTION_AMOUNT = exports.SET_DRAFT_TRANSACTION_AMOUNT = 'SET_DRAFT_TRANSACTION_AMOUNT'; +var SET_DRAFT_TRANSACTION_ADDRESS = exports.SET_DRAFT_TRANSACTION_ADDRESS = 'SET_DRAFT_TRANSACTION_ADDRESS'; // Claims var RESOLVE_URIS_STARTED = exports.RESOLVE_URIS_STARTED = 'RESOLVE_URIS_STARTED'; @@ -1625,15 +1646,13 @@ var DO_PREPARE_EDIT = exports.DO_PREPARE_EDIT = 'DO_PREPARE_EDIT'; var CREATE_NOTIFICATION = exports.CREATE_NOTIFICATION = 'CREATE_NOTIFICATION'; var EDIT_NOTIFICATION = exports.EDIT_NOTIFICATION = 'EDIT_NOTIFICATION'; var DELETE_NOTIFICATION = exports.DELETE_NOTIFICATION = 'DELETE_NOTIFICATION'; +var DISMISS_NOTIFICATION = exports.DISMISS_NOTIFICATION = 'DISMISS_NOTIFICATION'; var CREATE_TOAST = exports.CREATE_TOAST = 'CREATE_TOAST'; var DISMISS_TOAST = exports.DISMISS_TOAST = 'DISMISS_TOAST'; var CREATE_ERROR = exports.CREATE_ERROR = 'CREATE_ERROR'; var DISMISS_ERROR = exports.DISMISS_ERROR = 'DISMISS_ERROR'; -var SET_DRAFT_TRANSACTION_AMOUNT = exports.SET_DRAFT_TRANSACTION_AMOUNT = 'SET_DRAFT_TRANSACTION_AMOUNT'; -var SET_DRAFT_TRANSACTION_ADDRESS = exports.SET_DRAFT_TRANSACTION_ADDRESS = 'SET_DRAFT_TRANSACTION_ADDRESS'; var FETCH_DATE = exports.FETCH_DATE = 'FETCH_DATE'; -var DISMISS_NOTIFICATION = exports.DISMISS_NOTIFICATION = 'DISMISS_NOTIFICATION'; /***/ }), /* 4 */ @@ -2118,6 +2137,16 @@ Lbry.utxo_release = function () { return daemonCallWithResult('utxo_release', params); }; +// sync +Lbry.sync_hash = function () { + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return daemonCallWithResult('sync_hash', params); +}; +Lbry.sync_apply = function () { + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return daemonCallWithResult('sync_apply', params); +}; + Lbry.connectPromise = null; Lbry.connect = function () { if (Lbry.connectPromise === null) { @@ -2161,14 +2190,14 @@ Lbry.getMediaType = function (contentType, extname) { return 'unknown'; }; -/** - * Wrappers for API methods to simulate missing or future behavior. Unlike the old-style stubs, - * these are designed to be transparent wrappers around the corresponding API methods. +/** + * Wrappers for API methods to simulate missing or future behavior. Unlike the old-style stubs, + * these are designed to be transparent wrappers around the corresponding API methods. */ -/** - * Returns results from the file_list API method, plus dummy entries for pending publishes. - * (If a real publish with the same name is found, the pending publish will be ignored and removed.) +/** + * Returns results from the file_list API method, plus dummy entries for pending publishes. + * (If a real publish with the same name is found, the pending publish will be ignored and removed.) */ Lbry.file_list = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; @@ -2838,8 +2867,8 @@ var selectSearchOptions /*: (state: State) => SearchOptions*/ = exports.selectSe return state.options; }); -var selectSuggestions /*: ( - state: State +var selectSuggestions /*: ( + state: State ) => { [string]: Array }*/ = exports.selectSuggestions = (0, _reselect.createSelector)(selectState, function (state) { return state.suggestions; }); @@ -2848,8 +2877,8 @@ var selectIsSearching /*: (state: State) => boolean*/ = exports.selectIsSearchin return state.searching; }); -var selectSearchUrisByQuery /*: ( - state: State +var selectSearchUrisByQuery /*: ( + state: State ) => { [string]: Array }*/ = exports.selectSearchUrisByQuery = (0, _reselect.createSelector)(selectState, function (state) { return state.urisByQuery; }); @@ -3212,7 +3241,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.doUpdateBalance = doUpdateBalance; +exports.doUpdateTotalBalance = doUpdateTotalBalance; exports.doBalanceSubscribe = doBalanceSubscribe; +exports.doTotalBalanceSubscribe = doTotalBalanceSubscribe; exports.doFetchTransactions = doFetchTransactions; exports.doFetchBlock = doFetchBlock; exports.doGetNewAddress = doGetNewAddress; @@ -3254,7 +3285,6 @@ function doUpdateBalance() { _lbry2.default.account_balance().then(function (balanceAsString) { var balance = parseFloat(balanceAsString); - if (balanceInStore !== balance) { dispatch({ type: ACTIONS.UPDATE_BALANCE, @@ -3267,6 +3297,30 @@ function doUpdateBalance() { }; } +function doUpdateTotalBalance() { + return function (dispatch, getState) { + var _getState2 = getState(), + totalBalanceInStore = _getState2.wallet.totalBalance; + + _lbry2.default.account_list().then(function (accountList) { + var accounts = accountList.lbc_mainnet; + + var totalSatoshis = accounts.length === 1 ? accounts[0].satoshis : accounts.reduce(function (a, b) { + return a.satoshis + b.satoshis; + }); + var totalBalance = (Number.isNaN(totalSatoshis) ? 0 : totalSatoshis) / Math.pow(10, 8); + if (totalBalanceInStore !== totalBalance) { + dispatch({ + type: ACTIONS.UPDATE_TOTAL_BALANCE, + data: { + totalBalance: totalBalance + } + }); + } + }); + }; +} + function doBalanceSubscribe() { return function (dispatch) { dispatch(doUpdateBalance()); @@ -3276,6 +3330,15 @@ function doBalanceSubscribe() { }; } +function doTotalBalanceSubscribe() { + return function (dispatch) { + dispatch(doUpdateTotalBalance()); + setInterval(function () { + return dispatch(doUpdateTotalBalance()); + }, 5000); + }; +} + function doFetchTransactions() { return function (dispatch) { dispatch({ @@ -3602,7 +3665,7 @@ function doUpdateBlockHeight() { Object.defineProperty(exports, "__esModule", { value: true }); -exports.selectTransactionListFilter = exports.makeSelectBlockDate = exports.selectCurrentHeight = 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; +exports.selectTransactionListFilter = exports.makeSelectBlockDate = exports.selectCurrentHeight = 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.selectTotalBalance = 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__(15); @@ -3676,6 +3739,10 @@ var selectBalance = exports.selectBalance = (0, _reselect.createSelector)(select return state.balance; }); +var selectTotalBalance = exports.selectTotalBalance = (0, _reselect.createSelector)(selectState, function (state) { + return state.totalBalance; +}); + var selectTransactionsById = exports.selectTransactionsById = (0, _reselect.createSelector)(selectState, function (state) { return state.transactions; }); @@ -5117,13 +5184,13 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } // @flow -/*:: import type { - NotificationState, - DoToast, - DoError, - DoNotification, - DoEditNotification, - DoDeleteNotification, +/*:: import type { + NotificationState, + DoToast, + DoError, + DoNotification, + DoEditNotification, + DoDeleteNotification, } from 'types/Notification';*/ @@ -5260,13 +5327,13 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } // @flow -/*:: import type { - SearchState, - SearchSuccess, - UpdateSearchQuery, - UpdateSearchSuggestions, - HistoryNavigate, - UpdateSearchOptions, +/*:: import type { + SearchState, + SearchSuccess, + UpdateSearchQuery, + UpdateSearchSuggestions, + HistoryNavigate, + UpdateSearchOptions, } from 'types/Search';*/ @@ -5365,37 +5432,38 @@ var buildDraftTransaction = function buildDraftTransaction() { // 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 ActionResult = { + type: any, + result: any, };*/ -/*:: type WalletState = { - balance: any, - blocks: any, - latestBlock: ?number, - 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, +/*:: type WalletState = { + balance: any, + blocks: any, + latestBlock: ?number, + 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, + totalBalance: undefined, blocks: {}, latestBlock: undefined, transactions: {}, @@ -5464,6 +5532,12 @@ reducers[ACTIONS.UPDATE_BALANCE] = function (state /*: WalletState*/, action) { }); }; +reducers[ACTIONS.UPDATE_TOTAL_BALANCE] = function (state /*: WalletState*/, action) { + return Object.assign({}, state, { + totalBalance: action.data.totalBalance + }); +}; + reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED] = function (state /*: WalletState*/) { return Object.assign({}, state, { checkingAddressOwnership: true @@ -5831,7 +5905,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); /* hardcoded names still exist for these in reducers/settings.js - only discovered when debugging */ -/* Many SETTINGS are stored in the localStorage by their name - +/* Many SETTINGS are stored in the localStorage by their name - be careful about changing the value of a SETTINGS constant, as doing so can invalidate existing SETTINGS */ var CREDIT_REQUIRED_ACKNOWLEDGED = exports.CREDIT_REQUIRED_ACKNOWLEDGED = 'credit_required_acknowledged'; var NEW_USER_ACKNOWLEDGED = exports.NEW_USER_ACKNOWLEDGED = 'welcome_acknowledged'; diff --git a/src/constants/action_types.js b/src/constants/action_types.js index 3800f87..649431a 100644 --- a/src/constants/action_types.js +++ b/src/constants/action_types.js @@ -34,6 +34,7 @@ export const GET_NEW_ADDRESS_COMPLETED = 'GET_NEW_ADDRESS_COMPLETED'; export const FETCH_TRANSACTIONS_STARTED = 'FETCH_TRANSACTIONS_STARTED'; export const FETCH_TRANSACTIONS_COMPLETED = 'FETCH_TRANSACTIONS_COMPLETED'; export const UPDATE_BALANCE = 'UPDATE_BALANCE'; +export const UPDATE_TOTAL_BALANCE = 'UPDATE_TOTAL_BALANCE'; export const CHECK_ADDRESS_IS_MINE_STARTED = 'CHECK_ADDRESS_IS_MINE_STARTED'; export const CHECK_ADDRESS_IS_MINE_COMPLETED = 'CHECK_ADDRESS_IS_MINE_COMPLETED'; export const SEND_TRANSACTION_STARTED = 'SEND_TRANSACTION_STARTED'; diff --git a/src/index.js b/src/index.js index 9efcbc7..0519c28 100644 --- a/src/index.js +++ b/src/index.js @@ -71,6 +71,8 @@ export { savePosition } from 'redux/actions/content'; export { doUpdateBalance, doBalanceSubscribe, + doUpdateTotalBalance, + doTotalBalanceSubscribe, doFetchTransactions, doFetchBlock, doGetNewAddress, @@ -178,6 +180,7 @@ export { export { makeSelectBlockDate, selectBalance, + selectTotalBalance, selectTransactionsById, selectTransactionItems, selectRecentTransactions, diff --git a/src/lbry.js b/src/lbry.js index 765ac27..3554362 100644 --- a/src/lbry.js +++ b/src/lbry.js @@ -93,6 +93,10 @@ Lbry.claim_tip = (params = {}) => daemonCallWithResult('claim_tip', params); Lbry.transaction_list = (params = {}) => daemonCallWithResult('transaction_list', params); Lbry.utxo_release = (params = {}) => daemonCallWithResult('utxo_release', params); +// sync +Lbry.sync_hash = (params = {}) => daemonCallWithResult('sync_hash', params); +Lbry.sync_apply = (params = {}) => daemonCallWithResult('sync_apply', params); + Lbry.connectPromise = null; Lbry.connect = () => { if (Lbry.connectPromise === null) { diff --git a/src/redux/actions/wallet.js b/src/redux/actions/wallet.js index 43a1c0d..6724ed3 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -11,7 +11,6 @@ export function doUpdateBalance() { } = getState(); Lbry.account_balance().then(balanceAsString => { const balance = parseFloat(balanceAsString); - if (balanceInStore !== balance) { dispatch({ type: ACTIONS.UPDATE_BALANCE, @@ -24,6 +23,30 @@ export function doUpdateBalance() { }; } +export function doUpdateTotalBalance() { + return (dispatch, getState) => { + const { + wallet: { totalBalance: totalBalanceInStore }, + } = getState(); + Lbry.account_list().then(accountList => { + const { lbc_mainnet: accounts } = accountList; + const totalSatoshis = + accounts.length === 1 + ? accounts[0].satoshis + : accounts.reduce((a, b) => a.satoshis + b.satoshis); + const totalBalance = (Number.isNaN(totalSatoshis) ? 0 : totalSatoshis) / 10 ** 8; + if (totalBalanceInStore !== totalBalance) { + dispatch({ + type: ACTIONS.UPDATE_TOTAL_BALANCE, + data: { + totalBalance, + }, + }); + } + }); + }; +} + export function doBalanceSubscribe() { return dispatch => { dispatch(doUpdateBalance()); @@ -31,6 +54,13 @@ export function doBalanceSubscribe() { }; } +export function doTotalBalanceSubscribe() { + return dispatch => { + dispatch(doUpdateTotalBalance()); + setInterval(() => dispatch(doUpdateTotalBalance()), 5000); + }; +} + export function doFetchTransactions() { return dispatch => { dispatch({ diff --git a/src/redux/reducers/wallet.js b/src/redux/reducers/wallet.js index 0df481e..f32d801 100644 --- a/src/redux/reducers/wallet.js +++ b/src/redux/reducers/wallet.js @@ -40,6 +40,7 @@ type WalletState = { const defaultState = { balance: undefined, + totalBalance: undefined, blocks: {}, latestBlock: undefined, transactions: {}, @@ -103,6 +104,11 @@ reducers[ACTIONS.UPDATE_BALANCE] = (state: WalletState, action) => balance: action.data.balance, }); +reducers[ACTIONS.UPDATE_TOTAL_BALANCE] = (state: WalletState, action) => + Object.assign({}, state, { + totalBalance: action.data.totalBalance, + }); + reducers[ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED] = (state: WalletState) => Object.assign({}, state, { checkingAddressOwnership: true, diff --git a/src/redux/selectors/wallet.js b/src/redux/selectors/wallet.js index 6b0fe6a..af5d340 100644 --- a/src/redux/selectors/wallet.js +++ b/src/redux/selectors/wallet.js @@ -1,83 +1,82 @@ import { createSelector } from 'reselect'; import * as TRANSACTIONS from 'constants/transaction_types'; -export const selectState = (state) => state.wallet || {}; +export const selectState = state => state.wallet || {}; export const selectWalletState = selectState; export const selectWalletIsEncrypted = createSelector( selectState, - (state) => state.walletIsEncrypted + state => state.walletIsEncrypted ); export const selectWalletEncryptPending = createSelector( selectState, - (state) => state.walletEncryptPending + state => state.walletEncryptPending ); export const selectWalletEncryptSucceeded = createSelector( selectState, - (state) => state.walletEncryptSucceded + state => state.walletEncryptSucceded ); export const selectWalletEncryptResult = createSelector( selectState, - (state) => state.walletEncryptResult + state => state.walletEncryptResult ); export const selectWalletDecryptPending = createSelector( selectState, - (state) => state.walletDecryptPending + state => state.walletDecryptPending ); export const selectWalletDecryptSucceeded = createSelector( selectState, - (state) => state.walletDecryptSucceded + state => state.walletDecryptSucceded ); export const selectWalletDecryptResult = createSelector( selectState, - (state) => state.walletDecryptResult + state => state.walletDecryptResult ); export const selectWalletUnlockPending = createSelector( selectState, - (state) => state.walletUnlockPending + state => state.walletUnlockPending ); export const selectWalletUnlockSucceeded = createSelector( selectState, - (state) => state.walletUnlockSucceded + state => state.walletUnlockSucceded ); export const selectWalletUnlockResult = createSelector( selectState, - (state) => state.walletUnlockResult + state => state.walletUnlockResult ); export const selectWalletLockPending = createSelector( selectState, - (state) => state.walletLockPending + state => state.walletLockPending ); export const selectWalletLockSucceeded = createSelector( selectState, - (state) => state.walletLockSucceded + state => state.walletLockSucceded ); -export const selectWalletLockResult = createSelector( - selectState, - (state) => state.walletLockResult -); +export const selectWalletLockResult = createSelector(selectState, state => state.walletLockResult); -export const selectBalance = createSelector(selectState, (state) => state.balance); +export const selectBalance = createSelector(selectState, state => state.balance); -export const selectTransactionsById = createSelector(selectState, (state) => state.transactions); +export const selectTotalBalance = createSelector(selectState, state => state.totalBalance); -export const selectTransactionItems = createSelector(selectTransactionsById, (byId) => { +export const selectTransactionsById = createSelector(selectState, state => state.transactions); + +export const selectTransactionItems = createSelector(selectTransactionsById, byId => { const items = []; - Object.keys(byId).forEach((txid) => { + Object.keys(byId).forEach(txid => { const tx = byId[txid]; // ignore dust/fees @@ -95,24 +94,24 @@ export const selectTransactionItems = createSelector(selectTransactionsById, (by const append = []; append.push( - ...tx.claim_info.map((item) => + ...tx.claim_info.map(item => Object.assign({}, tx, item, { type: item.claim_name[0] === '@' ? TRANSACTIONS.CHANNEL : TRANSACTIONS.PUBLISH, }) ) ); append.push( - ...tx.support_info.map((item) => + ...tx.support_info.map(item => Object.assign({}, tx, item, { type: !item.is_tip ? TRANSACTIONS.SUPPORT : TRANSACTIONS.TIP, }) ) ); append.push( - ...tx.update_info.map((item) => Object.assign({}, tx, item, { type: TRANSACTIONS.UPDATE })) + ...tx.update_info.map(item => Object.assign({}, tx, item, { type: TRANSACTIONS.UPDATE })) ); append.push( - ...tx.abandon_info.map((item) => Object.assign({}, tx, item, { type: TRANSACTIONS.ABANDON })) + ...tx.abandon_info.map(item => Object.assign({}, tx, item, { type: TRANSACTIONS.ABANDON })) ); if (!append.length) { @@ -124,7 +123,7 @@ export const selectTransactionItems = createSelector(selectTransactionsById, (by } items.push( - ...append.map((item) => { + ...append.map(item => { // value on transaction, amount on outpoint // amount is always positive, but should match sign of value const balanceDelta = parseFloat(item.balance_delta); @@ -161,10 +160,10 @@ export const selectTransactionItems = createSelector(selectTransactionsById, (by }); }); -export const selectRecentTransactions = createSelector(selectTransactionItems, (transactions) => { +export const selectRecentTransactions = createSelector(selectTransactionItems, transactions => { const threshold = new Date(); threshold.setDate(threshold.getDate() - 7); - return transactions.filter((transaction) => { + return transactions.filter(transaction => { if (!transaction.date) { return true; // pending transaction } @@ -175,48 +174,48 @@ export const selectRecentTransactions = createSelector(selectTransactionItems, ( export const selectHasTransactions = createSelector( selectTransactionItems, - (transactions) => transactions && transactions.length > 0 + transactions => transactions && transactions.length > 0 ); export const selectIsFetchingTransactions = createSelector( selectState, - (state) => state.fetchingTransactions + state => state.fetchingTransactions ); -export const selectIsSendingSupport = createSelector(selectState, (state) => state.sendingSupport); +export const selectIsSendingSupport = createSelector(selectState, state => state.sendingSupport); -export const selectReceiveAddress = createSelector(selectState, (state) => state.receiveAddress); +export const selectReceiveAddress = createSelector(selectState, state => state.receiveAddress); export const selectGettingNewAddress = createSelector( selectState, - (state) => state.gettingNewAddress + state => state.gettingNewAddress ); export const selectDraftTransaction = createSelector( selectState, - (state) => state.draftTransaction || {} + state => state.draftTransaction || {} ); export const selectDraftTransactionAmount = createSelector( selectDraftTransaction, - (draft) => draft.amount + draft => draft.amount ); export const selectDraftTransactionAddress = createSelector( selectDraftTransaction, - (draft) => draft.address + draft => draft.address ); export const selectDraftTransactionError = createSelector( selectDraftTransaction, - (draft) => draft.error + draft => draft.error ); -export const selectBlocks = createSelector(selectState, (state) => state.blocks); +export const selectBlocks = createSelector(selectState, state => state.blocks); -export const selectCurrentHeight = createSelector(selectState, (state) => state.latestBlock); +export const selectCurrentHeight = createSelector(selectState, state => state.latestBlock); -export const makeSelectBlockDate = (block) => +export const makeSelectBlockDate = block => createSelector(selectBlocks, selectCurrentHeight, (blocks, latestBlock) => { // If we have the block data, look at the actual date, // If not, try to simulate it based on 2.5 minute blocks @@ -239,5 +238,5 @@ export const makeSelectBlockDate = (block) => export const selectTransactionListFilter = createSelector( selectState, - (state) => state.transactionListFilter || '' + state => state.transactionListFilter || '' );