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 sizing on squat videos (#419)
|
||||
* Support claims no longer show up on Published page (#384)
|
||||
* Check for valid address when sending credits (#445)
|
||||
|
||||
### Deprecated
|
||||
*
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as types from "constants/action_types";
|
|||
import lbry from "lbry";
|
||||
import {
|
||||
selectDraftTransaction,
|
||||
selectDraftTransactionAddress,
|
||||
selectDraftTransactionAmount,
|
||||
selectBalance,
|
||||
} from "selectors/wallet";
|
||||
|
@ -69,6 +70,7 @@ export function doSendDraftTransaction() {
|
|||
return function(dispatch, getState) {
|
||||
const state = getState();
|
||||
const draftTx = selectDraftTransaction(state);
|
||||
const address = selectDraftTransactionAddress(state);
|
||||
const balance = selectBalance(state);
|
||||
const amount = selectDraftTransactionAmount(state);
|
||||
|
||||
|
@ -76,6 +78,15 @@ export function doSendDraftTransaction() {
|
|||
return dispatch(doOpenModal("insufficientBalance"));
|
||||
}
|
||||
|
||||
lbry
|
||||
.is_address({ address })
|
||||
.then(addressIsValid => {
|
||||
if (!addressIsValid) {
|
||||
dispatch(doOpenModal("invalidAddress"));
|
||||
reject();
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
dispatch({
|
||||
type: types.SEND_TRANSACTION_STARTED,
|
||||
});
|
||||
|
@ -109,6 +120,7 @@ export function doSendDraftTransaction() {
|
|||
address: draftTx.address,
|
||||
})
|
||||
.then(successCallback, errorCallback);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,14 @@ const WalletSend = props => {
|
|||
<input type="submit" className="hidden" />
|
||||
</div>
|
||||
</form>
|
||||
{modal == "invalidAddress" &&
|
||||
<Modal
|
||||
isOpen={true}
|
||||
contentLabel={__("Invalid address")}
|
||||
onConfirmed={closeModal}
|
||||
>
|
||||
{__("You have entered an invalid LBRY address.")}
|
||||
</Modal>}
|
||||
{modal == "insufficientBalance" &&
|
||||
<Modal
|
||||
isOpen={true}
|
||||
|
|
Loading…
Reference in a new issue