update code

This commit is contained in:
ddawson
2023-06-21 12:12:33 -07:00
parent dc0e3ca191
commit a0fef7a975
12 changed files with 644 additions and 388 deletions

View File

@@ -2,14 +2,12 @@ import tkinter as tk
import xrpl
import json
from mod1 import get_account
from mod1 import get_account_info
from mod1 import send_xrp
from mod1 import get_account, get_account_info, send_xrp
#############################################
## Handlers #################################
#############################################
# sb seed: snk7pMfHPZoUpwMQuFApo3XTLRJhn
# op seed: spmiHeaCDMFX56SNZVsCbi34WEE52
@@ -19,12 +17,16 @@ def get_standby_account():
ent_standby_seed.delete(0, tk.END)
ent_standby_account.insert(0, new_wallet.classic_address)
ent_standby_seed.insert(0, new_wallet.seed)
def get_standby_account_info():
accountInfo = get_account_info(ent_standby_account.get())
ent_standby_balance.delete(0, tk.END)
ent_standby_balance.insert(0,accountInfo['Balance'])
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
def standby_send_xrp():
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get())
@@ -32,18 +34,24 @@ def standby_send_xrp():
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
get_standby_account_info()
get_operational_account_info()
def get_operational_account():
new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed)
def get_operational_account_info():
accountInfo = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operational_send_xrp():
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END)
@@ -51,6 +59,7 @@ def operational_send_xrp():
get_standby_account_info()
get_operational_account_info()
# Create a new window with the title "Quickstart Module 1"
window = tk.Tk()
window.title("Quickstart Module 1")
@@ -64,12 +73,12 @@ lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
ent_standby_seed = tk.Entry(master=frm_form, width=50)
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
ent_standby_account = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
ent_standby_amount = tk.Entry(master=frm_form, width=50)
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
ent_standby_destination = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standby_results = tk.Label(master=frm_form,text='Results')
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
@@ -96,12 +105,12 @@ lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
ent_operational_seed = tk.Entry(master=frm_form, width=50)
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
ent_operational_account = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
ent_operational_amount = tk.Entry(master=frm_form, width=50)
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
ent_operational_destination = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_results = tk.Label(master=frm_form,text='Results')
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)

View File

@@ -2,14 +2,13 @@ import tkinter as tk
import xrpl
import json
from mod2 import create_trust_line
from mod2 import send_currency
from mod2 import get_balance
from mod2 import configure_account
from mod1 import get_account
from mod1 import get_account_info
from mod1 import send_xrp
from mod1 import get_account, get_account_info, send_xrp
from mod2 import (
create_trust_line,
send_currency,
get_balance,
configure_account,
)
#############################################
## Handlers #################################
@@ -23,6 +22,8 @@ def standby_create_trust_line():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_send_currency():
results = send_currency(ent_standby_seed.get(),
ent_standby_destination.get(),
@@ -30,12 +31,16 @@ def standby_send_currency():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_configure_account():
results = configure_account(
ent_standby_seed.get(),
standbyRippling)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_create_trust_line():
results = create_trust_line(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -43,6 +48,8 @@ def operational_create_trust_line():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_send_currency():
results = send_currency(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -50,19 +57,24 @@ def operational_send_currency():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_configure_account():
results = configure_account(
ent_operational_seed.get(),
operationalRippling)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def get_balances():
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
text_standby_results.insert("1.0", json.dumps(results, indent=4))
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 1 Handlers
def get_standby_account():
@@ -71,12 +83,16 @@ def get_standby_account():
ent_standby_seed.delete(0, tk.END)
ent_standby_account.insert(0, new_wallet.classic_address)
ent_standby_seed.insert(0, new_wallet.seed)
def get_standby_account_info():
accountInfo = get_account_info(ent_standby_account.get())
ent_standby_balance.delete(0, tk.END)
ent_standby_balance.insert(0,accountInfo['Balance'])
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
def standby_send_xrp():
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get())
@@ -84,18 +100,24 @@ def standby_send_xrp():
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
get_standby_account_info()
get_operational_account_info()
def get_operational_account():
new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed)
def get_operational_account_info():
accountInfo = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operational_send_xrp():
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END)
@@ -103,6 +125,7 @@ def operational_send_xrp():
get_standby_account_info()
get_operational_account_info()
# Create a new window with the title "Quickstart Module 2"
window = tk.Tk()
window.title("Quickstart Module 2")
@@ -121,12 +144,12 @@ lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
ent_standby_seed = tk.Entry(master=frm_form, width=50)
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
ent_standby_account = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
ent_standby_amount = tk.Entry(master=frm_form, width=50)
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
ent_standby_destination = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
ent_standby_currency = tk.Entry(master=frm_form, width=50)
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
@@ -160,12 +183,12 @@ lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
ent_operational_seed = tk.Entry(master=frm_form, width=50)
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
ent_operational_account = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
ent_operational_amount = tk.Entry(master=frm_form, width=50)
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
ent_operational_destination = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
ent_operational_currency = tk.Entry(master=frm_form, width=50)
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)

View File

