Skip to content

Commit

Permalink
feat(sb): address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Jul 24, 2020
1 parent cfc72a9 commit 8e4c666
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
Expand Up @@ -8,6 +8,7 @@ import {
SBAccountType,
SBBalancesType,
SBCardType,
SBOrderActionType,
SBOrderType,
SBPairType,
SBPaymentMethodsType,
Expand Down Expand Up @@ -374,7 +375,7 @@ export const initializeBillingAddress = () => ({
})

export const initializeCheckout = (
orderType: 'BUY' | 'SELL',
orderType: SBOrderActionType,
amount?: string
) => ({
type: AT.INITIALIZE_CHECKOUT,
Expand Down
Expand Up @@ -4,6 +4,7 @@ import {
FiatType,
FiatTypeEnum,
SBCardType,
SBOrderActionType,
SBOrderType,
SBPairsType,
SBQuoteType
Expand All @@ -30,7 +31,7 @@ export const splitPair = (
return pair.split('-') as [FiatType | CoinType, '-', FiatType | CoinType]
}

export const getOrderType = (pair: SBPairsType): 'BUY' | 'SELL' => {
export const getOrderType = (pair: SBPairsType): SBOrderActionType => {
return splitPair(pair)[0] in FiatTypeEnum ? 'SELL' : 'BUY'
}

Expand Down
Expand Up @@ -22,10 +22,13 @@ export const getDefaultPaymentMethod = (state: RootState) => {
orders: ExtractSuccess<typeof ordersR>,
sbMethods: ExtractSuccess<typeof sbMethodsR>
) => {
const { paymentType: type, inputCurrency } = orders[0]
const lastOrder = orders.shift()
if (!lastOrder) return undefined

return sbMethods.methods.find(
method => method.type === type && method.currency === inputCurrency
method =>
method.type === lastOrder.paymentType &&
method.currency === lastOrder.inputCurrency
)
}

Expand Down
Expand Up @@ -9,6 +9,7 @@ import {
SBAccountType,
SBBalancesType,
SBCardType,
SBOrderActionType,
SBOrderType,
SBPairType,
SBPaymentMethodsType,
Expand All @@ -34,7 +35,7 @@ export type SBAddCardErrorType =
export type SBBillingAddressFormValuesType = NabuAddressType
export type SBCheckoutFormValuesType = {
amount: string
orderType: 'BUY' | 'SELL'
orderType: SBOrderActionType
}
export type SBCurrencySelectFormType = {
search: string
Expand Down
Expand Up @@ -6,6 +6,7 @@ import {
SBBalancesType,
SBCardType,
SBMoneyType,
SBOrderActionType,
SBOrderType,
SBPairsType,
SBPairType,
Expand Down Expand Up @@ -70,7 +71,7 @@ export default ({

const createSBOrder = (
pair: SBPairsType,
action: 'BUY' | 'SELL',
action: SBOrderActionType,
pending: boolean,
input: SBMoneyType,
output: {
Expand Down Expand Up @@ -211,7 +212,7 @@ export default ({

const getSBQuote = (
currencyPair: SBPairsType,
action: 'BUY' | 'SELL',
action: SBOrderActionType,
amount: string
): SBQuoteType =>
authorizedGet({
Expand Down
Expand Up @@ -178,6 +178,7 @@ export type ISBBuyOrderType = {
state: SBOrderStateType
updatedAt: string
}
export type SBOrderActionType = 'BUY' | 'SELL'
export type SBBuyOrderType = ISBBuyOrderType & {
inputCurrency: FiatType
outputCurrency: CoinType
Expand All @@ -200,7 +201,7 @@ export type SBOrderStateType =
| 'EXPIRED'

export type SBQuoteType = {
action: 'BUY' | 'SELL'
action: SBOrderActionType
fee: string
pair: SBPairsType
rate: string
Expand Down

0 comments on commit 8e4c666

Please sign in to comment.