Skip to content

Commit 47ebac5

Browse files
authored
Feat: add swap type (#160)
* fix: make-cgw-types.sh script users wrong url * feat: add SwapOrder type
1 parent f952755 commit 47ebac5

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

scripts/make-cgw-types.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

33
mkdir -p openapi
4-
curl 'https://safe-client.safe.global/openapi.json' > openapi/cgw.json
4+
curl 'https://safe-client.safe.global/api-json' > openapi/cgw.json
55
npx openapi-typescript openapi/cgw.json --output openapi/cgw.ts

src/types/transactions.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export enum TransactionInfoType {
6868
SETTINGS_CHANGE = 'SettingsChange',
6969
CUSTOM = 'Custom',
7070
CREATION = 'Creation',
71+
SWAP_ORDER = 'SwapOrder',
7172
}
7273

7374
export enum ConflictType {
@@ -235,7 +236,37 @@ export type Creation = {
235236
richDecodedInfo?: RichDecodedInfo
236237
}
237238

238-
export type TransactionInfo = Transfer | SettingsChange | Custom | MultiSend | Cancellation | Creation
239+
export type OrderStatuses = 'presignaturePending' | 'open' | 'fulfilled' | 'cancelled' | 'expired'
240+
export type OrderKind = 'sell' | 'buy'
241+
export type OrderToken = {
242+
logo?: string | null
243+
symbol: string
244+
amount: string
245+
}
246+
export type SwapOrder = {
247+
type: TransactionInfoType.SWAP_ORDER
248+
humanDescription?: string | null
249+
richDecodedInfo?: null | RichDecodedInfo
250+
orderUid: string
251+
status: OrderStatuses
252+
orderKind: OrderKind
253+
sellToken: OrderToken
254+
buyToken: OrderToken
255+
expiresTimestamp: number
256+
filledPercentage: string
257+
explorerUrl: string
258+
surplusLabel?: string
259+
executionPriceLabel?: string
260+
limitPriceLabel?: string
261+
}
262+
263+
export type FulfilledSwapOrder = SwapOrder & {
264+
status: 'fulfilled'
265+
surplusLabel: string
266+
executionPriceLabel: string
267+
}
268+
269+
export type TransactionInfo = Transfer | SettingsChange | Custom | MultiSend | Cancellation | Creation | SwapOrder
239270

240271
export type ModuleExecutionInfo = {
241272
type: DetailedExecutionInfoType.MODULE

0 commit comments

Comments
 (0)