Skip to content

Commit 13f272e

Browse files
authored
Update chain config types (#31)
* chore: Update chain config types * chore: Bump version * chore: Fix type * fix: Rm safeAppsRpcUri + ensRegistryAddress option * chore: Rename type to match struct * chore: Remove enums in favour of CGW alignment * Revert "chore: Remove enums in favour of CGW alignment" This reverts commit baa82d4.
1 parent b0d6638 commit 13f272e

File tree

4 files changed

+55
-27
lines changed

4 files changed

+55
-27
lines changed

package.json

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

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { callEndpoint } from './endpoint'
22
import { operations } from './types/api'
33
import { SafeTransactionEstimation, TransactionDetails, TransactionListPage } from './types/transactions'
44
import { FiatCurrencies, OwnedSafes, SafeBalanceResponse, SafeCollectibleResponse, SafeInfo } from './types/common'
5-
import { ChainListResponse, ChainConfig } from './types/chains'
5+
import { ChainListResponse, ChainInfo } from './types/chains'
66
export * from './types/transactions'
77
export * from './types/chains'
88
export * from './types/common'
@@ -150,7 +150,7 @@ export function getChainsConfig(
150150
/**
151151
* Returns a chain config
152152
*/
153-
export function getChainConfig(baseUrl: string, chainId: string): Promise<ChainConfig> {
153+
export function getChainConfig(baseUrl: string, chainId: string): Promise<ChainInfo> {
154154
return callEndpoint(baseUrl, '/chains/{chainId}/', {
155155
path: { chainId: chainId },
156156
})

src/types/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
SafeTransactionEstimationRequest,
77
TransactionListPage,
88
} from './transactions'
9-
import { ChainListResponse, ChainConfig } from './chains'
9+
import { ChainListResponse, ChainInfo } from './chains'
1010

1111
export interface paths {
1212
'/chains/{chainId}/safes/{address}/': {
@@ -320,7 +320,7 @@ export interface operations {
320320
}
321321
responses: {
322322
200: {
323-
schema: ChainConfig
323+
schema: ChainInfo
324324
}
325325
}
326326
}

src/types/chains.ts

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,86 @@
1-
export type BaseRpcUri = {
2-
authentication?: string
3-
value?: string
1+
export enum RPC_AUTHENTICATION {
2+
API_KEY_PATH = 'API_KEY_PATH',
3+
NO_AUTHENTICATION = 'NO_AUTHENTICATION',
4+
UNKNOWN = 'UNKNOWN',
5+
}
6+
7+
export type RpcUri = {
8+
authentication: RPC_AUTHENTICATION
9+
value: string
410
}
511

612
export type BlockExplorerUriTemplate = {
713
address: string
814
txHash: string
15+
api: string
916
}
1017

11-
export type Currency = {
18+
export type NativeCurrency = {
1219
name: string
1320
symbol: string
1421
decimals: number
15-
logoUri?: string
22+
logoUri: string
1623
}
1724

1825
export type Theme = {
1926
textColor: string
2027
backgroundColor: string
2128
}
2229

30+
export enum GAS_PRICE_TYPE {
31+
ORACLE = 'ORACLE',
32+
FIXED = 'FIXED',
33+
UNKNOWN = 'UNKNOWN',
34+
}
35+
2336
export type GasPriceOracle = {
24-
type: 'ORACLE'
37+
type: GAS_PRICE_TYPE.ORACLE
2538
uri: string
2639
gasParameter: string
2740
gweiFactor: string
2841
}
2942

3043
export type GasPriceFixed = {
31-
type: 'FIXED'
44+
type: GAS_PRICE_TYPE.FIXED
3245
weiValue: string
3346
}
3447

35-
export type GasPrices = (GasPriceOracle | GasPriceFixed)[]
48+
export type GasPriceUnknown = {
49+
type: GAS_PRICE_TYPE.UNKNOWN
50+
}
51+
52+
export type GasPrice = (GasPriceOracle | GasPriceFixed | GasPriceUnknown)[]
53+
54+
export enum FEATURES {
55+
ERC721 = 'ERC721',
56+
ERC1155 = 'ERC1155',
57+
SAFE_APPS = 'SAFE_APPS',
58+
CONTRACT_INTERACTION = 'CONTRACT_INTERACTION',
59+
DOMAIN_LOOKUP = 'DOMAIN_LOOKUP',
60+
SPENDING_LIMIT = 'SPENDING_LIMIT',
61+
}
3662

37-
export type ChainConfig = {
38-
chainId: string
63+
// Remain agnostic as possible and reference what is returned in the CGW, i.e.
64+
// https://gnosis.github.io/safe-client-gateway/docs/routes/chains/models/struct.ChainInfo.html
65+
export type ChainInfo = {
66+
transactionService: string
67+
chainId: string // Restricted by what is returned by the CGW
3968
chainName: string
4069
shortName: string
41-
description?: string
4270
l2: boolean
43-
rpcUri?: BaseRpcUri
44-
safeAppsRpcUri?: BaseRpcUri
45-
blockExplorerUriTemplate?: BlockExplorerUriTemplate
46-
nativeCurrency?: Currency
47-
transactionService?: string
48-
vpcTransactionService: string
49-
theme?: Theme
50-
gasPrice?: GasPrices
71+
description: string
72+
rpcUri: RpcUri
73+
blockExplorerUriTemplate: BlockExplorerUriTemplate
74+
nativeCurrency: NativeCurrency
75+
theme: Theme
5176
ensRegistryAddress?: string
77+
gasPrice: GasPrice
78+
disabledWallets: string[]
79+
features: FEATURES[]
5280
}
5381

5482
export type ChainListResponse = {
55-
next?: string
56-
previous?: string
57-
results: ChainConfig[]
83+
next: string | null
84+
previous: string | null
85+
results: ChainInfo[]
5886
}

0 commit comments

Comments
 (0)