estimate claim date with block height
This commit is contained in:
parent
aa10240bc1
commit
6f1e3b054f
6 changed files with 144 additions and 72 deletions
124
dist/bundle.js
vendored
124
dist/bundle.js
vendored
|
@ -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 = 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;
|
||||
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 = exports.selectMyClaims = undefined;
|
||||
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.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.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);
|
||||
|
||||
|
@ -403,6 +388,12 @@ Object.defineProperty(exports, 'doSetTransactionListFilter', {
|
|||
return _wallet.doSetTransactionListFilter;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'doUpdateBlockHeight', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _wallet.doUpdateBlockHeight;
|
||||
}
|
||||
});
|
||||
|
||||
var _batchActions = __webpack_require__(21);
|
||||
|
||||
|
@ -1647,6 +1638,7 @@ 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 SET_TRANSACTION_LIST_FILTER = exports.SET_TRANSACTION_LIST_FILTER = 'SET_TRANSACTION_LIST_FILTER';
|
||||
var UPDATE_CURRENT_HEIGHT = exports.UPDATE_CURRENT_HEIGHT = 'UPDATE_CURRENT_HEIGHT';
|
||||
|
||||
// Claims
|
||||
var FETCH_FEATURED_CONTENT_STARTED = exports.FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
||||
|
@ -2537,26 +2529,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;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
@ -4524,6 +4516,7 @@ exports.doWalletLock = doWalletLock;
|
|||
exports.doWalletDecrypt = doWalletDecrypt;
|
||||
exports.doWalletStatus = doWalletStatus;
|
||||
exports.doSetTransactionListFilter = doSetTransactionListFilter;
|
||||
exports.doUpdateBlockHeight = doUpdateBlockHeight;
|
||||
|
||||
var _action_types = __webpack_require__(4);
|
||||
|
||||
|
@ -4883,6 +4876,19 @@ function doSetTransactionListFilter(filterOption) {
|
|||
};
|
||||
}
|
||||
|
||||
function doUpdateBlockHeight() {
|
||||
return function (dispatch) {
|
||||
return _lbry2.default.status().then(function (status) {
|
||||
if (status.wallet) {
|
||||
dispatch({
|
||||
type: ACTIONS.UPDATE_CURRENT_HEIGHT,
|
||||
data: status.wallet.blocks
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
/* 29 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
@ -4893,7 +4899,7 @@ function doSetTransactionListFilter(filterOption) {
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.selectTransactionListFilter = 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;
|
||||
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;
|
||||
|
||||
var _reselect = __webpack_require__(16);
|
||||
|
||||
|
@ -5093,9 +5099,29 @@ var selectBlocks = exports.selectBlocks = (0, _reselect.createSelector)(selectSt
|
|||
return state.blocks;
|
||||
});
|
||||
|
||||
var selectCurrentHeight = exports.selectCurrentHeight = (0, _reselect.createSelector)(selectState, function (state) {
|
||||
return state.latestBlock;
|
||||
});
|
||||
|
||||
var makeSelectBlockDate = exports.makeSelectBlockDate = function makeSelectBlockDate(block) {
|
||||
return (0, _reselect.createSelector)(selectBlocks, function (blocks) {
|
||||
return blocks && blocks[block] ? new Date(blocks[block].time * 1000) : undefined;
|
||||
return (0, _reselect.createSelector)(selectBlocks, selectCurrentHeight, function (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
|
||||
// Adding this on 11/7/2018 because caling block_show for every claim is causing
|
||||
// performance issues.
|
||||
if (blocks && blocks[block]) {
|
||||
return new Date(blocks[block].time * 1000);
|
||||
}
|
||||
|
||||
// Pending claim
|
||||
if (block < 1) {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
var difference = latestBlock - block;
|
||||
var msSincePublish = difference * 2.5 * 60 * 1000; // Number of blocks * 2.5 minutes in ms
|
||||
var publishDate = Date.now() - msSincePublish;
|
||||
return new Date(publishDate);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -6158,6 +6184,7 @@ var buildDraftTransaction = function buildDraftTransaction() {
|
|||
/*:: type WalletState = {
|
||||
balance: any,
|
||||
blocks: any,
|
||||
latestBlock: number,
|
||||
transactions: any,
|
||||
fetchingTransactions: boolean,
|
||||
gettingNewAddress: boolean,
|
||||
|
@ -6182,6 +6209,7 @@ var buildDraftTransaction = function buildDraftTransaction() {
|
|||
var defaultState = {
|
||||
balance: undefined,
|
||||
blocks: {},
|
||||
latestBlock: undefined,
|
||||
transactions: {},
|
||||
fetchingTransactions: false,
|
||||
gettingNewAddress: false,
|
||||
|
@ -6448,6 +6476,12 @@ reducers[ACTIONS.SET_TRANSACTION_LIST_FILTER] = function (state /*: WalletState*
|
|||
});
|
||||
};
|
||||
|
||||
reducers[ACTIONS.UPDATE_CURRENT_HEIGHT] = function (state /*: WalletState*/, action /*: { data: number }*/) {
|
||||
return Object.assign({}, state, {
|
||||
latestBlock: action.data
|
||||
});
|
||||
};
|
||||
|
||||
function walletReducer() {
|
||||
var state /*: WalletState*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
||||
var action /*: ActionResult*/ = arguments[1];
|
||||
|
|
|
@ -58,6 +58,7 @@ 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 SET_TRANSACTION_LIST_FILTER = 'SET_TRANSACTION_LIST_FILTER';
|
||||
export const UPDATE_CURRENT_HEIGHT = 'UPDATE_CURRENT_HEIGHT';
|
||||
|
||||
// Claims
|
||||
export const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
||||
|
|
|
@ -88,6 +88,7 @@ export {
|
|||
doWalletUnlock,
|
||||
doWalletStatus,
|
||||
doSetTransactionListFilter,
|
||||
doUpdateBlockHeight,
|
||||
} from 'redux/actions/wallet';
|
||||
|
||||
// utils
|
||||
|
|
|
@ -9,7 +9,7 @@ export function doUpdateBalance() {
|
|||
const {
|
||||
wallet: { balance: balanceInStore },
|
||||
} = getState();
|
||||
Lbry.account_balance().then(balance => {
|
||||
Lbry.account_balance().then((balance) => {
|
||||
if (balanceInStore !== balance) {
|
||||
dispatch({
|
||||
type: ACTIONS.UPDATE_BALANCE,
|
||||
|
@ -23,19 +23,19 @@ export function doUpdateBalance() {
|
|||
}
|
||||
|
||||
export function doBalanceSubscribe() {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch(doUpdateBalance());
|
||||
setInterval(() => dispatch(doUpdateBalance()), 5000);
|
||||
};
|
||||
}
|
||||
|
||||
export function doFetchTransactions() {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_TRANSACTIONS_STARTED,
|
||||
});
|
||||
|
||||
Lbry.transaction_list().then(results => {
|
||||
Lbry.transaction_list().then((results) => {
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_TRANSACTIONS_COMPLETED,
|
||||
data: {
|
||||
|
@ -47,8 +47,8 @@ export function doFetchTransactions() {
|
|||
}
|
||||
|
||||
export function doFetchBlock(height) {
|
||||
return dispatch => {
|
||||
Lbry.block_show({ height }).then(block => {
|
||||
return (dispatch) => {
|
||||
Lbry.block_show({ height }).then((block) => {
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_BLOCK_SUCCESS,
|
||||
data: { block },
|
||||
|
@ -58,13 +58,13 @@ export function doFetchBlock(height) {
|
|||
}
|
||||
|
||||
export function doGetNewAddress() {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.GET_NEW_ADDRESS_STARTED,
|
||||
});
|
||||
|
||||
// Removed localStorage use, since address is expected to be stored in redux store
|
||||
Lbry.address_unused().then(address => {
|
||||
Lbry.address_unused().then((address) => {
|
||||
dispatch({
|
||||
type: ACTIONS.GET_NEW_ADDRESS_COMPLETED,
|
||||
data: { address },
|
||||
|
@ -74,12 +74,12 @@ export function doGetNewAddress() {
|
|||
}
|
||||
|
||||
export function doCheckAddressIsMine(address) {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.CHECK_ADDRESS_IS_MINE_STARTED,
|
||||
});
|
||||
|
||||
Lbry.address_is_mine({ address }).then(isMine => {
|
||||
Lbry.address_is_mine({ address }).then((isMine) => {
|
||||
if (!isMine) dispatch(doGetNewAddress());
|
||||
|
||||
dispatch({
|
||||
|
@ -110,7 +110,7 @@ export function doSendDraftTransaction(address, amount) {
|
|||
type: ACTIONS.SEND_TRANSACTION_STARTED,
|
||||
});
|
||||
|
||||
const successCallback = response => {
|
||||
const successCallback = (response) => {
|
||||
if (response.txid) {
|
||||
dispatch({
|
||||
type: ACTIONS.SEND_TRANSACTION_COMPLETED,
|
||||
|
@ -141,7 +141,7 @@ export function doSendDraftTransaction(address, amount) {
|
|||
}
|
||||
};
|
||||
|
||||
const errorCallback = error => {
|
||||
const errorCallback = (error) => {
|
||||
dispatch({
|
||||
type: ACTIONS.SEND_TRANSACTION_FAILED,
|
||||
data: { error: error.message },
|
||||
|
@ -213,7 +213,7 @@ export function doSendTip(amount, claimId, uri, successCallback, errorCallback)
|
|||
}
|
||||
};
|
||||
|
||||
const error = err => {
|
||||
const error = (err) => {
|
||||
dispatch(
|
||||
doNotify({
|
||||
message: __(`There was an error sending support funds.`),
|
||||
|
@ -245,12 +245,12 @@ export function doSendTip(amount, claimId, uri, successCallback, errorCallback)
|
|||
}
|
||||
|
||||
export function doWalletEncrypt(newPassword) {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_ENCRYPT_START,
|
||||
});
|
||||
|
||||
Lbry.account_encrypt({ new_password: newPassword }).then(result => {
|
||||
Lbry.account_encrypt({ new_password: newPassword }).then((result) => {
|
||||
if (result === true) {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_ENCRYPT_COMPLETED,
|
||||
|
@ -267,12 +267,12 @@ export function doWalletEncrypt(newPassword) {
|
|||
}
|
||||
|
||||
export function doWalletUnlock(password) {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_UNLOCK_START,
|
||||
});
|
||||
|
||||
Lbry.account_unlock({ password }).then(result => {
|
||||
Lbry.account_unlock({ password }).then((result) => {
|
||||
if (result === true) {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_UNLOCK_COMPLETED,
|
||||
|
@ -289,12 +289,12 @@ export function doWalletUnlock(password) {
|
|||
}
|
||||
|
||||
export function doWalletLock() {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_LOCK_START,
|
||||
});
|
||||
|
||||
Lbry.wallet_lock().then(result => {
|
||||
Lbry.wallet_lock().then((result) => {
|
||||
if (result === true) {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_LOCK_COMPLETED,
|
||||
|
@ -311,12 +311,12 @@ export function doWalletLock() {
|
|||
}
|
||||
|
||||
export function doWalletDecrypt() {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_DECRYPT_START,
|
||||
});
|
||||
|
||||
Lbry.account_decrypt().then(result => {
|
||||
Lbry.account_decrypt().then((result) => {
|
||||
if (result === true) {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_DECRYPT_COMPLETED,
|
||||
|
@ -333,12 +333,12 @@ export function doWalletDecrypt() {
|
|||
}
|
||||
|
||||
export function doWalletStatus() {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_STATUS_START,
|
||||
});
|
||||
|
||||
Lbry.status().then(status => {
|
||||
Lbry.status().then((status) => {
|
||||
if (status && status.wallet) {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_STATUS_COMPLETED,
|
||||
|
@ -355,3 +355,15 @@ export function doSetTransactionListFilter(filterOption) {
|
|||
data: filterOption,
|
||||
};
|
||||
}
|
||||
|
||||
export function doUpdateBlockHeight() {
|
||||
return (dispatch) =>
|
||||
Lbry.status().then((status) => {
|
||||
if (status.wallet) {
|
||||
dispatch({
|
||||
type: ACTIONS.UPDATE_CURRENT_HEIGHT,
|
||||
data: status.wallet.blocks,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ type ActionResult = {
|
|||
type WalletState = {
|
||||
balance: any,
|
||||
blocks: any,
|
||||
latestBlock: number,
|
||||
transactions: any,
|
||||
fetchingTransactions: boolean,
|
||||
gettingNewAddress: boolean,
|
||||
|
@ -40,6 +41,7 @@ type WalletState = {
|
|||
const defaultState = {
|
||||
balance: undefined,
|
||||
blocks: {},
|
||||
latestBlock: undefined,
|
||||
transactions: {},
|
||||
fetchingTransactions: false,
|
||||
gettingNewAddress: false,
|
||||
|
@ -281,6 +283,11 @@ reducers[ACTIONS.SET_TRANSACTION_LIST_FILTER] = (state: WalletState, action: {})
|
|||
transactionListFilter: action.data,
|
||||
});
|
||||
|
||||
reducers[ACTIONS.UPDATE_CURRENT_HEIGHT] = (state: WalletState, action: { data: number }) =>
|
||||
Object.assign({}, state, {
|
||||
latestBlock: action.data,
|
||||
});
|
||||
|
||||
export function walletReducer(state: WalletState = defaultState, action: ActionResult) {
|
||||
const handler = reducers[action.type];
|
||||
if (handler) return handler(state, action);
|
||||
|
|
|
@ -211,11 +211,28 @@ export const selectDraftTransactionError = createSelector(
|
|||
|
||||
export const selectBlocks = createSelector(selectState, (state) => state.blocks);
|
||||
|
||||
export const selectCurrentHeight = createSelector(selectState, (state) => state.latestBlock);
|
||||
|
||||
export const makeSelectBlockDate = (block) =>
|
||||
createSelector(
|
||||
selectBlocks,
|
||||
(blocks) => (blocks && blocks[block] ? new Date(blocks[block].time * 1000) : undefined)
|
||||
);
|
||||
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
|
||||
// Adding this on 11/7/2018 because caling block_show for every claim is causing
|
||||
// performance issues.
|
||||
if (blocks && blocks[block]) {
|
||||
return new Date(blocks[block].time * 1000);
|
||||
}
|
||||
|
||||
// Pending claim
|
||||
if (block < 1) {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
const difference = latestBlock - block;
|
||||
const msSincePublish = difference * 2.5 * 60 * 1000; // Number of blocks * 2.5 minutes in ms
|
||||
const publishDate = Date.now() - msSincePublish;
|
||||
return new Date(publishDate);
|
||||
});
|
||||
|
||||
export const selectTransactionListFilter = createSelector(
|
||||
selectState,
|
||||
|
|
Loading…
Reference in a new issue