From eec073b25cde5cafe1a224f1a22b039f5bd3ad34 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 25 Oct 2018 12:57:55 -0400 Subject: [PATCH] updates for lbrynet30 --- dist/bundle.js | 239 +++++++++++++++++++++------------- src/index.js | 7 +- src/lbry.js | 16 +-- src/redux/actions/wallet.js | 27 ++-- src/redux/reducers/claims.js | 27 ++-- src/redux/selectors/claims.js | 37 +++++- src/redux/selectors/wallet.js | 4 +- src/util/formatCredits.js | 9 ++ 8 files changed, 223 insertions(+), 143 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index 70fcead..cbfcda7 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -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.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.selectSearchSuggestions = exports.selectSearchBarFocused = exports.selectWunderBarAddress = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchValue = exports.selectSearchQuery = exports.makeSelectSearchUris = exports.selectSearchState = 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.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.selectFetchingCostInfo = exports.selectCostForCurrentPageUri = exports.selectAllCostInfoByUri = exports.makeSelectCostInfoForUri = exports.makeSelectFetchingCostInfoForUri = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.selectResolvingUris = exports.selectMyChannelClaims = undefined; -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.makeSelectChannelForClaimUri = exports.makeSelectRecommendedContentForUri = 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.doSetTransactionListFilter = 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.doSetFileListSort = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doFetchCostInfoForUri = 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.PAGES = exports.SORT_OPTIONS = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.MODALS = exports.ACTIONS = exports.Notification = 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.selectBalance = exports.makeSelectBlockDate = exports.selectSearchSuggestions = exports.selectSearchBarFocused = exports.selectWunderBarAddress = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchValue = exports.selectSearchQuery = exports.makeSelectSearchUris = exports.selectSearchState = 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.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.selectFetchingCostInfo = exports.selectCostForCurrentPageUri = exports.selectAllCostInfoByUri = exports.makeSelectCostInfoForUri = exports.makeSelectFetchingCostInfoForUri = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = undefined; +exports.selectMyClaims = exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.selectPendingById = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.makeSelectChannelForClaimUri = exports.makeSelectRecommendedContentForUri = 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.creditsToString = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = 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.doBlackListedOutpointsSubscribe = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doSetFileListSort = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doFetchCostInfoForUri = 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.PAGES = exports.SORT_OPTIONS = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.MODALS = exports.ACTIONS = exports.Notification = undefined; var _Notification = __webpack_require__(1); @@ -367,10 +352,10 @@ Object.defineProperty(exports, 'doSetDraftTransactionAddress', { return _wallet.doSetDraftTransactionAddress; } }); -Object.defineProperty(exports, 'doSendSupport', { +Object.defineProperty(exports, 'doSendTip', { enumerable: true, get: function get() { - return _wallet.doSendSupport; + return _wallet.doSendTip; } }); Object.defineProperty(exports, 'doWalletEncrypt', { @@ -442,6 +427,12 @@ Object.defineProperty(exports, 'formatFullPrice', { return _formatCredits.formatFullPrice; } }); +Object.defineProperty(exports, 'creditsToString', { + enumerable: true, + get: function get() { + return _formatCredits.creditsToString; + } +}); var _claims2 = __webpack_require__(32); @@ -628,6 +619,24 @@ Object.defineProperty(exports, 'makeSelectChannelForClaimUri', { return _claims3.makeSelectChannelForClaimUri; } }); +Object.defineProperty(exports, 'makeSelectClaimIsPending', { + enumerable: true, + get: function get() { + return _claims3.makeSelectClaimIsPending; + } +}); +Object.defineProperty(exports, 'makeSelectPendingByUri', { + enumerable: true, + get: function get() { + return _claims3.makeSelectPendingByUri; + } +}); +Object.defineProperty(exports, 'selectPendingById', { + enumerable: true, + get: function get() { + return _claims3.selectPendingById; + } +}); Object.defineProperty(exports, 'selectClaimsById', { enumerable: true, get: function get() { @@ -2168,38 +2177,42 @@ Lbry.claim_list_by_channel = function () { }; // wallet -Lbry.wallet_balance = function () { +Lbry.account_balance = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return daemonCallWithResult('wallet_balance', params); + return daemonCallWithResult('account_balance', params); }; -Lbry.wallet_decrypt = function () { - return daemonCallWithResult('wallet_decrypt', {}); +Lbry.account_decrypt = function () { + return daemonCallWithResult('account_decrypt', {}); }; -Lbry.wallet_encrypt = function () { +Lbry.account_encrypt = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return daemonCallWithResult('wallet_encrypt', params); + return daemonCallWithResult('account_encrypt', params); }; -Lbry.wallet_is_address_mine = function () { +Lbry.address_is_mine = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return daemonCallWithResult('wallet_is_address_mine', params); + return daemonCallWithResult('address_is_mine', params); }; Lbry.wallet_lock = function () { return daemonCallWithResult('wallet_lock', {}); }; -Lbry.wallet_new_address = function () { +Lbry.address_unused = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return daemonCallWithResult('wallet_new_address', params); + return daemonCallWithResult('address_unused', params); }; Lbry.wallet_send = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return daemonCallWithResult('wallet_send', params); }; -Lbry.wallet_unlock = function () { +Lbry.account_unlock = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return daemonCallWithResult('wallet_unlock', params); + return daemonCallWithResult('account_unlock', params); }; -Lbry.wallet_unused_address = function () { - return daemonCallWithResult('wallet_unused_address', {}); +Lbry.address_unused = function () { + return daemonCallWithResult('address_unused', {}); +}; +Lbry.claim_tip = function () { + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return daemonCallWithResult('claim_tip', params); }; // transactions @@ -2504,26 +2517,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; /***/ }), @@ -3026,7 +3039,7 @@ var objectKeys = Object.keys || function (obj) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.makeSelectChannelForClaimUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.makeSelectIsUriResolving = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectClaimsInChannelForPage = exports.makeSelectFetchingChannelClaims = exports.selectAllFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.makeSelectClaimForUri = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = undefined; +exports.makeSelectChannelForClaimUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.makeSelectIsUriResolving = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectIsFetchingClaimListMine = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectClaimsInChannelForPage = exports.makeSelectFetchingChannelClaims = exports.selectAllFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.makeSelectClaimForUri = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.selectPendingClaims = exports.selectPendingById = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = undefined; var _lbryURI = __webpack_require__(2); @@ -3072,9 +3085,45 @@ var selectAllClaimsByChannel = exports.selectAllClaimsByChannel = (0, _reselect. return state.claimsByChannel || {}; }); +var selectPendingById = exports.selectPendingById = (0, _reselect.createSelector)(selectState, function (state) { + return state.pendingById; +}); + +var selectPendingClaims = exports.selectPendingClaims = (0, _reselect.createSelector)(selectState, function (state) { + return Object.values(state.pendingById || {}); +}); + +var makeSelectClaimIsPending = exports.makeSelectClaimIsPending = function makeSelectClaimIsPending(uri) { + return (0, _reselect.createSelector)(selectPendingById, function (pendingById) { + var _parseURI = (0, _lbryURI.parseURI)(uri), + claimId = _parseURI.claimId; + + return Boolean(pendingById[claimId]); + }); +}; + +var makeSelectPendingByUri = exports.makeSelectPendingByUri = function makeSelectPendingByUri(uri) { + return (0, _reselect.createSelector)(selectPendingById, function (pendingById) { + var _parseURI2 = (0, _lbryURI.parseURI)(uri), + claimId = _parseURI2.claimId; + + return pendingById[claimId]; + }); +}; + var makeSelectClaimForUri = exports.makeSelectClaimForUri = function makeSelectClaimForUri(uri) { - return (0, _reselect.createSelector)(selectClaimsByUri, function (claims) { - return claims && claims[(0, _lbryURI.normalizeURI)(uri)]; + return (0, _reselect.createSelector)(selectClaimsByUri, selectPendingById, function (byUri, pendingById) { + // Check if a claim is pending first + // It won't be in claimsByUri because resolving it will return nothing + var _parseURI3 = (0, _lbryURI.parseURI)(uri), + claimId = _parseURI3.claimId; + + var pendingClaim = pendingById[claimId]; + if (pendingClaim) { + return pendingClaim; + } + + return byUri && byUri[(0, _lbryURI.normalizeURI)(uri)]; }); }; @@ -3164,10 +3213,6 @@ var selectIsFetchingClaimListMine = exports.selectIsFetchingClaimListMine = (0, return state.isFetchingClaimListMine; }); -var selectPendingClaims = exports.selectPendingClaims = (0, _reselect.createSelector)(selectState, function (state) { - return Object.values(state.pendingById || {}); -}); - var selectMyClaims = exports.selectMyClaims = (0, _reselect.createSelector)(selectMyActiveClaims, selectClaimsById, selectAbandoningIds, selectPendingClaims, function (myClaimIds, byId, abandoningIds, pendingClaims) { var claims = []; @@ -4451,7 +4496,7 @@ exports.doCheckAddressIsMine = doCheckAddressIsMine; exports.doSendDraftTransaction = doSendDraftTransaction; exports.doSetDraftTransactionAmount = doSetDraftTransactionAmount; exports.doSetDraftTransactionAddress = doSetDraftTransactionAddress; -exports.doSendSupport = doSendSupport; +exports.doSendTip = doSendTip; exports.doWalletEncrypt = doWalletEncrypt; exports.doWalletUnlock = doWalletUnlock; exports.doWalletLock = doWalletLock; @@ -4471,6 +4516,8 @@ var _notifications = __webpack_require__(3); var _wallet = __webpack_require__(29); +var _formatCredits = __webpack_require__(31); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; } } @@ -4480,7 +4527,7 @@ function doUpdateBalance() { var _getState = getState(), balanceInStore = _getState.wallet.balance; - _lbry2.default.wallet_balance().then(function (balance) { + _lbry2.default.account_balance().then(function (balance) { if (balanceInStore !== balance) { dispatch({ type: ACTIONS.UPDATE_BALANCE, @@ -4537,7 +4584,7 @@ function doGetNewAddress() { }); // Removed localStorage use, since address is expected to be stored in redux store - _lbry2.default.wallet_new_address().then(function (address) { + _lbry2.default.address_unused().then(function (address) { dispatch({ type: ACTIONS.GET_NEW_ADDRESS_COMPLETED, data: { address: address } @@ -4552,7 +4599,7 @@ function doCheckAddressIsMine(address) { type: ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED }); - _lbry2.default.wallet_is_address_mine({ address: address }).then(function (isMine) { + _lbry2.default.address_is_mine({ address: address }).then(function (isMine) { if (!isMine) dispatch(doGetNewAddress()); dispatch({ @@ -4581,8 +4628,8 @@ function doSendDraftTransaction(address, amount) { type: ACTIONS.SEND_TRANSACTION_STARTED }); - var successCallback = function successCallback(results) { - if (results === true) { + var successCallback = function successCallback(response) { + if (response.txid) { dispatch({ type: ACTIONS.SEND_TRANSACTION_COMPLETED }); @@ -4597,7 +4644,7 @@ function doSendDraftTransaction(address, amount) { } else { dispatch({ type: ACTIONS.SEND_TRANSACTION_FAILED, - data: { error: results } + data: { error: response } }); dispatch((0, _notifications.doNotify)({ title: 'Transaction failed', @@ -4622,8 +4669,8 @@ function doSendDraftTransaction(address, amount) { }; _lbry2.default.wallet_send({ - amount: amount, - address: address + address: address, + amount: (0, _formatCredits.creditsToString)(amount) }).then(successCallback, errorCallback); }; } @@ -4642,7 +4689,7 @@ function doSetDraftTransactionAddress(address) { }; } -function doSendSupport(amount, claimId, uri, successCallback, errorCallback) { +function doSendTip(amount, claimId, uri, successCallback, errorCallback) { return function (dispatch, getState) { var state = getState(); var balance = (0, _wallet.selectBalance)(state); @@ -4696,9 +4743,9 @@ function doSendSupport(amount, claimId, uri, successCallback, errorCallback) { type: ACTIONS.SUPPORT_TRANSACTION_STARTED }); - _lbry2.default.wallet_send({ + _lbry2.default.claim_tip({ claim_id: claimId, - amount: amount + amount: (0, _formatCredits.creditsToString)(amount) }).then(success, error); }; } @@ -4709,7 +4756,7 @@ function doWalletEncrypt(newPassword) { type: ACTIONS.WALLET_ENCRYPT_START }); - _lbry2.default.wallet_encrypt({ new_password: newPassword }).then(function (result) { + _lbry2.default.account_encrypt({ new_password: newPassword }).then(function (result) { if (result === true) { dispatch({ type: ACTIONS.WALLET_ENCRYPT_COMPLETED, @@ -4731,7 +4778,7 @@ function doWalletUnlock(password) { type: ACTIONS.WALLET_UNLOCK_START }); - _lbry2.default.wallet_unlock({ password: password }).then(function (result) { + _lbry2.default.account_unlock({ password: password }).then(function (result) { if (result === true) { dispatch({ type: ACTIONS.WALLET_UNLOCK_COMPLETED, @@ -4775,7 +4822,7 @@ function doWalletDecrypt() { type: ACTIONS.WALLET_DECRYPT_START }); - _lbry2.default.wallet_decrypt().then(function (result) { + _lbry2.default.account_decrypt().then(function (result) { if (result === true) { dispatch({ type: ACTIONS.WALLET_DECRYPT_COMPLETED, @@ -4957,7 +5004,7 @@ var selectTransactionItems = exports.selectTransactionItems = (0, _reselect.crea }; }))); }); - return items.reverse(); + return items; }); var selectRecentTransactions = exports.selectRecentTransactions = (0, _reselect.createSelector)(selectTransactionItems, function (transactions) { @@ -5051,6 +5098,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.formatCredits = formatCredits; exports.formatFullPrice = formatFullPrice; +exports.creditsToString = creditsToString; function formatCredits(amount, precision) { return amount.toFixed(precision || 1).replace(/\.?0+$/, ''); } @@ -5077,6 +5125,15 @@ function formatFullPrice(amount) { return parseFloat(quantity[0] + formated); } +function creditsToString(amount) { + var creditString = String(amount); + + if (creditString.includes('.')) { + return creditString; + } + return creditString + '.0'; +} + /***/ }), /* 32 */ /***/ (function(module, exports, __webpack_require__) { @@ -5170,22 +5227,18 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = function (state, action) { var pendingById = Object.assign({}, state.pendingById); claims.filter(function (claim) { - return claim.category && (claim.category.match(/claim/) || claim.category.match(/update/)); + return claim.type && claim.type.match(/claim|update/); }).forEach(function (claim) { - byId[claim.claim_id] = claim; - - var pending = Object.values(pendingById).find(function (pendingClaim) { - return pendingClaim.name === claim.name && pendingClaim.channel_name === claim.channel_name; - }); - - if (pending) { - delete pendingById[pending.claim_id]; + if (claim.confirmations < 1) { + pendingById[claim.claim_id] = claim; + } else { + byId[claim.claim_id] = claim; } }); - // Remove old timed out pending publishes + // Remove old pending publishes Object.values(pendingById).filter(function (pendingClaim) { - return Date.now() - pendingClaim.time >= 20 * 60 * 1000; + return byId[pendingClaim.claim_id]; }).forEach(function (pendingClaim) { delete pendingById[pendingClaim.claim_id]; }); @@ -5210,7 +5263,7 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = function (state, action) { claims.forEach(function (claim) { myChannelClaims.add(claim.claim_id); - byId[claims.claim_id] = claim; + byId[claim.claim_id] = claim; }); return Object.assign({}, state, { diff --git a/src/index.js b/src/index.js index b74bdc5..e498adb 100644 --- a/src/index.js +++ b/src/index.js @@ -82,7 +82,7 @@ export { doSendDraftTransaction, doSetDraftTransactionAmount, doSetDraftTransactionAddress, - doSendSupport, + doSendTip, doWalletEncrypt, doWalletDecrypt, doWalletUnlock, @@ -93,7 +93,7 @@ export { // utils export { batchActions } from 'util/batchActions'; export { parseQueryParams, toQueryString } from 'util/query_params'; -export { formatCredits, formatFullPrice } from 'util/formatCredits'; +export { formatCredits, formatFullPrice, creditsToString } from 'util/formatCredits'; // reducers export { claimsReducer } from 'redux/reducers/claims'; @@ -129,6 +129,9 @@ export { makeSelectNsfwCountForChannel, makeSelectRecommendedContentForUri, makeSelectChannelForClaimUri, + makeSelectClaimIsPending, + makeSelectPendingByUri, + selectPendingById, selectClaimsById, selectClaimsByUri, selectAllClaimsByChannel, diff --git a/src/lbry.js b/src/lbry.js index b3fa175..f9197ae 100644 --- a/src/lbry.js +++ b/src/lbry.js @@ -75,16 +75,16 @@ Lbry.file_set_status = (params = {}) => daemonCallWithResult('file_set_status', Lbry.claim_list_by_channel = (params = {}) => daemonCallWithResult('claim_list_by_channel', params); // wallet -Lbry.wallet_balance = (params = {}) => daemonCallWithResult('wallet_balance', params); -Lbry.wallet_decrypt = () => daemonCallWithResult('wallet_decrypt', {}); -Lbry.wallet_encrypt = (params = {}) => daemonCallWithResult('wallet_encrypt', params); -Lbry.wallet_is_address_mine = (params = {}) => - daemonCallWithResult('wallet_is_address_mine', params); +Lbry.account_balance = (params = {}) => daemonCallWithResult('account_balance', params); +Lbry.account_decrypt = () => daemonCallWithResult('account_decrypt', {}); +Lbry.account_encrypt = (params = {}) => daemonCallWithResult('account_encrypt', params); +Lbry.address_is_mine = (params = {}) => daemonCallWithResult('address_is_mine', params); Lbry.wallet_lock = () => daemonCallWithResult('wallet_lock', {}); -Lbry.wallet_new_address = (params = {}) => daemonCallWithResult('wallet_new_address', params); +Lbry.address_unused = (params = {}) => daemonCallWithResult('address_unused', params); Lbry.wallet_send = (params = {}) => daemonCallWithResult('wallet_send', params); -Lbry.wallet_unlock = (params = {}) => daemonCallWithResult('wallet_unlock', params); -Lbry.wallet_unused_address = () => daemonCallWithResult('wallet_unused_address', {}); +Lbry.account_unlock = (params = {}) => daemonCallWithResult('account_unlock', params); +Lbry.address_unused = () => daemonCallWithResult('address_unused', {}); +Lbry.claim_tip = (params = {}) => daemonCallWithResult('claim_tip', params); // transactions Lbry.transaction_list = (params = {}) => daemonCallWithResult('transaction_list', params); diff --git a/src/redux/actions/wallet.js b/src/redux/actions/wallet.js index b249a78..0e816bd 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -2,13 +2,14 @@ import * as ACTIONS from 'constants/action_types'; import Lbry from 'lbry'; import { doNotify } from 'redux/actions/notifications'; import { selectBalance } from 'redux/selectors/wallet'; +import { creditsToString } from 'util/formatCredits'; export function doUpdateBalance() { return (dispatch, getState) => { const { wallet: { balance: balanceInStore }, } = getState(); - Lbry.wallet_balance().then(balance => { + Lbry.account_balance().then(balance => { if (balanceInStore !== balance) { dispatch({ type: ACTIONS.UPDATE_BALANCE, @@ -63,7 +64,7 @@ export function doGetNewAddress() { }); // Removed localStorage use, since address is expected to be stored in redux store - Lbry.wallet_new_address().then(address => { + Lbry.address_unused().then(address => { dispatch({ type: ACTIONS.GET_NEW_ADDRESS_COMPLETED, data: { address }, @@ -78,7 +79,7 @@ export function doCheckAddressIsMine(address) { type: ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED, }); - Lbry.wallet_is_address_mine({ address }).then(isMine => { + Lbry.address_is_mine({ address }).then(isMine => { if (!isMine) dispatch(doGetNewAddress()); dispatch({ @@ -109,8 +110,8 @@ export function doSendDraftTransaction(address, amount) { type: ACTIONS.SEND_TRANSACTION_STARTED, }); - const successCallback = results => { - if (results === true) { + const successCallback = response => { + if (response.txid) { dispatch({ type: ACTIONS.SEND_TRANSACTION_COMPLETED, }); @@ -127,7 +128,7 @@ export function doSendDraftTransaction(address, amount) { } else { dispatch({ type: ACTIONS.SEND_TRANSACTION_FAILED, - data: { error: results }, + data: { error: response }, }); dispatch( doNotify({ @@ -156,8 +157,8 @@ export function doSendDraftTransaction(address, amount) { }; Lbry.wallet_send({ - amount, address, + amount: creditsToString(amount), }).then(successCallback, errorCallback); }; } @@ -176,7 +177,7 @@ export function doSetDraftTransactionAddress(address) { }; } -export function doSendSupport(amount, claimId, uri, successCallback, errorCallback) { +export function doSendTip(amount, claimId, uri, successCallback, errorCallback) { return (dispatch, getState) => { const state = getState(); const balance = selectBalance(state); @@ -236,9 +237,9 @@ export function doSendSupport(amount, claimId, uri, successCallback, errorCallba type: ACTIONS.SUPPORT_TRANSACTION_STARTED, }); - Lbry.wallet_send({ + Lbry.claim_tip({ claim_id: claimId, - amount, + amount: creditsToString(amount), }).then(success, error); }; } @@ -249,7 +250,7 @@ export function doWalletEncrypt(newPassword) { type: ACTIONS.WALLET_ENCRYPT_START, }); - Lbry.wallet_encrypt({ new_password: newPassword }).then(result => { + Lbry.account_encrypt({ new_password: newPassword }).then(result => { if (result === true) { dispatch({ type: ACTIONS.WALLET_ENCRYPT_COMPLETED, @@ -271,7 +272,7 @@ export function doWalletUnlock(password) { type: ACTIONS.WALLET_UNLOCK_START, }); - Lbry.wallet_unlock({ password }).then(result => { + Lbry.account_unlock({ password }).then(result => { if (result === true) { dispatch({ type: ACTIONS.WALLET_UNLOCK_COMPLETED, @@ -315,7 +316,7 @@ export function doWalletDecrypt() { type: ACTIONS.WALLET_DECRYPT_START, }); - Lbry.wallet_decrypt().then(result => { + Lbry.account_decrypt().then(result => { if (result === true) { dispatch({ type: ACTIONS.WALLET_DECRYPT_COMPLETED, diff --git a/src/redux/reducers/claims.js b/src/redux/reducers/claims.js index 9186e69..a4e0a09 100644 --- a/src/redux/reducers/claims.js +++ b/src/redux/reducers/claims.js @@ -54,26 +54,17 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => { const byId = Object.assign({}, state.byId); const pendingById = Object.assign({}, state.pendingById); - claims - .filter( - claim => claim.category && (claim.category.match(/claim/) || claim.category.match(/update/)) - ) - .forEach(claim => { + claims.filter(claim => claim.type && claim.type.match(/claim|update/)).forEach(claim => { + if (claim.confirmations < 1) { + pendingById[claim.claim_id] = claim; + } else { byId[claim.claim_id] = claim; + } + }); - const pending = Object.values(pendingById).find( - pendingClaim => - pendingClaim.name === claim.name && pendingClaim.channel_name === claim.channel_name - ); - - if (pending) { - delete pendingById[pending.claim_id]; - } - }); - - // Remove old timed out pending publishes + // Remove old pending publishes Object.values(pendingById) - .filter(pendingClaim => Date.now() - pendingClaim.time >= 20 * 60 * 1000) + .filter(pendingClaim => byId[pendingClaim.claim_id]) .forEach(pendingClaim => { delete pendingById[pendingClaim.claim_id]; }); @@ -96,7 +87,7 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => { claims.forEach(claim => { myChannelClaims.add(claim.claim_id); - byId[claims.claim_id] = claim; + byId[claim.claim_id] = claim; }); return Object.assign({}, state, { diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 826727d..3775056 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -1,9 +1,8 @@ -import { normalizeURI } from 'lbryURI'; +import { normalizeURI, buildURI, parseURI } from 'lbryURI'; import { makeSelectCurrentParam } from 'redux/selectors/navigation'; import { selectSearchUrisByQuery } from 'redux/selectors/search'; import { createSelector } from 'reselect'; import { isClaimNsfw } from 'util/claim'; -import { buildURI } from 'lbryURI'; const selectState = state => state.claims || {}; @@ -34,8 +33,36 @@ export const selectAllClaimsByChannel = createSelector( state => state.claimsByChannel || {} ); +export const selectPendingById = createSelector(selectState, state => state.pendingById); + +export const selectPendingClaims = createSelector(selectState, state => + Object.values(state.pendingById || {}) +); + +export const makeSelectClaimIsPending = uri => + createSelector(selectPendingById, pendingById => { + const { claimId } = parseURI(uri); + return Boolean(pendingById[claimId]); + }); + +export const makeSelectPendingByUri = uri => + createSelector(selectPendingById, pendingById => { + const { claimId } = parseURI(uri); + return pendingById[claimId]; + }); + export const makeSelectClaimForUri = uri => - createSelector(selectClaimsByUri, claims => claims && claims[normalizeURI(uri)]); + createSelector(selectClaimsByUri, selectPendingById, (byUri, pendingById) => { + // Check if a claim is pending first + // It won't be in claimsByUri because resolving it will return nothing + const { claimId } = parseURI(uri); + const pendingClaim = pendingById[claimId]; + if (pendingClaim) { + return pendingClaim; + } + + return byUri && byUri[normalizeURI(uri)]; + }); export const selectMyClaimsRaw = createSelector(selectState, state => state.myClaims); @@ -122,10 +149,6 @@ export const selectIsFetchingClaimListMine = createSelector( state => state.isFetchingClaimListMine ); -export const selectPendingClaims = createSelector(selectState, state => - Object.values(state.pendingById || {}) -); - export const selectMyClaims = createSelector( selectMyActiveClaims, selectClaimsById, diff --git a/src/redux/selectors/wallet.js b/src/redux/selectors/wallet.js index 3463608..2c75897 100644 --- a/src/redux/selectors/wallet.js +++ b/src/redux/selectors/wallet.js @@ -130,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, @@ -139,7 +139,7 @@ export const selectTransactionItems = createSelector(selectTransactionsById, byI }) ); }); - return items.reverse(); + return items; }); export const selectRecentTransactions = createSelector(selectTransactionItems, transactions => { diff --git a/src/util/formatCredits.js b/src/util/formatCredits.js index 98383c0..1c65590 100644 --- a/src/util/formatCredits.js +++ b/src/util/formatCredits.js @@ -19,3 +19,12 @@ export function formatFullPrice(amount, precision = 1) { return parseFloat(quantity[0] + formated); } + +export function creditsToString(amount) { + const creditString = String(amount); + + if (creditString.includes('.')) { + return creditString; + } + return `${creditString}.0`; +}