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
14 changes: 6 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
name: 'Lint'
on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.8.0
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Yarn install
run: yarn install --immutable
- run: npm install

- uses: Maggi64/eslint-plus-action@master
with:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: 'Unit tests'
on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: npm install

- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@safe-global/safe-gateway-typescript-sdk",
"version": "3.7.3",
"version": "3.8.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type { MasterCopyReponse } from './types/master-copies'
import type { DecodedDataResponse } from './types/decoded-data'
import type { SafeMessage, SafeMessageListPage } from './types/safe-messages'
import { DEFAULT_BASE_URL } from './config'
import type { DelegateResponse, DelegatesRequest } from './types/delegates'

export * from './types/safe-info'
export * from './types/safe-apps'
Expand Down Expand Up @@ -343,4 +344,14 @@ export function confirmSafeMessage(
})
}

/**
* Returns a list of delegates
*/
export function getDelegates(chainId: string, query: DelegatesRequest = {}): Promise<DelegateResponse> {
return getEndpoint(baseUrl, '/v1/chains/{chainId}/delegates', {
path: { chainId },
query,
})
}

/* eslint-enable @typescript-eslint/explicit-module-boundary-types */
23 changes: 23 additions & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type {
SafeMessage,
SafeMessageListPage,
} from './safe-messages'
import type { DelegateResponse, DelegatesRequest } from './delegates'

export type Primitive = string | number | boolean | null

Expand Down Expand Up @@ -260,6 +261,15 @@ export interface paths extends PathRegistry {
}
}
}
'/v1/chains/{chainId}/delegates': {
get: operations['get_delegates']
parameters: {
path: {
chainId: string
}
query: DelegatesRequest
}
}
}

export interface operations {
Expand Down Expand Up @@ -666,4 +676,17 @@ export interface operations {
}
}
}
get_delegates: {
parameters: {
path: {
chainId: string
}
query: DelegatesRequest
}
responses: {
200: {
schema: DelegateResponse
}
}
}
}
37 changes: 37 additions & 0 deletions src/types/delegates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { Page } from './common'

export type Delegate = {
safe?: string
delegate: string
delegator: string
label: string
}

export type DelegateResponse = Page<Delegate>

export type DelegatesRequest = {
safe?: string
delegate?: string
delegator?: string
label?: string
}

export type AddDelegateRequest = {
safe?: string
delegate: string
delegator: string
signature: string
label: string
}

export type DeleteDelegateRequest = {
delegate: string
delegator: string
signature: string
}

export type DeleteSafeDelegateRequest = {
safe: string
delegate: string
signature: string
}
Loading