2017-09-25 02:06:28 +00:00
|
|
|
import {
|
|
|
|
TBityOrderCreateRequestedSwap,
|
|
|
|
TChangeStepSwap,
|
|
|
|
TDestinationAddressSwap,
|
2018-01-02 18:04:50 +00:00
|
|
|
TShapeshiftOrderCreateRequestedSwap,
|
2017-09-25 02:06:28 +00:00
|
|
|
TStopLoadBityRatesSwap
|
|
|
|
} from 'actions/swap';
|
2017-12-11 17:44:53 +00:00
|
|
|
import { SwapInput } from 'reducers/swap/types';
|
2017-09-25 02:06:28 +00:00
|
|
|
import SimpleButton from 'components/ui/SimpleButton';
|
2018-01-20 20:06:28 +00:00
|
|
|
import { donationAddressMap } from 'config';
|
2017-07-02 05:49:06 +00:00
|
|
|
import { isValidBTCAddress, isValidETHAddress } from 'libs/validators';
|
2018-01-29 19:13:46 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2017-06-25 05:57:43 +00:00
|
|
|
import translate from 'translations';
|
2017-07-31 23:14:30 +00:00
|
|
|
import { combineAndUpper } from 'utils/formatters';
|
2017-09-25 02:06:28 +00:00
|
|
|
import './ReceivingAddress.scss';
|
2018-03-01 17:53:29 +00:00
|
|
|
import { Input } from 'components/ui';
|
2017-07-22 21:24:03 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
export interface StateProps {
|
2017-12-11 17:44:53 +00:00
|
|
|
origin: SwapInput;
|
2017-12-19 22:46:34 +00:00
|
|
|
destinationId: keyof typeof donationAddressMap;
|
2017-09-25 02:06:28 +00:00
|
|
|
isPostingOrder: boolean;
|
|
|
|
destinationAddress: string;
|
2018-01-02 18:04:50 +00:00
|
|
|
destinationKind: number;
|
|
|
|
provider: string;
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
2017-07-22 21:24:03 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
export interface ActionProps {
|
|
|
|
destinationAddressSwap: TDestinationAddressSwap;
|
|
|
|
changeStepSwap: TChangeStepSwap;
|
|
|
|
stopLoadBityRatesSwap: TStopLoadBityRatesSwap;
|
|
|
|
bityOrderCreateRequestedSwap: TBityOrderCreateRequestedSwap;
|
2018-01-02 18:04:50 +00:00
|
|
|
shapeshiftOrderCreateRequestedSwap: TShapeshiftOrderCreateRequestedSwap;
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
2017-06-24 06:09:44 +00:00
|
|
|
|
2018-01-29 19:13:46 +00:00
|
|
|
export default class ReceivingAddress extends PureComponent<StateProps & ActionProps, {}> {
|
2017-12-19 22:46:34 +00:00
|
|
|
public onChangeDestinationAddress = (event: React.FormEvent<HTMLInputElement>) => {
|
|
|
|
const value = event.currentTarget.value;
|
2017-07-02 05:45:22 +00:00
|
|
|
this.props.destinationAddressSwap(value);
|
2017-06-24 01:26:54 +00:00
|
|
|
};
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public onClickPartTwoComplete = () => {
|
2018-01-02 18:04:50 +00:00
|
|
|
const { origin, destinationId, destinationAddress, destinationKind, provider } = this.props;
|
2017-12-11 17:44:53 +00:00
|
|
|
if (!origin) {
|
2017-09-25 02:06:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-01-02 18:04:50 +00:00
|
|
|
if (provider === 'shapeshift') {
|
|
|
|
this.props.shapeshiftOrderCreateRequestedSwap(
|
|
|
|
destinationAddress,
|
2018-03-01 17:53:29 +00:00
|
|
|
origin.label,
|
2018-01-02 18:04:50 +00:00
|
|
|
destinationId,
|
|
|
|
destinationKind
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.props.bityOrderCreateRequestedSwap(
|
|
|
|
origin.amount as number,
|
|
|
|
this.props.destinationAddress,
|
2018-03-01 17:53:29 +00:00
|
|
|
combineAndUpper(origin.label, destinationId)
|
2018-01-02 18:04:50 +00:00
|
|
|
);
|
|
|
|
}
|
2017-07-02 05:45:22 +00:00
|
|
|
};
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public render() {
|
2017-12-11 17:44:53 +00:00
|
|
|
const { destinationId, destinationAddress, isPostingOrder } = this.props;
|
2017-06-24 06:09:44 +00:00
|
|
|
let validAddress;
|
|
|
|
// TODO - find better pattern here once currencies move beyond BTC, ETH, REP
|
2017-12-11 17:44:53 +00:00
|
|
|
if (destinationId === 'BTC') {
|
2017-07-02 05:49:06 +00:00
|
|
|
validAddress = isValidBTCAddress(destinationAddress);
|
2017-06-24 06:09:44 +00:00
|
|
|
} else {
|
2017-07-02 05:49:06 +00:00
|
|
|
validAddress = isValidETHAddress(destinationAddress);
|
2017-06-24 06:09:44 +00:00
|
|
|
}
|
2017-06-24 01:26:54 +00:00
|
|
|
|
|
|
|
return (
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
<section className="SwapAddress block">
|
|
|
|
<section className="row">
|
|
|
|
<div className="col-sm-8 col-sm-offset-2 col-xs-12">
|
|
|
|
<label className="SwapAddress-address">
|
|
|
|
<h4 className="SwapAddress-address-label">
|
2017-12-11 17:44:53 +00:00
|
|
|
{translate('SWAP_rec_add')} ({destinationId})
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
</h4>
|
|
|
|
|
2018-03-01 17:53:29 +00:00
|
|
|
<Input
|
|
|
|
className={`SwapAddress-address-input ${!validAddress ? 'invalid' : ''}`}
|
2017-06-24 01:26:54 +00:00
|
|
|
type="text"
|
2017-07-02 05:45:22 +00:00
|
|
|
value={destinationAddress}
|
|
|
|
onChange={this.onChangeDestinationAddress}
|
2018-01-02 18:04:50 +00:00
|
|
|
placeholder={
|
|
|
|
destinationId === 'BTC'
|
|
|
|
? donationAddressMap[destinationId]
|
|
|
|
: donationAddressMap.ETH
|
|
|
|
}
|
2017-06-24 01:26:54 +00:00
|
|
|
/>
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section className="SwapAddress-submit row">
|
|
|
|
<SimpleButton
|
|
|
|
text={translate('SWAP_start_CTA')}
|
|
|
|
onClick={this.onClickPartTwoComplete}
|
|
|
|
disabled={!validAddress}
|
|
|
|
loading={isPostingOrder}
|
|
|
|
/>
|
2017-06-24 01:26:54 +00:00
|
|
|
</section>
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
</section>
|
2017-06-24 01:26:54 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|