Skip to content

Commit 8967bcc

Browse files
authored
Merge pull request #30 from bitpay/4.0.0-dev
New Major Version: 4.0.0
2 parents 45e53d3 + bd78c03 commit 8967bcc

File tree

226 files changed

+17282
-6343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+17282
-6343
lines changed

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
push:
9+
branches-ignore:
10+
- 'master'
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install pipenv
26+
run: |
27+
pip3 install pipenv
28+
pip3 install --upgrade pip
29+
- name: Install dependencies
30+
run: |
31+
pipenv install --dev
32+
pipenv run pip3 install typing-extensions
33+
- name: Run code formatter
34+
run: pipenv run black src/
35+
- name: Run static analysis
36+
run: |
37+
pipenv run mypy --install-types --non-interactive src/
38+
pipenv run mypy -p src
39+
- name: Run unit tests
40+
run: pipenv run pytest -vv -s -m unit

Pipfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
ecdsa = "==0.18.0"
8+
requests = "==2.28.2"
9+
10+
[dev-packages]
11+
black = "==23.3.0"
12+
pytest = "==7.3.1"
13+
pytest-mock = "==3.10.0"
14+
mypy = "==1.3.0"
15+
pytest-mypy-plugins = "==1.11.1"
16+
pytest-cov = "==4.1.0"
17+
18+
[requires]
19+
python_version = "3"

Pipfile.lock

Lines changed: 596 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/ledger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Facades : **`MERCHANT`**
8282
```python
8383
today = date.today().strftime("%Y%m%d")
8484
date_start = (date.today() - timedelta(days=100)).strftime("%Y%m%d")
85-
ledger = bitpay.get_ledger(Currency.USD, date_start, today)
85+
ledger = bitpay.get_ledger_entries(Currency.USD, date_start, today)
8686
print(ledger)
8787
```
8888

pytest.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[pytest]
2+
minversion = 7.0
3+
testpaths = tests
4+
python_files = test_*.py
5+
pythonpath = src
6+
addopts = "--import-mode=importlib"
7+
markers =
8+
unit: Unit test
9+
functional: Functional test

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.cfg

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
[metadata]
2-
description-file = README.md
2+
description-file = README.md
3+
4+
[mypy]
5+
disallow_untyped_defs = True
6+
ignore_missing_imports = True
7+
no_implicit_optional = True
8+
check_untyped_defs = True
9+
show_error_codes = True
10+
warn_unused_ignores = True

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
name="bitpay",
88
package_dir={"": "src"},
99
packages=setuptools.find_packages(where="src"),
10-
version="3.4.2203",
10+
version="4.0.0",
1111
description="Accept bitcoin with BitPay",
1212
author="Antonio Buedo",
1313
author_email="[email protected]",

src/bitpay/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bitpay.config.json

src/bitpay/bitpay_setup.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import os
22
import json
3+
from typing import Optional
4+
35
import requests
46

57
from bitpay.utils.key_utils import *
68
from bitpay.exceptions.bitpay_exception import BitPayException
79

810
# Will be set to Test otherwise
911
private_key_name = "private_key.pem" # Add here the name for your Private key
10-
private_key_path = os.path.join(os.path.abspath(os.curdir), private_key_name)
12+
private_key_path: Optional[str] = os.path.join(
13+
os.path.abspath(os.curdir), private_key_name
14+
)
1115
plain_private_key = None
1216
proxy = None
1317
api_url = None
@@ -16,7 +20,7 @@
1620
payout_token = None
1721

1822

19-
def select_env():
23+
def select_env() -> None:
2024
global environment
2125
try:
2226
print("Select target environment: ")
@@ -29,21 +33,21 @@ def select_env():
2933
else:
3034
select_env()
3135

32-
set_environment(environment)
36+
set_environment(environment) # type: ignore
3337
select_create_key()
3438
except BitPayException as exe:
3539
print(exe)
3640

3741

38-
def set_environment(env):
42+
def set_environment(env: str) -> None:
3943
global api_url
4044
if env == "Test":
4145
api_url = "https://test.bitpay.com"
4246
else:
4347
api_url = "https://bitpay.com"
4448

4549

46-
def select_create_key():
50+
def select_create_key() -> None:
4751
try:
4852
input_value = input(
4953
"Press enter to generate a brand new key or enter your private key location:"
@@ -56,15 +60,15 @@ def select_create_key():
5660
print(exe)
5761

5862

59-
def create_new_key():
63+
def create_new_key() -> None:
6064
try:
61-
private_key = generate_pem()
65+
private_key = generate_pem() # type: ignore
6266
store_key(private_key)
6367
except BitPayException as exe:
6468
print(exe)
6569

6670

67-
def store_key(private_key):
71+
def store_key(private_key: str) -> None:
6872
global plain_private_key, private_key_path
6973
try:
7074
print("Select the way you want to store your private key:")
@@ -89,7 +93,7 @@ def store_key(private_key):
8993
print(exe)
9094

9195

92-
def select_tokens(private_key):
96+
def select_tokens(private_key: str) -> None:
9397
try:
9498
print("Select the tokens that you would like to request:")
9599
input_value = input("Press M for merchant, P for payout, or B for both: \n")
@@ -102,12 +106,12 @@ def select_tokens(private_key):
102106
print(exe)
103107

104108

105-
def request_tokens(token_type, private_key):
109+
def request_tokens(token_type: str, private_key: str) -> None:
106110
global merchant_token
107111
global payout_token
108112

109113
try:
110-
sin = get_sin_from_pem(private_key)
114+
sin = get_sin_from_pem(private_key) # type: ignore
111115
url = "%s/tokens" % api_url
112116
headers = {"content-type": "application/json", "X-accept-version": "2.0.0"}
113117

@@ -148,7 +152,7 @@ def request_tokens(token_type, private_key):
148152
print(exe)
149153

150154

151-
def update_config_file():
155+
def update_config_file() -> None:
152156
try:
153157
config = {
154158
"BitPayConfiguration": {
@@ -187,7 +191,7 @@ def update_config_file():
187191
print(exe)
188192

189193

190-
def load_key():
194+
def load_key() -> None:
191195
# TODO: Need to implement this function
192196
pass
193197

0 commit comments

Comments
 (0)