From 7351dfd45b074dd2b82a1cd5a47fb5d185aa93ab Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Tue, 3 Dec 2024 11:29:00 +0100 Subject: [PATCH] feat: add isTestnet to curve lite networks --- package.json | 2 +- src/external-api.ts | 36 ++++++++++++++++-------------------- src/interfaces.ts | 1 + 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index a69d5d5a..8460a93e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@curvefi/api", - "version": "2.65.17", + "version": "2.65.18", "description": "JavaScript library for curve.fi", "main": "lib/index.js", "author": "Macket", diff --git a/src/external-api.ts b/src/external-api.ts index 3b208edc..0940eec3 100644 --- a/src/external-api.ts +++ b/src/external-api.ts @@ -1,15 +1,15 @@ import axios from "axios"; import memoize from "memoizee"; import { - IExtendedPoolDataFromApi, + ICurveLiteNetwork, + IDaoProposal, + IDaoProposalListItem, IDict, + IExtendedPoolDataFromApi, + IGaugesDataFromApi, INetworkName, IPoolType, - IGaugesDataFromApi, - IDaoProposal, - IDaoProposalListItem, IVolumeAndAPYs, - ICurveLiteNetwork, } from "./interfaces"; @@ -317,24 +317,20 @@ export const _getCurveLiteNetworks = memoize( } const { platforms, platformsMetadata } = response.data.data; - - const networks: ICurveLiteNetwork[] = Object.entries(platforms) - .map(([platformId, _factories]) => { - const metadata = platformsMetadata[platformId]; - if (!metadata) return null; - + return Object.keys(platforms) + .map(id => { + const {explorerBaseUrl, name, rpcUrl, nativeCurrencySymbol, isMainnet, chainId} = platformsMetadata[id]; return { - id: platformId, - name: metadata.name, - rpcUrl: metadata.rpcUrl, - chainId: metadata.chainId, - explorerUrl: metadata.explorerBaseUrl, - nativeCurrencySymbol: metadata.nativeCurrencySymbol, + id, + name, + rpcUrl, + chainId, + explorerUrl: explorerBaseUrl, + nativeCurrencySymbol, + isTestnet: !isMainnet, }; }) - .filter((network): network is ICurveLiteNetwork => network !== null); - - return networks; + .filter(({ name }) => name); }, { promise: true, diff --git a/src/interfaces.ts b/src/interfaces.ts index cb5f70e7..4c9730be 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -292,6 +292,7 @@ export interface ICurveLiteNetwork { rpcUrl: string explorerUrl: string nativeCurrencySymbol: string + isTestnet: boolean } export type TVoteType = "PARAMETER" | "OWNERSHIP"