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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gnosis.pm/safe-react-gateway-sdk",
"version": "2.5.3",
"version": "2.5.4",
"main": "dist/index.min.js",
"types": "dist/index.d.ts",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { callEndpoint } from './endpoint'
import { operations } from './types/api'
import { SafeTransactionEstimation, TransactionDetails, TransactionListPage } from './types/transactions'
import { FiatCurrencies, OwnedSafes, SafeBalanceResponse, SafeCollectibleResponse, SafeInfo } from './types/common'
import { ChainListResponse, ChainConfig } from './types/chains'
import { ChainListResponse, ChainInfo } from './types/chains'
export * from './types/transactions'
export * from './types/chains'
export * from './types/common'
Expand Down Expand Up @@ -150,7 +150,7 @@ export function getChainsConfig(
/**
* Returns a chain config
*/
export function getChainConfig(baseUrl: string, chainId: string): Promise<ChainConfig> {
export function getChainConfig(baseUrl: string, chainId: string): Promise<ChainInfo> {
return callEndpoint(baseUrl, '/chains/{chainId}/', {
path: { chainId: chainId },
})
Expand Down
4 changes: 2 additions & 2 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
SafeTransactionEstimationRequest,
TransactionListPage,
} from './transactions'
import { ChainListResponse, ChainConfig } from './chains'
import { ChainListResponse, ChainInfo } from './chains'

export interface paths {
'/chains/{chainId}/safes/{address}/': {
Expand Down Expand Up @@ -320,7 +320,7 @@ export interface operations {
}
responses: {
200: {
schema: ChainConfig
schema: ChainInfo
}
}
}
Expand Down
72 changes: 50 additions & 22 deletions src/types/chains.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,86 @@
export type BaseRpcUri = {
authentication?: string
value?: string
export enum RPC_AUTHENTICATION {
API_KEY_PATH = 'API_KEY_PATH',
NO_AUTHENTICATION = 'NO_AUTHENTICATION',
UNKNOWN = 'UNKNOWN',
}

export type RpcUri = {
authentication: RPC_AUTHENTICATION
value: string
}

export type BlockExplorerUriTemplate = {
address: string
txHash: string
api: string
}

export type Currency = {
export type NativeCurrency = {
name: string
symbol: string
decimals: number
logoUri?: string
logoUri: string
}

export type Theme = {
textColor: string
backgroundColor: string
}

export enum GAS_PRICE_TYPE {
ORACLE = 'ORACLE',
FIXED = 'FIXED',
UNKNOWN = 'UNKNOWN',
}

export type GasPriceOracle = {
type: 'ORACLE'
type: GAS_PRICE_TYPE.ORACLE
uri: string
gasParameter: string
gweiFactor: string
}

export type GasPriceFixed = {
type: 'FIXED'
type: GAS_PRICE_TYPE.FIXED
weiValue: string
}

export type GasPrices = (GasPriceOracle | GasPriceFixed)[]
export type GasPriceUnknown = {
type: GAS_PRICE_TYPE.UNKNOWN
}

export type GasPrice = (GasPriceOracle | GasPriceFixed | GasPriceUnknown)[]

export enum FEATURES {
ERC721 = 'ERC721',
ERC1155 = 'ERC1155',
SAFE_APPS = 'SAFE_APPS',
CONTRACT_INTERACTION = 'CONTRACT_INTERACTION',
DOMAIN_LOOKUP = 'DOMAIN_LOOKUP',
SPENDING_LIMIT = 'SPENDING_LIMIT',
}

export type ChainConfig = {
chainId: string
// Remain agnostic as possible and reference what is returned in the CGW, i.e.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

// https://gnosis.github.io/safe-client-gateway/docs/routes/chains/models/struct.ChainInfo.html
export type ChainInfo = {
transactionService: string
chainId: string // Restricted by what is returned by the CGW
chainName: string
shortName: string
description?: string
l2: boolean
rpcUri?: BaseRpcUri
safeAppsRpcUri?: BaseRpcUri
blockExplorerUriTemplate?: BlockExplorerUriTemplate
nativeCurrency?: Currency
transactionService?: string
vpcTransactionService: string
theme?: Theme
gasPrice?: GasPrices
description: string
rpcUri: RpcUri
blockExplorerUriTemplate: BlockExplorerUriTemplate
nativeCurrency: NativeCurrency
theme: Theme
ensRegistryAddress?: string
gasPrice: GasPrice
disabledWallets: string[]
features: FEATURES[]
}

export type ChainListResponse = {
next?: string
previous?: string
results: ChainConfig[]
next: string | null
previous: string | null
results: ChainInfo[]
}