Skip to content

Commit 68da3b1

Browse files
authored
[SDK] remove SUBGRAPH_API_KEY placeholder and simplify subgraph URL handling (#3760)
1 parent 523691a commit 68da3b1

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

.changeset/proud-carrots-stop.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@human-protocol/sdk": patch
3+
"@human-protocol/python-sdk": patch
4+
---
5+
6+
remove SUBGRAPH_API_KEY placeholder and simplify subgraph URL handling

packages/sdk/python/human-protocol-sdk/human_protocol_sdk/constants.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ class OperatorCategory(Enum):
165165
}
166166

167167

168-
SUBGRAPH_API_KEY_PLACEHOLDER = "[SUBGRAPH_API_KEY]"
169-
"""Placeholder string in subgraph URLs that gets replaced with the actual API key from environment variables."""
170-
171-
172168
class Status(Enum):
173169
"""Escrow contract lifecycle statuses.
174170

packages/sdk/python/human-protocol-sdk/human_protocol_sdk/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,7 @@ def _fetch_subgraph_data(
308308
"""
309309
subgraph_api_key = os.getenv("SUBGRAPH_API_KEY", "")
310310
if subgraph_api_key:
311-
subgraph_url = network["subgraph_url_api_key"].replace(
312-
SUBGRAPH_API_KEY_PLACEHOLDER, subgraph_api_key
313-
)
311+
subgraph_url = network["subgraph_url_api_key"]
314312
else:
315313
logger.warning(
316314
"Warning: SUBGRAPH_API_KEY is not provided. It might cause issues with the subgraph."

packages/sdk/typescript/human-protocol-sdk/src/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,4 @@ export const Role = {
154154
RecordingOracle: 'recording_oracle',
155155
};
156156

157-
export const SUBGRAPH_API_KEY_PLACEHOLDER = '[SUBGRAPH_API_KEY]';
158-
159157
export const ESCROW_BULK_PAYOUT_MAX_ITEMS = 99;

packages/sdk/typescript/human-protocol-sdk/src/utils.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { ethers } from 'ethers';
33
import gqlFetch from 'graphql-request';
44

55
import { isURL } from 'validator';
6-
import { SUBGRAPH_API_KEY_PLACEHOLDER } from './constants';
76
import { ChainId } from './enums';
87
import {
98
ContractExecutionError,
@@ -17,8 +16,8 @@ import {
1716
TransactionReplaced,
1817
WarnSubgraphApiKeyNotProvided,
1918
} from './error';
20-
import { NetworkData } from './types';
2119
import { SubgraphOptions } from './interfaces';
20+
import { NetworkData } from './types';
2221

2322
/**
2423
* Handles and throws appropriate error types based on the Ethereum error.
@@ -88,10 +87,7 @@ export const isValidJson = (input: string): boolean => {
8887
export const getSubgraphUrl = (networkData: NetworkData) => {
8988
let subgraphUrl = networkData.subgraphUrl;
9089
if (process.env.SUBGRAPH_API_KEY) {
91-
subgraphUrl = networkData.subgraphUrlApiKey.replace(
92-
SUBGRAPH_API_KEY_PLACEHOLDER,
93-
process.env.SUBGRAPH_API_KEY
94-
);
90+
subgraphUrl = networkData.subgraphUrlApiKey;
9591
} else if (networkData.chainId !== ChainId.LOCALHOST) {
9692
// eslint-disable-next-line no-console
9793
console.warn(WarnSubgraphApiKeyNotProvided);

0 commit comments

Comments
 (0)