Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,16 +16,16 @@ main_chain='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/chai
|
|
| 16 |
main_balance='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/balance/'
|
| 17 |
main_trans='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/transact/'
|
| 18 |
|
| 19 |
-
main_nodes='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/node_file1.json'
|
| 20 |
-
main_pending='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/pending1.json'
|
| 21 |
token_self = os.environ['HF_TOKEN']
|
| 22 |
pa=os.environ['PASS']
|
| 23 |
|
| 24 |
trans_name = 'trans1.json'
|
| 25 |
-
repo_d='Omnibus/static-bin'
|
| 26 |
chain_d='chain1.json'
|
| 27 |
-
node_file='node_file.json'
|
| 28 |
-
space='blockchain-simulator-dev1'
|
| 29 |
api = HfApi(token=token_self)
|
| 30 |
|
| 31 |
|
|
@@ -77,7 +77,7 @@ def mine_block(chain_r=None,chain_n=None):
|
|
| 77 |
show_chain=display_chain()
|
| 78 |
message = "New Chain Created at Max 20 Blocks"
|
| 79 |
return response, show_chain,pd.DataFrame(blockchain.pending_transactions), message
|
| 80 |
-
|
| 81 |
def sort_valid():
|
| 82 |
#nodes=main_nodes.replace("'","")
|
| 83 |
f = requests.get(f'{main_nodes}')
|
|
@@ -135,7 +135,7 @@ def sort_valid():
|
|
| 135 |
cnt2+=1
|
| 136 |
print (out)
|
| 137 |
return response
|
| 138 |
-
|
| 139 |
def valid():
|
| 140 |
valid,ind,mes = blockchain.chain_valid(blockchain.chain)
|
| 141 |
if valid:
|
|
@@ -593,61 +593,87 @@ with gr.Blocks() as bc:
|
|
| 593 |
|
| 594 |
with gr.Box(visible=False) as valida:
|
| 595 |
gr.Markdown("""<h1><center>Blockchain Simulator<br><h3>(Transactions have no value)<br><h4>Chain will reset at 20 blocks""")
|
| 596 |
-
blockchain = gr.State()
|
| 597 |
with gr.Row():
|
| 598 |
-
with gr.
|
| 599 |
-
with gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 600 |
with gr.Row():
|
| 601 |
-
|
| 602 |
-
chain_n=gr.Textbox(label="Chain file")
|
| 603 |
with gr.Row():
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
am=gr.Textbox(label="Amount")
|
| 610 |
-
send_trans=gr.Button("Post Transaction")
|
| 611 |
-
mine_b = gr.Button("Mine Block")
|
| 612 |
-
check = gr.Button("Check Chain")
|
| 613 |
-
check_trans = gr.Button("Check Transactions")
|
| 614 |
-
check_all = gr.Button("Check All")
|
| 615 |
-
with gr.Column():
|
| 616 |
-
block_text = gr.Textbox()
|
| 617 |
-
trans_data = gr.Dataframe()
|
| 618 |
-
json_out = gr.JSON()
|
| 619 |
-
chain_json = gr.JSON()
|
| 620 |
-
with gr.Accordion("Nodes", open=False):
|
| 621 |
-
with gr.Row():
|
| 622 |
-
this_space=gr.Textbox(label="This Repo/Space")
|
| 623 |
-
with gr.Row():
|
| 624 |
-
node_repo=gr.Textbox(label="Node Repo")
|
| 625 |
-
node_space=gr.Textbox(label="Node Space")
|
| 626 |
-
node_file=gr.Textbox(label="Node File")
|
| 627 |
-
node_add=gr.Button("Add Node")
|
| 628 |
-
with gr.Accordion("Tokens", open=False):
|
| 629 |
-
with gr.Row():
|
| 630 |
-
with gr.Column():
|
| 631 |
-
issue_btn=gr.Button()
|
| 632 |
-
with gr.Column():
|
| 633 |
with gr.Row():
|
| 634 |
-
|
| 635 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 636 |
with gr.Row():
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 651 |
|
| 652 |
def res_bc():
|
| 653 |
blockchain.reset(create="chain1.json")
|
|
|
|
| 16 |
main_balance='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/balance/'
|
| 17 |
main_trans='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/transact/'
|
| 18 |
|
| 19 |
+
#main_nodes='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/node_file1.json'
|
| 20 |
+
#main_pending='https://huggingface.co/datasets/Omnibus/blockchain-sim/raw/main/pending1.json'
|
| 21 |
token_self = os.environ['HF_TOKEN']
|
| 22 |
pa=os.environ['PASS']
|
| 23 |
|
| 24 |
trans_name = 'trans1.json'
|
| 25 |
+
#repo_d='Omnibus/static-bin'
|
| 26 |
chain_d='chain1.json'
|
| 27 |
+
#node_file='node_file.json'
|
| 28 |
+
#space='blockchain-simulator-dev1'
|
| 29 |
api = HfApi(token=token_self)
|
| 30 |
|
| 31 |
|
|
|
|
| 77 |
show_chain=display_chain()
|
| 78 |
message = "New Chain Created at Max 20 Blocks"
|
| 79 |
return response, show_chain,pd.DataFrame(blockchain.pending_transactions), message
|
| 80 |
+
'''
|
| 81 |
def sort_valid():
|
| 82 |
#nodes=main_nodes.replace("'","")
|
| 83 |
f = requests.get(f'{main_nodes}')
|
|
|
|
| 135 |
cnt2+=1
|
| 136 |
print (out)
|
| 137 |
return response
|
| 138 |
+
'''
|
| 139 |
def valid():
|
| 140 |
valid,ind,mes = blockchain.chain_valid(blockchain.chain)
|
| 141 |
if valid:
|
|
|
|
| 593 |
|
| 594 |
with gr.Box(visible=False) as valida:
|
| 595 |
gr.Markdown("""<h1><center>Blockchain Simulator<br><h3>(Transactions have no value)<br><h4>Chain will reset at 20 blocks""")
|
| 596 |
+
#blockchain = gr.State()
|
| 597 |
with gr.Row():
|
| 598 |
+
with gr.Tab("OG"):
|
| 599 |
+
with gr.Row():
|
| 600 |
+
with gr.Column():
|
| 601 |
+
with gr.Accordion(label="Load",open=False):
|
| 602 |
+
with gr.Row():
|
| 603 |
+
chain_repo=gr.Textbox(label="repo/name")
|
| 604 |
+
chain_n=gr.Textbox(label="Chain file")
|
| 605 |
+
with gr.Row():
|
| 606 |
+
in_chain_btn=gr.Button("Load Chain")
|
| 607 |
+
create_bc = gr.Button("Create New Blockchain")
|
| 608 |
+
#send=gr.Textbox(label="Sender")
|
| 609 |
+
send = gr.Dropdown(label="Sender", choices=[f for f in send_list], value = "Bank")
|
| 610 |
+
rec=gr.Dropdown(label="Recipient", choices=[f for f in rec_list], allow_custom_value=True)
|
| 611 |
+
am=gr.Textbox(label="Amount")
|
| 612 |
+
send_trans=gr.Button("Post Transaction")
|
| 613 |
+
mine_b = gr.Button("Mine Block")
|
| 614 |
+
check = gr.Button("Check Chain")
|
| 615 |
+
check_trans = gr.Button("Check Transactions")
|
| 616 |
+
check_all = gr.Button("Check All")
|
| 617 |
+
with gr.Column():
|
| 618 |
+
block_text = gr.Textbox()
|
| 619 |
+
trans_data = gr.Dataframe()
|
| 620 |
+
json_out = gr.JSON()
|
| 621 |
+
chain_json = gr.JSON()
|
| 622 |
+
with gr.Accordion("Nodes", open=False):
|
| 623 |
with gr.Row():
|
| 624 |
+
this_space=gr.Textbox(label="This Repo/Space")
|
|
|
|
| 625 |
with gr.Row():
|
| 626 |
+
node_repo=gr.Textbox(label="Node Repo")
|
| 627 |
+
node_space=gr.Textbox(label="Node Space")
|
| 628 |
+
node_file=gr.Textbox(label="Node File")
|
| 629 |
+
node_add=gr.Button("Add Node")
|
| 630 |
+
with gr.Accordion("Tokens", open=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
with gr.Row():
|
| 632 |
+
with gr.Column():
|
| 633 |
+
issue_btn=gr.Button()
|
| 634 |
+
with gr.Column():
|
| 635 |
+
with gr.Row():
|
| 636 |
+
reset_blockchain=gr.Button("Reset Main Blockchain")
|
| 637 |
+
reset_source=gr.Button("Reset __Source__")
|
| 638 |
+
with gr.Row():
|
| 639 |
+
reset_sender=gr.Button("Reset Sender")
|
| 640 |
+
reset_recieve=gr.Button("Reset Recipient")
|
| 641 |
+
out_box_bool=gr.Textbox()
|
| 642 |
with gr.Row():
|
| 643 |
+
with gr.Column():
|
| 644 |
+
block_text_send = gr.Textbox()
|
| 645 |
+
trans_data_send = gr.Dataframe()
|
| 646 |
+
json_out_send = gr.JSON()
|
| 647 |
+
chain_json_send = gr.JSON()
|
| 648 |
+
with gr.Column():
|
| 649 |
+
block_text_rec = gr.Textbox()
|
| 650 |
+
trans_data_rec = gr.Dataframe()
|
| 651 |
+
json_out_rec = gr.JSON()
|
| 652 |
+
chain_json_rec = gr.JSON()
|
| 653 |
+
with gr.Tab("BC"):
|
| 654 |
+
with gr.Row():
|
| 655 |
+
with gr.Tab("Gen Wal"):
|
| 656 |
+
gen_wal_btn=gr.Button()
|
| 657 |
+
seed = gr.Textbox(label='Seed Phrase')
|
| 658 |
+
img1=gr.Pil(label='Private Key')
|
| 659 |
+
out1 = gr.Textbox(label='Private Key',max_lines=4)
|
| 660 |
+
img2=gr.Pil(label='Public Key')
|
| 661 |
+
out2 = gr.Textbox(label='Public Key',max_lines=4)
|
| 662 |
+
img3=gr.Pil(label='Address')
|
| 663 |
+
out3 = gr.Textbox(label='Address')
|
| 664 |
+
with gr.Tab("Encrypt"):
|
| 665 |
+
rsa_to_enc = gr.Textbox(label="txt to encrypt")
|
| 666 |
+
pub_key_in = gr.Image(label="Public Key", type="filepath")
|
| 667 |
+
rsa_enc_btn = gr.Button("RSA Encrypt")
|
| 668 |
+
rsa_enc_mes = gr.Textbox(label="encoded", max_lines=4)
|
| 669 |
+
qr_enc_mes = gr.Image(type="filepath")
|
| 670 |
+
with gr.Tab("Decrypt"):
|
| 671 |
+
mes_in = gr.Image(label="Message", type="filepath")
|
| 672 |
+
priv_key_in = gr.Image(label="Private Key", type="filepath")
|
| 673 |
+
rsa_dec_btn = gr.Button("RSA Decrypt")
|
| 674 |
+
rsa_dec_mes = gr.Textbox(label="decoded")
|
| 675 |
+
|
| 676 |
+
|
| 677 |
|
| 678 |
def res_bc():
|
| 679 |
blockchain.reset(create="chain1.json")
|