MyCrypto/common/actions/swap.js

170 lines
3.4 KiB
JavaScript
Raw Normal View History

// @flow
import type {
OriginKindSwapAction,
DestinationKindSwapAction,
OriginAmountSwapAction,
DestinationAmountSwapAction,
LoadBityRatesSucceededSwapAction,
DestinationAddressSwapAction,
BityOrderCreateSucceededSwapAction,
BityOrderCreateRequestedSwapAction,
OrderStatusSucceededSwapAction,
ChangeStepSwapAction,
Pairs,
RestartSwapAction,
LoadBityRatesRequestedSwapAction,
StopLoadBityRatesSwapAction,
BityOrderResponse,
BityOrderPostResponse,
OrderStatusRequestedSwapAction,
StopOrderTimerSwapAction,
StartOrderTimerSwapAction,
StartPollBityOrderStatusAction,
StopPollBityOrderStatusAction
} from './swapTypes';
export function changeStepSwap(value: number): ChangeStepSwapAction {
2017-06-19 05:39:07 +00:00
return {
type: 'SWAP_STEP',
value
2017-06-19 05:39:07 +00:00
};
}
2017-06-12 01:00:28 +00:00
export function originKindSwap(value: string): OriginKindSwapAction {
2017-06-19 05:39:07 +00:00
return {
type: 'SWAP_ORIGIN_KIND',
2017-06-19 05:39:07 +00:00
value
};
}
2017-06-12 01:00:28 +00:00
export function destinationKindSwap(value: string): DestinationKindSwapAction {
2017-06-19 05:39:07 +00:00
return {
type: 'SWAP_DESTINATION_KIND',
2017-06-19 05:39:07 +00:00
value
};
}
2017-06-12 01:00:28 +00:00
export function originAmountSwap(value: ?number): OriginAmountSwapAction {
2017-06-19 05:39:07 +00:00
return {
type: 'SWAP_ORIGIN_AMOUNT',
2017-06-19 05:39:07 +00:00
value
};
}
export function destinationAmountSwap(
value: ?number
): DestinationAmountSwapAction {
return {
type: 'SWAP_DESTINATION_AMOUNT',
value
};
}
export function loadBityRatesSucceededSwap(
value: Pairs
): LoadBityRatesSucceededSwapAction {
return {
type: 'SWAP_LOAD_BITY_RATES_SUCCEEDED',
value
};
}
export function destinationAddressSwap(
value: ?string
): DestinationAddressSwapAction {
2017-07-02 05:45:22 +00:00
return {
type: 'SWAP_DESTINATION_ADDRESS',
2017-07-02 05:45:22 +00:00
value
};
}
export function restartSwap(): RestartSwapAction {
2017-07-02 05:45:22 +00:00
return {
type: 'SWAP_RESTART'
2017-07-02 05:45:22 +00:00
};
}
export function loadBityRatesRequestedSwap(): LoadBityRatesRequestedSwapAction {
return {
type: 'SWAP_LOAD_BITY_RATES_REQUESTED'
};
}
export function stopLoadBityRatesSwap(): StopLoadBityRatesSwapAction {
return {
type: 'SWAP_STOP_LOAD_BITY_RATES'
};
}
export function orderTimeSwap(value: number) {
return {
type: 'SWAP_ORDER_TIME',
value
};
}
export function bityOrderCreateSucceededSwap(
payload: BityOrderPostResponse
): BityOrderCreateSucceededSwapAction {
return {
type: 'SWAP_BITY_ORDER_CREATE_SUCCEEDED',
payload
};
}
export function bityOrderCreateRequestedSwap(
amount: number,
destinationAddress: string,
pair: string,
mode: number = 0
): BityOrderCreateRequestedSwapAction {
return {
type: 'SWAP_ORDER_CREATE_REQUESTED',
payload: {
amount,
destinationAddress,
pair,
mode
}
};
}
export function orderStatusSucceededSwap(
payload: BityOrderResponse
): OrderStatusSucceededSwapAction {
return {
type: 'SWAP_BITY_ORDER_STATUS_SUCCEEDED',
payload
};
}
export function orderStatusRequestedSwap(): OrderStatusRequestedSwapAction {
return {
type: 'SWAP_BITY_ORDER_STATUS_REQUESTED'
};
}
export function startOrderTimerSwap(): StartOrderTimerSwapAction {
return {
type: 'SWAP_ORDER_START_TIMER'
};
}
export function stopOrderTimerSwap(): StopOrderTimerSwapAction {
return {
type: 'SWAP_ORDER_STOP_TIMER'
};
}
export function startPollBityOrderStatus(): StartPollBityOrderStatusAction {
return {
type: 'SWAP_START_POLL_BITY_ORDER_STATUS'
};
}
export function stopPollBityOrderStatus(): StopPollBityOrderStatusAction {
return {
type: 'SWAP_STOP_POLL_BITY_ORDER_STATUS'
};
}