@@ -2,23 +2,23 @@ import tkinter as tk
import xrpl
import json
from mod3 import mint_token
from mod3 import get_tokens
from mod3 import burn_token
from mod2 import create_trust_line
from mod2 import send_currency
from mod2 import get_balance
from mod2 import configure_account
from mod1 import get_account
from mod1 import get_account_info
from mod1 import send_xrp
from mod1 import get_account, get_account_info, send_xrp
from mod2 import (
create_trust_line,
send_currency,
get_balance,
configure_account,
)
from mod3 import (
mint_token,
get_tokens,
burn_token,
)
#############################################
## Handlers #################################
#############################################
# Module 3 Handlers
def standby_mint_token():
@@ -31,10 +31,14 @@ def standby_mint_token():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_get_tokens():
results = get_tokens(ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_burn_token():
results = burn_token(
ent_standby_seed.get(),
@@ -42,6 +46,8 @@ def standby_burn_token():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_mint_token():
results = mint_token(
ent_operational_seed.get(),
@@ -52,10 +58,14 @@ def operational_mint_token():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_get_tokens():
results = get_tokens(ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_burn_token():
results = burn_token(
ent_operational_seed.get(),
@@ -64,6 +74,7 @@ def operational_burn_token():
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 2 Handlers
def standby_create_trust_line():
@@ -73,6 +84,8 @@ def standby_create_trust_line():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_send_currency():
results = send_currency(ent_standby_seed.get(),
ent_standby_destination.get(),
@@ -80,12 +93,16 @@ def standby_send_currency():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_configure_account():
results = configure_account(
ent_standby_seed.get(),
standbyRippling)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_create_trust_line():
results = create_trust_line(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -93,6 +110,8 @@ def operational_create_trust_line():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_send_currency():
results = send_currency(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -100,19 +119,23 @@ def operational_send_currency():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_configure_account():
results = configure_account(
ent_operational_seed.get(),
operationalRippling)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def get_balances():
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
text_standby_results.insert("1.0", json.dumps(results, indent=4))
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 1 Handlers
def get_standby_account():
@@ -121,12 +144,16 @@ def get_standby_account():
ent_standby_seed.delete(0, tk.END)
ent_standby_account.insert(0, new_wallet.classic_address)
ent_standby_seed.insert(0, new_wallet.seed)
def get_standby_account_info():
accountInfo = get_account_info(ent_standby_account.get())
ent_standby_balance.delete(0, tk.END)
ent_standby_balance.insert(0,accountInfo['Balance'])
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
def standby_send_xrp():
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get())
@@ -134,18 +161,24 @@ def standby_send_xrp():
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
get_standby_account_info()
get_operational_account_info()
def get_operational_account():
new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed)
def get_operational_account_info():
accountInfo = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operational_send_xrp():
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END)
@@ -153,6 +186,7 @@ def operational_send_xrp():
get_standby_account_info()
get_operational_account_info()
# Create a new window with the title "Quickstart Module 3"
window = tk.Tk()
window.title("Quickstart Module 3")
@@ -171,12 +205,12 @@ lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
ent_standby_seed = tk.Entry(master=frm_form, width=50)
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
ent_standby_account = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
ent_standby_amount = tk.Entry(master=frm_form, width=50)
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
ent_standby_destination = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
ent_standby_currency = tk.Entry(master=frm_form, width=50)
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
@@ -234,12 +268,12 @@ lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
ent_operational_seed = tk.Entry(master=frm_form, width=50)
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
ent_operational_account = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
ent_operational_amount = tk.Entry(master=frm_form, width=50)
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
ent_operational_destination = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
ent_operational_currency = tk.Entry(master=frm_form, width=50)
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)

View File

@@ -2,25 +2,26 @@ import tkinter as tk
import xrpl
import json
from mod4 import create_sell_offer
from mod4 import create_buy_offer
from mod4 import get_offers
from mod4 import cancel_offer
from mod4 import accept_sell_offer
from mod4 import accept_buy_offer
from mod3 import mint_token
from mod3 import get_tokens
from mod3 import burn_token
from mod2 import create_trust_line
from mod2 import send_currency
from mod2 import get_balance
from mod2 import configure_account
from mod1 import get_account
from mod1 import get_account_info
from mod1 import send_xrp
from mod1 import get_account, get_account_info, send_xrp
from mod2 import (
create_trust_line,
send_currency,
get_balance,
configure_account,
)
from mod3 import (
mint_token,
get_tokens,
burn_token,
)
from mod4 import (
create_sell_offer,
create_buy_offer,
get_offers,
cancel_offer,
accept_sell_offer,
accept_buy_offer,
)
#############################################
## Handlers #################################
@@ -38,6 +39,8 @@ def standby_create_sell_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_accept_sell_offer():
results = accept_sell_offer (
ent_standby_seed.get(),
@@ -45,6 +48,8 @@ def standby_accept_sell_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_create_buy_offer():
results = create_buy_offer(
ent_standby_seed.get(),
@@ -56,6 +61,8 @@ def standby_create_buy_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_accept_buy_offer():
results = accept_buy_offer (
ent_standby_seed.get(),
@@ -63,17 +70,23 @@ def standby_accept_buy_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_get_offers():
results = get_offers(ent_standby_nft_id.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", results)
def standby_cancel_offer():
results = cancel_offer(
ent_standby_seed.get(),
ent_standby_nft_offer_index.get()
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def op_create_sell_offer():
results = create_sell_offer(
ent_operational_seed.get(),
@@ -84,6 +97,8 @@ def op_create_sell_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_accept_sell_offer():
results = accept_sell_offer (
ent_operational_seed.get(),
@@ -91,6 +106,8 @@ def op_accept_sell_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_create_buy_offer():
results = create_buy_offer(
ent_operational_seed.get(),
@@ -101,7 +118,9 @@ def op_create_buy_offer():
ent_operational_destination.get()
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_accept_buy_offer():
results = accept_buy_offer (
ent_operational_seed.get(),
@@ -109,17 +128,21 @@ def op_accept_buy_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_get_offers():
results = get_offers(ent_operational_nft_id.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", results)
def op_cancel_offer():
results = cancel_offer(
ent_operational_seed.get(),
ent_operational_nft_offer_index.get()
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 3 Handlers
@@ -134,10 +157,14 @@ def standby_mint_token():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_get_tokens():
results = get_tokens(ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_burn_token():
results = burn_token(
ent_standby_seed.get(),
@@ -145,6 +172,8 @@ def standby_burn_token():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_mint_token():
results = mint_token(
ent_operational_seed.get(),
@@ -155,10 +184,14 @@ def operational_mint_token():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_get_tokens():
results = get_tokens(ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_burn_token():
results = burn_token(
ent_operational_seed.get(),
@@ -167,6 +200,7 @@ def operational_burn_token():
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 2 Handlers
def standby_create_trust_line():
@@ -176,6 +210,8 @@ def standby_create_trust_line():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_send_currency():
results = send_currency(ent_standby_seed.get(),
ent_standby_destination.get(),
@@ -183,12 +219,16 @@ def standby_send_currency():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_configure_account():
results = configure_account(
ent_standby_seed.get(),
standbyRippling)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_create_trust_line():
results = create_trust_line(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -196,6 +236,8 @@ def operational_create_trust_line():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_send_currency():
results = send_currency(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -203,19 +245,24 @@ def operational_send_currency():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_configure_account():
results = configure_account(
ent_operational_seed.get(),
operationalRippling)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def get_balances():
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
text_standby_results.insert("1.0", json.dumps(results, indent=4))
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 1 Handlers
def get_standby_account():
@@ -224,12 +271,16 @@ def get_standby_account():
ent_standby_seed.delete(0, tk.END)
ent_standby_account.insert(0, new_wallet.classic_address)
ent_standby_seed.insert(0, new_wallet.seed)
def get_standby_account_info():
accountInfo = get_account_info(ent_standby_account.get())
ent_standby_balance.delete(0, tk.END)
ent_standby_balance.insert(0,accountInfo['Balance'])
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
def standby_send_xrp():
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get())
@@ -237,18 +288,24 @@ def standby_send_xrp():
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
get_standby_account_info()
get_operational_account_info()
def get_operational_account():
new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed)
def get_operational_account_info():
accountInfo = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operational_send_xrp():
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END)
@@ -256,6 +313,7 @@ def operational_send_xrp():
get_standby_account_info()
get_operational_account_info()
# Create a new window with the title "Quickstart Module 4"
window = tk.Tk()
window.title("Quickstart Module 4")
@@ -274,12 +332,12 @@ lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
ent_standby_seed = tk.Entry(master=frm_form, width=50)
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
ent_standby_account = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
ent_standby_amount = tk.Entry(master=frm_form, width=50)
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
ent_standby_destination = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
ent_standby_currency = tk.Entry(master=frm_form, width=50)
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
@@ -299,8 +357,6 @@ lbl_standby_owner = tk.Label(master=frm_form, text="Owner")
ent_standby_owner = tk.Entry(master=frm_form, width="50")
lbl_standby_expiration = tk.Label(master=frm_form, text="Expiration")
ent_standby_expiration = tk.Entry(master=frm_form, width="50")
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
lbl_standby_results = tk.Label(master=frm_form,text='Results')
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
@@ -351,12 +407,12 @@ lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
ent_operational_seed = tk.Entry(master=frm_form, width=50)
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
ent_operational_account = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
ent_operational_amount = tk.Entry(master=frm_form, width=50)
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
ent_operational_destination = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
ent_operational_currency = tk.Entry(master=frm_form, width=50)
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
@@ -376,8 +432,6 @@ lbl_operational_owner = tk.Label(master=frm_form, text="Owner")
ent_operational_owner = tk.Entry(master=frm_form, width="50")
lbl_operational_expiration = tk.Label(master=frm_form, text="Expiration")
ent_operational_expiration = tk.Entry(master=frm_form, width="50")
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
lbl_operational_results = tk.Label(master=frm_form,text="Results")
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)

View File

@@ -2,28 +2,28 @@ import tkinter as tk
import xrpl
import json
from mod1 import get_account, get_account_info, send_xrp
from mod2 import (
create_trust_line,
send_currency,
get_balance,
configure_account,
)
from mod3 import (
mint_token,
get_tokens,
burn_token,
)
from mod4 import (
create_sell_offer,
create_buy_offer,
get_offers,
cancel_offer,
accept_sell_offer,
accept_buy_offer,
)
from mod5 import broker_sale
from mod4 import create_sell_offer
from mod4 import create_buy_offer
from mod4 import get_offers
from mod4 import cancel_offer
from mod4 import accept_sell_offer
from mod4 import accept_buy_offer
from mod3 import mint_token
from mod3 import get_tokens
from mod3 import burn_token
from mod2 import create_trust_line
from mod2 import send_currency
from mod2 import get_balance
from mod2 import configure_account
from mod1 import get_account
from mod1 import get_account_info
from mod1 import send_xrp
#############################################
## Handlers #################################
#############################################
@@ -36,12 +36,16 @@ def get_broker_account():
ent_broker_seed.delete(0, tk.END)
ent_broker_account.insert(0, new_wallet.classic_address)
ent_broker_seed.insert(0, new_wallet.seed)
def get_broker_account_info():
accountInfo = get_account_info(ent_broker_account.get())
ent_broker_balance.delete(0, tk.END)
ent_broker_balance.insert(0,accountInfo['Balance'])
text_broker_results.delete("1.0", tk.END)
text_broker_results.insert("1.0",json.dumps(accountInfo, indent=4))
def broker_broker_sale():
results = broker_sale(
ent_broker_seed.get(),
@@ -50,18 +54,22 @@ def broker_broker_sale():
ent_broker_fee.get()
)
text_broker_results.delete("1.0", tk.END)
text_broker_results.insert("1.0", json.dumps(results, indent=4))
text_broker_results.insert("1.0", json.dumps(results, indent=4))
def broker_get_offers():
results = get_offers(ent_broker_nft_id.get())
text_broker_results.delete("1.0", tk.END)
text_broker_results.insert("1.0", results)
def broker_cancel_offer():
results = cancel_offer(
ent_broker_seed.get(),
ent_broker_buy_nft_idx.get()
)
text_broker_results.delete("1.0", tk.END)
text_broker_results.insert("1.0", json.dumps(results, indent=4))
text_broker_results.insert("1.0", json.dumps(results, indent=4))
# Module 4 Handlers
@@ -76,6 +84,8 @@ def standby_create_sell_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_accept_sell_offer():
results = accept_sell_offer (
ent_standby_seed.get(),
@@ -83,6 +93,8 @@ def standby_accept_sell_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_create_buy_offer():
results = create_buy_offer(
ent_standby_seed.get(),
@@ -94,6 +106,8 @@ def standby_create_buy_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_accept_buy_offer():
results = accept_buy_offer (
ent_standby_seed.get(),
@@ -101,17 +115,23 @@ def standby_accept_buy_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_get_offers():
results = get_offers(ent_standby_nft_id.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", results)
def standby_cancel_offer():
results = cancel_offer(
ent_standby_seed.get(),
ent_standby_nft_offer_index.get()
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def op_create_sell_offer():
results = create_sell_offer(
ent_operational_seed.get(),
@@ -122,6 +142,8 @@ def op_create_sell_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_accept_sell_offer():
results = accept_sell_offer (
ent_operational_seed.get(),
@@ -129,6 +151,8 @@ def op_accept_sell_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_create_buy_offer():
results = create_buy_offer(
ent_operational_seed.get(),
@@ -139,7 +163,9 @@ def op_create_buy_offer():
ent_operational_destination.get()
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_accept_buy_offer():
results = accept_buy_offer (
ent_operational_seed.get(),
@@ -147,17 +173,21 @@ def op_accept_buy_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_get_offers():
results = get_offers(ent_operational_nft_id.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", results)
def op_cancel_offer():
results = cancel_offer(
ent_operational_seed.get(),
ent_operational_nft_offer_index.get()
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
@@ -173,10 +203,14 @@ def standby_mint_token():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_get_tokens():
results = get_tokens(ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_burn_token():
results = burn_token(
ent_standby_seed.get(),
@@ -184,6 +218,8 @@ def standby_burn_token():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_mint_token():
results = mint_token(
ent_operational_seed.get(),
@@ -194,10 +230,14 @@ def operational_mint_token():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_get_tokens():
results = get_tokens(ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_burn_token():
results = burn_token(
ent_operational_seed.get(),
@@ -206,6 +246,7 @@ def operational_burn_token():
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 2 Handlers
def standby_create_trust_line():
@@ -215,6 +256,8 @@ def standby_create_trust_line():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_send_currency():
results = send_currency(ent_standby_seed.get(),
ent_standby_destination.get(),
@@ -222,12 +265,16 @@ def standby_send_currency():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_configure_account():
results = configure_account(
ent_standby_seed.get(),
standbyRippling)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_create_trust_line():
results = create_trust_line(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -235,6 +282,8 @@ def operational_create_trust_line():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_send_currency():
results = send_currency(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -242,19 +291,24 @@ def operational_send_currency():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_configure_account():
results = configure_account(
ent_operational_seed.get(),
operationalRippling)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def get_balances():
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
text_standby_results.insert("1.0", json.dumps(results, indent=4))
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 1 Handlers
def get_standby_account():
@@ -263,12 +317,16 @@ def get_standby_account():
ent_standby_seed.delete(0, tk.END)
ent_standby_account.insert(0, new_wallet.classic_address)
ent_standby_seed.insert(0, new_wallet.seed)
def get_standby_account_info():
accountInfo = get_account_info(ent_standby_account.get())
ent_standby_balance.delete(0, tk.END)
ent_standby_balance.insert(0,accountInfo['Balance'])
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
def standby_send_xrp():
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get())
@@ -276,18 +334,24 @@ def standby_send_xrp():
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
get_standby_account_info()
get_operational_account_info()
def get_operational_account():
new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed)
def get_operational_account_info():
accountInfo = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operational_send_xrp():
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END)
@@ -303,7 +367,6 @@ myscrollbar=tk.Scrollbar(window,orient="vertical")
myscrollbar.pack(side="right",fill="y")
standbyRippling = tk.BooleanVar()
operationalRippling = tk.BooleanVar()
@@ -370,7 +433,7 @@ btn_broker_get_offers.grid(row=3, column=2, sticky = "nsew")
btn_broker_cancel_offer = tk.Button(master=frm_broker, text="Cancel Offer",
command = broker_cancel_offer)
btn_broker_cancel_offer.grid(row=4, column=2, sticky="nsew")
# Form frame
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
frm_form.pack()
@@ -380,12 +443,12 @@ lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
ent_standby_seed = tk.Entry(master=frm_form, width=50)
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
ent_standby_account = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
ent_standby_amount = tk.Entry(master=frm_form, width=50)
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
ent_standby_destination = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
ent_standby_currency = tk.Entry(master=frm_form, width=50)
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
@@ -405,8 +468,6 @@ lbl_standby_owner = tk.Label(master=frm_form, text="Owner")
ent_standby_owner = tk.Entry(master=frm_form, width="50")
lbl_standby_expiration = tk.Label(master=frm_form, text="Expiration")
ent_standby_expiration = tk.Entry(master=frm_form, width="50")
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
lbl_standby_results = tk.Label(master=frm_form,text='Results')
text_standby_results = tk.Text(master=frm_form, height = 10, width = 65)
@@ -457,12 +518,12 @@ lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
ent_operational_seed = tk.Entry(master=frm_form, width=50)
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
ent_operational_account = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
ent_operational_amount = tk.Entry(master=frm_form, width=50)
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
ent_operational_destination = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
ent_operational_currency = tk.Entry(master=frm_form, width=50)
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
@@ -482,8 +543,6 @@ lbl_operational_owner = tk.Label(master=frm_form, text="Owner")
ent_operational_owner = tk.Entry(master=frm_form, width="50")
lbl_operational_expiration = tk.Label(master=frm_form, text="Expiration")
ent_operational_expiration = tk.Entry(master=frm_form, width="50")
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
lbl_operational_results = tk.Label(master=frm_form,text="Results")
text_operational_results = tk.Text(master=frm_form, height = 10, width = 65)

View File

@@ -2,28 +2,28 @@ import tkinter as tk
import xrpl
import json
from mod6 import set_minter
from mod6 import mint_other
from mod4 import create_sell_offer
from mod4 import create_buy_offer
from mod4 import get_offers
from mod4 import cancel_offer
from mod4 import accept_sell_offer
from mod4 import accept_buy_offer
from mod3 import mint_token
from mod3 import get_tokens
from mod3 import burn_token
from mod2 import create_trust_line
from mod2 import send_currency
from mod2 import get_balance
from mod2 import configure_account
from mod1 import get_account
from mod1 import get_account_info
from mod1 import send_xrp
from mod1 import get_account, get_account_info, send_xrp
from mod2 import (
create_trust_line,
send_currency,
get_balance,
configure_account,
)
from mod3 import (
mint_token,
get_tokens,
burn_token,
)
from mod4 import (
create_sell_offer,
create_buy_offer,
get_offers,
cancel_offer,
accept_sell_offer,
accept_buy_offer,
)
from mod5 import broker_sale
from mod6 import set_minter, mint_other
#############################################
## Handlers #################################
@@ -35,6 +35,8 @@ def standby_set_minter():
results = set_minter(ent_standby_seed.get(),ent_standby_auth_minter.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_mint_other():
results = mint_other(
ent_standby_seed.get(),
@@ -46,10 +48,14 @@ def standby_mint_other():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_set_minter():
results = set_minter(ent_operational_seed.get(),ent_operational_auth_minter.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_mint_other():
results = mint_other(
ent_operational_seed.get(),
@@ -62,6 +68,7 @@ def operational_mint_other():
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 4 Handlers
def standby_create_sell_offer():
@@ -74,6 +81,8 @@ def standby_create_sell_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_accept_sell_offer():
results = accept_sell_offer (
ent_standby_seed.get(),
@@ -81,6 +90,8 @@ def standby_accept_sell_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_create_buy_offer():
results = create_buy_offer(
ent_standby_seed.get(),
@@ -92,6 +103,8 @@ def standby_create_buy_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_accept_buy_offer():
results = accept_buy_offer (
ent_standby_seed.get(),
@@ -99,17 +112,23 @@ def standby_accept_buy_offer():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_get_offers():
results = get_offers(ent_standby_nft_id.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", results)
def standby_cancel_offer():
results = cancel_offer(
ent_standby_seed.get(),
ent_standby_nft_offer_index.get()
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def op_create_sell_offer():
results = create_sell_offer(
ent_operational_seed.get(),
@@ -120,6 +139,8 @@ def op_create_sell_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_accept_sell_offer():
results = accept_sell_offer (
ent_operational_seed.get(),
@@ -127,6 +148,8 @@ def op_accept_sell_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_create_buy_offer():
results = create_buy_offer(
ent_operational_seed.get(),
@@ -137,7 +160,9 @@ def op_create_buy_offer():
ent_operational_destination.get()
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_accept_buy_offer():
results = accept_buy_offer (
ent_operational_seed.get(),
@@ -145,17 +170,21 @@ def op_accept_buy_offer():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def op_get_offers():
results = get_offers(ent_operational_nft_id.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", results)
def op_cancel_offer():
results = cancel_offer(
ent_operational_seed.get(),
ent_operational_nft_offer_index.get()
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
@@ -171,10 +200,14 @@ def standby_mint_token():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_get_tokens():
results = get_tokens(ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_burn_token():
results = burn_token(
ent_standby_seed.get(),
@@ -182,6 +215,8 @@ def standby_burn_token():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_mint_token():
results = mint_token(
ent_operational_seed.get(),
@@ -192,10 +227,14 @@ def operational_mint_token():
)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_get_tokens():
results = get_tokens(ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_burn_token():
results = burn_token(
ent_operational_seed.get(),
@@ -204,6 +243,7 @@ def operational_burn_token():
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 2 Handlers
def standby_create_trust_line():
@@ -213,6 +253,8 @@ def standby_create_trust_line():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_send_currency():
results = send_currency(ent_standby_seed.get(),
ent_standby_destination.get(),
@@ -220,12 +262,16 @@ def standby_send_currency():
ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def standby_configure_account():
results = configure_account(
ent_standby_seed.get(),
standbyRippling)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_create_trust_line():
results = create_trust_line(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -233,6 +279,8 @@ def operational_create_trust_line():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_send_currency():
results = send_currency(ent_operational_seed.get(),
ent_operational_destination.get(),
@@ -240,19 +288,24 @@ def operational_send_currency():
ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def operational_configure_account():
results = configure_account(
ent_operational_seed.get(),
operationalRippling)
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
def get_balances():
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
text_standby_results.insert("1.0", json.dumps(results, indent=4))
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
# Module 1 Handlers
def get_standby_account():
@@ -261,12 +314,16 @@ def get_standby_account():
ent_standby_seed.delete(0, tk.END)
ent_standby_account.insert(0, new_wallet.classic_address)
ent_standby_seed.insert(0, new_wallet.seed)
def get_standby_account_info():
accountInfo = get_account_info(ent_standby_account.get())
ent_standby_balance.delete(0, tk.END)
ent_standby_balance.insert(0,accountInfo['Balance'])
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
def standby_send_xrp():
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get())
@@ -274,18 +331,24 @@ def standby_send_xrp():
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
get_standby_account_info()
get_operational_account_info()
def get_operational_account():
new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed)
def get_operational_account_info():
accountInfo = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operational_send_xrp():
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END)
@@ -293,6 +356,7 @@ def operational_send_xrp():
get_standby_account_info()
get_operational_account_info()
# Create a new window with the title "Quickstart - Authorized Minter"
window = tk.Tk()
window.title("Quickstart - Authorized Minter")
@@ -312,12 +376,12 @@ lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
ent_standby_seed = tk.Entry(master=frm_form, width=50)
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
ent_standby_account = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
ent_standby_amount = tk.Entry(master=frm_form, width=50)
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
ent_standby_destination = tk.Entry(master=frm_form, width=50)
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_standby_balance = tk.Entry(master=frm_form, width=50)
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
ent_standby_currency = tk.Entry(master=frm_form, width=50)
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
@@ -337,8 +401,6 @@ lbl_standby_owner = tk.Label(master=frm_form, text="Owner")
ent_standby_owner = tk.Entry(master=frm_form, width="50")
lbl_standby_expiration = tk.Label(master=frm_form, text="Expiration")
ent_standby_expiration = tk.Entry(master=frm_form, width="50")
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
lbl_standby_auth_minter = tk.Label(master=frm_form, text="Authorized Minter")
ent_standby_auth_minter = tk.Entry(master=frm_form, width="50")
lbl_standby_issuer = tk.Label(master=frm_form, text="Issuer")
@@ -395,12 +457,12 @@ lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
ent_operational_seed = tk.Entry(master=frm_form, width=50)
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
ent_operational_account = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
ent_operational_amount = tk.Entry(master=frm_form, width=50)
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
ent_operational_destination = tk.Entry(master=frm_form, width=50)
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
ent_operational_balance = tk.Entry(master=frm_form, width=50)
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
ent_operational_currency = tk.Entry(master=frm_form, width=50)
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
@@ -420,8 +482,6 @@ lbl_operational_owner = tk.Label(master=frm_form, text="Owner")
ent_operational_owner = tk.Entry(master=frm_form, width="50")
lbl_operational_expiration = tk.Label(master=frm_form, text="Expiration")
ent_operational_expiration = tk.Entry(master=frm_form, width="50")
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
lbl_operational_auth_minter = tk.Label(master=frm_form, text="Authorized Minter")
ent_operational_auth_minter = tk.Entry(master=frm_form, width="50")
lbl_operational_issuer = tk.Label(master=frm_form, text="Issuer")

View File

@@ -1,45 +1,40 @@
import xrpl
import json
import xrpl.clients
import xrpl.wallet
def get_account(_seed):
from xrpl.clients import JsonRpcClient
from xrpl.wallet import Wallet
def get_account(seed):
"""get_account"""
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
client = JsonRpcClient(JSON_RPC_URL)
if (_seed == ''):
client = xrpl.clients.JsonRpcClient(JSON_RPC_URL)
if (seed == ''):
new_wallet = xrpl.wallet.generate_faucet_wallet(client)
else:
new_wallet = Wallet(_seed, sequence = 79396029)
new_wallet = xrpl.wallet.Wallet(seed, sequence = 79396029)
return(new_wallet)
def get_account_info(_accountId):
from xrpl.clients import JsonRpcClient
from xrpl.models.requests.account_info import AccountInfo
import json
def get_account_info(accountId):
"""get_account_info"""
JSON_RPC_URL = 'wss://s.altnet.rippletest.net:51234'
client = JsonRpcClient(JSON_RPC_URL)
acct_info = AccountInfo(
account=_accountId,
client = xrpl.clients.JsonRpcClient(JSON_RPC_URL)
acct_info = xrpl.models.requests.account_info.AccountInfo(
account=accountId,
ledger_index="validated"
)
response = client.request(acct_info)
return response.result['account_data']
def send_xrp(_seed, _amount, _destination):
from xrpl.clients import JsonRpcClient
from xrpl.wallet import Wallet
sending_wallet = Wallet(_seed, sequence = 16237283)
def send_xrp(seed, amount, destination):
sending_wallet = xrpl.wallet.Wallet(seed, sequence = 16237283)
testnet_url = "https://s.altnet.rippletest.net:51234"
client = JsonRpcClient(testnet_url)
client = xrpl.clients.JsonRpcClient(testnet_url)
payment = xrpl.models.transactions.Payment(
account=sending_wallet.classic_address,
amount=xrpl.utils.xrp_to_drops(int(_amount)),
destination=_destination,
amount=xrpl.utils.xrp_to_drops(int(amount)),
destination=destination,
)
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
payment, sending_wallet, client)
# max_ledger = signed_tx.last_ledger_sequence
# tx_id = signed_tx.get_hash()
payment, sending_wallet, client)
try:
tx_response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response = tx_response

View File

@@ -11,68 +11,75 @@ testnet_url = "https://s.altnet.rippletest.net:51234"
# create_trust_line #
#####################
def create_trust_line(_seed, _issuer, _currency, _amount):
def create_trust_line(seed, issuer, currency, amount):
"""create_trust_line"""
# Get the client
receiving_wallet = Wallet(_seed, sequence = 16237283)
receiving_wallet = Wallet(seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
# Define the trust line transaction
trustline_tx = xrpl.models.transactions.TrustSet(
account = receiving_wallet.classic_address,
limit_amount = xrpl.models.amounts.IssuedCurrencyAmount(
currency = _currency,
issuer = _issuer,
value = int(_amount)
trustline_tx=xrpl.models.transactions.TrustSet(
account=receiving_wallet.classic_address,
limit_amount=xrpl.models.amounts.IssuedCurrencyAmount(
currency=currency,
issuer=issuer,
value=int(amount)
)
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
trustline_tx, receiving_wallet, client)
trustline_tx, receiving_wallet, client)
# Submit the transaction and get results
reply = ""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
reply = response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply = f"Submit failed: {e}"
return reply
#################
# send_currency #
#################
def send_currency(_seed, _destination, _currency, _amount):
def send_currency(seed, destination, currency, amount):
"""send_currency"""
# Get the client
sending_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
sending_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
# Define the payment transaction.
send_currency_tx = xrpl.models.transactions.Payment(
account = sending_wallet.classic_address,
amount = xrpl.models.amounts.IssuedCurrencyAmount(
currency = _currency,
value = int(_amount),
issuer = sending_wallet.classic_address
send_currency_tx=xrpl.models.transactions.Payment(
account=sending_wallet.classic_address,
amount=xrpl.models.amounts.IssuedCurrencyAmount(
currency=currency,
value=int(amount),
issuer=sending_wallet.classic_address
),
destination=_destination
destination=destination
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
send_currency_tx, sending_wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
send_currency_tx, sending_wallet, client)
# Submit the transaction and get results
reply = ""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply = response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply = f"Submit failed: {e}"
return reply
###############
# get_balance #
###############
def get_balance(_sb_account_id, _op_account_id):
JSON_RPC_URL = 'wss://s.altnet.rippletest.net:51234'
client = JsonRpcClient(JSON_RPC_URL)
balance = xrpl.models.requests.GatewayBalances(
account=_sb_account_id,
def get_balance(sb_account_id, op_account_id):
"""get_balance"""
JSON_RPC_URL='wss://s.altnet.rippletest.net:51234'
client=JsonRpcClient(JSON_RPC_URL)
balance=xrpl.models.requests.GatewayBalances(
account=sb_account_id,
ledger_index="validated",
hotwallet=[_op_account_id]
hotwallet=[op_account_id]
)
response = client.request(balance)
return response.result
@@ -81,29 +88,32 @@ def get_balance(_sb_account_id, _op_account_id):
# configure_account #
#####################
def configure_account(_seed, _default_setting):
def configure_account(seed, default_setting):
"""configure_account"""
# Get the client
wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
wallet=Wallet(seed, sequence = 16237283)
client=JsonRpcClient(testnet_url)
# Create transaction
if (_default_setting.get()):
setting_tx = xrpl.models.transactions.AccountSet(
account = wallet.classic_address,
if (default_setting):
setting_tx=xrpl.models.transactions.AccountSet(
account=wallet.classic_address,
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
)
else:
setting_tx = xrpl.models.transactions.AccountSet(
account = wallet.classic_address,
clear_flag = xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
setting_tx=xrpl.models.transactions.AccountSet(
account=wallet.classic_address,
clear_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
setting_tx, wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
setting_tx, wallet, client)
# Submit the transaction and get results
reply = ""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
reply = response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response.result = f"Submit failed: {e}"
return response.result
reply = f"Submit failed: {e}"
return reply

View File

@@ -6,67 +6,59 @@ from xrpl.models.requests import AccountNFTs
testnet_url = "https://s.altnet.rippletest.net:51234"
##############
# mint_token #
##############
def mint_token(_seed, _uri, _flags, _transfer_fee, _taxon):
def mint_token(seed, uri, flags, transfer_fee, taxon):
"""mint_token"""
# Get the client
mint_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
mint_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
# Define the mint transaction
mint_tx = xrpl.models.transactions.NFTokenMint(
account = mint_wallet.classic_address,
uri = xrpl.utils.str_to_hex(_uri),
flags = int(_flags),
transfer_fee = int(_transfer_fee),
nftoken_taxon = int(_taxon)
mint_tx=xrpl.models.transactions.NFTokenMint(
account=mint_wallet.classic_address,
uri=xrpl.utils.str_to_hex(uri),
flags=int(flags),
transfer_fee=int(transfer_fee),
nftoken_taxon=int(taxon)
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
mint_tx, mint_wallet, client)
mint_tx, mint_wallet, client)
# Submit the transaction and get results
reply=""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply=f"Submit failed: {e}"
return reply
##############
# get_tokens #
##############
def get_tokens(_account):
from xrpl.clients import JsonRpcClient
import json
client = JsonRpcClient(testnet_url)
acct_nfts = AccountNFTs(
account=_account
def get_tokens(account):
"""get_tokens"""
client=JsonRpcClient(testnet_url)
acct_nfts=AccountNFTs(
account=account
)
response = client.request(acct_nfts)
response=client.request(acct_nfts)
return response.result
##############
# burn_token #
##############
def burn_token(_seed, _nftoken_id):
def burn_token(seed, nftoken_id):
"""burn_token"""
# Get the client
owner_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
burn_tx = xrpl.models.transactions.NFTokenBurn(
account = owner_wallet.classic_address,
nftoken_id = _nftoken_id
owner_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
burn_tx=xrpl.models.transactions.NFTokenBurn(
account=owner_wallet.classic_address,
nftoken_id=nftoken_id
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
burn_tx, owner_wallet, client)
# Submit the transaction and get results
reply=""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply=f"Submit failed: {e}"
return reply

View File

@@ -9,126 +9,141 @@ from xrpl.models.requests import NFTBuyOffers
from xrpl.models.transactions import NFTokenAcceptOffer
testnet_url = "https://s.altnet.rippletest.net:51234"
def create_sell_offer(_seed, _amount, _nftoken_id, _expiration, _destination):
def create_sell_offer(seed, amount, nftoken_id, expiration, destination):
"""create_sell_offer"""
# Get the client
owner_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
owner_wallet = Wallet(seed, sequence=16237283)
client = JsonRpcClient(testnet_url)
expiration_date = datetime.now()
if (_expiration != ''):
if expiration != '':
expiration_date = xrpl.utils.datetime_to_ripple_time(expiration_date)
expiration_date = expiration_date + int(_expiration)
expiration_date = expiration_date + int(expiration)
# Define the sell offer
sell_offer_tx = xrpl.models.transactions.NFTokenCreateOffer(
account = owner_wallet.classic_address,
nftoken_id = _nftoken_id,
amount = _amount,
destination=_destination if _destination != '' else None,
expiration = expiration_date if _expiration != '' else None,
flags = 1
sell_offer_tx=xrpl.models.transactions.NFTokenCreateOffer(
account=owner_wallet.classic_address,
nftoken_id=nftoken_id,
amount=amount,
destination=destination if destination != '' else None,
expiration=expiration_date if expiration != '' else None,
flags=1
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
sell_offer_tx, owner_wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
sell_offer_tx, owner_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
def accept_sell_offer(_seed, _offer_index):
buyer_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
accept_offer_tx = xrpl.models.transactions.NFTokenAcceptOffer(
account = buyer_wallet.classic_address,
nftoken_sell_offer = _offer_index
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
accept_offer_tx, buyer_wallet, client)
# Submit the transaction and report the results
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply=f"Submit failed: {e}"
return reply
def create_buy_offer(_seed, _amount, _nft_id, _owner, _expiration, _destination):
def accept_sell_offer(seed, offer_index):
"""accept_sell_offer"""
buyer_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
account=buyer_wallet.classic_address,
nftoken_sell_offer=offer_index
)
# Sign and fill the transaction
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
accept_offer_tx, buyer_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
reply=f"Submit failed: {e}"
return reply
def create_buy_offer(seed, amount, nft_id, owner, expiration, destination):
"""create_buy_offer"""
# Get the client
buyer_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
expiration_date = datetime.now()
if (_expiration != ''):
expiration_date = xrpl.utils.datetime_to_ripple_time(expiration_date)
expiration_date = expiration_date + int(_expiration)
buyer_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
expiration_date=datetime.now()
if (expiration!=''):
expiration_date=xrpl.utils.datetime_to_ripple_time(expiration_date)
expiration_date=expiration_date + int(expiration)
# Define the buy offer transaction with an expiration date
buy_offer_tx = xrpl.models.transactions.NFTokenCreateOffer(
account = buyer_wallet.classic_address,
nftoken_id = _nft_id,
amount = _amount,
owner = _owner,
expiration = expiration_date if _expiration != '' else None,
destination=_destination if _destination != '' else None,
flags = 0
buy_offer_tx=xrpl.models.transactions.NFTokenCreateOffer(
account=buyer_wallet.classic_address,
nftoken_id=nft_id,
amount=amount,
owner=owner,
expiration=expiration_date if expiration!='' else None,
destination=destination if destination!='' else None,
flags=0
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
buy_offer_tx, buyer_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
def accept_buy_offer(_seed, _offer_index):
buyer_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
accept_offer_tx = xrpl.models.transactions.NFTokenAcceptOffer(
account = buyer_wallet.classic_address,
nftoken_buy_offer = _offer_index
reply=f"Submit failed: {e}"
return reply
def accept_buy_offer(seed, offer_index):
"""accept_buy_offer"""
buyer_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
account=buyer_wallet.classic_address,
nftoken_buy_offer=offer_index
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
accept_offer_tx, buyer_wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
accept_offer_tx, buyer_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply=f"Submit failed: {e}"
return reply
def get_offers(_nft_id):
client = JsonRpcClient(testnet_url)
offers = NFTBuyOffers(
nft_id=_nft_id
def get_offers(nft_id):
"""get_offers"""
client=JsonRpcClient(testnet_url)
offers=NFTBuyOffers(
nft_id=nft_id
)
response = client.request(offers)
allOffers = "Buy Offers:\n" + json.dumps(response.result, indent=4)
offers = NFTSellOffers(
nft_id=_nft_id
response=client.request(offers)
allOffers="Buy Offers:\n"+json.dumps(response.result, indent=4)
offers=NFTSellOffers(
nft_id=nft_id
)
response = client.request(offers)
allOffers += "\n\nSell Offers:\n" + json.dumps(response.result, indent=4)
response=client.request(offers)
allOffers+="\n\nSell Offers:\n"+json.dumps(response.result, indent=4)
return allOffers
def cancel_offer(_seed, _nftoken_offer_ids):
owner_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
tokenOfferIDs = [_nftoken_offer_ids]
nftSellOffers = "No sell offers"
cancel_offer_tx = xrpl.models.transactions.NFTokenCancelOffer(
account = owner_wallet.classic_address,
nftoken_offers = tokenOfferIDs
)
def cancel_offer(seed, nftoken_offer_ids):
"""cancel_offer"""
owner_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
tokenOfferIDs=[nftoken_offer_ids]
nftSellOffers="No sell offers"
cancel_offer_tx=xrpl.models.transactions.NFTokenCancelOffer(
account=owner_wallet.classic_address,
nftoken_offers=tokenOfferIDs
)
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
cancel_offer_tx, owner_wallet, client)
cancel_offer_tx, owner_wallet, client)
reply=""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply=f"Submit failed: {e}"
return reply

View File

@@ -5,21 +5,24 @@ from xrpl.wallet import Wallet
testnet_url = "https://s.altnet.rippletest.net:51234"
def broker_sale(_seed, _sell_offer_index, _buy_offer_index, _broker_fee):
broker_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
accept_offer_tx = xrpl.models.transactions.NFTokenAcceptOffer(
account = broker_wallet.classic_address,
nftoken_sell_offer = _sell_offer_index,
nftoken_buy_offer = _buy_offer_index,
nftoken_broker_fee = _broker_fee
def broker_sale(seed, sell_offer_index, buy_offer_index, broker_fee):
"""broker_sale"""
broker_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
account=broker_wallet.classic_address,
nftoken_sell_offer=sell_offer_index,
nftoken_buy_offer=buy_offer_index,
nftoken_broker_fee=broker_fee
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
accept_offer_tx, broker_wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
accept_offer_tx, broker_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply=f"Submit failed: {e}"
return reply

View File

@@ -1,45 +1,47 @@
import xrpl
import xrpl
import json
from xrpl.clients import JsonRpcClient
from xrpl.wallet import Wallet
testnet_url = "https://s.altnet.rippletest.net:51234"
testnet_url="https://s.altnet.rippletest.net:51234"
def set_minter(_seed, _minter):
granter_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
def set_minter(seed, minter):
"""set_minter"""
granter_wallet=Wallet(seed, sequence = 16237283)
client=JsonRpcClient(testnet_url)
set_minter_tx = xrpl.models.transactions.AccountSet(
account = granter_wallet.classic_address,
nftoken_minter = _minter,
set_flag = xrpl.models.transactions.AccountSetFlag.ASF_AUTHORIZED_NFTOKEN_MINTER
set_minter_tx=xrpl.models.transactions.AccountSet(
account=granter_wallet.classic_address,
nftoken_minter=minter,
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_AUTHORIZED_NFTOKEN_MINTER
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
set_minter_tx, granter_wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
set_minter_tx, granter_wallet, client)
# Submit the transaction and report the results
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
response=f"Submit failed: {e}"
return response.result
def mint_other(_seed, _uri, _flags, _transfer_fee, _taxon, _issuer):
minter_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
mint_other_tx = xrpl.models.transactions.NFTokenMint(
account = minter_wallet.classic_address,
uri = xrpl.utils.str_to_hex(_uri),
flags = int(_flags),
transfer_fee = int(_transfer_fee),
nftoken_taxon = int(_taxon),
issuer = _issuer
def mint_other(seed, uri, flags, transfer_fee, taxon, issuer):
"""mint_other"""
minter_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
mint_other_tx=xrpl.models.transactions.NFTokenMint(
account=minter_wallet.classic_address,
uri=xrpl.utils.str_to_hex(uri),
flags=int(flags),
transfer_fee=int(transfer_fee),
nftoken_taxon=int(taxon),
issuer=issuer
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
mint_other_tx, minter_wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
mint_other_tx, minter_wallet, client)
# Submit the transaction and report the results
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
response=f"Submit failed: {e}"
return response.result