Skip to content

Commit 7b53442

Browse files
Add custom coingecko url (#3275)
* Add custom coingecko url * object for coingecko config
1 parent b2ed156 commit 7b53442

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

wormhole-connect/src/config/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export function buildConfig(
119119
],
120120
Devnet: ['http://localhost:7071'],
121121
}[network],
122-
coinGeckoApiKey: customConfig.coinGeckoApiKey,
122+
coingecko: customConfig.coingecko,
123123

124124
// Callbacks
125125
triggerEvent: wrapEventHandler(customConfig.eventHandler),

wormhole-connect/src/config/types.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ export interface WormholeConnectConfig {
9494

9595
// External resources
9696
rpcs?: ChainResourceMap;
97-
coinGeckoApiKey?: string;
97+
coingecko?: {
98+
apiKey?: string;
99+
customUrl?: string;
100+
};
98101

99102
// White lists
100103
chains?: Chain[];
@@ -137,7 +140,10 @@ export interface InternalConfig<N extends Network> {
137140
mayanApi: string;
138141
wormholeApi: string;
139142
wormholeRpcHosts: string[];
140-
coinGeckoApiKey?: string;
143+
coingecko?: {
144+
apiKey?: string;
145+
customUrl?: string;
146+
};
141147

142148
tokens: TokenCache;
143149
tokenWhitelist?: (string | TokenTuple)[];

wormhole-connect/src/utils/coingecko.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ const coingeckoRequest = async (
4545
): Promise<Response> => {
4646
const headers = new Headers({
4747
'Content-Type': 'application/json',
48-
...(config.coinGeckoApiKey
49-
? { 'x-cg-pro-api-key': config.coinGeckoApiKey }
48+
...(config.coingecko?.apiKey
49+
? { 'x-cg-pro-api-key': config.coingecko.apiKey }
5050
: {}),
5151
});
5252

53-
const hostname = config.coinGeckoApiKey ? COINGECKO_URL_PRO : COINGECKO_URL;
53+
const hostname = config.coingecko?.customUrl
54+
? config.coingecko.customUrl
55+
: config.coingecko?.apiKey
56+
? COINGECKO_URL_PRO
57+
: COINGECKO_URL;
5458

5559
return fetch(`${hostname}${path}`, {
5660
signal: params?.abort?.signal,

0 commit comments

Comments
 (0)