Use ShapeShift for all swaps (#1019)

* Use shapeshift for all swaps.

* fix snapshot
This commit is contained in:
Daniel Ternyak 2018-02-07 17:42:07 -06:00 committed by GitHub
parent 82cd123632
commit 8cb5e8bb79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 25 deletions

View File

@ -110,31 +110,11 @@ export default class CurrencySwap extends PureComponent<Props, State> {
public componentDidUpdate(prevProps: Props, prevState: State) {
const { origin, destination } = this.state;
const { options, bityRates, shapeshiftRates } = this.props;
const { options } = this.props;
if (origin !== prevState.origin) {
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) {
const originKindOptions: any[] = Object.values(options.byId);
const destinationKindOptions: any[] = Object.values(

View File

@ -113,12 +113,10 @@ class Swap extends Component<ReduxActionProps & ReduxStateProps & RouteComponent
}
public componentWillUnmount() {
this.props.stopLoadBityRatesSwap();
this.props.stopLoadShapeshiftRatesSwap();
}
public loadRates() {
this.props.loadBityRatesRequestedSwap();
this.props.loadShapeshiftRatesRequestedSwap();
}

View File

@ -45,7 +45,7 @@ export const INITIAL_STATE: State = {
byId: {},
allIds: []
},
provider: 'bity',
provider: 'shapeshift',
destinationAddress: '',
bityOrder: {},
shapeshiftOrder: {},

View File

@ -78,7 +78,7 @@ exports[`render snapshot 1`] = `
}
outputTx={null}
paymentAddress={null}
provider="bity"
provider="shapeshift"
restartSwap={[Function]}
secondsRemaining={null}
shapeshiftOrder={Object {}}