Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Code Lao committed Dec 15, 2023
1 parent b50e1cd commit ca4e028
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 176 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.0.5
*2023-12-15*

### Small improvements.
### Added latest release check in the CLI mode.


# 1.0.0
*2023-08-24*

Expand Down
138 changes: 138 additions & 0 deletions PocketTRC20/CLI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# -*- coding: utf-8 -*-

import sys, time, requests, json
from .config import VERSION
from progress.bar import IncrementalBar


class Scan():
def __init__(self):
self.bar = IncrementalBar('Scanning transaction', max=7, suffix='%(percent)d%%')

def banner(self):
banner = '''
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ ____ ___ ____ _ _______ _____ $
$ | _ \ / _ \ / ___| |/ / ____|_ _| $
$ | |_) | | | | | | ' /| _| | | $
$ | __/| |_| | |___| . \| |___ | | $
$ |_| \___/ \____|_|\_\_____| |_| $
$ _____ ____ ____ ____ ___ $
$ |_ _| _ \ / ___|___ \ / _ \ $
$ | | | |_) | | __) | | | | $
$ | | | _ <| |___ / __/| |_| | $
$ |_| |_| \_|\____|_____|\___/ $
$ $
$ $
$ (..) $
$$$$$$$$ $$$$$$$$
$$$$$$$$$$$$$$$$$$
\033[1;34mby Lao\033[0m
'''
print(banner + ' \033[34mv' + VERSION + '\033[0m')

def check_latest_release(self):
headers = {'Accept': 'application/vnd.github+json'}
check_latest_release = requests.get('https://api.github.com/repos/codelao/PocketTRC20/releases/latest', headers=headers)
if check_latest_release.status_code == 200:
latest_release = json.loads(check_latest_release.text)
if not latest_release['tag_name'] == 'v'+VERSION:
return latest_release['tag_name']

def hash_scanner(self, hash):
if not self.check_latest_release() == None:
print('\033[32mNew PocketTRC20 release found!\033[0m\nInstalled release: v'+VERSION+'\nLatest: '+self.check_latest_release()+'\n\nVisit \033[96mhttps://github.com/codelao/PocketTRC20/releases/latest\033[0m.\n')
if not len(hash) == 64:
print('\033[31m! Incorrect hash entered\033[0m')
sys.exit(1)
else:
link = 'https://apilist.tronscan.org/api/transaction-info?hash=' + hash
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'}
get_link = requests.get(link, headers=headers).text
time.sleep(0.1)
self.bar.next()
self.check_hash = json.loads(get_link)
time.sleep(0.1)
self.bar.next()
if self.check_hash == {} or self.check_hash == {"message":"some parameters are missing"} or self.check_hash == {"riskTransaction":False}:
time.sleep(0.1)
self.bar.finish()
print('\033[31m! Unable to get details of this transaction\033[0m')
sys.exit(1)
else:
token_check = self.check_hash["contractType"]
time.sleep(0.1)
self.bar.next()
if token_check == 31:
status = self.check_hash["contractRet"]
time.sleep(0.1)
self.bar.next()
if status == 'SUCCESS':
from_address = self.check_hash["tokenTransferInfo"]["from_address"]
time.sleep(0.1)
self.bar.next()
to_address = self.check_hash["tokenTransferInfo"]["to_address"]
time.sleep(0.1)
self.bar.next()
amount = self.check_hash["tokenTransferInfo"]["amount_str"]
time.sleep(0.1)
self.bar.next()
time.sleep(0.1)
self.bar.finish()
print(
'\033[32mTransaction details:\033[0m' +
'\nStatus: ' + status +
'\nFrom: ' + from_address +
'\nTo: ' + to_address +
'\nAmount: ' + str(amount)[0:-6] + ' USDT'
)
sys.exit(0)
else:
time.sleep(0.1)
self.bar.finish()
print(
'\033[32mTransaction details:\033[0m' +
'\nStatus: ' + status +
'\nAmount: 0 USDT'
)
sys.exit(0)
elif token_check == 1:
status = self.check_hash["contractRet"]
time.sleep(0.1)
self.bar.next()
if status == 'SUCCESS':
from_address = self.check_hash["contractData"]["owner_address"]
time.sleep(0.1)
self.bar.next()
to_address = self.check_hash["contractData"]["to_address"]
time.sleep(0.1)
self.bar.next()
amount = self.check_hash["contractData"]["amount"]
time.sleep(0.1)
self.bar.next()
time.sleep(0.1)
self.bar.finish()
print(
'\033[32mTransaction details:\033[0m' +
'\nStatus: ' + status +
'\nFrom: ' + from_address +
'\nTo: ' + to_address +
'\nAmount: ' + str(amount)[0:-6] + ' TRX'
)
sys.exit(0)
else:
time.sleep(0.1)
self.bar.finish()
print(
'\033[32mTransaction details:\033[0m' +
'\nStatus: ' + status +
'\nAmount: 0 TRX'
)
sys.exit(0)
else:
time.sleep(0.1)
self.bar.finish()
print('\033[31m! Unable to get details of this transaction\033[0m')
sys.exit(1)
4 changes: 0 additions & 4 deletions PocketTRC20/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@
#$$$$$$$$$$$$$$$$$

from .scanner import transaction, status, amount


NAME = 'PocketTRC20'
VERSION = '1.2.5'
26 changes: 20 additions & 6 deletions PocketTRC20/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,38 @@
#$$$$$$$ $$$$$$$$
#$$$$$$$$$$$$$$$$$

import sys
import colorama
from .console import Scan
import sys, colorama, requests
from .CLI import Scan


def checkConnection():
try:
requests.get('https://google.com', timeout=1)
return True
except:
return False

def entry_point():
colorama.init()
if '--hash' in sys.argv:
if len(sys.argv) == 3:
hash = sys.argv[2]
Scan().banner()
Scan().hash_scanner(hash)
if checkConnection() == True:
hash = sys.argv[2]
Scan().banner()
Scan().hash_scanner(hash)
else:
print('\033[31m! Check your internet connection\033[0m')
sys.exit(1)
else:
print('\033[31m! Hash wasn\'t entered\033[0m')
sys.exit(1)
elif '--info' in sys.argv:
if len(sys.argv) == 2:
print('PocketTRC20\nby Lao\nLicensed under MIT\n\nOptions:\n--hash TRANSACTION_HASH scan transaction\n--info you\'re here')
sys.exit(0)
else:
print('\033[31m! Unknown value: \033[0m' + sys.argv[2])
sys.exit(1)
else:
print('\033[31m! Incorrect option\033[0m')
sys.exit(1)
21 changes: 1 addition & 20 deletions PocketTRC20/config.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
# $
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
# ____ ___ ____ _ _______ _____ $
# | _ \ / _ \ / ___| |/ / ____|_ _| $
# | |_) | | | | | | ' /| _| | | $
# | __/| |_| | |___| . \| |___ | | $
# |_| \___/ \____|_|\_\_____| |_| $
# _____ ____ ____ ____ ___ $
# |_ _| _ \ / ___|___ \ / _ \ $
# | | | |_) | | __) | | | | $
# | | | _ <| |___ / __/| |_| | $
# |_| |_| \_|\____|_____|\___/ $
# $
# $
# (..) $
#$$$$$$$ $$$$$$$$
#$$$$$$$$$$$$$$$$$

NAME = 'PocketTRC20'
VERSION = '1.0.0'
VERSION = '1.0.5'
143 changes: 0 additions & 143 deletions PocketTRC20/console.py

This file was deleted.

4 changes: 2 additions & 2 deletions PocketTRC20/scanner.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import requests
import json
from .console import Scan
from .__main__ import checkConnection


def transaction(hash):
if Scan().check_intConnection() == True:
if checkConnection() == True:
if not len(hash) == 64:
raise ValueError('Incorrect hash entered.')
else:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- [Welcome to PocketTRC20's wiki!](https://github.com/codelao/PocketTRC20/wiki#welcome-to-pockettrc20s-wiki)
- [Description](https://github.com/codelao/PocketTRC20/wiki#description)
- [Getting started](https://github.com/codelao/PocketTRC20/wiki/Getting-started)
- [Using PocketTRC20 as a console program](https://github.com/codelao/PocketTRC20/wiki/Getting-started#using-pockettrc20-as-a-console-program)
- [Using PocketTRC20 as a CLI app](https://github.com/codelao/PocketTRC20/wiki/Getting-started#using-pockettrc20-as-a-cli-app)
- [Using PocketTRC20 as a Python module](https://github.com/codelao/PocketTRC20/wiki/Getting-started#using-pockettrc20-as-a-python-module)
- [Installation](https://github.com/codelao/PocketTRC20/wiki/Installation)
- [Install via pip](https://github.com/codelao/PocketTRC20/wiki/Installation#install-via-pip)

0 comments on commit ca4e028

Please sign in to comment.