MyCrypto/common/actions/swapTypes.js
Daniel Ternyak a66337ac0a Swap Part 4 (#101)
### Re-implements:
* min/max validators on initial currency swap selection
* polling of order status
* timer that persists across refreshes via localStorage (computed based on `createdTime` and `validFor` amount)
* swap persists across refreshes once order is created.
* various type refactors

### New additions:
* *SimpleButton* (can be PRd separately on request)
* clear loading state after order create (via SimpleButton and font-awesome)
* buffers for non-BTC swaps (bity does not actually accept 0.01 BTC worth of ETH as they claim they do in their JSON response, so a magic number of 10% is added to the minimum).
2017-07-31 18:14:30 -05:00

129 lines
2.7 KiB
JavaScript

export type Pairs = {
ETHBTC: number,
ETHREP: number,
BTCETH: number,
BTCREP: number
};
export type OriginKindSwapAction = {
type: 'SWAP_ORIGIN_KIND',
value: string
};
export type DestinationKindSwapAction = {
type: 'SWAP_DESTINATION_KIND',
value: string
};
export type OriginAmountSwapAction = {
type: 'SWAP_ORIGIN_AMOUNT',
value: ?number
};
export type DestinationAmountSwapAction = {
type: 'SWAP_DESTINATION_AMOUNT',
value: ?number
};
export type LoadBityRatesSucceededSwapAction = {
type: 'SWAP_LOAD_BITY_RATES_SUCCEEDED',
value: Pairs
};
export type DestinationAddressSwapAction = {
type: 'SWAP_DESTINATION_ADDRESS',
value: ?number
};
export type RestartSwapAction = {
type: 'SWAP_RESTART'
};
export type LoadBityRatesRequestedSwapAction = {
type: 'SWAP_LOAD_BITY_RATES_REQUESTED'
};
export type ChangeStepSwapAction = {
type: 'SWAP_STEP',
value: number
};
export type StopLoadBityRatesSwapAction = {
type: 'SWAP_STOP_LOAD_BITY_RATES'
};
export type BityOrderCreateRequestedSwapAction = {
type: 'SWAP_ORDER_CREATE_REQUESTED',
payload: {
amount: number,
destinationAddress: string,
pair: string,
mode: number
}
};
type BityOrderInput = {
amount: string
};
type BityOrderOutput = {
amount: string
};
export type BityOrderResponse = {
status: string
};
export type BityOrderPostResponse = BityOrderResponse & {
payment_address: string,
status: string,
input: BityOrderInput,
output: BityOrderOutput,
timestamp_created: string,
validFor: number
};
export type BityOrderCreateSucceededSwapAction = {
type: 'SWAP_BITY_ORDER_CREATE_SUCCEEDED',
payload: BityOrderPostResponse
};
export type OrderStatusRequestedSwapAction = {
type: 'SWAP_BITY_ORDER_STATUS_REQUESTED',
payload: BityOrderResponse
};
export type OrderStatusSucceededSwapAction = {
type: 'SWAP_BITY_ORDER_STATUS_SUCCEEDED',
payload: BityOrderResponse
};
export type StartOrderTimerSwapAction = {
type: 'SWAP_ORDER_START_TIMER'
};
export type StopOrderTimerSwapAction = {
type: 'SWAP_ORDER_STOP_TIMER'
};
export type StartPollBityOrderStatusAction = {
type: 'SWAP_START_POLL_BITY_ORDER_STATUS'
};
export type StopPollBityOrderStatusAction = {
type: 'SWAP_STOP_POLL_BITY_ORDER_STATUS'
};
/*** Action Type Union ***/
export type SwapAction =
| ChangeStepSwapAction
| OriginKindSwapAction
| DestinationKindSwapAction
| OriginAmountSwapAction
| DestinationAmountSwapAction
| LoadBityRatesSucceededSwapAction
| DestinationAddressSwapAction
| RestartSwapAction
| LoadBityRatesRequestedSwapAction
| StopLoadBityRatesSwapAction
| BityOrderCreateRequestedSwapAction
| BityOrderCreateSucceededSwapAction
| BityOrderResponse
| OrderStatusSucceededSwapAction
| StartPollBityOrderStatusAction;