Skip to content

Commit

Permalink
Feat: add swap type (#160)
Browse files Browse the repository at this point in the history
* fix: make-cgw-types.sh script users wrong url

* feat: add SwapOrder type
  • Loading branch information
compojoom authored Apr 9, 2024
1 parent f952755 commit 47ebac5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/make-cgw-types.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

mkdir -p openapi
curl 'https://safe-client.safe.global/openapi.json' > openapi/cgw.json
curl 'https://safe-client.safe.global/api-json' > openapi/cgw.json
npx openapi-typescript openapi/cgw.json --output openapi/cgw.ts
33 changes: 32 additions & 1 deletion src/types/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export enum TransactionInfoType {
SETTINGS_CHANGE = 'SettingsChange',
CUSTOM = 'Custom',
CREATION = 'Creation',
SWAP_ORDER = 'SwapOrder',
}

export enum ConflictType {
Expand Down Expand Up @@ -235,7 +236,37 @@ export type Creation = {
richDecodedInfo?: RichDecodedInfo
}

export type TransactionInfo = Transfer | SettingsChange | Custom | MultiSend | Cancellation | Creation
export type OrderStatuses = 'presignaturePending' | 'open' | 'fulfilled' | 'cancelled' | 'expired'
export type OrderKind = 'sell' | 'buy'
export type OrderToken = {
logo?: string | null
symbol: string
amount: string
}
export type SwapOrder = {
type: TransactionInfoType.SWAP_ORDER
humanDescription?: string | null
richDecodedInfo?: null | RichDecodedInfo
orderUid: string
status: OrderStatuses
orderKind: OrderKind
sellToken: OrderToken
buyToken: OrderToken
expiresTimestamp: number
filledPercentage: string
explorerUrl: string
surplusLabel?: string
executionPriceLabel?: string
limitPriceLabel?: string
}

export type FulfilledSwapOrder = SwapOrder & {
status: 'fulfilled'
surplusLabel: string
executionPriceLabel: string
}

export type TransactionInfo = Transfer | SettingsChange | Custom | MultiSend | Cancellation | Creation | SwapOrder

export type ModuleExecutionInfo = {
type: DetailedExecutionInfoType.MODULE
Expand Down

0 comments on commit 47ebac5

Please sign in to comment.