Skip to content

Commit 034b3eb

Browse files
authored
Feat: add getDeletegates (#124)
* Feat: add getDeletegates * Update the lint action * Upgrade minor versions
1 parent ba92b0e commit 034b3eb

File tree

7 files changed

+1384
-1285
lines changed

7 files changed

+1384
-1285
lines changed

.github/workflows/lint.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
name: 'Lint'
22
on: [pull_request]
33

4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}
6+
cancel-in-progress: true
7+
48
jobs:
59
eslint:
610
runs-on: ubuntu-latest
711
steps:
8-
- name: Cancel previous runs
9-
uses: styfle/[email protected]
10-
with:
11-
access_token: ${{ github.token }}
12-
13-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1413

15-
- name: Yarn install
16-
run: yarn install --immutable
14+
- run: npm install
1715

1816
- uses: Maggi64/eslint-plus-action@master
1917
with:

.github/workflows/test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
name: 'Unit tests'
22
on: [pull_request]
33

4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}
6+
cancel-in-progress: true
7+
48
jobs:
59
tests:
610
runs-on: ubuntu-latest
711
steps:
8-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
913
- run: npm install
1014

1115
- name: Run tests

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@safe-global/safe-gateway-typescript-sdk",
3-
"version": "3.7.3",
3+
"version": "3.8.0",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"files": [

src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type { MasterCopyReponse } from './types/master-copies'
2222
import type { DecodedDataResponse } from './types/decoded-data'
2323
import type { SafeMessage, SafeMessageListPage } from './types/safe-messages'
2424
import { DEFAULT_BASE_URL } from './config'
25+
import type { DelegateResponse, DelegatesRequest } from './types/delegates'
2526

2627
export * from './types/safe-info'
2728
export * from './types/safe-apps'
@@ -343,4 +344,14 @@ export function confirmSafeMessage(
343344
})
344345
}
345346

347+
/**
348+
* Returns a list of delegates
349+
*/
350+
export function getDelegates(chainId: string, query: DelegatesRequest = {}): Promise<DelegateResponse> {
351+
return getEndpoint(baseUrl, '/v1/chains/{chainId}/delegates', {
352+
path: { chainId },
353+
query,
354+
})
355+
}
356+
346357
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */

src/types/api.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type {
2626
SafeMessage,
2727
SafeMessageListPage,
2828
} from './safe-messages'
29+
import type { DelegateResponse, DelegatesRequest } from './delegates'
2930

3031
export type Primitive = string | number | boolean | null
3132

@@ -260,6 +261,15 @@ export interface paths extends PathRegistry {
260261
}
261262
}
262263
}
264+
'/v1/chains/{chainId}/delegates': {
265+
get: operations['get_delegates']
266+
parameters: {
267+
path: {
268+
chainId: string
269+
}
270+
query: DelegatesRequest
271+
}
272+
}
263273
}
264274

265275
export interface operations {
@@ -666,4 +676,17 @@ export interface operations {
666676
}
667677
}
668678
}
679+
get_delegates: {
680+
parameters: {
681+
path: {
682+
chainId: string
683+
}
684+
query: DelegatesRequest
685+
}
686+
responses: {
687+
200: {
688+
schema: DelegateResponse
689+
}
690+
}
691+
}
669692
}

src/types/delegates.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { Page } from './common'
2+
3+
export type Delegate = {
4+
safe?: string
5+
delegate: string
6+
delegator: string
7+
label: string
8+
}
9+
10+
export type DelegateResponse = Page<Delegate>
11+
12+
export type DelegatesRequest = {
13+
safe?: string
14+
delegate?: string
15+
delegator?: string
16+
label?: string
17+
}
18+
19+
export type AddDelegateRequest = {
20+
safe?: string
21+
delegate: string
22+
delegator: string
23+
signature: string
24+
label: string
25+
}
26+
27+
export type DeleteDelegateRequest = {
28+
delegate: string
29+
delegator: string
30+
signature: string
31+
}
32+
33+
export type DeleteSafeDelegateRequest = {
34+
safe: string
35+
delegate: string
36+
signature: string
37+
}

0 commit comments

Comments
 (0)