fix: send credits
This commit is contained in:
parent
c04d64ad30
commit
230f33a504
2 changed files with 25 additions and 5637 deletions
5623
dist/bundle.js
vendored
5623
dist/bundle.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,15 +1,13 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import Lbry from 'lbry';
|
import Lbry from 'lbry';
|
||||||
import { doNotify } from 'redux/actions/notifications';
|
import { doNotify } from 'redux/actions/notifications';
|
||||||
import {
|
import { selectBalance } from 'redux/selectors/wallet';
|
||||||
selectBalance,
|
|
||||||
selectDraftTransaction,
|
|
||||||
selectDraftTransactionAmount,
|
|
||||||
} from 'redux/selectors/wallet';
|
|
||||||
|
|
||||||
export function doUpdateBalance() {
|
export function doUpdateBalance() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const { wallet: { balance: balanceInStore } } = getState();
|
const {
|
||||||
|
wallet: { balance: balanceInStore },
|
||||||
|
} = getState();
|
||||||
Lbry.wallet_balance().then(balance => {
|
Lbry.wallet_balance().then(balance => {
|
||||||
if (balanceInStore !== balance) {
|
if (balanceInStore !== balance) {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -90,12 +88,10 @@ export function doCheckAddressIsMine(address) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doSendDraftTransaction() {
|
export function doSendDraftTransaction(address, amount) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const draftTx = selectDraftTransaction(state);
|
|
||||||
const balance = selectBalance(state);
|
const balance = selectBalance(state);
|
||||||
const amount = selectDraftTransactionAmount(state);
|
|
||||||
|
|
||||||
if (balance - amount <= 0) {
|
if (balance - amount <= 0) {
|
||||||
dispatch(
|
dispatch(
|
||||||
|
@ -138,7 +134,7 @@ export function doSendDraftTransaction() {
|
||||||
title: 'Transaction failed',
|
title: 'Transaction failed',
|
||||||
message: 'Transaction failed',
|
message: 'Transaction failed',
|
||||||
type: 'error',
|
type: 'error',
|
||||||
displayType: ['modal', 'toast'],
|
displayType: ['snackbar', 'toast'],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -154,14 +150,14 @@ export function doSendDraftTransaction() {
|
||||||
title: 'Transaction failed',
|
title: 'Transaction failed',
|
||||||
message: 'Transaction failed',
|
message: 'Transaction failed',
|
||||||
type: 'error',
|
type: 'error',
|
||||||
displayType: ['modal', 'toast'],
|
displayType: ['snackbar', 'toast'],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Lbry.wallet_send({
|
Lbry.wallet_send({
|
||||||
amount: draftTx.amount,
|
amount,
|
||||||
address: draftTx.address,
|
address,
|
||||||
}).then(successCallback, errorCallback);
|
}).then(successCallback, errorCallback);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -197,6 +193,21 @@ export function doSendSupport(amount, claimId, uri, successCallback, errorCallba
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const success = () => {
|
||||||
|
dispatch(
|
||||||
|
doNotify({
|
||||||
|
message: __(`You sent ${amount} LBC as support, Mahalo!`),
|
||||||
|
linkText: __('History'),
|
||||||
|
linkTarget: __('/wallet'),
|
||||||
|
displayType: ['snackbar'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (successCallback) {
|
||||||
|
successCallback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.SUPPORT_TRANSACTION_STARTED,
|
type: ACTIONS.SUPPORT_TRANSACTION_STARTED,
|
||||||
});
|
});
|
||||||
|
@ -204,6 +215,6 @@ export function doSendSupport(amount, claimId, uri, successCallback, errorCallba
|
||||||
Lbry.wallet_send({
|
Lbry.wallet_send({
|
||||||
claim_id: claimId,
|
claim_id: claimId,
|
||||||
amount,
|
amount,
|
||||||
}).then(successCallback, errorCallback);
|
}).then(success, errorCallback);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue