From 7351dfd45b074dd2b82a1cd5a47fb5d185aa93ab Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Tue, 3 Dec 2024 11:29:00 +0100 Subject: [PATCH 1/3] 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" From 8cfa308336e3ff96272843c195a1adafd545fc2a Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Tue, 3 Dec 2024 11:32:15 +0100 Subject: [PATCH 2/3] fix: lint --- package.json | 2 +- src/external-api.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8460a93e..a69d5d5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@curvefi/api", - "version": "2.65.18", + "version": "2.65.17", "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 0940eec3..f2e2c5ce 100644 --- a/src/external-api.ts +++ b/src/external-api.ts @@ -318,9 +318,9 @@ export const _getCurveLiteNetworks = memoize( const { platforms, platformsMetadata } = response.data.data; return Object.keys(platforms) - .map(id => { - const {explorerBaseUrl, name, rpcUrl, nativeCurrencySymbol, isMainnet, chainId} = platformsMetadata[id]; - return { + .map((id) => { + const { name, rpcUrl, nativeCurrencySymbol, explorerBaseUrl, isMainnet, chainId} = platformsMetadata[id] ?? {}; + return name && { id, name, rpcUrl, @@ -330,7 +330,7 @@ export const _getCurveLiteNetworks = memoize( isTestnet: !isMainnet, }; }) - .filter(({ name }) => name); + .filter(Boolean); }, { promise: true, From dfb7f92dc2a967effcb2c667a6a2a1fff4ab1514 Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Tue, 3 Dec 2024 11:46:01 +0100 Subject: [PATCH 3/3] build: v2.65.18 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",