Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Airdrop/Airdrop.js
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
`; | `; | ||||
const StyledModal = styled(Modal)` | const StyledModal = styled(Modal)` | ||||
.ant-progress-text { | .ant-progress-text { | ||||
color: ${props => props.theme.lightWhite} !important; | color: ${props => props.theme.lightWhite} !important; | ||||
} | } | ||||
`; | `; | ||||
// Note jestBCH is only used for unit tests; BCHJS must be mocked for jest | // Note jestBCH is only used for unit tests; BCHJS must be mocked for jest | ||||
const Airdrop = ({ jestBCH, passLoadingStatus }) => { | const Airdrop = ({ passLoadingStatus }) => { | ||||
const ContextValue = React.useContext(WalletContext); | const ContextValue = React.useContext(WalletContext); | ||||
const { | const { | ||||
BCH, | |||||
wallet, | wallet, | ||||
fiatPrice, | fiatPrice, | ||||
cashtabSettings, | cashtabSettings, | ||||
chronik, | chronik, | ||||
changeCashtabSettings, | changeCashtabSettings, | ||||
} = ContextValue; | } = ContextValue; | ||||
const location = useLocation(); | const location = useLocation(); | ||||
const walletState = getWalletState(wallet); | const walletState = getWalletState(wallet); | ||||
const { balances } = walletState; | const { balances } = walletState; | ||||
const [bchObj, setBchObj] = useState(false); | |||||
const [isAirdropCalcModalVisible, setIsAirdropCalcModalVisible] = | const [isAirdropCalcModalVisible, setIsAirdropCalcModalVisible] = | ||||
useState(false); | useState(false); | ||||
const [airdropCalcModalProgress, setAirdropCalcModalProgress] = useState(0); // the dynamic % progress bar | const [airdropCalcModalProgress, setAirdropCalcModalProgress] = useState(0); // the dynamic % progress bar | ||||
useEffect(() => { | useEffect(() => { | ||||
// jestBCH is only ever specified for unit tests, otherwise app will use getBCH(); | |||||
const activeBCH = jestBCH ? jestBCH : BCH; | |||||
// set the BCH instance to state, for other functions to reference | |||||
setBchObj(activeBCH); | |||||
}, [BCH]); | |||||
useEffect(() => { | |||||
if (location && location.state && location.state.airdropEtokenId) { | if (location && location.state && location.state.airdropEtokenId) { | ||||
setFormData({ | setFormData({ | ||||
...formData, | ...formData, | ||||
tokenId: location.state.airdropEtokenId, | tokenId: location.state.airdropEtokenId, | ||||
}); | }); | ||||
handleTokenIdInput({ | handleTokenIdInput({ | ||||
target: { | target: { | ||||
value: location.state.airdropEtokenId, | value: location.state.airdropEtokenId, | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | const calculateXecAirdrop = async () => { | ||||
// if Ignore eToken Minter option is checked, then filter out from recipients list | // if Ignore eToken Minter option is checked, then filter out from recipients list | ||||
if (ignoreMintAddress) { | if (ignoreMintAddress) { | ||||
// extract the eToken mint address | // extract the eToken mint address | ||||
let mintEtokenAddress; | let mintEtokenAddress; | ||||
try { | try { | ||||
mintEtokenAddress = await getMintAddress( | mintEtokenAddress = await getMintAddress( | ||||
chronik, | chronik, | ||||
bchObj, | |||||
formData.tokenId, | formData.tokenId, | ||||
); | ); | ||||
} catch (err) { | } catch (err) { | ||||
console.log(`Error in getMintAddress`, err); | console.log(`Error in getMintAddress`, err); | ||||
errorNotification( | errorNotification( | ||||
null, | null, | ||||
'Unable to retrieve minting address for eToken ID: ' + | 'Unable to retrieve minting address for eToken ID: ' + | ||||
formData.tokenId, | formData.tokenId, | ||||
▲ Show 20 Lines • Show All 611 Lines • Show Last 20 Lines |