Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add getAllOwnedSafes endpoint #144

Merged
merged 1 commit into from
Feb 2, 2024
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
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
NoncesResponse,
} from './types/transactions'
import type {
AllOwnedSafes,
FiatCurrencies,
OwnedSafes,
SafeBalanceResponse,
Expand Down Expand Up @@ -143,6 +144,13 @@ export function getOwnedSafes(chainId: string, address: string): Promise<OwnedSa
return getEndpoint(baseUrl, '/v1/chains/{chainId}/owners/{address}/safes', { path: { chainId, address } })
}

/**
* Get the addresses of all Safes belonging to an owner on all chains
*/
export function getAllOwnedSafes(address: string): Promise<AllOwnedSafes> {
return getEndpoint(baseUrl, '/v1/owners/{address}/safes', { path: { address } })
}

/**
* Get NFTs stored in a Safe
*/
Expand Down
21 changes: 21 additions & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
AllOwnedSafes,
FiatCurrencies,
OwnedSafes,
SafeBalanceResponse,
Expand Down Expand Up @@ -209,6 +210,14 @@ export interface paths extends PathRegistry {
}
}
}
'/v1/owners/{address}/safes': {
get: operations['get_all_owned_safes']
parameters: {
path: {
address: string
}
}
}
'/v1/chains': {
get: operations['chains_list']
parameters: null
Expand Down Expand Up @@ -594,6 +603,18 @@ export interface operations {
}
}
}
get_all_owned_safes: {
parameters: {
path: {
address: string
}
}
responses: {
200: {
schema: AllOwnedSafes
}
}
}
chains_list: {
parameters: {
query?: {
Expand Down
2 changes: 2 additions & 0 deletions src/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export type FiatCurrencies = string[]

export type OwnedSafes = { safes: string[] }

export type AllOwnedSafes = Record<string, string[]>

export enum TokenType {
ERC20 = 'ERC20',
ERC721 = 'ERC721',
Expand Down
Loading