Skip to content

Commit

Permalink
remove INFURA_KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Apr 19, 2024
1 parent d141d58 commit 41b3745
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 20 deletions.
2 changes: 0 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ DUNE_QUERY_ID=
# Official Dune API
DUNE_API_KEY=

INFURA_KEY=

ORDERBOOK_HOST=
ORDERBOOK_USER=
ORDERBOOK_PORT=
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.10
- name: Setup Python 3.12
uses: actions/setup-python@v2
with:
python-version: '3.10'
python-version: '3.12'
- name: Install Requirements
run:
pip install -r requirements.txt
Expand All @@ -26,5 +26,3 @@ jobs:
- name: Unit Tests
run:
python -m pytest tests
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ New updated Docker instructions:
```shell
docker run \
-e SPELLBOOK_PATH=$SPELLBOOK_PATH \
-e INFURA_KEY=$INFURA_KEY \
-e DUNE_API_KEY=$DUNE_API_KEY \
-v $SPELLBOOK_PATH:$SPELLBOOK_PATH \
ghcr.io/cowprotocol/data-misc-missing-tokens:main
```

Note that this will require `SPELLBOOK_PATH`, `DUNE_API_KEY` and `INFURA_KEY` variables set.
Note that this will require `SPELLBOOK_PATH`, `DUNE_API_KEY` variables set.

Step-by-step instructions:

Expand All @@ -47,7 +46,7 @@ clone it to your local machine, and create a new branch with
```sh
python -m src.missing_tokens
```
Note that this will require a `DUNE_API_KEY` and `INFURA_KEY`.
Note that this will require a `DUNE_API_KEY`
This script will print the contents to be inserted in the console.
4. Results should be inserted into:
- V1 - `deprecated-dune-v1-abstractions/ethereum/erc20/tokens.sql`
Expand Down
4 changes: 1 addition & 3 deletions src/gas_saved.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def main(batch_tx_hash: str) -> int:
# Ref: https://github.com/cowprotocol/services/blob/fd5f7cf47a6afdff89b310b60b869dfc577ac7a7/crates/shared/src/price_estimation/gas.rs#L37
df_quotes["gas_amount"] = df_quotes["gas_amount"].apply(lambda x: x - 106391)
load_dotenv()
w3 = Web3(
Web3.HTTPProvider(f"https://mainnet.infura.io/v3/{os.environ['INFURA_KEY']}")
)
w3 = Web3(Web3.HTTPProvider("https://rpc.ankr.com/eth"))
tx: TxReceipt = w3.eth.get_transaction_receipt(HexStr(batch_tx_hash))
gas_used = tx["gasUsed"]
print(
Expand Down
6 changes: 3 additions & 3 deletions src/missing_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def as_dune_v2_repr(self) -> str:
"""Returns Dune V1 Network String (as compatible with Dune V2 Engine)"""
return {Network.MAINNET: "ethereum", Network.GNOSIS: "gnosis"}[self]

def node_url(self, api_key: str) -> str:
def node_url(self) -> str:
"""Returns URL to Node for Network"""
return {
Network.MAINNET: f"https://mainnet.infura.io/v3/{api_key}",
Network.MAINNET: "https://rpc.ankr.com/eth",
Network.GNOSIS: "https://rpc.gnosischain.com",
}[self]

Expand Down Expand Up @@ -116,7 +116,7 @@ def replace_line(old_line: str, new_line: str, file_loc: str) -> None:

def run_missing_tokens(chain: Network, insert_loc: Optional[str] = None) -> None:
"""Script's main entry point, runs for given network."""
w3 = Web3(Web3.HTTPProvider(chain.node_url(os.environ["INFURA_KEY"])))
w3 = Web3(Web3.HTTPProvider(chain.node_url()))
client = DuneClient(os.environ["DUNE_API_KEY"])
missing_tokens = fetch_missing_tokens(client, chain)

Expand Down
2 changes: 1 addition & 1 deletion src/subgraph/ens_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}

load_dotenv()
w3 = Web3(Web3.HTTPProvider(f"https://mainnet.infura.io/v3/{os.environ['INFURA_KEY']}"))
w3 = Web3(Web3.HTTPProvider("https://rpc.ankr.com/eth"))


def read_ens_text(resolver: str, node: str, key: str) -> str:
Expand Down
6 changes: 2 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ def test_network_class(self):
self.assertEqual(gnosis.chain_id, 100)
self.assertEqual(mainnet.chain_id, 1)

self.assertEqual(gnosis.node_url("FakeKey"), "https://rpc.gnosischain.com")
self.assertEqual(
mainnet.node_url("FakeKey"), "https://mainnet.infura.io/v3/FakeKey"
)
self.assertEqual(gnosis.node_url(), "https://rpc.gnosischain.com")
self.assertEqual(mainnet.node_url(), "https://rpc.ankr.com/eth")

self.assertEqual(gnosis.as_dune_v2_repr(), "gnosis")
self.assertEqual(mainnet.as_dune_v2_repr(), "ethereum")
Expand Down

0 comments on commit 41b3745

Please sign in to comment.