Spaces:
Sleeping
Sleeping
Commit
·
516d83c
1
Parent(s):
aca02b6
Add application file
Browse files- .DS_Store +0 -0
- README.md +2 -2
- data/.DS_Store +0 -0
- data/config.ini +2 -0
- data/eths_data.db +0 -0
- data/ethscriptions_data.db +2 -2
- data/name_set.db +2 -2
- pages/1_🔍_批量查询铭文状态.py +70 -139
- pages/4_💹️_铭文数据分析.py +19 -14
- 🖊️EthPen-以太之笔.py +54 -43
.DS_Store
CHANGED
|
Binary files a/.DS_Store and b/.DS_Store differ
|
|
|
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: yellow
|
| 6 |
python_version: 3.9.2
|
|
|
|
| 1 |
---
|
| 2 |
+
title: eths
|
| 3 |
+
emoji: 🖊️
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: yellow
|
| 6 |
python_version: 3.9.2
|
data/.DS_Store
CHANGED
|
Binary files a/data/.DS_Store and b/data/.DS_Store differ
|
|
|
data/config.ini
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[thread_start_state]
|
| 2 |
+
state = 0
|
data/eths_data.db
DELETED
|
Binary file (8.19 kB)
|
|
|
data/ethscriptions_data.db
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:299ff9699e6f7f4a75763b1cd7fa361c3c2820233f6cfa8f8cfc0f4cdf1c4b6a
|
| 3 |
+
size 399089664
|
data/name_set.db
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:117d6852105e8ba3543cc6a39daeef6e66c628999ad5299fe87c367835d3d704
|
| 3 |
+
size 2281472
|
pages/1_🔍_批量查询铭文状态.py
CHANGED
|
@@ -3,6 +3,9 @@ import re
|
|
| 3 |
import os
|
| 4 |
import sqlite3
|
| 5 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
# 获取当前文件目录
|
|
@@ -20,14 +23,11 @@ def text_to_hex(text):
|
|
| 20 |
return '0x' + ''.join(format(ord(char), '02x') for char in text)
|
| 21 |
|
| 22 |
|
| 23 |
-
def get_name_set_data(set_choose):
|
| 24 |
-
global content_set
|
| 25 |
-
name_set_cursor.execute(f"SELECT data FROM set_data WHERE name='{set_choose}'")
|
| 26 |
-
content_set = f'{name_set_cursor.fetchone()[0]}'
|
| 27 |
-
|
| 28 |
-
|
| 29 |
st.set_page_config(page_title="EthPen - 批量查询铭文状态", page_icon="🔍", layout='wide', initial_sidebar_state='auto')
|
| 30 |
st.subheader('🔍 EthPen - 批量查询铭文状态', anchor=False, divider='rainbow')
|
|
|
|
|
|
|
|
|
|
| 31 |
name_selected_option = st.radio("选择查询的类型:",
|
| 32 |
['🔤纯文本', '🪙代币铭文', '🆔.eths', '🆔.eth', '🌲.tree', '🦛.honk', '🔄.etch', '🌐.com', '🥳.club'], index=0,
|
| 33 |
horizontal=True)
|
|
@@ -48,7 +48,7 @@ if name_selected_option == '🪙代币铭文':
|
|
| 48 |
token_str_list.append(token_str.replace('@#', str(token_id)))
|
| 49 |
content_set = '\n'.join(token_str_list)
|
| 50 |
st.code(token_str_list[0], language="json", line_numbers=False)
|
| 51 |
-
content = st.text_area('
|
| 52 |
else:
|
| 53 |
token_check = False
|
| 54 |
if name_selected_option == '🆔.eths':
|
|
@@ -67,132 +67,57 @@ if name_selected_option == '🥳.club':
|
|
| 67 |
check_type = '.club'
|
| 68 |
|
| 69 |
if not token_check:
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
if emoji_name_set == 'Emoji 物体':
|
| 118 |
-
get_name_set_data(emoji_name_set)
|
| 119 |
-
if emoji_name_set == 'Emoji 符号':
|
| 120 |
-
get_name_set_data(emoji_name_set)
|
| 121 |
-
if emoji_name_set == 'Emoji 旗帜':
|
| 122 |
-
get_name_set_data(emoji_name_set)
|
| 123 |
-
if emoji_name_set == 'Emoji99':
|
| 124 |
-
get_name_set_data(emoji_name_set)
|
| 125 |
-
if emoji_name_set == 'Emoji1K':
|
| 126 |
-
get_name_set_data(emoji_name_set)
|
| 127 |
-
if emoji_name_set == 'Emoji10K':
|
| 128 |
-
get_name_set_data(emoji_name_set)
|
| 129 |
-
if name_set == "🔤字母":
|
| 130 |
-
letter_options = ["四字母单词", "五字母单词", "助记词", "英语名词"]
|
| 131 |
-
letter_name_set = st.radio("字母系列", letter_options, index=0, disabled=token_check, horizontal=True, label_visibility="collapsed")
|
| 132 |
-
if letter_name_set == '四字母单词':
|
| 133 |
-
get_name_set_data(letter_name_set)
|
| 134 |
-
if letter_name_set == '五字母单词':
|
| 135 |
-
get_name_set_data(letter_name_set)
|
| 136 |
-
if letter_name_set == '助记词':
|
| 137 |
-
get_name_set_data(letter_name_set)
|
| 138 |
-
if letter_name_set == '英语名词':
|
| 139 |
-
get_name_set_data(letter_name_set)
|
| 140 |
-
if name_set == "📛名字":
|
| 141 |
-
full_name_options = ["全球姓氏", "全球名字", "百家姓", "美国姓氏", "美国男名", "美国女名", "宝可梦第一世代", "宝可梦",
|
| 142 |
-
"哈利波特", "星球大战", "魔力宝贝", "我的世界"]
|
| 143 |
-
full_name_set = st.radio("名字系列", full_name_options, index=0, disabled=token_check, horizontal=True, label_visibility="collapsed")
|
| 144 |
-
if full_name_set == '全球姓氏':
|
| 145 |
-
get_name_set_data(full_name_set)
|
| 146 |
-
if full_name_set == '全球名字':
|
| 147 |
-
get_name_set_data(full_name_set)
|
| 148 |
-
if full_name_set == '百家姓':
|
| 149 |
-
get_name_set_data(full_name_set)
|
| 150 |
-
if full_name_set == '美国姓氏':
|
| 151 |
-
get_name_set_data(full_name_set)
|
| 152 |
-
if full_name_set == '美国男名':
|
| 153 |
-
get_name_set_data(full_name_set)
|
| 154 |
-
if full_name_set == '美国女名':
|
| 155 |
-
get_name_set_data(full_name_set)
|
| 156 |
-
if full_name_set == '宝可梦第一世代':
|
| 157 |
-
get_name_set_data(full_name_set)
|
| 158 |
-
if full_name_set == '宝可梦':
|
| 159 |
-
get_name_set_data(full_name_set)
|
| 160 |
-
if full_name_set == '哈利波特':
|
| 161 |
-
get_name_set_data(full_name_set)
|
| 162 |
-
if full_name_set == '星球大战':
|
| 163 |
-
get_name_set_data(full_name_set)
|
| 164 |
-
if full_name_set == '魔力宝贝':
|
| 165 |
-
get_name_set_data(full_name_set)
|
| 166 |
-
if full_name_set == '我的世界':
|
| 167 |
-
get_name_set_data(full_name_set)
|
| 168 |
-
if name_set == "💡其他":
|
| 169 |
-
other_name_options = ["汉字", "24H 计时"]
|
| 170 |
-
other_name_set = st.radio("其他系列", other_name_options, index=0, disabled=token_check, horizontal=True, label_visibility="collapsed")
|
| 171 |
-
if other_name_set == '汉字':
|
| 172 |
-
get_name_set_data(other_name_set)
|
| 173 |
-
if other_name_set == '24H 计时':
|
| 174 |
-
get_name_set_data(other_name_set)
|
| 175 |
-
if name_set == "📃导入文件":
|
| 176 |
-
uploaded_file = st.file_uploader("上传文件", type=['txt', 'csv', 'xlsx'])
|
| 177 |
-
|
| 178 |
-
if uploaded_file is not None:
|
| 179 |
-
if uploaded_file.type not in ['text/plain', 'text/csv', 'application/vnd.ms-excel']:
|
| 180 |
-
st.error('文件类型不支持')
|
| 181 |
-
else:
|
| 182 |
-
# 读取上传的文件内容
|
| 183 |
-
uploaded_file_contents = uploaded_file.read().decode('utf-8')
|
| 184 |
-
|
| 185 |
-
# 将文件内容分割成列表,使用空格、换行符和逗号作为分隔符
|
| 186 |
-
separators = [' ', '\n', ',']
|
| 187 |
-
uploaded_file_contents_list = re.split('|'.join(map(re.escape, separators)), uploaded_file_contents)
|
| 188 |
-
|
| 189 |
-
# 在这里,file_contents_list 包含了分割后的文本元素
|
| 190 |
-
# 去除重复元素,将列表转换为集合,然后再转回列表
|
| 191 |
-
uploaded_unique_contents_list = list(set(uploaded_file_contents_list))
|
| 192 |
-
content_set = ' '.join(uploaded_unique_contents_list)
|
| 193 |
|
| 194 |
if not token_check:
|
| 195 |
-
|
|
|
|
| 196 |
col1, col2 = st.columns(2)
|
| 197 |
with col1:
|
| 198 |
custom_prefix = st.text_input("自定义前缀")
|
|
@@ -206,7 +131,8 @@ if not token_check:
|
|
| 206 |
custom_prefix, custom_suffix = '', ''
|
| 207 |
|
| 208 |
if not token_check:
|
| 209 |
-
|
|
|
|
| 210 |
col1, col2, col3, col4, col5, col6 = st.columns(6)
|
| 211 |
with col1:
|
| 212 |
start_with = st.text_input("以*开头", key='过滤器(可选)1')
|
|
@@ -246,14 +172,17 @@ if not token_check:
|
|
| 246 |
content_set = ' '.join(filtered_list)
|
| 247 |
|
| 248 |
if not token_check:
|
| 249 |
-
content = st.text_area('
|
|
|
|
| 250 |
|
| 251 |
-
|
|
|
|
| 252 |
hide_inscribed = True
|
| 253 |
else:
|
| 254 |
hide_inscribed = False
|
| 255 |
|
| 256 |
if st.button('🔎 查询', key='🔎 查询'):
|
|
|
|
| 257 |
all_items = []
|
| 258 |
names = []
|
| 259 |
if token_check:
|
|
@@ -284,7 +213,8 @@ if st.button('🔎 查询', key='🔎 查询'):
|
|
| 284 |
ethscriptions_conn = sqlite3.connect(ethscrptions_db_file)
|
| 285 |
|
| 286 |
ethscriptions_cursor = ethscriptions_conn.cursor()
|
| 287 |
-
|
|
|
|
| 288 |
result = []
|
| 289 |
for index in range(len(names)):
|
| 290 |
ethscriptions_cursor.execute("SELECT * FROM data WHERE data=?", (all_items[index],))
|
|
@@ -292,13 +222,15 @@ if st.button('🔎 查询', key='🔎 查询'):
|
|
| 292 |
if hide_inscribed:
|
| 293 |
if not row:
|
| 294 |
result.append({"铭文": names[index], "状态": "未题写", "十六进制数据": all_items[index]})
|
|
|
|
| 295 |
else:
|
| 296 |
if row:
|
| 297 |
result.append({"铭文": names[index], "状态": "已题写", "十六进制数据": all_items[index]})
|
| 298 |
else:
|
| 299 |
result.append({"铭文": names[index], "状态": "未题写", "十六进制数据": all_items[index]})
|
| 300 |
-
|
| 301 |
-
|
|
|
|
| 302 |
st.markdown(f'## ☹️ 你来迟了~')
|
| 303 |
else:
|
| 304 |
# 将结果转换为Pandas DataFrame
|
|
@@ -308,11 +240,10 @@ if st.button('🔎 查询', key='🔎 查询'):
|
|
| 308 |
csv_export = result_df.to_csv(index=False, encoding='utf-8')
|
| 309 |
# Add a download button for the DataFrame
|
| 310 |
st.download_button(
|
| 311 |
-
label="下载搜索结果",
|
| 312 |
data=csv_export,
|
| 313 |
file_name="ethpen_result_data.csv",
|
| 314 |
mime="text/csv"
|
| 315 |
)
|
| 316 |
|
| 317 |
|
| 318 |
-
|
|
|
|
| 3 |
import os
|
| 4 |
import sqlite3
|
| 5 |
import pandas as pd
|
| 6 |
+
import time
|
| 7 |
+
import matplotlib.pyplot as plt
|
| 8 |
+
import random
|
| 9 |
|
| 10 |
|
| 11 |
# 获取当前文件目录
|
|
|
|
| 23 |
return '0x' + ''.join(format(ord(char), '02x') for char in text)
|
| 24 |
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
st.set_page_config(page_title="EthPen - 批量查询铭文状态", page_icon="🔍", layout='wide', initial_sidebar_state='auto')
|
| 27 |
st.subheader('🔍 EthPen - 批量查询铭文状态', anchor=False, divider='rainbow')
|
| 28 |
+
|
| 29 |
+
st.write("<style>div.row-widget.stRadio > div{background-color:white;border: 1px solid #e6e9ef;border-radius:8px;padding:10px;box-shadow: 2px 2px 10px #e6e9ef;}</style>", unsafe_allow_html=True)
|
| 30 |
+
|
| 31 |
name_selected_option = st.radio("选择查询的类型:",
|
| 32 |
['🔤纯文本', '🪙代币铭文', '🆔.eths', '🆔.eth', '🌲.tree', '🦛.honk', '🔄.etch', '🌐.com', '🥳.club'], index=0,
|
| 33 |
horizontal=True)
|
|
|
|
| 48 |
token_str_list.append(token_str.replace('@#', str(token_id)))
|
| 49 |
content_set = '\n'.join(token_str_list)
|
| 50 |
st.code(token_str_list[0], language="json", line_numbers=False)
|
| 51 |
+
content = st.text_area('铭文列表:', value=content_set)
|
| 52 |
else:
|
| 53 |
token_check = False
|
| 54 |
if name_selected_option == '🆔.eths':
|
|
|
|
| 67 |
check_type = '.club'
|
| 68 |
|
| 69 |
if not token_check:
|
| 70 |
+
# 执行SQL查询,获取所有表名
|
| 71 |
+
name_set_cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
| 72 |
+
# 检索查询结果
|
| 73 |
+
tables = name_set_cursor.fetchall()
|
| 74 |
+
name_srt_tables_options = []
|
| 75 |
+
name_srt_tables_options.append('⌨️ 直接输入')
|
| 76 |
+
for table in tables:
|
| 77 |
+
name_srt_tables_options.append(table[0])
|
| 78 |
+
name_srt_tables_options.append('📃 导入文件')
|
| 79 |
+
name_set_table = st.radio("选择系列:", name_srt_tables_options, index=0, disabled=token_check, horizontal=True)
|
| 80 |
+
if name_set_table and name_set_table != '⌨️ 直接输入' and name_set_table != '📃 导入文件':
|
| 81 |
+
name_set_tables_name_options = []
|
| 82 |
+
# 执行SQL查询,获取指定表的所有 'name' 列的值
|
| 83 |
+
name_set_cursor.execute(f"SELECT name FROM {name_set_table}")
|
| 84 |
+
# 检索查询结果
|
| 85 |
+
names = name_set_cursor.fetchall()
|
| 86 |
+
# 打印所有 'name' 列的值
|
| 87 |
+
for name in names:
|
| 88 |
+
name_set_tables_name_options.append(name[0])
|
| 89 |
+
name_set_tables_name_options.sort()
|
| 90 |
+
name_set_table_name = st.radio("系列", name_set_tables_name_options, index=0, disabled=token_check, horizontal=True,
|
| 91 |
+
label_visibility="collapsed")
|
| 92 |
+
if name_set_table_name:
|
| 93 |
+
# 执行SQL查询,获取指定表的 'name' 和 'data' 列的值
|
| 94 |
+
name_set_cursor.execute(f"SELECT data FROM {name_set_table} WHERE name='{name_set_table_name}'")
|
| 95 |
+
# 检索查询结果
|
| 96 |
+
all_data = name_set_cursor.fetchall()
|
| 97 |
+
content_set = f'{all_data[0][0]}'
|
| 98 |
+
if name_set_table == "⌨️ 直接输入":
|
| 99 |
+
content_set = ''
|
| 100 |
+
if name_set_table == "📃 导入文件":
|
| 101 |
+
uploaded_file = st.file_uploader("上传文件", type=['txt', 'csv', 'xlsx'])
|
| 102 |
+
if uploaded_file is not None:
|
| 103 |
+
if uploaded_file.type not in ['text/plain', 'text/csv', 'application/vnd.ms-excel']:
|
| 104 |
+
st.error('文件类型不支持')
|
| 105 |
+
else:
|
| 106 |
+
# 读取上传的文件内容
|
| 107 |
+
uploaded_file_contents = uploaded_file.read().decode('utf-8')
|
| 108 |
+
|
| 109 |
+
# 将文件内容分割成列表,使用空格、换行符和逗号作为分隔符
|
| 110 |
+
separators = [' ', '\n', ',']
|
| 111 |
+
uploaded_file_contents_list = re.split('|'.join(map(re.escape, separators)), uploaded_file_contents)
|
| 112 |
+
|
| 113 |
+
# 在这里,file_contents_list 包含了分割后的文本元素
|
| 114 |
+
# 去除重复元素,将列表转换为集合,然后再转回列表
|
| 115 |
+
uploaded_unique_contents_list = list(set(uploaded_file_contents_list))
|
| 116 |
+
content_set = ' '.join(uploaded_unique_contents_list)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
if not token_check:
|
| 119 |
+
custom_suffix = st.toggle('自定义前后缀')
|
| 120 |
+
if custom_suffix:
|
| 121 |
col1, col2 = st.columns(2)
|
| 122 |
with col1:
|
| 123 |
custom_prefix = st.text_input("自定义前缀")
|
|
|
|
| 131 |
custom_prefix, custom_suffix = '', ''
|
| 132 |
|
| 133 |
if not token_check:
|
| 134 |
+
filter = st.toggle('过滤器')
|
| 135 |
+
if filter:
|
| 136 |
col1, col2, col3, col4, col5, col6 = st.columns(6)
|
| 137 |
with col1:
|
| 138 |
start_with = st.text_input("以*开头", key='过滤器(可选)1')
|
|
|
|
| 172 |
content_set = ' '.join(filtered_list)
|
| 173 |
|
| 174 |
if not token_check:
|
| 175 |
+
content = st.text_area('铭文列表:', value=content_set)
|
| 176 |
+
|
| 177 |
|
| 178 |
+
hide_inscribed = st.toggle('隐藏已题写')
|
| 179 |
+
if hide_inscribed:
|
| 180 |
hide_inscribed = True
|
| 181 |
else:
|
| 182 |
hide_inscribed = False
|
| 183 |
|
| 184 |
if st.button('🔎 查询', key='🔎 查询'):
|
| 185 |
+
st.markdown(f'## 📄 查询结果')
|
| 186 |
all_items = []
|
| 187 |
names = []
|
| 188 |
if token_check:
|
|
|
|
| 213 |
ethscriptions_conn = sqlite3.connect(ethscrptions_db_file)
|
| 214 |
|
| 215 |
ethscriptions_cursor = ethscriptions_conn.cursor()
|
| 216 |
+
names_total = len(names)
|
| 217 |
+
name_not_yet_total = 0
|
| 218 |
result = []
|
| 219 |
for index in range(len(names)):
|
| 220 |
ethscriptions_cursor.execute("SELECT * FROM data WHERE data=?", (all_items[index],))
|
|
|
|
| 222 |
if hide_inscribed:
|
| 223 |
if not row:
|
| 224 |
result.append({"铭文": names[index], "状态": "未题写", "十六进制数据": all_items[index]})
|
| 225 |
+
name_not_yet_total += 1
|
| 226 |
else:
|
| 227 |
if row:
|
| 228 |
result.append({"铭文": names[index], "状态": "已题写", "十六进制数据": all_items[index]})
|
| 229 |
else:
|
| 230 |
result.append({"铭文": names[index], "状态": "未题写", "十六进制数据": all_items[index]})
|
| 231 |
+
name_not_yet_total += 1
|
| 232 |
+
st.progress(name_not_yet_total / names_total, f'题写进度({name_not_yet_total / names_total * 100:.0f}%):')
|
| 233 |
+
if not result:
|
| 234 |
st.markdown(f'## ☹️ 你来迟了~')
|
| 235 |
else:
|
| 236 |
# 将结果转换为Pandas DataFrame
|
|
|
|
| 240 |
csv_export = result_df.to_csv(index=False, encoding='utf-8')
|
| 241 |
# Add a download button for the DataFrame
|
| 242 |
st.download_button(
|
| 243 |
+
label="⏬ 下载搜索结果",
|
| 244 |
data=csv_export,
|
| 245 |
file_name="ethpen_result_data.csv",
|
| 246 |
mime="text/csv"
|
| 247 |
)
|
| 248 |
|
| 249 |
|
|
|
pages/4_💹️_铭文数据分析.py
CHANGED
|
@@ -7,6 +7,7 @@ import time
|
|
| 7 |
from datetime import datetime, timezone
|
| 8 |
import threading
|
| 9 |
import base64
|
|
|
|
| 10 |
|
| 11 |
# 使用你的Ethereum节点的RPC地址
|
| 12 |
w3 = Web3(Web3.HTTPProvider("https://mainnet.infura.io/v3/9bbc614b8a1d49d59869e97d0ee3bf61"))
|
|
@@ -17,6 +18,8 @@ parent_dir = os.path.dirname(current_dir)
|
|
| 17 |
# 构造数据库文件路径
|
| 18 |
eths_db_file = os.path.join(parent_dir, 'data', 'eths_data.db')
|
| 19 |
ethscrptions_db_file = os.path.join(parent_dir, 'data', 'ethscriptions_data.db')
|
|
|
|
|
|
|
| 20 |
|
| 21 |
ethscriptions_con = sqlite3.connect(ethscrptions_db_file)
|
| 22 |
ethscriptions_cur = ethscriptions_con.cursor()
|
|
@@ -185,8 +188,11 @@ if eths_data:
|
|
| 185 |
eths_stakers = st.metric(label='ETHS TVL', value=f'${eths_data[0][8]:,.0f}')
|
| 186 |
|
| 187 |
|
| 188 |
-
#
|
| 189 |
-
#
|
|
|
|
|
|
|
|
|
|
| 190 |
ethscriptions_cur.execute("SELECT block_number FROM process_blocks")
|
| 191 |
index_result = ethscriptions_cur.fetchone()
|
| 192 |
index_processed_block = index_result[0]
|
|
@@ -207,25 +213,24 @@ if download:
|
|
| 207 |
mime='application/octet-stream'
|
| 208 |
)
|
| 209 |
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
if
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
# index_status_thread = threading.Thread(target=get_index_status, args=(index_status,))
|
| 220 |
eths_thread = threading.Thread(target=get_eths_data)
|
| 221 |
ethscriptions_thread = threading.Thread(target=get_ethscriptions_data)
|
| 222 |
|
| 223 |
# 启动线程
|
| 224 |
-
# index_status_thread.start()
|
| 225 |
eths_thread.start()
|
| 226 |
ethscriptions_thread.start()
|
| 227 |
|
| 228 |
# 等待线程结束
|
| 229 |
eths_thread.join()
|
| 230 |
ethscriptions_thread.join()
|
| 231 |
-
|
|
|
|
|
|
| 7 |
from datetime import datetime, timezone
|
| 8 |
import threading
|
| 9 |
import base64
|
| 10 |
+
import configparser
|
| 11 |
|
| 12 |
# 使用你的Ethereum节点的RPC地址
|
| 13 |
w3 = Web3(Web3.HTTPProvider("https://mainnet.infura.io/v3/9bbc614b8a1d49d59869e97d0ee3bf61"))
|
|
|
|
| 18 |
# 构造数据库文件路径
|
| 19 |
eths_db_file = os.path.join(parent_dir, 'data', 'eths_data.db')
|
| 20 |
ethscrptions_db_file = os.path.join(parent_dir, 'data', 'ethscriptions_data.db')
|
| 21 |
+
config_ini_file = os.path.join(parent_dir, 'data', 'config.ini')
|
| 22 |
+
|
| 23 |
|
| 24 |
ethscriptions_con = sqlite3.connect(ethscrptions_db_file)
|
| 25 |
ethscriptions_cur = ethscriptions_con.cursor()
|
|
|
|
| 188 |
eths_stakers = st.metric(label='ETHS TVL', value=f'${eths_data[0][8]:,.0f}')
|
| 189 |
|
| 190 |
|
| 191 |
+
# with st.expander('🆕新铭文题写', expanded=True):
|
| 192 |
+
#
|
| 193 |
+
#
|
| 194 |
+
|
| 195 |
+
|
| 196 |
ethscriptions_cur.execute("SELECT block_number FROM process_blocks")
|
| 197 |
index_result = ethscriptions_cur.fetchone()
|
| 198 |
index_processed_block = index_result[0]
|
|
|
|
| 213 |
mime='application/octet-stream'
|
| 214 |
)
|
| 215 |
|
| 216 |
+
config = configparser.ConfigParser()
|
| 217 |
+
config.read(config_ini_file)
|
| 218 |
+
thread_start_state_value = config['thread_start_state']['state']
|
| 219 |
+
if thread_start_state_value == '0':
|
| 220 |
+
print('线程未启动。')
|
| 221 |
+
config['thread_start_state']['state'] = '1'
|
| 222 |
+
with open(config_ini_file, 'w') as configfile:
|
| 223 |
+
config.write(configfile)
|
| 224 |
+
|
|
|
|
| 225 |
eths_thread = threading.Thread(target=get_eths_data)
|
| 226 |
ethscriptions_thread = threading.Thread(target=get_ethscriptions_data)
|
| 227 |
|
| 228 |
# 启动线程
|
|
|
|
| 229 |
eths_thread.start()
|
| 230 |
ethscriptions_thread.start()
|
| 231 |
|
| 232 |
# 等待线程结束
|
| 233 |
eths_thread.join()
|
| 234 |
ethscriptions_thread.join()
|
| 235 |
+
else:
|
| 236 |
+
print('线程已经启动。')
|
🖊️EthPen-以太之笔.py
CHANGED
|
@@ -1126,7 +1126,7 @@ def get_eths_staking():
|
|
| 1126 |
return {} # 返回一个空字典作为默认值
|
| 1127 |
|
| 1128 |
|
| 1129 |
-
st.set_page_config(page_title="EthPen - 以太之笔", page_icon="🖊", layout='wide', initial_sidebar_state='
|
| 1130 |
|
| 1131 |
# 首页
|
| 1132 |
st.markdown(
|
|
@@ -1263,48 +1263,59 @@ if search_rune_expander.button('🔍 查询', key='批量查询铭文'):
|
|
| 1263 |
table_data.drop(columns=['sort_helper'], inplace=True)
|
| 1264 |
|
| 1265 |
# 定义样式和生成带有专门类名的HTML表格
|
| 1266 |
-
table_style = """
|
| 1267 |
-
<style>
|
| 1268 |
-
|
| 1269 |
-
|
| 1270 |
-
|
| 1271 |
-
|
| 1272 |
-
|
| 1273 |
-
|
| 1274 |
-
|
| 1275 |
-
|
| 1276 |
-
|
| 1277 |
-
|
| 1278 |
-
|
| 1279 |
-
|
| 1280 |
-
|
| 1281 |
-
|
| 1282 |
-
|
| 1283 |
-
|
| 1284 |
-
|
| 1285 |
-
|
| 1286 |
-
|
| 1287 |
-
|
| 1288 |
-
|
| 1289 |
-
|
| 1290 |
-
|
| 1291 |
-
|
| 1292 |
-
</style>
|
| 1293 |
-
"""
|
| 1294 |
-
search_rune_expander.markdown(table_style, unsafe_allow_html=True)
|
| 1295 |
-
table_html = table_data.to_html(index=False, classes='styled_table', border=0, escape=False,
|
| 1296 |
-
|
| 1297 |
-
|
| 1298 |
-
# 生成HTML表格但不为状态列添加特殊格式
|
| 1299 |
-
table_html = table_data.to_html(index=False, classes='styled_table', border=0, escape=False)
|
| 1300 |
-
|
| 1301 |
-
# 使用字符串替换为状态列添加特定属性
|
| 1302 |
-
table_html = table_html.replace('<td>已题写</td>', '<td status="已题写">已题写</td>')
|
| 1303 |
-
table_html = table_html.replace('<td>未题写</td>', '<td status="未题写">未题写</td>')
|
| 1304 |
-
|
| 1305 |
-
# 使用st.write输出带样式的HTML表格
|
| 1306 |
-
search_rune_expander.write(table_html, unsafe_allow_html=True)
|
| 1307 |
-
search_rune_expander.markdown('')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1308 |
|
| 1309 |
# 题写铭文页面
|
| 1310 |
create_rune_expander.markdown("##### 文本转换到十六进制")
|
|
|
|
| 1126 |
return {} # 返回一个空字典作为默认值
|
| 1127 |
|
| 1128 |
|
| 1129 |
+
st.set_page_config(page_title="EthPen - 以太之笔", page_icon="🖊", layout='wide', initial_sidebar_state='collapsed')
|
| 1130 |
|
| 1131 |
# 首页
|
| 1132 |
st.markdown(
|
|
|
|
| 1263 |
table_data.drop(columns=['sort_helper'], inplace=True)
|
| 1264 |
|
| 1265 |
# 定义样式和生成带有专门类名的HTML表格
|
| 1266 |
+
# table_style = """
|
| 1267 |
+
# <style>
|
| 1268 |
+
# .styled_table {
|
| 1269 |
+
# width: 100%;
|
| 1270 |
+
# border-collapse: collapse;
|
| 1271 |
+
# border-radius: 8px;
|
| 1272 |
+
# overflow: hidden; /* Ensures border-radius applies to table */
|
| 1273 |
+
# }
|
| 1274 |
+
# .styled_table th, .styled_table td {
|
| 1275 |
+
# border: 1px solid #ddd;
|
| 1276 |
+
# padding: 8px;
|
| 1277 |
+
# text-align: left;
|
| 1278 |
+
# }
|
| 1279 |
+
# .styled_table th {
|
| 1280 |
+
# background-color: #f2f2f2;
|
| 1281 |
+
# color: black;
|
| 1282 |
+
# }
|
| 1283 |
+
# .styled_table tr:hover {
|
| 1284 |
+
# background-color: #f5f5f5;
|
| 1285 |
+
# }
|
| 1286 |
+
# .styled_table td[status="已题写"] {
|
| 1287 |
+
# background-color: #f2dede; /* Reddish */
|
| 1288 |
+
# }
|
| 1289 |
+
# .styled_table td[status="未题写"] {
|
| 1290 |
+
# background-color: #dff0d8; /* Greenish */
|
| 1291 |
+
# }
|
| 1292 |
+
# </style>
|
| 1293 |
+
# """
|
| 1294 |
+
# search_rune_expander.markdown(table_style, unsafe_allow_html=True)
|
| 1295 |
+
# table_html = table_data.to_html(index=False, classes='styled_table', border=0, escape=False,
|
| 1296 |
+
# formatters=dict(状态=lambda x: f'<td status="{x}">{x}</td>'))
|
| 1297 |
+
#
|
| 1298 |
+
# # 生成HTML表格但不为状态列添加特殊格式
|
| 1299 |
+
# table_html = table_data.to_html(index=False, classes='styled_table', border=0, escape=False)
|
| 1300 |
+
#
|
| 1301 |
+
# # 使用字符串替换为状态列添加特定属性
|
| 1302 |
+
# table_html = table_html.replace('<td>已题写</td>', '<td status="已题写">已题写</td>')
|
| 1303 |
+
# table_html = table_html.replace('<td>未题写</td>', '<td status="未题写">未题写</td>')
|
| 1304 |
+
#
|
| 1305 |
+
# # 使用st.write输出带样式的HTML表格
|
| 1306 |
+
# search_rune_expander.write(table_html, unsafe_allow_html=True)
|
| 1307 |
+
# search_rune_expander.markdown('')
|
| 1308 |
+
result_df = pd.DataFrame(table_data)
|
| 1309 |
+
search_rune_expander.dataframe(result_df, use_container_width=True, hide_index=True)
|
| 1310 |
+
# Convert DataFrame to CSV with proper encoding
|
| 1311 |
+
csv_export = result_df.to_csv(index=False, encoding='utf-8')
|
| 1312 |
+
# Add a download button for the DataFrame
|
| 1313 |
+
search_rune_expander.download_button(
|
| 1314 |
+
label="下载搜索结果",
|
| 1315 |
+
data=csv_export,
|
| 1316 |
+
file_name="ethpen_result_data.csv",
|
| 1317 |
+
mime="text/csv"
|
| 1318 |
+
)
|
| 1319 |
|
| 1320 |
# 题写铭文页面
|
| 1321 |
create_rune_expander.markdown("##### 文本转换到十六进制")
|