mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-20 14:58:24 +00:00
Use ShapeShift for all swaps (#1019)
* Use shapeshift for all swaps. * fix snapshot
This commit is contained in:
parent
82cd123632
commit
8cb5e8bb79
@ -110,31 +110,11 @@ export default class CurrencySwap extends PureComponent<Props, State> {
|
|||||||
|
|
||||||
public componentDidUpdate(prevProps: Props, prevState: State) {
|
public componentDidUpdate(prevProps: Props, prevState: State) {
|
||||||
const { origin, destination } = this.state;
|
const { origin, destination } = this.state;
|
||||||
const { options, bityRates, shapeshiftRates } = this.props;
|
const { options } = this.props;
|
||||||
if (origin !== prevState.origin) {
|
if (origin !== prevState.origin) {
|
||||||
this.setDisabled(origin, destination);
|
this.setDisabled(origin, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
const originCap = origin.id.toUpperCase();
|
|
||||||
const destCap = destination.id.toUpperCase();
|
|
||||||
const { provider } = this.props;
|
|
||||||
|
|
||||||
const ensureCorrectProvider =
|
|
||||||
(originCap === 'BTC' && destCap === 'ETH') || (destCap === 'BTC' && originCap === 'ETH');
|
|
||||||
const ensureBityRatesLoaded =
|
|
||||||
bityRates.allIds.includes('ETHBTC') && bityRates.allIds.includes('BTCETH');
|
|
||||||
const ensureShapeshiftRatesLoaded = shapeshiftRates.allIds.length > 0;
|
|
||||||
|
|
||||||
if (ensureBityRatesLoaded && ensureCorrectProvider) {
|
|
||||||
if (provider === 'shapeshift') {
|
|
||||||
this.props.swapProvider('bity');
|
|
||||||
}
|
|
||||||
} else if (ensureShapeshiftRatesLoaded) {
|
|
||||||
if (provider !== 'shapeshift') {
|
|
||||||
this.props.swapProvider('shapeshift');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.allIds !== prevProps.options.allIds && options.byId) {
|
if (options.allIds !== prevProps.options.allIds && options.byId) {
|
||||||
const originKindOptions: any[] = Object.values(options.byId);
|
const originKindOptions: any[] = Object.values(options.byId);
|
||||||
const destinationKindOptions: any[] = Object.values(
|
const destinationKindOptions: any[] = Object.values(
|
||||||
|
@ -113,12 +113,10 @@ class Swap extends Component<ReduxActionProps & ReduxStateProps & RouteComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
this.props.stopLoadBityRatesSwap();
|
|
||||||
this.props.stopLoadShapeshiftRatesSwap();
|
this.props.stopLoadShapeshiftRatesSwap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadRates() {
|
public loadRates() {
|
||||||
this.props.loadBityRatesRequestedSwap();
|
|
||||||
this.props.loadShapeshiftRatesRequestedSwap();
|
this.props.loadShapeshiftRatesRequestedSwap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ export const INITIAL_STATE: State = {
|
|||||||
byId: {},
|
byId: {},
|
||||||
allIds: []
|
allIds: []
|
||||||
},
|
},
|
||||||
provider: 'bity',
|
provider: 'shapeshift',
|
||||||
destinationAddress: '',
|
destinationAddress: '',
|
||||||
bityOrder: {},
|
bityOrder: {},
|
||||||
shapeshiftOrder: {},
|
shapeshiftOrder: {},
|
||||||
|
@ -78,7 +78,7 @@ exports[`render snapshot 1`] = `
|
|||||||
}
|
}
|
||||||
outputTx={null}
|
outputTx={null}
|
||||||
paymentAddress={null}
|
paymentAddress={null}
|
||||||
provider="bity"
|
provider="shapeshift"
|
||||||
restartSwap={[Function]}
|
restartSwap={[Function]}
|
||||||
secondsRemaining={null}
|
secondsRemaining={null}
|
||||||
shapeshiftOrder={Object {}}
|
shapeshiftOrder={Object {}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user