Compare commits

...

10 Commits

Author SHA1 Message Date
a6364d3208
Update ranchimallflo_api.py
Added testnet address checking for smartcontracts
2024-12-01 12:29:51 +05:30
21f421a5a4
Update README.md 2024-12-01 10:49:31 +05:30
82d296c0e6
Update README.md 2024-12-01 10:49:10 +05:30
bfd10addba
Create ranchimallflo_api.py 2024-12-01 10:45:18 +05:30
b19f2b0beb
Update config.ini 2024-12-01 10:40:46 +05:30
b69097c64b
Update config.ini
Merging Scanner and API configs
2024-12-01 10:40:02 +05:30
b2a7ce64b4
Update tracktokens_smartcontracts.py 2024-12-01 10:34:38 +05:30
a724c1b22d
Merged requirements.txt for Scanner and API 2024-12-01 10:33:40 +05:30
e44e5e7192
Update README.md 2024-11-28 06:37:05 +05:30
b6cf2080e1
Update setup.sh 2024-11-28 06:29:52 +05:30
6 changed files with 4540 additions and 57 deletions

View File

@ -1,21 +1,28 @@
# What is it
This contains both RanchiMall Token SmartContract Scanner, as well as API on MYSQL. Installation for Scanner will also install all dependencies for API.
# Howto start the MYSQL version
## Setup setps
1. Run setup.sh to install python3.7 virtual environment, install and configure MySQL if it does not exist, install all dependencies and then start the application.
2. Give setup.sh execute permissions first `chmod +x setup.sh`, and then `./setup.sh`
1. Just download one file from this setup.sh and run it. It will download the rest of repository
2. Give setup.sh execute permissions first `chmod +x setup.sh`, and then `./setup.sh`
3. Run setup.sh to install python3.7 virtual environment, install and configure MySQL if it does not exist, install all dependencies and then start the application.
## How to run
1. python3.7 tracktokens-smartcontracts.py
2. python3.7 tracktokens-smartcontracts.py --reset
3. python3.7 tracktokens-smartcontracts.py --rebuild
4. python3.7 tracktokens-smartcontracts.py --rebuild usd# tokenroom#
### Scanner
1. python3 tracktokens-smartcontracts.py
2. python3 tracktokens-smartcontracts.py --reset
3. python3 tracktokens-smartcontracts.py --rebuild
4. python3 tracktokens-smartcontracts.py --rebuild usd# tokenroom#
1. python3.7 tracktokens-smartcontracts.py => To run normally
2. python3.7 tracktokens-smartcontracts.py --reset => To remove all data and start from scratch
3. python3.7 tracktokens-smartcontracts.py --rebuild => To reprocess existing blockchain data for ALL TOKENS as stored in latestBlocks table of rm_latestCache_db database
4. python3.7 tracktokens-smartcontracts.py --rebuild usd# tokenroom# => To reprocess existing blockchain data for USD# TOKENROOM# as stored in latestBlocks table of rm_latestCache_db database
1. python3 tracktokens-smartcontracts.py => To run normally
2. python3 tracktokens-smartcontracts.py --reset => To remove all data and start from scratch
3. python3 tracktokens-smartcontracts.py --rebuild => To reprocess existing blockchain data for ALL TOKENS as stored in latestBlocks table of rm_latestCache_db database
4. python3 tracktokens-smartcontracts.py --rebuild usd# tokenroom# => To reprocess existing blockchain data for USD# TOKENROOM# as stored in latestBlocks table of rm_latestCache_db database
### API
1. python3 ranchimallflo_api.py
# FLO Token & Smart Contract System
[![Test flodata parsing](https://github.com/ranchimall/flo-token-tracking/actions/workflows/test_parsing.yml/badge.svg?branch=swap-statef-testing)](https://github.com/ranchimall/flo-token-tracking/actions/workflows/test_parsing.yml)

View File

@ -2,9 +2,9 @@
NET = mainnet
FLO_CLI_PATH = /usr/local/bin/flo-cli
START_BLOCK = 3387923
FLOSIGHT_NETURL = https://blockbook.ranchimall.net/
TESTNET_FLOSIGHT_SERVER_LIST = https://0.0.0.0:19166/
MAINNET_FLOSIGHT_SERVER_LIST = https://blockbook.ranchimall.net/
BLOCKBOOK_NETURL = https://blockbook.ranchimall.net/
TESTNET_BLOCKBOOK_SERVER_LIST = https://0.0.0.0:19166/
MAINNET_BLOCKBOOK_SERVER_LIST = https://blockbook.ranchimall.net/
TOKENAPI_SSE_URL = https://ranchimallflo-blockbook.ranchimall.net
IGNORE_BLOCK_LIST = 2
IGNORE_TRANSACTION_LIST = b4
@ -16,3 +16,14 @@ USERNAME = FUfB6cwSsGDbQpmA7Qs8zQJxU3HpwCdnjT
PASSWORD = RAcifrTM2V75ipy5MeLYaDU3UNcUXtrit933TGM5o7Yj2fs8XdP5
HOST = localhost
DATABASE_PREFIX = rm
[API]
APIHOST = localhost
APIPORT = 5432
apiUrl = https://blockbook.ranchimall.net/
# Timeout configurations
RETRY_TIMEOUT_LONG = 1800
RETRY_TIMEOUT_SHORT = 60
DB_RETRY_TIMEOUT = 60
API_TIMEOUT = 1

4458
ranchimallflo_api.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,43 @@
aiofiles
aiohttp
aiomysql
apscheduler==3.9.1
arrow==1.1.0
arduino
bidict==0.21.2
certifi==2021.5.30
cffi==1.14.5
blinker==1.4
cachetools
certifi==2022.12.7
cffi
chardet==3.0.4
Click==7.0
cryptography
DBUtils
greenlet==1.1.0
h11==0.9.0
h2==3.1.1
hpack==3.0.0
Hypercorn==0.8.2
hyperframe==5.2.0
idna==2.10
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe
multidict==4.5.2
priority==1.3.0
pycparser==2.20
pyflo-lib==2.0.9
pymysql
python-dateutil==2.8.1
python-engineio==3.14.2
websockets==11.0.3
Quart==0.10.0
Quart-CORS==0.2.0
requests==2.25.0
six==1.16.0
sortedcontainers==2.1.0
SQLAlchemy==1.4.18
toml==0.10.0
typing-extensions==3.7.4
urllib3==1.26.5
pyflo-lib==2.0.9
pymysql
cryptography
arduino
websockets==11.0.3
wsproto==0.15.0

View File

@ -77,12 +77,13 @@ sudo mysql -e "FLUSH PRIVILEGES;"
echo "MySQL user '${MYSQL_USER}' created and granted privileges on databases matching 'rm_%_db'."
# Step 8: Clone the PyFLO Repository
if [ ! -d "pyflo" ]; then
echo "Cloning the PyFLO repository..."
git clone https://github.com/ranchimall/pyflo
# Step 8: Clone the FLO Token Tracking Repository Only if `setup.sh` Is Not Already Inside the Repository Directory
if [ ! -f "tracktokens-smartcontracts.py" ]; then
echo "Cloning the FLO Token Tracking repository (mysql-migration branch)..."
git clone --branch mysql-migration https://github.com/ranchimall/flo-token-tracking
cd flo-token-tracking
else
echo "PyFLO repository already exists. Skipping clone."
echo "Setup is already in the directory containing the repository. Skipping clone."
fi
# Step 9: Install Python Dependencies
@ -105,26 +106,7 @@ pip install --upgrade pip
# Install Python packages
pip install --use-pep517 -r requirements.txt
# Step 10: Install PyFLO
echo "Installing PyFLO..."
sudo python3 pyflo/setup.py install
# Inform the user
echo "Python dependencies and PyFLO installed successfully."
# Step 11: Clone the FLO Token Tracking Repository
if [ ! -d "flo-token-tracking" ]; then
echo "Cloning the FLO Token Tracking repository (mysql-migration branch)..."
git clone --branch mysql-migration https://github.com/ranchimall/flo-token-tracking
else
echo "FLO Token Tracking repository already exists. Skipping clone."
fi
# Step 12: Navigate into the FLO Token Tracking Directory
echo "Navigating into the FLO Token Tracking directory..."
cd flo-token-tracking
# Step 13: Start the Python Application
# Step 10: Start the Python Application
echo "Starting the Python application 'tracktokens-smartcontracts.py'..."
python3.7 tracktokens-smartcontracts.py

View File

@ -261,7 +261,7 @@ def refresh_committee_list_old(admin_flo_id, api_url, blocktime):
if response.status_code == 200:
response = response.json()
else:
logger.info('Response from the Flosight API failed')
logger.info('Response from the Blockbook API failed')
sys.exit(0)
committee_list = []
@ -302,11 +302,11 @@ def refresh_committee_list(admin_flo_id, api_url, blocktime):
if response.status_code == 200:
return response.json()
else:
logger.info(f'Response from the Flosight API failed. Retry in {RETRY_TIMEOUT_SHORT}s')
logger.info(f'Response from the Blockbook API failed. Retry in {RETRY_TIMEOUT_SHORT}s')
#sys.exit(0)
time.sleep(RETRY_TIMEOUT_SHORT)
except:
logger.info(f'Fetch from the Flosight API failed. Retry in {RETRY_TIMEOUT_LONG}s...')
logger.info(f'Fetch from the Blockbook API failed. Retry in {RETRY_TIMEOUT_LONG}s...')
time.sleep(RETRY_TIMEOUT_LONG)
url = f'{api_url}api/v1/address/{admin_flo_id}?details=txs'
@ -2983,7 +2983,7 @@ def scanBlockchain():
processBlock(blockindex=blockindex)
# At this point the script has updated to the latest block
# Now we connect to flosight's websocket API to get information about the latest blocks
# Now we connect to Blockbook's websocket API to get information about the latest blocks
def switchNeturl(currentneturl):
# Use modulo operation to simplify the logic
@ -2992,9 +2992,9 @@ def switchNeturl(currentneturl):
def reconnectWebsocket(socket_variable):
# Switch a to different flosight
# Switch a to different Blockbook
# neturl = switchNeturl(neturl)
# Connect to Flosight websocket to get data on new incoming blocks
# Connect to Blockbook websocket to get data on new incoming blocks
i=0
newurl = serverlist[0]
while(not socket_variable.connected):
@ -3073,7 +3073,8 @@ logging.getLogger('sqlalchemy.pool').setLevel(logging.WARNING)
logging.getLogger('sqlalchemy.dialects').setLevel(logging.WARNING)
formatter = logging.Formatter('%(asctime)s:%(name)s:%(message)s')
file_handler = logging.FileHandler(os.path.join(config['DEFAULT']['DATA_PATH'],'tracking.log'))
DATA_PATH = os.path.dirname(os.path.abspath(__file__))
file_handler = logging.FileHandler(os.path.join(DATA_PATH, 'tracking.log'))
file_handler.setLevel(logging.INFO)
file_handler.setFormatter(formatter)
@ -3087,7 +3088,7 @@ logger.addHandler(stream_handler)
# Rule 1 - Read command line arguments to reset the databases as blank
# Rule 2 - Read config to set testnet/mainnet
# Rule 3 - Set flo blockexplorer location depending on testnet or mainnet
# Rule 4 - Set the local flo-cli path depending on testnet or mainnet ( removed this feature | Flosights are the only source )
# Rule 4 - Set the local flo-cli path depending on testnet or mainnet ( removed this feature | Blockbooks are the only source )
# Rule 5 - Set the block number to scan from
@ -3111,15 +3112,15 @@ if (config['DEFAULT']['NET'] != 'mainnet') and (config['DEFAULT']['NET'] != 'tes
# Specify ADMIN ID
serverlist = None
if config['DEFAULT']['NET'] == 'mainnet':
serverlist = config['DEFAULT']['MAINNET_FLOSIGHT_SERVER_LIST']
serverlist = config['DEFAULT']['MAINNET_BLOCKBOOK_SERVER_LIST']
APP_ADMIN = 'FNcvkz9PZNZM3HcxM1XTrVL4tgivmCkHp9'
websocket_uri = get_websocket_uri(testnet=False)
elif config['DEFAULT']['NET'] == 'testnet':
serverlist = config['DEFAULT']['TESTNET_FLOSIGHT_SERVER_LIST']
serverlist = config['DEFAULT']['TESTNET_BLOCKBOOK_SERVER_LIST']
APP_ADMIN = 'oWooGLbBELNnwq8Z5YmjoVjw8GhBGH3qSP'
websocket_uri = get_websocket_uri(testnet=True)
serverlist = serverlist.split(',')
neturl = config['DEFAULT']['FLOSIGHT_NETURL']
neturl = config['DEFAULT']['BLOCKBOOK_NETURL']
api_url = neturl
tokenapi_sse_url = config['DEFAULT']['TOKENAPI_SSE_URL']
API_VERIFY = config['DEFAULT']['API_VERIFY']