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
6 changes: 6 additions & 0 deletions .changeset/proud-carrots-stop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@human-protocol/sdk": patch
"@human-protocol/python-sdk": patch
---

remove SUBGRAPH_API_KEY placeholder and simplify subgraph URL handling
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ class OperatorCategory(Enum):
}


SUBGRAPH_API_KEY_PLACEHOLDER = "[SUBGRAPH_API_KEY]"
"""Placeholder string in subgraph URLs that gets replaced with the actual API key from environment variables."""


class Status(Enum):
"""Escrow contract lifecycle statuses.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,7 @@ def _fetch_subgraph_data(
"""
subgraph_api_key = os.getenv("SUBGRAPH_API_KEY", "")
if subgraph_api_key:
subgraph_url = network["subgraph_url_api_key"].replace(
SUBGRAPH_API_KEY_PLACEHOLDER, subgraph_api_key
)
subgraph_url = network["subgraph_url_api_key"]
else:
logger.warning(
"Warning: SUBGRAPH_API_KEY is not provided. It might cause issues with the subgraph."
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/typescript/human-protocol-sdk/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,4 @@ export const Role = {
RecordingOracle: 'recording_oracle',
};

export const SUBGRAPH_API_KEY_PLACEHOLDER = '[SUBGRAPH_API_KEY]';

export const ESCROW_BULK_PAYOUT_MAX_ITEMS = 99;
8 changes: 2 additions & 6 deletions packages/sdk/typescript/human-protocol-sdk/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ethers } from 'ethers';
import gqlFetch from 'graphql-request';

import { isURL } from 'validator';
import { SUBGRAPH_API_KEY_PLACEHOLDER } from './constants';
import { ChainId } from './enums';
import {
ContractExecutionError,
Expand All @@ -17,8 +16,8 @@ import {
TransactionReplaced,
WarnSubgraphApiKeyNotProvided,
} from './error';
import { NetworkData } from './types';
import { SubgraphOptions } from './interfaces';
import { NetworkData } from './types';

/**
* Handles and throws appropriate error types based on the Ethereum error.
Expand Down Expand Up @@ -88,10 +87,7 @@ export const isValidJson = (input: string): boolean => {
export const getSubgraphUrl = (networkData: NetworkData) => {
let subgraphUrl = networkData.subgraphUrl;
if (process.env.SUBGRAPH_API_KEY) {
subgraphUrl = networkData.subgraphUrlApiKey.replace(
SUBGRAPH_API_KEY_PLACEHOLDER,
process.env.SUBGRAPH_API_KEY
);
subgraphUrl = networkData.subgraphUrlApiKey;
} else if (networkData.chainId !== ChainId.LOCALHOST) {
// eslint-disable-next-line no-console
console.warn(WarnSubgraphApiKeyNotProvided);
Expand Down
Loading