Check for valid address when sending credits on Wallet page #489
3 changed files with 52 additions and 31 deletions
|
@ -30,6 +30,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
|
||||||
* Fixed pagination styling for pages > 5 (#416)
|
* Fixed pagination styling for pages > 5 (#416)
|
||||||
* Fixed sizing on squat videos (#419)
|
* Fixed sizing on squat videos (#419)
|
||||||
* Support claims no longer show up on Published page (#384)
|
* Support claims no longer show up on Published page (#384)
|
||||||
|
* Check for valid address when sending credits (#445)
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,6 +2,7 @@ import * as types from "constants/action_types";
|
||||||
import lbry from "lbry";
|
import lbry from "lbry";
|
||||||
import {
|
import {
|
||||||
selectDraftTransaction,
|
selectDraftTransaction,
|
||||||
|
selectDraftTransactionAddress,
|
||||||
selectDraftTransactionAmount,
|
selectDraftTransactionAmount,
|
||||||
selectBalance,
|
selectBalance,
|
||||||
} from "selectors/wallet";
|
} from "selectors/wallet";
|
||||||
|
@ -69,6 +70,7 @@ export function doSendDraftTransaction() {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const draftTx = selectDraftTransaction(state);
|
const draftTx = selectDraftTransaction(state);
|
||||||
|
const address = selectDraftTransactionAddress(state);
|
||||||
const balance = selectBalance(state);
|
const balance = selectBalance(state);
|
||||||
const amount = selectDraftTransactionAmount(state);
|
const amount = selectDraftTransactionAmount(state);
|
||||||
|
|
||||||
|
@ -76,39 +78,49 @@ export function doSendDraftTransaction() {
|
||||||
return dispatch(doOpenModal("insufficientBalance"));
|
return dispatch(doOpenModal("insufficientBalance"));
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: types.SEND_TRANSACTION_STARTED,
|
|
||||||
});
|
|
||||||
|
|
||||||
const successCallback = results => {
|
|
||||||
if (results === true) {
|
|
||||||
dispatch({
|
|
||||||
type: types.SEND_TRANSACTION_COMPLETED,
|
|
||||||
});
|
|
||||||
dispatch(doOpenModal("transactionSuccessful"));
|
|
||||||
} else {
|
|
||||||
dispatch({
|
|
||||||
type: types.SEND_TRANSACTION_FAILED,
|
|
||||||
data: { error: results },
|
|
||||||
});
|
|
||||||
dispatch(doOpenModal("transactionFailed"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errorCallback = error => {
|
|
||||||
dispatch({
|
|
||||||
type: types.SEND_TRANSACTION_FAILED,
|
|
||||||
data: { error: error.message },
|
|
||||||
});
|
|
||||||
dispatch(doOpenModal("transactionFailed"));
|
|
||||||
};
|
|
||||||
|
|
||||||
lbry
|
lbry
|
||||||
.wallet_send({
|
.is_address({ address })
|
||||||
amount: draftTx.amount,
|
.then(addressIsValid => {
|
||||||
address: draftTx.address,
|
if (!addressIsValid) {
|
||||||
|
dispatch(doOpenModal("invalidAddress"));
|
||||||
|
reject();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(successCallback, errorCallback);
|
.then(() => {
|
||||||
|
dispatch({
|
||||||
|
type: types.SEND_TRANSACTION_STARTED,
|
||||||
|
});
|
||||||
|
|
||||||
|
const successCallback = results => {
|
||||||
|
if (results === true) {
|
||||||
|
dispatch({
|
||||||
|
type: types.SEND_TRANSACTION_COMPLETED,
|
||||||
|
});
|
||||||
|
dispatch(doOpenModal("transactionSuccessful"));
|
||||||
|
} else {
|
||||||
|
dispatch({
|
||||||
|
type: types.SEND_TRANSACTION_FAILED,
|
||||||
|
data: { error: results },
|
||||||
|
});
|
||||||
|
dispatch(doOpenModal("transactionFailed"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const errorCallback = error => {
|
||||||
|
dispatch({
|
||||||
|
type: types.SEND_TRANSACTION_FAILED,
|
||||||
|
data: { error: error.message },
|
||||||
|
});
|
||||||
|
dispatch(doOpenModal("transactionFailed"));
|
||||||
|
};
|
||||||
|
|
||||||
|
lbry
|
||||||
|
.wallet_send({
|
||||||
|
amount: draftTx.amount,
|
||||||
|
address: draftTx.address,
|
||||||
|
})
|
||||||
|
.then(successCallback, errorCallback);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,14 @@ const WalletSend = props => {
|
||||||
<input type="submit" className="hidden" />
|
<input type="submit" className="hidden" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{modal == "invalidAddress" &&
|
||||||
|
<Modal
|
||||||
|
isOpen={true}
|
||||||
|
contentLabel={__("Invalid address")}
|
||||||
|
onConfirmed={closeModal}
|
||||||
|
>
|
||||||
|
{__("You have entered an invalid LBRY address.")}
|
||||||
|
</Modal>}
|
||||||
{modal == "insufficientBalance" &&
|
{modal == "insufficientBalance" &&
|
||||||
<Modal
|
<Modal
|
||||||
isOpen={true}
|
isOpen={true}
|
||||||
|
|
Loading…
Reference in a new issue