Skip to content

Commit e77877f

Browse files
committed
Feat: safe overviews endpoint
1 parent 47ebac5 commit e77877f

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

src/index.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import type {
1010
NoncesResponse,
1111
} from './types/transactions'
1212
import type {
13+
EthereumAddress,
1314
AllOwnedSafes,
1415
FiatCurrencies,
1516
OwnedSafes,
1617
SafeBalanceResponse,
1718
SafeCollectibleResponse,
1819
SafeCollectiblesPage,
1920
} from './types/common'
20-
import type { SafeInfo } from './types/safe-info'
21+
import type { SafeInfo, SafeOverview } from './types/safe-info'
2122
import type { ChainListResponse, ChainInfo } from './types/chains'
2223
import type { SafeAppsResponse } from './types/safe-apps'
2324
import type { MasterCopyReponse } from './types/master-copies'
@@ -599,4 +600,19 @@ export function unsubscribeAll(query: operations['unsubscribe_all']['parameters'
599600
return deleteEndpoint(baseUrl, '/v1/subscriptions/all', { query })
600601
}
601602

603+
/**
604+
* Get Safe overviews per address
605+
*/
606+
export function getSafeOverviews(
607+
safes: `${number}:${EthereumAddress}`[],
608+
query: Omit<operations['SafesController_getSafeOverview']['parameters']['query'], 'safes'>,
609+
): Promise<SafeOverview[]> {
610+
return getEndpoint(baseUrl, '/v1/safes', {
611+
query: {
612+
...query,
613+
safes: safes.join(','),
614+
},
615+
})
616+
}
617+
602618
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */

src/types/api.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type {
1717
SafeMultisigTransactionsResponse,
1818
NoncesResponse,
1919
} from './transactions'
20-
import type { SafeInfo } from './safe-info'
20+
import type { SafeInfo, SafeOverview } from './safe-info'
2121
import type { ChainListResponse, ChainInfo } from './chains'
2222
import type { SafeAppsResponse } from './safe-apps'
2323
import type { DecodedDataRequest, DecodedDataResponse } from './decoded-data'
@@ -413,19 +413,18 @@ export interface paths extends PathRegistry {
413413
delete: operations['unsubscribe_single']
414414
parameters: {
415415
path: null
416-
query: {
417-
category: string
418-
token: string
419-
}
420416
}
421417
}
422418
'/v1/subscriptions/all': {
423419
delete: operations['unsubscribe_all']
424420
parameters: {
425421
path: null
426-
query: {
427-
token: string
428-
}
422+
}
423+
}
424+
'/v1/safes': {
425+
get: operations['SafesController_getSafeOverview']
426+
parameters: {
427+
path: null
429428
}
430429
}
431430
}
@@ -1111,4 +1110,20 @@ export interface operations {
11111110
}
11121111
}
11131112
}
1113+
SafesController_getSafeOverview: {
1114+
parameters: {
1115+
query: {
1116+
currency: string
1117+
safes: string
1118+
trusted: boolean
1119+
exclude_spam: boolean
1120+
walletAddress: string
1121+
}
1122+
}
1123+
responses: {
1124+
200: {
1125+
schema: SafeOverview[]
1126+
}
1127+
}
1128+
}
11141129
}

src/types/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ export type SafeCollectibleResponse = {
5858
}
5959

6060
export type SafeCollectiblesPage = Page<SafeCollectibleResponse>
61+
62+
export type EthereumAddress = `0x${string}`

src/types/safe-info.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@ export type SafeInfo = {
2323
txHistoryTag: string | null
2424
messagesTag: string | null
2525
}
26+
27+
export type SafeOverview = {
28+
address: AddressEx
29+
chainId: string
30+
threshold: number
31+
owners: AddressEx[]
32+
fiatTotal: string
33+
queued: number
34+
awaitingConfirmation: number
35+
}

0 commit comments

Comments
 (0)