Skip to content

Commit

Permalink
reafactor: order types (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom authored Jun 26, 2024
1 parent 7e4cb8b commit d818c45
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { SafeInfo, SafeOverview } from './types/safe-info'
import type { ChainListResponse, ChainInfo } from './types/chains'
import type { SafeAppsResponse } from './types/safe-apps'
import type { MasterCopyReponse } from './types/master-copies'
import type { BaselineConfirmationView, CowConfirmationView, DecodedDataResponse } from './types/decoded-data'
import type { BaselineConfirmationView, OrderConfirmationView, DecodedDataResponse } from './types/decoded-data'
import type { SafeMessage, SafeMessageListPage } from './types/safe-messages'
import { DEFAULT_BASE_URL } from './config'
import type { DelegateResponse, DelegatesRequest } from './types/delegates'
Expand Down Expand Up @@ -304,7 +304,7 @@ export function getConfirmationView(
safeAddress: string,
encodedData: operations['data_decoder']['parameters']['body']['data'],
to?: operations['data_decoder']['parameters']['body']['to'],
): Promise<BaselineConfirmationView | CowConfirmationView> {
): Promise<BaselineConfirmationView | OrderConfirmationView> {
return postEndpoint(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation', {
path: { chainId: chainId, safe_address: safeAddress },
body: { data: encodedData, to },
Expand Down
4 changes: 2 additions & 2 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { ChainListResponse, ChainInfo } from './chains'
import type { SafeAppsResponse } from './safe-apps'
import type {
BaselineConfirmationView,
CowConfirmationView,
OrderConfirmationView,
DecodedDataRequest,
DecodedDataResponse,
} from './decoded-data'
Expand Down Expand Up @@ -794,7 +794,7 @@ export interface operations {
}
responses: {
200: {
schema: BaselineConfirmationView | CowConfirmationView
schema: BaselineConfirmationView | OrderConfirmationView
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/types/decoded-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export type BaselineConfirmationView = {
type: 'GENERIC'
} & DecodedDataResponse

export type SwapConfirmationView = {
export type SwapOrderConfirmationView = {
type: ConfirmationViewTypes.COW_SWAP_ORDER
} & DecodedDataResponse &
Omit<SwapOrder, 'type' | 'humanDescription' | 'richDecodedInfo'>

export type TwapConfirmationView = {
export type TwapOrderConfirmationView = {
type: ConfirmationViewTypes.COW_SWAP_TWAP_ORDER
} & DecodedDataResponse &
Omit<TwapOrder, 'type' | 'humanDescription' | 'richDecodedInfo'>

export type CowConfirmationView = SwapConfirmationView | TwapConfirmationView
export type OrderConfirmationView = SwapOrderConfirmationView | TwapOrderConfirmationView
14 changes: 7 additions & 7 deletions src/types/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,20 @@ export type BaseOrder = {
}

export enum DurationType {
Auto,
LimitDuration,
AUTO = 'AUTO',
LIMIT_DURATION = 'LIMIT_DURATION',
}

export enum StartTimeValue {
AtMiningTime,
AtEpoch,
AT_MINING_TIME = 'AT_MINING_TIME',
AT_EPOCH = 'AT_EPOCH',
}

type DurationOfPart =
| { durationType: DurationType.Auto }
| { durationType: DurationType.LimitDuration; duration: number }
| { durationType: DurationType.AUTO }
| { durationType: DurationType.LIMIT_DURATION; duration: number }

type StartTime = { startType: StartTimeValue.AtMiningTime } | { startType: StartTimeValue.AtEpoch; epoch: number }
type StartTime = { startType: StartTimeValue.AT_MINING_TIME } | { startType: StartTimeValue.AT_EPOCH; epoch: number }

// Specific type for SwapOrder
export type SwapOrder = BaseOrder & {
Expand Down

0 comments on commit d818c45

Please sign in to comment.