diff --git a/web/cashtab/src/components/Airdrop/Airdrop.js b/web/cashtab/src/components/Airdrop/Airdrop.js --- a/web/cashtab/src/components/Airdrop/Airdrop.js +++ b/web/cashtab/src/components/Airdrop/Airdrop.js @@ -9,7 +9,7 @@ import { Form, Alert, Collapse, Input, Modal, Spin, Progress } from 'antd'; const { Panel } = Collapse; const { TextArea } = Input; -import { Row, Col } from 'antd'; +import { Row, Col, Switch } from 'antd'; import { SmartButton } from 'components/Common/PrimaryButton'; import useBCH from 'hooks/useBCH'; import { @@ -23,6 +23,7 @@ getWalletState, convertEtokenToEcashAddr, fromSmallestDenomination, + convertToEcashPrefix, } from 'utils/cashMethods'; import { isValidTokenId, @@ -76,6 +77,11 @@ } `; +const AirdropOptions = styled.div` + text-align: left; + color: ${props => props.theme.contrast}; +`; + // Note jestBCH is only used for unit tests; BCHJS must be mocked for jest const Airdrop = ({ jestBCH, passLoadingStatus }) => { const ContextValue = React.useContext(WalletContext); @@ -120,6 +126,7 @@ const [airdropOutputIsValid, setAirdropOutputIsValid] = useState(true); const [etokenHolders, setEtokenHolders] = useState(new BigNumber(0)); const [showAirdropOutputs, setShowAirdropOutputs] = useState(false); + const [ignoreOwnAddress, setIgnoreOwnAddress] = useState(false); const { getBCH } = useBCH(); @@ -184,7 +191,15 @@ return; } - if (!airdropList) { + // if Ignore Own Address option is checked, then filter out from recipients list + if (ignoreOwnAddress) { + const ownEtokenAddress = convertToEcashPrefix( + wallet.Path1899.slpAddress, + ); + airdropList.delete(ownEtokenAddress); + } + + if (!airdropList || airdropList.size === 0) { errorNotification( null, 'No recipients found for tokenId ' + formData.tokenId, @@ -253,6 +268,10 @@ passLoadingStatus(false); }; + const handleIgnoreOwnAddress = e => { + setIgnoreOwnAddress(e); + }; + let airdropCalcInputIsValid = tokenIdIsValid && totalAirdropIsValid; return ( @@ -370,6 +389,20 @@ } /> + + + + handleIgnoreOwnAddress( + prev => !prev, + ) + } + defaultunchecked="true" + checked={ignoreOwnAddress} + /> +  Ignore my own address + +