Skip to content

Commit e028bac

Browse files
authored
Merge pull request #245 from crypkit/feat-python-3.12-update
feat: make blockapi run under python 3.12
2 parents 65c5bfa + 6edd0b1 commit e028bac

11 files changed

Lines changed: 240 additions & 73 deletions

File tree

.github/workflows/blockapi-ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ jobs:
1414
with:
1515
fetch-depth: 0
1616

17-
- name: Set up Python 3.9
17+
- name: Set up Python 3.12.11
1818
uses: actions/setup-python@v4
1919
with:
20-
python-version: '3.9'
20+
python-version: '3.12.11'
21+
22+
- name: Verify Python
23+
run: python --version
2124

2225
- name: Restore cache
2326
uses: actions/cache@v3

blockapi/services.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
from datetime import datetime
44
from time import sleep
55

6-
import cfscrape
76
import requests
87

98
import blockapi
109

11-
cfscrape.DEFAULT_CIPHERS += ':!SHA'
12-
1310

1411
class Service(ABC):
1512
"""General class for handling blockchain API services."""
@@ -34,13 +31,7 @@ def build_request_url(self, request_method, **params):
3431
return self.base_url
3532

3633
def request(
37-
self,
38-
request_method,
39-
with_rate_limit=False,
40-
with_cloudflare=False,
41-
body=None,
42-
headers=None,
43-
**params
34+
self, request_method, with_rate_limit=False, body=None, headers=None, **params
4435
):
4536
request_url = self.build_request_url(request_method, **params)
4637

