Skip to content

Commit

Permalink
chore: upgrade to 0.6 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jan 31, 2023
1 parent a901217 commit 5af1e10
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 76 deletions.
15 changes: 8 additions & 7 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
name: Bug report
about: Report an error that you've encountered.
labels: 'bug'
labels: bug
---

### Environment information

* `ape` and plugin versions:
- `ape` and plugin versions:

```
$ ape --version
Expand All @@ -15,16 +16,16 @@ $ ape plugins list
# ...copy and paste result of above command here...
```

* Python Version: x.x.x
* OS: osx/linux/win
- Python Version: x.x.x
- OS: osx/linux/win

### What went wrong?

Please include information like:

* what command you ran
* the code that caused the failure (see [this link](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for help with formatting code)
* full output of the error you received
- what command you ran
- the code that caused the failure (see [this link](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for help with formatting code)
- full output of the error you received

### How can it be fixed?

Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
name: Feature request
about: Request a new feature, or an improvement to existing functionality.
labels: 'enhancement'
labels: enhancement
---

### Overview

Provide a simple overview of what you wish to see added. Please include:

* What you are trying to do
* Why Ape's current functionality is inadequate to address your goal
- What you are trying to do
- Why Ape's current functionality is inadequate to address your goal

### Specification

Expand Down
21 changes: 14 additions & 7 deletions .github/ISSUE_TEMPLATE/work-item.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
---
name: Work item
about: New work item for Ape team
labels: 'backlog'

labels: backlog
---

### Elevator pitch:

<!-- 1-2 line summary of the scope of this work item -->

### Value:

<!--
Who is this for?
Persona or group of people whom will derive value from the scenario.
What benefits will be achieved or business metrics improved?
-->

### Dependencies:

<!-- Call out key people, teams, tech dependencies, or assumptions. -->

### Design approach:

<!--
Free text / diagram / whiteboard picture / etc. that clearly shows your approach and considerations to build the task list.
Existing code patterns in production code base that you will base your work off of.
-->

### Task list:

<!-- Bulleted list describing the exit criteria, desired end state and any documentation, monitors, work for DRI, etc. that will need to be added to make sure someone else can support once it's live. -->
* [ ] Tasks go here

### Estimated completion date:
- [ ] Tasks go here

### Estimated completion date:

### Design review:

<!-- 1-2 people needed for signoff -->

Do not signoff unless:
- 1) agreed the tasks and design approach will achieve acceptance, and
- 2) the work can be completed by one person within the SLA.
Design reviewers should consider simpler approaches to achieve goals.

- 1. agreed the tasks and design approach will achieve acceptance, and
- 2. the work can be completed by one person within the SLA.
Design reviewers should consider simpler approaches to achieve goals.

(Please leave a comment to sign off)
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### What I did

<!-- The `fixes:` field denotes an issue that will be marked resolved by merging this PR -->

fixes: #

### How I did it
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ on: ["push", "pull_request"]

name: Test

concurrency:
# Cancel older, in-progress jobs from the same PR, same workflow.
# use run_id if the job is triggered by a push to ensure
# push-triggered jobs to not get canceled.
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
linting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand All @@ -22,20 +29,23 @@ jobs:
- name: Run Black
run: black --check .

- name: Run isort
run: isort --check-only .

- name: Run flake8
run: flake8 .

- name: Run isort
run: isort --check-only .
- name: Run mdformat
run: mdformat . --check

type-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand All @@ -56,10 +66,10 @@ jobs:
python-version: [3.8, 3.9, "3.10"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -81,10 +91,10 @@ jobs:
# fail-fast: true
#
# steps:
# - uses: actions/checkout@v2
# - uses: actions/checkout@v3
#
# - name: Setup Python
# uses: actions/setup-python@v2
# uses: actions/setup-python@v4
# with:
# python-version: 3.8
#
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,7 @@ version.py

# Ape stuff
.build/

**/.DS_Store
*.swp
*.swo
1 change: 1 addition & 0 deletions .mdformat.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
number = true
13 changes: 6 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 22.6.0
rev: 22.12.0
hooks:
- id: black
name: black

- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.971
rev: v0.991
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-requests]

additional_dependencies: [types-requests, types-setuptools, pydantic]

default_language_version:
python: python3.9
python: python3
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Quick Start

Ecosystem Plugin for Tenderly support in Ape
Ecosystem plugin for Tenderly support in Ape.

## Dependencies

* [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev
- [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev

## Installation

Expand All @@ -28,14 +28,16 @@ python3 setup.py install

## Quick Usage

This plugin works as a normal provider for forked mainnet networks only (e.g. Ethereum, Fantom, etc.)
This plugin works as a normal provider for forked mainnet networks only (e.g. Ethereum, Fantom, etc.).

If you know your fork ID (from the Tenderly console) you can use that like this

```sh
export TENDERLY_FORK_ID=...
```

If you have an API service that automatically provisions tenderly forks, you can use it like this

```sh
export TENDERLY_FORK_SERVICE_URI=...
```
2 changes: 1 addition & 1 deletion ape_tenderly/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ape import plugins

from .providers import TenderlyProvider
from .provider import TenderlyProvider


@plugins.register(plugins.ProviderPlugin)
Expand Down
15 changes: 9 additions & 6 deletions ape_tenderly/providers.py → ape_tenderly/provider.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import os

import requests # type: ignore
import requests
from ape.api import ProviderAPI, Web3Provider
from ape.exceptions import ConfigError
from ape.utils import cached_property
from web3 import HTTPProvider, Web3

TENDERLY_FORK_ID = "TENDERLY_FORK_ID"
TENDERLY_FORK_SERVICE_URI = "TENDERLY_FORK_SERVICE_URI"


class TenderlyProvider(Web3Provider, ProviderAPI):
@cached_property
def fork_id(self) -> str:
if "TENDERLY_FORK_ID" in os.environ:
return os.environ["TENDERLY_FORK_ID"]
if TENDERLY_FORK_ID in os.environ:
return os.environ[TENDERLY_FORK_ID]

elif "TENDERLY_FORK_SERVICE_URI" in os.environ:
elif TENDERLY_FORK_SERVICE_URI in os.environ:
fork_network_name = self.network.name.replace("-fork", "")
chain_id = self.network.ecosystem.get_network(fork_network_name).chain_id
response = requests.post(
os.environ["TENDERLY_FORK_SERVICE_URI"],
os.environ[TENDERLY_FORK_SERVICE_URI],
json={"network_id": str(chain_id)},
)
return response.json()["simulation_fork"]["id"]

else:
raise ConfigError("No valid tenderly fork id found.")
raise ConfigError("No valid tenderly fork ID found.")

@property
def uri(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0"]

[tool.mypy]
exclude = "build/"
plugins = ["pydantic.mypy"]

[tool.setuptools_scm]
write_to = "ape_tenderly/version.py"
Expand All @@ -19,7 +20,6 @@ include = '\.pyi?$'

[tool.pytest.ini_options]
addopts = """
-n auto
-p no:ape_test
--cov-branch
--cov-report term
Expand Down
Loading

0 comments on commit 5af1e10

Please sign in to comment.