-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #335 from eosnetworkfoundation/kayan_test_brownie
[1.0] Kayan brownie integration
- Loading branch information
Showing
4 changed files
with
707 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
from flask import Flask, request, jsonify | ||
from flask_cors import CORS | ||
import requests | ||
import json | ||
|
||
app = Flask(__name__) | ||
CORS(app) | ||
writemethods = {"eth_sendRawTransaction","eth_gasPrice"} | ||
readEndpoint = "http://127.0.0.1:8881" | ||
writeEndpoint = os.getenv("WRITE_RPC_ENDPOINT", "http://127.0.0.1:18888") | ||
flaskListenPort = os.getenv("FLASK_SERVER_PORT", 5000) | ||
|
||
import logging | ||
log = logging.getLogger('werkzeug') | ||
log.setLevel(logging.ERROR) | ||
|
||
@app.route("/", methods=["POST"]) | ||
def default(): | ||
def forward_request(req): | ||
if type(req) == dict and ("method" in req) and (req["method"] in writemethods): | ||
#print("send req to miner:" + str(req)) | ||
resp = requests.post(writeEndpoint, json.dumps(req), headers={"Accept":"application/json","Content-Type":"application/json"}).json() | ||
#print("got resp from miner:" + str(resp)) | ||
return resp | ||
else: | ||
#print("send req to eos-evm-rpc:" + str(req)) | ||
resp = requests.post(readEndpoint, json.dumps(req), headers={"Accept":"application/json","Content-Type":"application/json"}).json() | ||
#print("got from eos-evm-rpc:" + str(resp)) | ||
return resp | ||
|
||
request_data = request.get_json() | ||
if type(request_data) == dict: | ||
return jsonify(forward_request(request_data)) | ||
|
||
res = [] | ||
for r in request_data: | ||
res.append(forward_request(r)) | ||
|
||
return jsonify(res) | ||
|
||
app.run(host='0.0.0.0', port=flaskListenPort) |
Oops, something went wrong.