Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import type {
NoncesResponse,
} from './types/transactions'
import type {
EthereumAddress,
AllOwnedSafes,
FiatCurrencies,
OwnedSafes,
SafeBalanceResponse,
SafeCollectibleResponse,
SafeCollectiblesPage,
} from './types/common'
import type { SafeInfo } from './types/safe-info'
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'
Expand Down Expand Up @@ -599,4 +600,19 @@ export function unsubscribeAll(query: operations['unsubscribe_all']['parameters'
return deleteEndpoint(baseUrl, '/v1/subscriptions/all', { query })
}

/**
* Get Safe overviews per address
*/
export function getSafeOverviews(
safes: `${number}:${EthereumAddress}`[],
query: Omit<operations['SafesController_getSafeOverview']['parameters']['query'], 'safes'>,
): Promise<SafeOverview[]> {
return getEndpoint(baseUrl, '/v1/safes', {
query: {
...query,
safes: safes.join(','),
},
})
}

/* eslint-enable @typescript-eslint/explicit-module-boundary-types */
31 changes: 23 additions & 8 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
SafeMultisigTransactionsResponse,
NoncesResponse,
} from './transactions'
import type { SafeInfo } from './safe-info'
import type { SafeInfo, SafeOverview } from './safe-info'
import type { ChainListResponse, ChainInfo } from './chains'
import type { SafeAppsResponse } from './safe-apps'
import type { DecodedDataRequest, DecodedDataResponse } from './decoded-data'
Expand Down Expand Up @@ -413,19 +413,18 @@ export interface paths extends PathRegistry {
delete: operations['unsubscribe_single']
parameters: {
path: null
query: {
category: string
token: string
}
}
}
'/v1/subscriptions/all': {
delete: operations['unsubscribe_all']
parameters: {
path: null
query: {
token: string
}
}
}
'/v1/safes': {
get: operations['SafesController_getSafeOverview']
parameters: {
path: null
}
}
}
Expand Down Expand Up @@ -1111,4 +1110,20 @@ export interface operations {
}
}
}
SafesController_getSafeOverview: {
parameters: {
query: {
currency: string
safes: string
trusted: boolean
exclude_spam: boolean
walletAddress?: string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamacook should this be ? or | null?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct.

}
}
responses: {
200: {
schema: SafeOverview[]
}
}
}
}
2 changes: 2 additions & 0 deletions src/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ export type SafeCollectibleResponse = {
}

export type SafeCollectiblesPage = Page<SafeCollectibleResponse>

export type EthereumAddress = `0x${string}`
10 changes: 10 additions & 0 deletions src/types/safe-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ export type SafeInfo = {
txHistoryTag: string | null
messagesTag: string | null
}

export type SafeOverview = {
address: AddressEx
chainId: string
threshold: number
owners: AddressEx[]
fiatTotal: string
queued: number
awaitingConfirmation: number | null
}