@@ -53,10 +44,7 @@ def request(
5344
if not headers:
5445
headers = {}
5546

56-
if with_cloudflare:
57-
reqobj = cfscrape.create_scraper()
58-
else:
59-
reqobj = requests
47+
reqobj = requests
6048

6149
if with_rate_limit and self.rate_limit:
6250
self.wait_for_next_request()
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
Referer:
12+
- https://www.mintscan.io/
13+
User-Agent:
14+
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML,
15+
like Gecko) Chrome/50.0.2661.102 Safari/537.36
16+
method: GET
17+
uri: https://lcd-dydx.cosmostation.io/cosmos/bank/v1beta1/balances/dydx1aff76avnwpnk02wxkc6n5xnwasjkgekarwznsh
18+
response:
19+
body:
20+
string: '{"balances":[{"denom":"adydx","amount":"8342195962385344539"}],"pagination":{"next_key":null,"total":"1"}}'
21+
headers:
22+
Access-Control-Allow-Headers:
23+
- DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
24+
Access-Control-Allow-Methods:
25+
- GET, POST, OPTIONS
26+
Access-Control-Expose-Headers:
27+
- Content-Length,Content-Range
28+
Connection:
29+
- keep-alive
30+
Content-Encoding:
31+
- gzip
32+
Content-Type:
33+
- application/json
34+
Date:
35+
- Thu, 28 Aug 2025 13:12:14 GMT
36+
Grpc-Metadata-Content-Type:
37+
- application/grpc+cosmos-sdk-grpc-codec
38+
Grpc-Metadata-X-Cosmos-Block-Height:
39+
- '53991912'
40+
Server:
41+
- nginx
42+
Transfer-Encoding:
43+
- chunked
44+
Vary:
45+
- Accept-Encoding
46+
X-Server-Time:
47+
- '1756386734'
48+
status:
49+
code: 200
50+
message: OK
51+
- request:
52+
body: null
53+
headers:
54+
Accept:
55+
- '*/*'
56+
Accept-Encoding:
57+
- gzip, deflate
58+
Connection:
59+
- keep-alive
60+
Referer:
61+
- https://www.mintscan.io/
62+
User-Agent:
63+
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML,
64+
like Gecko) Chrome/50.0.2661.102 Safari/537.36
65+
method: GET
66+
uri: https://lcd-dydx.cosmostation.io/cosmos/staking/v1beta1/delegations/dydx1aff76avnwpnk02wxkc6n5xnwasjkgekarwznsh?pagination.limit=1000
67+
response:
68+
body:
69+
string: '{"delegation_responses":[],"pagination":{"next_key":null,"total":"0"}}'
70+
headers:
71+
Access-Control-Allow-Headers:
72+
- DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
73+
Access-Control-Allow-Methods:
74+
- GET, POST, OPTIONS
75+
Access-Control-Expose-Headers:
76+
- Content-Length,Content-Range
77+
Connection:
78+
- keep-alive
79+
Content-Length:
80+
- '70'
81+
Content-Type:
82+
- application/json
83+
Date:
84+
- Thu, 28 Aug 2025 13:12:15 GMT
85+
Grpc-Metadata-Content-Type:
86+
- application/grpc+cosmos-sdk-grpc-codec
87+
Grpc-Metadata-X-Cosmos-Block-Height:
88+
- '53991912'
89+
Server:
90+
- nginx
91+
X-Server-Time:
92+
- '1756386735'
93+
status:
94+
code: 200
95+
message: OK
96+
- request:
97+
body: null
98+
headers:
99+
Accept:
100+
- '*/*'
101+
Accept-Encoding:
102+
- gzip, deflate
103+
Connection:
104+
- keep-alive
105+
Referer:
106+
- https://www.mintscan.io/
107+
User-Agent:
108+
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML,
109+
like Gecko) Chrome/50.0.2661.102 Safari/537.36
110+
method: GET
111+
uri: https://lcd-dydx.cosmostation.io/cosmos/staking/v1beta1/delegators/dydx1aff76avnwpnk02wxkc6n5xnwasjkgekarwznsh/unbonding_delegations
112+
response:
113+
body:
114+
string: '{"unbonding_responses":[],"pagination":{"next_key":null,"total":"0"}}'
115+
headers:
116+
Access-Control-Allow-Headers:
117+
- DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
118+
Access-Control-Allow-Methods:
119+
- GET, POST, OPTIONS
120+
Access-Control-Expose-Headers:
121+
- Content-Length,Content-Range
122+
Connection:
123+
- keep-alive
124+
Content-Length:
125+
- '69'
126+
Content-Type:
127+
- application/json
128+
Date:
129+
- Thu, 28 Aug 2025 13:12:16 GMT
130+
Grpc-Metadata-Content-Type:
131+
- application/grpc+cosmos-sdk-grpc-codec
132+
Grpc-Metadata-X-Cosmos-Block-Height:
133+
- '53991913'
134+
Server:
135+
- nginx
136+
X-Server-Time:
137+
- '1756386736'
138+
status:
139+
code: 200
140+
message: OK
141+
- request:
142+
body: null
143+
headers:
144+
Accept:
145+
- '*/*'
146+
Accept-Encoding:
147+
- gzip, deflate
148+
Connection:
149+
- keep-alive
150+
Referer:
151+
- https://www.mintscan.io/
152+
User-Agent:
153+
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML,
154+
like Gecko) Chrome/50.0.2661.102 Safari/537.36
155+
method: GET
156+
uri: https://lcd-dydx.cosmostation.io/cosmos/distribution/v1beta1/delegators/dydx1aff76avnwpnk02wxkc6n5xnwasjkgekarwznsh/rewards
157+
response:
158+
body:
159+
string: '{"rewards":[],"total":[]}'
160+
headers:
161+
Access-Control-Allow-Headers:
162+
- DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
163+
Access-Control-Allow-Methods:
164+
- GET, POST, OPTIONS
165+
Access-Control-Expose-Headers:
166+
- Content-Length,Content-Range
167+
Connection:
168+
- keep-alive
169+
Content-Length:
170+
- '25'
171+
Content-Type:
172+
- application/json
173+
Date:
174+
- Thu, 28 Aug 2025 13:12:16 GMT
175+
Grpc-Metadata-Content-Type:
176+
- application/grpc+cosmos-sdk-grpc-codec
177+
Grpc-Metadata-X-Cosmos-Block-Height:
178+
- '53991914'
179+
Server:
180+
- nginx
181+
X-Server-Time:
182+
- '1756386736'
183+
status:
184+
code: 200
185+
message: OK
186+
version: 1

