diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index b6162368..366b627a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -79,6 +79,7 @@ jobs: env: PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }} PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }} + GRAPH_API_KEY: ${{ secrets.GRAPH_API_KEY }} AWS_ACCESS_KEY_ID: ${{ secrets.DIGITALOCEAN_SPACES_API_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_API_SECRET }} WEB3_INFURA_PROJECT_ID: ${{ secrets.WEB3_INFURA_PROJECT_ID }} @@ -114,7 +115,7 @@ jobs: - name: Update deployment file with image run: sed -i 's||'${DOCKER_IMAGE}'|' $GITHUB_WORKSPACE/agent/k8s/base/deployment.yaml - name: Write secrets file - run: $GITHUB_WORKSPACE/scripts/properties_from_env.sh PREFECT_API_KEY PREFECT_API_URL AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID PREFECT_POOL WEB3_INFURA_PROJECT_ID > $GITHUB_WORKSPACE/agent/k8s/secret.properties + run: $GITHUB_WORKSPACE/scripts/properties_from_env.sh PREFECT_API_KEY PREFECT_API_URL AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID PREFECT_POOL WEB3_INFURA_PROJECT_ID GRAPH_API_KEY > $GITHUB_WORKSPACE/agent/k8s/secret.properties - name: Save DigitalOcean kubeconfig with short-lived credentials run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.DIGITALOCEAN_CLUSTER_NAME }} - name: Deploy to DigitalOcean Kubernetes diff --git a/agent/k8s/base/deployment.yaml b/agent/k8s/base/deployment.yaml index 906ead82..a2e9dfaa 100644 --- a/agent/k8s/base/deployment.yaml +++ b/agent/k8s/base/deployment.yaml @@ -50,3 +50,8 @@ spec: secretKeyRef: name: data-pipelines-secrets key: WEB3_INFURA_PROJECT_ID + - name: GRAPH_API_KEY + valueFrom: + secretKeyRef: + name: data-pipelines-secrets + key: GRAPH_API_KEY diff --git a/flows/constants.py b/flows/constants.py index 5589321b..d17dbb9d 100644 --- a/flows/constants.py +++ b/flows/constants.py @@ -1,21 +1,44 @@ -CARBON_SUBGRAPH_URL = ( - "https://api.thegraph.com/subgraphs/name/klimadao/polygon-digital-carbon" -) -CARBON_LEGACY_SUBGRAPH_URL = ( - "https://api.thegraph.com/subgraphs/name/klimadao/polygon-bridged-carbon" -) -CARBON_ETH_SUBGRAPH_URL = ( - "https://api.thegraph.com/subgraphs/name/klimadao/ethereum-bridged-carbon" -) -CARBON_CELO_SUBGRAPH_URL = ( - "https://api.thegraph.com/subgraphs/name/klimadao/celo-bridged-carbon" -) -CARBON_HOLDERS_SUBGRAPH_URL = ( - "https://api.thegraph.com/subgraphs/name/klimadao/klimadao-user-carbon" -) -PAIRS_SUBGRAPH_URL = ( - "https://api.thegraph.com/subgraphs/name/klimadao/klimadao-pairs" -) +import os + +GRAPH_API_KEY = os.environ.get('GRAPH_API_KEY') +GRAPH_BASE_URL = f'https://gateway-arbitrum.network.thegraph.com/api/{GRAPH_API_KEY}/subgraphs/id/' +GRAPH_DEV_BASE_URL = 'https://api.studio.thegraph.com/query/71975/' +GRAPH_VERSION_SUFFIX = '/version/latest' + +CARBON_SG_ID = 'ECLEwJKgujmiRCW1XbfbbUbpae2igeHa2KJ6BXNSWrZF' +CARBON_LEGACY_SG_ID = '9skh5pMQGRdyJcBe8PjWdDjLoYqoYTMLRDpFh6acSHUu' +CARBON_ETH_SG_ID = 'A3dewmSVoxFvvyaMQUJFQHDg3cF8ageeq3hXHnMgs3kp' +CARBON_CELO_SG_ID = 'H5UMmbFgxE73i8s445cRuSx5bg7AUUrsKdtBBCQfinYX' +CARBON_HOLDERS_SG_ID = 'BJFQSmoqffMD8e1pN9xdsuRDYQNgVs8z3DBiXa6AdkGY' +PAIRS_SG_ID = 'hwk9GJd5cf5EASZRxQZJ56KocpYt7tNDtho9HZwN6rL' + +if os.environ.get('ENV') == 'production': + CARBON_SUBGRAPH_URL = GRAPH_BASE_URL + CARBON_SG_ID + CARBON_LEGACY_SUBGRAPH_URL = GRAPH_BASE_URL + CARBON_LEGACY_SG_ID + CARBON_ETH_SUBGRAPH_URL = GRAPH_BASE_URL + CARBON_ETH_SG_ID + CARBON_CELO_SUBGRAPH_URL = GRAPH_BASE_URL + CARBON_CELO_SG_ID + CARBON_HOLDERS_SUBGRAPH_URL = GRAPH_BASE_URL + CARBON_HOLDERS_SG_ID + PAIRS_SUBGRAPH_URL = GRAPH_BASE_URL + PAIRS_SG_ID + +else: + CARBON_SUBGRAPH_URL = ( + GRAPH_DEV_BASE_URL + "staging-polygon-digital-carbon" + GRAPH_VERSION_SUFFIX + ) + CARBON_LEGACY_SUBGRAPH_URL = ( + GRAPH_DEV_BASE_URL + "staging-polygon-bridged-carbon" + GRAPH_VERSION_SUFFIX + ) + CARBON_ETH_SUBGRAPH_URL = ( + GRAPH_DEV_BASE_URL + "staging-ethereum-bridged-carbon" + GRAPH_VERSION_SUFFIX + ) + CARBON_CELO_SUBGRAPH_URL = ( + GRAPH_DEV_BASE_URL + "staging-celo-bridged-carbon" + GRAPH_VERSION_SUFFIX + ) + CARBON_HOLDERS_SUBGRAPH_URL = ( + GRAPH_DEV_BASE_URL + "staging-klimadao-user-carbon" + GRAPH_VERSION_SUFFIX + ) + PAIRS_SUBGRAPH_URL = ( + GRAPH_DEV_BASE_URL + "staging-klimadao-pairs" + GRAPH_VERSION_SUFFIX + ) BCT_ADDRESS = "0x2f800db0fdb5223b3c3f354886d907a671414a7f" NCT_ADDRESS = "0xd838290e877e0188a4a44700463419ed96c16107"