Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/safe-global/safe-gateway-typescript-sdk
Safe Gateway TypeScript SDK
https://github.com/safe-global/safe-gateway-typescript-sdk
ethereum gnosis-safe sdk typescript
Last synced: 12 days ago
JSON representation
Safe Gateway TypeScript SDK
- Host: GitHub
- URL: https://github.com/safe-global/safe-gateway-typescript-sdk
- Owner: safe-global
- License: mit
- Created: 2021-07-07T08:04:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-26T12:03:15.000Z (7 months ago)
- Last Synced: 2024-05-02T00:53:36.996Z (7 months ago)
- Topics: ethereum, gnosis-safe, sdk, typescript
- Language: TypeScript
- Homepage: https://safe-global.github.io/safe-gateway-typescript-sdk/modules.html
- Size: 3.84 MB
- Stars: 19
- Watchers: 11
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Safe Gateway TypeScript SDK
[![npm](https://img.shields.io/npm/v/@safe-global/safe-gateway-typescript-sdk?label=%40safe-global%2Fsafe-gateway-typescript-sdk)](https://www.npmjs.com/package/@safe-global/safe-gateway-typescript-sdk)
A TypeScript SDK for the [Safe Client Gateway](https://github.com/safe-global/safe-client-gateway)
📖 [Type reference](https://safe-global.github.io/safe-gateway-typescript-sdk/modules.html)  |  [CGW Swagger](https://safe-client.safe.global)
## Usage policy
NB: Safe Client Gateway isn't meant for public use.
Please _do not_ use this SDK if you're building, e.g., a Safe App.## Using the SDK
Install:
```shell
yarn add @safe-global/safe-gateway-typescript-sdk
```Import:
```ts
import { getChainsConfig, type ChainListResponse } from '@safe-global/safe-gateway-typescript-sdk'
```Use:
```ts
const chains = await getChainsConfig()
```The SDK needs no initialization unless you want to override the base URL. You can set an alternative base URL like so:
```ts
import { setBaseUrl } from '@safe-global/safe-gateway-typescript-sdk'// Switch the SDK to dev mode
setBaseUrl('https://safe-client.staging.5afe.dev')
```The full SDK reference can be found [here](https://safe-global.github.io/safe-gateway-typescript-sdk/modules.html).
## Adding an endpoint
Endpoint types are defined in `src/types/gateway.ts`.
Each endpoint consists of:
- a function defined in `src/index.ts` (e.g. `getBalances`)
- a path definition (e.g. `'/chains/{chainId}/safes/{address}/balances/{currency}/'`)
- operation definition (e.g. `safes_balances_list`)
- response definitionTo add a new endpoint, follow the pattern set by the existing endpoints.
## Eslint & prettier
This command will run before every commit:
```shell
yarn eslint:fix
```## Tests
To run the unit and e2e tests locally:
```shell
yarn test
```N.B.: the e2e tests make actual API calls on staging.