mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-03 06:44:39 +00:00
ab5fa1a799
* Make UnlockHeader a PureComponent * MVP * actually disable wallet format if not determined to be valid format for wallet * default to correct derivation in mnemonic modal * cleanup * fix tslint * use enums for HD wallet getPath * Add stricter typing * Fix labels not updating on selector * Ban hardware wallet support for custom network unsupported chainIds * Fix type error * Fix custom node dPath not being saved * Fix mnemonic modal * default path bugfixes * add react-select * misc fixes; rabbit holing hard. * fix tslint * revert identicon changes * reload on network change :/ * actually reload on network change * really really reload on network change * tslint fixes * Update styles * set table width * fix package versioning * push broken sagas * Fix saga test * fix tslint * address round of review * move non-selectors out to utilty; adjust reload timer * cleanup network util comments * manage wallet disable at WalletDecrypt instead of in both WalletDecrypt and WalletButton * Separate WalletDecrypt props into ownProps / StateProps * disable payment requests on non-eth networks * specialize connect; separate props * remove unused state prop * remove bad import * create tests for networks * Clarify Lite-Send error on non-ethereum networkS * remove string option for network config name * Create concept of always-on 'EXTRA_PATHS'; include SINGULAR_DTV legacy dPath in 'EXTRA_PATHS' * fix multiple imports * address PR comments
115 lines
3.5 KiB
TypeScript
115 lines
3.5 KiB
TypeScript
import {
|
|
TBityOrderCreateRequestedSwap,
|
|
TChangeStepSwap,
|
|
TDestinationAddressSwap,
|
|
TShapeshiftOrderCreateRequestedSwap,
|
|
TStopLoadBityRatesSwap
|
|
} from 'actions/swap';
|
|
import { SwapInput } from 'reducers/swap/types';
|
|
import classnames from 'classnames';
|
|
import SimpleButton from 'components/ui/SimpleButton';
|
|
import { donationAddressMap } from 'config';
|
|
import { isValidBTCAddress, isValidETHAddress } from 'libs/validators';
|
|
import React, { Component } from 'react';
|
|
import translate from 'translations';
|
|
import { combineAndUpper } from 'utils/formatters';
|
|
import './ReceivingAddress.scss';
|
|
|
|
export interface StateProps {
|
|
origin: SwapInput;
|
|
destinationId: keyof typeof donationAddressMap;
|
|
isPostingOrder: boolean;
|
|
destinationAddress: string;
|
|
destinationKind: number;
|
|
provider: string;
|
|
}
|
|
|
|
export interface ActionProps {
|
|
destinationAddressSwap: TDestinationAddressSwap;
|
|
changeStepSwap: TChangeStepSwap;
|
|
stopLoadBityRatesSwap: TStopLoadBityRatesSwap;
|
|
bityOrderCreateRequestedSwap: TBityOrderCreateRequestedSwap;
|
|
shapeshiftOrderCreateRequestedSwap: TShapeshiftOrderCreateRequestedSwap;
|
|
}
|
|
|
|
export default class ReceivingAddress extends Component<StateProps & ActionProps, {}> {
|
|
public onChangeDestinationAddress = (event: React.FormEvent<HTMLInputElement>) => {
|
|
const value = event.currentTarget.value;
|
|
this.props.destinationAddressSwap(value);
|
|
};
|
|
|
|
public onClickPartTwoComplete = () => {
|
|
const { origin, destinationId, destinationAddress, destinationKind, provider } = this.props;
|
|
if (!origin) {
|
|
return;
|
|
}
|
|
if (provider === 'shapeshift') {
|
|
this.props.shapeshiftOrderCreateRequestedSwap(
|
|
destinationAddress,
|
|
origin.id,
|
|
destinationId,
|
|
destinationKind
|
|
);
|
|
} else {
|
|
this.props.bityOrderCreateRequestedSwap(
|
|
origin.amount as number,
|
|
this.props.destinationAddress,
|
|
combineAndUpper(origin.id, destinationId)
|
|
);
|
|
}
|
|
};
|
|
|
|
public render() {
|
|
const { destinationId, destinationAddress, isPostingOrder } = this.props;
|
|
let validAddress;
|
|
// TODO - find better pattern here once currencies move beyond BTC, ETH, REP
|
|
if (destinationId === 'BTC') {
|
|
validAddress = isValidBTCAddress(destinationAddress);
|
|
} else {
|
|
validAddress = isValidETHAddress(destinationAddress);
|
|
}
|
|
|
|
const inputClasses = classnames({
|
|
'SwapAddress-address-input': true,
|
|
'form-control': true,
|
|
'is-valid': validAddress,
|
|
'is-invalid': !validAddress
|
|
});
|
|
|
|
return (
|
|
<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">
|
|
{translate('SWAP_rec_add')} ({destinationId})
|
|
</h4>
|
|
|
|
<input
|
|
className={inputClasses}
|
|
type="text"
|
|
value={destinationAddress}
|
|
onChange={this.onChangeDestinationAddress}
|
|
placeholder={
|
|
destinationId === 'BTC'
|
|
? donationAddressMap[destinationId]
|
|
: donationAddressMap.ETH
|
|
}
|
|
/>
|
|
</label>
|
|
</div>
|
|
</section>
|
|
|
|
<section className="SwapAddress-submit row">
|
|
<SimpleButton
|
|
text={translate('SWAP_start_CTA')}
|
|
onClick={this.onClickPartTwoComplete}
|
|
disabled={!validAddress}
|
|
loading={isPostingOrder}
|
|
/>
|
|
</section>
|
|
</section>
|
|
);
|
|
}
|
|
}
|