2017-09-24 19:06:28 -07:00
|
|
|
import { TypeKeys } from './constants';
|
2017-12-11 09:44:53 -08:00
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface Pairs {
|
|
|
|
ETHBTC: number;
|
|
|
|
ETHREP: number;
|
|
|
|
BTCETH: number;
|
|
|
|
BTCREP: number;
|
|
|
|
}
|
|
|
|
|
2017-12-11 09:44:53 -08:00
|
|
|
export interface SwapInput {
|
2018-03-01 09:53:29 -08:00
|
|
|
label: string;
|
2018-01-02 10:04:50 -08:00
|
|
|
amount: number | string;
|
2017-12-11 09:44:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface SwapInputs {
|
|
|
|
origin: SwapInput;
|
|
|
|
destination: SwapInput;
|
2017-09-24 19:06:28 -07:00
|
|
|
}
|
|
|
|
|
2017-12-11 09:44:53 -08:00
|
|
|
export interface InitSwap {
|
|
|
|
type: TypeKeys.SWAP_INIT;
|
|
|
|
payload: SwapInputs;
|
2017-09-24 19:06:28 -07:00
|
|
|
}
|
|
|
|
|
2017-12-11 09:44:53 -08:00
|
|
|
export interface Option {
|
|
|
|
id: string;
|
2018-01-02 10:04:50 -08:00
|
|
|
status?: string;
|
|
|
|
image?: string;
|
2017-12-11 09:44:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ApiResponseObj {
|
|
|
|
id: string;
|
|
|
|
options: Option[];
|
|
|
|
rate: number;
|
2017-09-24 19:06:28 -07:00
|
|
|
}
|
|
|
|
|
2017-12-11 09:44:53 -08:00
|
|
|
export interface ApiResponse {
|
|
|
|
[name: string]: ApiResponseObj;
|
2017-09-24 19:06:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface LoadBityRatesSucceededSwapAction {
|
|
|
|
type: TypeKeys.SWAP_LOAD_BITY_RATES_SUCCEEDED;
|
2017-12-11 09:44:53 -08:00
|
|
|
payload: ApiResponse;
|
2017-09-24 19:06:28 -07:00
|
|
|
}
|
|
|
|
|
2018-02-24 17:29:34 -08:00
|
|
|
export interface LoadShapeshiftRatesSucceededSwapAction {
|
2018-01-02 10:04:50 -08:00
|
|
|
type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_SUCCEEDED;
|
|
|
|
payload: ApiResponse;
|
|
|
|
}
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface DestinationAddressSwapAction {
|
|
|
|
type: TypeKeys.SWAP_DESTINATION_ADDRESS;
|
|
|
|
payload?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RestartSwapAction {
|
|
|
|
type: TypeKeys.SWAP_RESTART;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface LoadBityRatesRequestedSwapAction {
|
|
|
|
type: TypeKeys.SWAP_LOAD_BITY_RATES_REQUESTED;
|
|
|
|
}
|
|
|
|
|
2018-02-24 17:29:34 -08:00
|
|
|
export interface LoadShapeshiftRatesRequestedSwapAction {
|
2018-01-02 10:04:50 -08:00
|
|
|
type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_REQUESTED;
|
2018-02-24 17:29:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface LoadBityRatesFailedSwapAction {
|
|
|
|
type: TypeKeys.SWAP_LOAD_BITY_RATES_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface LoadShapeshiftRatesFailedSwapAction {
|
|
|
|
type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_FAILED;
|
2018-01-02 10:04:50 -08:00
|
|
|
}
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface ChangeStepSwapAction {
|
|
|
|
type: TypeKeys.SWAP_STEP;
|
|
|
|
payload: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface StopLoadBityRatesSwapAction {
|
|
|
|
type: TypeKeys.SWAP_STOP_LOAD_BITY_RATES;
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export interface StopLoadShapeshiftRatesSwapAction {
|
|
|
|
type: TypeKeys.SWAP_STOP_LOAD_SHAPESHIFT_RATES;
|
|
|
|
}
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface OrderSwapTimeSwapAction {
|
|
|
|
type: TypeKeys.SWAP_ORDER_TIME;
|
|
|
|
payload: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface BityOrderCreateRequestedSwapAction {
|
2018-01-02 10:04:50 -08:00
|
|
|
type: TypeKeys.SWAP_BITY_ORDER_CREATE_REQUESTED;
|
2017-09-24 19:06:28 -07:00
|
|
|
payload: {
|
|
|
|
amount: number;
|
|
|
|
destinationAddress: string;
|
|
|
|
pair: string;
|
|
|
|
mode: number;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export interface ShapeshiftOrderCreateRequestedSwapAction {
|
|
|
|
type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_REQUESTED;
|
|
|
|
payload: {
|
|
|
|
withdrawal: string;
|
|
|
|
originKind: string;
|
|
|
|
destinationKind: string;
|
|
|
|
destinationAmount: number;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-11-29 20:07:16 -08:00
|
|
|
export interface BityOrderInput {
|
2017-09-24 19:06:28 -07:00
|
|
|
amount: string;
|
|
|
|
currency: string;
|
|
|
|
reference: string;
|
|
|
|
status: string;
|
|
|
|
}
|
|
|
|
|
2017-11-29 20:07:16 -08:00
|
|
|
export interface BityOrderOutput {
|
2017-09-24 19:06:28 -07:00
|
|
|
amount: string;
|
|
|
|
currency: string;
|
|
|
|
reference: string;
|
|
|
|
status: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface BityOrderResponse {
|
|
|
|
input: BityOrderInput;
|
|
|
|
output: BityOrderOutput;
|
|
|
|
status: string;
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export interface ShapeshiftOrderResponse {
|
|
|
|
apiPubKey?: string;
|
|
|
|
deposit: string;
|
|
|
|
depositAmount: string;
|
|
|
|
expiration: number;
|
|
|
|
expirationFormatted?: string;
|
|
|
|
inputCurrency?: string;
|
|
|
|
maxLimit: number;
|
|
|
|
minerFee: string;
|
|
|
|
orderId: string;
|
|
|
|
outputCurrency?: string;
|
|
|
|
pair: string; // e.g. eth_bat
|
|
|
|
provider?: ProviderName; // shapeshift
|
|
|
|
quotedRate: string;
|
|
|
|
withdrawal: string;
|
|
|
|
withdrawalAmount: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ShapeshiftStatusResponse {
|
|
|
|
status: string;
|
|
|
|
address?: string;
|
|
|
|
withdraw?: string;
|
|
|
|
transaction: string;
|
|
|
|
}
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export type BityOrderPostResponse = BityOrderResponse & {
|
|
|
|
payment_address: string;
|
|
|
|
status: string;
|
|
|
|
input: BityOrderInput;
|
|
|
|
output: BityOrderOutput;
|
|
|
|
timestamp_created: string;
|
|
|
|
validFor: number;
|
|
|
|
id: string;
|
|
|
|
};
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export type ProviderName = 'shapeshift' | 'bity';
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface BityOrderCreateSucceededSwapAction {
|
|
|
|
type: TypeKeys.SWAP_BITY_ORDER_CREATE_SUCCEEDED;
|
|
|
|
payload: BityOrderPostResponse;
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export interface ShapeshiftOrderCreateSucceededSwapAction {
|
|
|
|
type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_SUCCEEDED;
|
|
|
|
payload: ShapeshiftOrderResponse;
|
|
|
|
}
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface BityOrderCreateFailedSwapAction {
|
2018-01-02 10:04:50 -08:00
|
|
|
type: TypeKeys.SWAP_BITY_ORDER_CREATE_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ShapeshiftOrderCreateFailedSwapAction {
|
|
|
|
type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_FAILED;
|
2017-09-24 19:06:28 -07:00
|
|
|
}
|
2018-01-02 10:04:50 -08:00
|
|
|
|
|
|
|
export interface BityOrderStatusRequestedSwapAction {
|
2017-09-24 19:06:28 -07:00
|
|
|
type: TypeKeys.SWAP_BITY_ORDER_STATUS_REQUESTED;
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export interface ShapeshiftOrderStatusRequestedSwapAction {
|
|
|
|
type: TypeKeys.SWAP_SHAPESHIFT_ORDER_STATUS_REQUESTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface BityOrderStatusSucceededSwapAction {
|
2017-09-24 19:06:28 -07:00
|
|
|
type: TypeKeys.SWAP_BITY_ORDER_STATUS_SUCCEEDED;
|
|
|
|
payload: BityOrderResponse;
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export interface ShapeshiftOrderStatusSucceededSwapAction {
|
|
|
|
type: TypeKeys.SWAP_SHAPESHIFT_ORDER_STATUS_SUCCEEDED;
|
|
|
|
payload: ShapeshiftStatusResponse;
|
|
|
|
}
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface StartOrderTimerSwapAction {
|
|
|
|
type: TypeKeys.SWAP_ORDER_START_TIMER;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface StopOrderTimerSwapAction {
|
|
|
|
type: TypeKeys.SWAP_ORDER_STOP_TIMER;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface StartPollBityOrderStatusAction {
|
|
|
|
type: TypeKeys.SWAP_START_POLL_BITY_ORDER_STATUS;
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export interface StartPollShapeshiftOrderStatusAction {
|
|
|
|
type: TypeKeys.SWAP_START_POLL_SHAPESHIFT_ORDER_STATUS;
|
|
|
|
}
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface StopPollBityOrderStatusAction {
|
|
|
|
type: TypeKeys.SWAP_STOP_POLL_BITY_ORDER_STATUS;
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:04:50 -08:00
|
|
|
export interface StopPollShapeshiftOrderStatusAction {
|
|
|
|
type: TypeKeys.SWAP_STOP_POLL_SHAPESHIFT_ORDER_STATUS;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ChangeProviderSwapAcion {
|
|
|
|
type: TypeKeys.SWAP_CHANGE_PROVIDER;
|
|
|
|
payload: ProviderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ConfigureLiteSendAction {
|
|
|
|
type: TypeKeys.SWAP_CONFIGURE_LITE_SEND;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ShowLiteSendAction {
|
|
|
|
type: TypeKeys.SWAP_SHOW_LITE_SEND;
|
|
|
|
payload: boolean;
|
|
|
|
}
|
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
/*** Action Type Union ***/
|
|
|
|
export type SwapAction =
|
|
|
|
| ChangeStepSwapAction
|
2017-12-11 09:44:53 -08:00
|
|
|
| InitSwap
|
2017-09-24 19:06:28 -07:00
|
|
|
| DestinationAddressSwapAction
|
|
|
|
| RestartSwapAction
|
|
|
|
| LoadBityRatesRequestedSwapAction
|
2018-02-24 17:29:34 -08:00
|
|
|
| LoadBityRatesSucceededSwapAction
|
|
|
|
| LoadBityRatesFailedSwapAction
|
|
|
|
| LoadShapeshiftRatesRequestedSwapAction
|
|
|
|
| LoadShapeshiftRatesSucceededSwapAction
|
|
|
|
| LoadShapeshiftRatesFailedSwapAction
|
2017-09-24 19:06:28 -07:00
|
|
|
| StopLoadBityRatesSwapAction
|
2018-01-02 10:04:50 -08:00
|
|
|
| StopLoadShapeshiftRatesSwapAction
|
2017-09-24 19:06:28 -07:00
|
|
|
| BityOrderCreateRequestedSwapAction
|
2018-01-02 10:04:50 -08:00
|
|
|
| ShapeshiftOrderCreateRequestedSwapAction
|
2017-09-24 19:06:28 -07:00
|
|
|
| BityOrderCreateSucceededSwapAction
|
2018-01-02 10:04:50 -08:00
|
|
|
| ShapeshiftOrderCreateSucceededSwapAction
|
|
|
|
| BityOrderStatusSucceededSwapAction
|
|
|
|
| ShapeshiftOrderStatusSucceededSwapAction
|
2017-09-24 19:06:28 -07:00
|
|
|
| StartPollBityOrderStatusAction
|
2018-01-02 10:04:50 -08:00
|
|
|
| StartPollShapeshiftOrderStatusAction
|
2017-09-24 19:06:28 -07:00
|
|
|
| BityOrderCreateFailedSwapAction
|
2018-01-02 10:04:50 -08:00
|
|
|
| ShapeshiftOrderCreateFailedSwapAction
|
|
|
|
| OrderSwapTimeSwapAction
|
|
|
|
| ChangeProviderSwapAcion
|
|
|
|
| ConfigureLiteSendAction
|
|
|
|
| ShowLiteSendAction;
|