blockapi/test/v2/api/cassettes/test_fetch_metaplex_account.yaml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,14 @@ interactions:
1414
Content-Type:
1515
- application/json
1616
User-Agent:
17-
- python-requests/2.31.0
17+
- python-requests/2.32.5
1818
method: POST
1919
uri: https://api.mainnet-beta.solana.com/
2020
response:
2121
body:
22-
string: !!binary |
23-
H4sIAAAAAAAEA6pWyirOzysqSFayUjLSM1DSUSpKLS7NKVGyqlZKzs8rSa0AMxMLMsNSi4oz8/OU
24-
rJQM9Qwt9IxMlXSUinPyS5SsjCzNDYwsjU1ManWUyhJzSlNBmlMSSxKVrKKVnLxM87MjgvJKQl1T
25-
y0vdM0sD/T19w0sstCOzy9zyIs31XfLTMwIqq0wLy/3yLcrDC6ryM3KSvQOywj1dnHOM89LT3YtL
26-
jJ1T3cpCtQMMyx3NKv18M3It0h0dHR0Dw/0MPF2z0/0znUIT3UPTA0Oz00M9vMqS3TNyIo2zQUpg
27-
2BvECAz1CwXRYOwLMsIpP8UjqDy5Kr/MxyglI8U9zDgyIrs02T2nNDIiKMMn1684yTgs28copzwq
28-
z7csNNwwPCrbMDDQMCwwuSos3DfcsiQyNMgoyci0wLcqw9jf3c0tOM/JPcy9wC08x8s/NNewLCwv
29-
JyfVLSMiKhBs6+An0kycHEFBM/hdOrxcGGhrq6SjlJRYnGpmohSro5RakZpcWpKYlJOqZJWWmFOc
30-
qqOUk5hbkF9UUqxkZWhqaGhqZmCgo5RfnpdapGSllJtakliYVFERmlqUUmhkkZxlGJTkGJ4dGZhr
31-
XJlUlZVklmiRVGJqaFFhWAzO5IDllbgW5CdnKFkZWpiYmJmbmBiYG5sbWJqaGpoZmuooFRckJqcq
32-
WZkZmNfW6ihlpihZGdZyAQAzXeNRLQQAAA==
22+
string: '{"jsonrpc":"2.0","result":{"context":{"apiVersion":"2.3.6","slot":363077074},"value":{"data":["BJ5okXRntUEewuGiuQOIMWt8+YkvFnY7/DoghPyz5qwNo8wWpzohlcKPjWIDCl3nggGst3CeFvU+P1wA6yNMhm8gAAAAQWN0IEkgOiBUaGUgQUkgUHJvcGhlY3kAAAAAAAAAAAAKAAAAQUNUAAAAAAAAAMgAAABodHRwczovL2dhdGV3YXkucGluYXRhLmNsb3VkL2lwZnMvUW1WZk1QQ1VQczVWMW9tYUR2b25pMzh3OGFFSnBGVGpFWlJOUm1vVnlleFhXZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf4BAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==","base64"],"executable":false,"lamports":5115600,"owner":"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s","rentEpoch":18446744073709551615,"space":607}},"id":1}
23+
24+
'
3325
headers:
3426
access-control-allow-headers:
3527
- authorization, *
@@ -46,7 +38,7 @@ interactions:
4638
content-type:
4739
- application/json; charset=utf-8
4840
date:
49-
- Tue, 22 Oct 2024 09:44:34 GMT
41+
- Thu, 28 Aug 2025 13:00:35 GMT
5042
transfer-encoding:
5143
- chunked
5244
vary:
@@ -62,11 +54,11 @@ interactions:
6254
x-ratelimit-endpoint-limit:
6355
- unlimited
6456
x-ratelimit-endpoint-remaining:
65-
- '-778'
57+
- '-2506'
6658
x-ratelimit-method-limit:
67-
- '10'
59+
- '30'
6860
x-ratelimit-method-remaining:
69-
- '9'
61+
- '29'
7062
x-ratelimit-pubsub-limit:
7163
- '5'
7264
x-ratelimit-pubsub-remaining:
@@ -78,7 +70,7 @@ interactions:
7870
x-ratelimit-tier:
7971
- free
8072
x-rpc-node:
81-
- lon68
73+
- fra113
8274
status:
8375
code: 200
8476
message: OK

