Skip to content

Commit

Permalink
Merge pull request #4270 from Giveth/read_subgraph_addresses_from_env
Browse files Browse the repository at this point in the history
hotfix(production) Read subgraph Urls from .env
  • Loading branch information
mhmdksh authored Jun 14, 2024
2 parents d161b05 + 96863af commit be3baf7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@types/apollo-upload-client": "^18.0.0",
"@types/axios": "^0.14.0",
"@types/extract-files": "^13.0.1",
"@types/jest": "^29.5.12",
"@types/jest-axe": "^3.5.9",
Expand Down
3 changes: 3 additions & 0 deletions src/config/development.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const config: EnvConfig = {
],
regenPools: [],
uniswapV2Subgraph:
process.env.NEXT_PUBLIC_SUBGRAPH_UNISWAP_V2 ||
'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2?source=giveth',
regenStreams: [],
},
Expand Down Expand Up @@ -310,6 +311,7 @@ const config: EnvConfig = {
],

uniswapV2Subgraph:
process.env.NEXT_PUBLIC_SUBGRAPH_HONEYSWAP_V2 ||
'https://api.thegraph.com/subgraphs/name/1hive/honeyswap-v2?source=giveth',

regenStreams: [
Expand Down Expand Up @@ -383,6 +385,7 @@ const config: EnvConfig = {
GIVETH_ANCHOR_CONTRACT_ADDRESS:
'0x503055e1f8b99c60a51c479a60b233976617bc7a',
superFluidSubgraph:
process.env.NEXT_PUBLIC_SUBGRAPH_SUPER_FLUID ||
'https://optimism-sepolia.subgraph.x.superfluid.dev/?source=giveth',
SUPER_FLUID_TOKENS: [
{
Expand Down
3 changes: 3 additions & 0 deletions src/config/production.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const config: EnvConfig = {
},
],
uniswapV2Subgraph:
process.env.NEXT_PUBLIC_SUBGRAPH_UNISWAP_V2 ||
'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2?source=giveth',
regenStreams: [
{
Expand Down Expand Up @@ -368,6 +369,7 @@ const config: EnvConfig = {
],

uniswapV2Subgraph:
process.env.NEXT_PUBLIC_SUBGRAPH_HONEYSWAP_V2 ||
'https://api.thegraph.com/subgraphs/name/1hive/honeyswap-v2?source=giveth',

regenStreams: [
Expand Down Expand Up @@ -428,6 +430,7 @@ const config: EnvConfig = {
GIVETH_ANCHOR_CONTRACT_ADDRESS:
'0x5430757bc19c87ec562e4660e56af6cac324b50a',
superFluidSubgraph:
process.env.NEXT_PUBLIC_SUBGRAPH_SUPER_FLUID ||
'https://api.thegraph.com/subgraphs/name/superfluid-finance/protocol-v1-optimism-mainnet?source=giveth',
SUPER_FLUID_TOKENS: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/features/price/price.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export const FETCH_MAINNET_TOKEN_PRICE = `query FetchMainnetTokenPrice($tokenId:

export const FETCH_GNOSIS_TOKEN_PRICE = `query FetchGnosisTokenPrice($id: String!){
token(id: $id) {
derivedETH
derivedNativeCurrency
}
}`;
18 changes: 15 additions & 3 deletions src/features/price/price.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ export const fetchMainnetTokenPrice = async (
query,
variables,
};
const myHeaders = new Headers();
myHeaders.append('content-type', 'application/json');
const res = await fetch(config.MAINNET_CONFIG.uniswapV2Subgraph, {
method: 'POST',
body: JSON.stringify(body),
headers: myHeaders,
});
const data = await res.json();
const tokenEthPrice = new BigNumber(data?.data?.token.derivedETH);
Expand All @@ -43,10 +46,19 @@ export const fetchGnosisTokenPrice = async (
query,
variables,
};
const res = await fetch(subgraph, {

const myHeaders = new Headers();
myHeaders.append('content-type', 'application/json');

const requestOptions: RequestInit = {
method: 'POST',
body: JSON.stringify(body),
});
headers: myHeaders,
};
const res = await fetch(
config.GNOSIS_CONFIG.uniswapV2Subgraph!,
requestOptions,
);
const data = await res.json();
return data?.data?.token?.derivedETH || '0';
return data?.data?.token?.derivedNativeCurrency || '0';
};
18 changes: 1 addition & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4500,13 +4500,6 @@
resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-5.0.4.tgz#1a31c3d378850d2778dabb6374d036dcba4ba708"
integrity sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==

"@types/axios@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@types/axios/-/axios-0.14.0.tgz#ec2300fbe7d7dddd7eb9d3abf87999964cafce46"
integrity sha512-KqQnQbdYE54D7oa/UmYVMZKq7CO4l8DEENzOKc4aBRwxCXSlJXGz83flFx5L7AWrOQnmuN3kVsRdt+GZPPjiVQ==
dependencies:
axios "*"

"@types/babel__core@^7.1.14":
version "7.20.5"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017"
Expand Down Expand Up @@ -6168,15 +6161,6 @@ axe-core@^3.5.5:
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-3.5.6.tgz#e762a90d7f6dbd244ceacb4e72760ff8aad521b5"
integrity sha512-LEUDjgmdJoA3LqklSTwKYqkjcZ4HKc4ddIYGSAiSkr46NTjzg2L9RNB+lekO9P7Dlpa87+hBtzc2Fzn/+GUWMQ==

axios@*:
version "1.6.8"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.8.tgz#66d294951f5d988a00e87a0ffb955316a619ea66"
integrity sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==
dependencies:
follow-redirects "^1.15.6"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axobject-query@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.2.1.tgz#39c378a6e3b06ca679f29138151e45b2b32da62a"
Expand Down Expand Up @@ -9557,7 +9541,7 @@ flatted@^3.2.9:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a"
integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==

follow-redirects@^1.12.1, follow-redirects@^1.15.6:
follow-redirects@^1.12.1:
version "1.15.6"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b"
integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==
Expand Down

0 comments on commit be3baf7

Please sign in to comment.