blockapi/test/v2/api/cassettes/test_parse_metaplex_account.yaml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,51 @@ interactions:
99
Connection:
1010
- keep-alive
1111
User-Agent:
12-
- python-requests/2.31.0
12+
- python-requests/2.32.5
1313
method: GET
1414
uri: https://gateway.pinata.cloud/ipfs/QmVfMPCUPs5V1omaDvoni38w8aEJpFTjEZRNRmoVyexXWe
1515
response:
1616
body:
17-
string: !!binary |
18-
H4sIAAAAAAAAAwAAAP//RI9Ba8JAFITv/oohZzVYLAVvWjwI1dqq0FJ6eJs8s6vJ7rr7Qkyl/70k
19-
Hnp8wzfzZm4DILFUcTJDMs8EK8yw14z5CtvgvOasTYYdFNtKubLHnvd3yVRU9EYt4uMsTQsSbqgd
20-
e2NJaJyVrs5T448xfat202qaLU71uXj61Ka66OP7QT34w3KqFtsPFdR6oR71z3WjDvN7fM4xC8aL
21-
cfa/nYlwluGOEM04cgMf3IkzieCrL10wtoB2DcSBbUEFozGiuz2KW2dzEDJX5iCbI6fKYzJydjRB
22-
HTmkFKOJQlbgKVBuimoIVQsogmBZGhfO3W++1FTGe02+CttonI3JDLffXhMquutrAADJ7vVlvrmP
23-
ApL1cr1MBsB3T2aBSVzorYPfPwAAAP//AwAE4qjcjwEAAA==
17+
string: "{\n \"name\": \"Act I : The AI Prophecy\",\n \"symbol\": \"ACT\",\n
18+
\ \"image\": \"https://gateway.pinata.cloud/ipfs/QmS4m4cBjukg7YhimqhfRUb2pUE4bBPXbrbMBb5hzxNbUA\",\n
19+
\ \"description\": \"Act I is one of the few projects exploring how to engage
20+
with AI beyond a cold and damp 1-on-1 user/assistant paradigm, but as a network
21+
of equals\",\n \"extensions\": {},\n \"tags\": [\n \"SOLANA\",\n \"MEME\"\n
22+
\ ],\n \"creator\": {}\n}"
2423
headers:
2524
Access-Control-Allow-Origin:
2625
- '*'
2726
Age:
28-
- '198388'
27+
- '4776'
2928
CF-Cache-Status:
3029
- HIT
3130
CF-Ray:
32-
- 8d688cb5c809cbf3-MAD
31+
- 976409232f4f80e8-PRG
3332
Cache-Control:
34-
- public, max-age=864000
33+
- public, max-age=29030400
3534
Connection:
3635
- keep-alive
3736
Content-Encoding:
3837
- gzip
3938
Content-Type:
4039
- application/json
4140
Date:
42-
- Tue, 22 Oct 2024 09:44:35 GMT
41+
- Thu, 28 Aug 2025 13:08:13 GMT
4342
ETag:
4443
- W/"QmVfMPCUPs5V1omaDvoni38w8aEJpFTjEZRNRmoVyexXWe"
4544
Expires:
46-
- Fri, 01 Nov 2024 09:44:35 GMT
45+
- Thu, 30 Jul 2026 13:08:13 GMT
4746
Server:
4847
- cloudflare
48+
Set-Cookie:
49+
- _cfuvid=s8i55DXcFh0WBxtugckw0rwrB6ACUXr.ttgTn8ZQbvc-1756386493815-0.0.1.1-604800000;
50+
path=/; domain=.pinata.cloud; HttpOnly; Secure; SameSite=None
4951
Strict-Transport-Security:
50-
- max-age=15724800; includeSubDomains
52+
- max-age=31536000; includeSubDomains
5153
Transfer-Encoding:
5254
- chunked
5355
Vary:
5456
- Accept-Encoding
55-
Via:
56-
- 1.1 3e64b4bceb49543044d7ca6510e86e3a.cloudfront.net (CloudFront)
5757
X-Robots-Tag:
5858
- noindex
5959
access-control-allow-headers:
@@ -75,18 +75,10 @@ interactions:
7575
content-security-policy:
7676
- 'default-src ''self''; img-src * data: blob: ''unsafe-inline''; style-src
7777
* ''unsafe-inline'''
78-
x-amz-cf-id:
79-
- Q2h-wBzIZXZ7r_fJ0O1vRsDizW7pZVa6jf0Ig2nKKR60zWRFmKpIow==
80-
x-amz-cf-pop:
81-
- MAD56-P1
82-
x-cache:
83-
- Hit from cloudfront
8478
x-ipfs-path:
8579
- /ipfs/QmVfMPCUPs5V1omaDvoni38w8aEJpFTjEZRNRmoVyexXWe
8680
x-ipfs-roots:
8781
- QmVfMPCUPs5V1omaDvoni38w8aEJpFTjEZRNRmoVyexXWe
88-
x-request-id:
89-
- 9d0047ad6bed38faa10f9dd5ae9de7b1
9082
status:
9183
code: 200
9284
message: OK

0 commit comments

Comments
 (0)