Snake case!

This commit is contained in:
ddawson
2023-05-18 16:59:25 -07:00
parent ace77f4660
commit 37c893b8fc
3 changed files with 242 additions and 188 deletions

View File

@@ -76,14 +76,14 @@ import xrpl
import json import json
``` ```
### getAccount ### get_account
This method lets you get an existing account by providing a seed value. If you provide no seed value, the method creates a new account for you. This method lets you get an existing account by providing a seed value. If you provide no seed value, the method creates a new account for you.
Import required methods. Import required methods.
```python ```python
def getAccount(_seed): def get_account(_seed):
from xrpl.clients import JsonRpcClient from xrpl.clients import JsonRpcClient
from xrpl.wallet import Wallet from xrpl.wallet import Wallet
``` ```
@@ -110,12 +110,12 @@ If you do not enter a seed, generate and return a new wallet. If you provide a s
return(new_wallet) return(new_wallet)
``` ```
### getAccountInfo ### get_account_info
Pass the account ID to the getAccountInfo method. Pass the account ID to the `get_account_info` method.
```python ```python
def getAccountInfo(_accountId): def get_account_info(_accountId):
``` ```
Import required methods and the JSON library. Import required methods and the JSON library.
@@ -154,12 +154,12 @@ Return the account data.
return response.result['account_data'] return response.result['account_data']
``` ```
### sendXRP ### send_xrp
Transfer XRP to another account by passing the client seed, amount to transfer, and the destination account. Transfer XRP to another account by passing the client seed, amount to transfer, and the destination account.
```python ```python
def sendXRP(_seed, _amount, _destination): def send_xrp(_seed, _amount, _destination):
``` ```
Get the sending wallet. Get the sending wallet.
@@ -215,21 +215,21 @@ import json
Import the methods from mod1.py. Import the methods from mod1.py.
```python ```python
from mod1 import getAccount from mod1 import get_account
from mod1 import getAccountInfo from mod1 import get_accountInfo
from mod1 import sendXRP from mod1 import send_xrp
``` ```
### getStandbyAccount ### getStandbyAccount
```python ```python
def getStandbyAccount(): def get_standby_account():
``` ```
Use the value in the standby Seed field (or an empty value) to request a new account. Use the value in the standby Seed field (or an empty value) to request a new account.
```python ```python
new_wallet = getAccount(ent_standby_seed.get()) new_wallet = get_account(ent_standby_seed.get())
``` ```
Clear the **Standby Seed** and **Standby Account** fields. Clear the **Standby Seed** and **Standby Account** fields.
@@ -246,13 +246,13 @@ Insert the account ID and seed values in the standby fields.
ent_standby_seed.insert(0, new_wallet.seed) ent_standby_seed.insert(0, new_wallet.seed)
``` ```
### get StandbyAccountInfo ### get_standby_account_info
With an account ID, anyone can request information about the account. Get the standby account value and use it to populate a `getAccountInfo` request. With an account ID, anyone can request information about the account. Get the standby account value and use it to populate a `get_account_info` request.
```python ```python
def getStandbyAccountInfo(): def get_standby_account_info():
accountInfo = getAccountInfo(ent_standby_account.get()) accountInfo = get_account_info(ent_standby_account.get())
``` ```
Clear the Standby **Balance** field and insert the value from the account info response. Clear the Standby **Balance** field and insert the value from the account info response.
@@ -269,15 +269,16 @@ Clear the Standby **Results** text area and fill it with the full JSON response.
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4)) text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
``` ```
### standbySendXRP ### standby_send_xrp
```python ```python
def standbySendXRP(): def standby_send_xrp():
``` ```
Call the `send_xrp` method, passing the standby seed, the amount, and the destination value.
```python ```python
Call the sendXRP method, passing the standby seed, the amount, and the destination value. response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
response = sendXRP(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get()) ent_standby_destination.get())
``` ```
@@ -288,11 +289,11 @@ Clear the standby **Results** field and insert the JSON response.
text_standby_results.insert("1.0",json.dumps(response.result, indent=4)) text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
``` ```
Use `getStandbyAccountInfo()` and `getOperationalAccountInfo()` to update the balance field for both accounts. Use `get_standby_account_info()` and `get_operational_account_info()` to update the balance field for both accounts.
```python ```python
getStandbyAccountInfo() get_standby_account_info()
getOperationalAccountInfo() get_operational_account_info()
``` ```
### Reciprocal Transactions and Requests ### Reciprocal Transactions and Requests
@@ -300,24 +301,25 @@ Use `getStandbyAccountInfo()` and `getOperationalAccountInfo()` to update the ba
The following four methods are the same as the previous standby transactions, but for the operational account. The following four methods are the same as the previous standby transactions, but for the operational account.
```python ```python
def getOperationalAccount(): def get_operational_account():
new_wallet = getAccount(ent_operational_seed.get()) new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END) ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address) ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END) ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed) ent_operational_seed.insert(0, new_wallet.seed)
def getOperationalAccountInfo(): def get_operational_account_info():
accountInfo = getAccountInfo(ent_operational_account.get()) account_info = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END) ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance']) ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END) text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4)) text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operationalSendXRP(): def operational_send_xrp():
response = sendXRP(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get()) response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(),
ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END) text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(response.result,indent=4)) text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
getStandbyAccountInfo() get_standby_account_info()
getOperationalAccountInfo() get_operational_account_info()
``` ```
Create UI elements, starting with the main window. Create UI elements, starting with the main window.
@@ -405,22 +407,25 @@ text_operational_results.grid(row=6, column=5, sticky="nw")
Create the standby account buttons and add them to the grid. Create the standby account buttons and add them to the grid.
```python ```python
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account", command = getStandbyAccount) btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account", command = get_standby_account)
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew") btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
btn_get_standby_account_info = tk.Button(master=frm_form, text="Get Standby Account Info", command = getStandbyAccountInfo) btn_get_standby_account_info = tk.Button(master=frm_form, text="Get Standby Account Info", command = get_standby_account_info)
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew") btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", command = standbySendXRP) btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", command = standby_send_xrp)
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew") btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
``` ```
Create the operational account buttons and add them to the grid. Create the operational account buttons and add them to the grid.
```python ```python
btn_get_operational_account = tk.Button(master=frm_form, text="Get Operational Account", command = getOperationalAccount) btn_get_operational_account = tk.Button(master=frm_form, text="Get Operational Account",
command = get_operational_account)
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew") btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info", command = getOperationalAccountInfo) btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
command = get_operational_account_info)
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew") btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP", command = operationalSendXRP) btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
command = operational_send_xrp)
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew") btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
``` ```

View File

@@ -7,9 +7,7 @@ labels:
- Payments - Payments
- Quickstart - Quickstart
- Tokens - Tokens
--- ---
# 2. Create Trust Line and Send Currency (Python) # 2. Create Trust Line and Send Currency (Python)
This example shows how to: This example shows how to:
@@ -89,9 +87,9 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
## mod2.py ## mod2.py
Module 2 provides the logic for creating trust lines and sending currency tokens between accounts. Module 2 provides the logic for creating trust lines and sending issued currency tokens between accounts.
Import dependencies and set the _testnet___url_. Import dependencies and set the `testnet_url`.
```python ```python
import xrpl import xrpl
@@ -107,7 +105,7 @@ testnet_url = "https://s.altnet.rippletest.net:51234"
Pass the wallet seed, the issuer account, the currency code, and the maximum amount of currency to send. Pass the wallet seed, the issuer account, the currency code, and the maximum amount of currency to send.
```python ```python
def createTrustline(_seed, _issuer, _currency, _amount): def create_trust_line(_seed, _issuer, _currency, _amount):
``` ```
Get the wallet and a new client instance. Get the wallet and a new client instance.
@@ -151,12 +149,12 @@ Return the results.
```python ```python
return response.result return response.result
``` ```
## sendCurrency ## send_currency
Send currency to another account based on the sender wallet, destination account, the currency type, and the amount of the currency. Send currency to another account based on the sender wallet, destination account, the currency type, and the amount of the currency.
```python ```python
def sendCurrency(_seed, _destination, _currency, _amount): def send_currency(_seed, _destination, _currency, _amount):
``` ```
Get the sending wallet and a client instance on Testnet. Get the sending wallet and a client instance on Testnet.
@@ -202,15 +200,15 @@ Return the JSON response, or an error message if the transaction fails.
return response.result return response.result
``` ```
### getBalances ### get_balance
Update the **XRP Balance** fields and list the balance information for issued currencies in the **Results** text areas. Update the **XRP Balance** fields and list the balance information for issued currencies in the **Results** text areas.
```python ```python
def getBalance(_sb_account_id, _op_account_id): def get_balance(_sb_account_id, _op_account_id):
``` ```
Import the `account_info` request model. Import the `AccountInfo` request method.
```python ```python
from xrpl.models.requests.account_info import AccountInfo from xrpl.models.requests.account_info import AccountInfo
@@ -241,13 +239,13 @@ Return the result.
return response.result return response.result
``` ```
### configureAccount ### configure_account
This example shows how to set and clear configuration flags using the `AccountSet` method. The `ASF_DEFAULT_RIPPLE` flag is pertinent to experimentation with transfer of issued currencies to third-party accounts, so it is demonstrated here. You can set any of the configuration flags using the same structure, substituting the particular flags you want to set. See [AccountSet Flags](accountset.html). This example shows how to set and clear configuration flags using the `AccountSet` method. The `ASF_DEFAULT_RIPPLE` flag is pertinent to experimentation with transfer of issued currencies to third-party accounts, so it is demonstrated here. You can set any of the configuration flags using the same structure, substituting the particular flags you want to set. See [AccountSet Flags](accountset.html).
Send the account seed and a Boolean value for whether to enable or disable rippling. Send the account seed and a Boolean value for whether to enable or disable rippling.
```python ```python
def configureAccount(_seed, _default_setting): def configure_account(_seed, _default_setting):
``` ```
Get the account wallet and instantiate a client. Get the account wallet and instantiate a client.
@@ -307,14 +305,14 @@ import json
Import methods from `mod2.py`. Import methods from `mod2.py`.
```python ```python
from mod2 import createTrustLine from mod2 import create_trust_line
from mod2 import sendCurrency from mod2 import send_currency
from mod2 import getBalance from mod2 import get_balance
from mod2 import configureAccount from mod2 import configure_account
from mod1 import getAccount from mod1 import get_account
from mod1 import getAccountInfo from mod1 import get_account_info
from mod1 import sendXRP from mod1 import send_xrp
############################################# #############################################
## Handlers ################################# ## Handlers #################################
@@ -324,91 +322,92 @@ from mod1 import sendXRP
Module 2 Handlers. Module 2 Handlers.
```python ```python
def standbyCreateTrustLine(): def standby_create_trust_line():
results = createTrustLine(ent_standby_seed.get(), results = create_trust_line(ent_standby_seed.get(),
ent_standby_destination.get(), ent_standby_destination.get(),
ent_standby_currency.get(), ent_standby_currency.get(),
ent_standby_amount.get()) ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END) 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 standbySendCurrency(): def standby_send_currency():
results = sendCurrency(ent_standby_seed.get(), results = send_currency(ent_standby_seed.get(),
ent_standby_destination.get(), ent_standby_destination.get(),
ent_standby_currency.get(), ent_standby_currency.get(),
ent_standby_amount.get()) ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END) 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 standbyConfigureAccount(): def standby_configure_account():
results = configureAccount( results = configure_account(
ent_standby_seed.get(), ent_standby_seed.get(),
standbyRippling) standbyRippling)
text_standby_results.delete("1.0", tk.END) 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 operationalCreateTrustLine(): def operational_create_trust_line():
results = createTrustLine(ent_operational_seed.get(), results = create_trust_line(ent_operational_seed.get(),
ent_operational_destination.get(), ent_operational_destination.get(),
ent_operational_currency.get(), ent_operational_currency.get(),
ent_operational_amount.get()) ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END) 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 operationalSendCurrency(): def operational_send_currency():
results = sendCurrency(ent_operational_seed.get(), results = send_currency(ent_operational_seed.get(),
ent_operational_destination.get(), ent_operational_destination.get(),
ent_operational_currency.get(), ent_operational_currency.get(),
ent_operational_amount.get()) ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END) 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 operationalConfigureAccount(): def operational_configure_account():
results = configureAccount( results = configure_account(
ent_operational_seed.get(), ent_operational_seed.get(),
operationalRippling) operationalRippling)
text_operational_results.delete("1.0", tk.END) 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 getBalances(): def get_balances():
results = getBalance(ent_operational_account.get(), ent_standby_account.get()) results = get_balance(ent_operational_account.get(), ent_standby_account.get())
text_standby_results.delete("1.0", tk.END) 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 = getBalance(ent_standby_account.get(), ent_operational_account.get()) results = get_balance(ent_standby_account.get(), ent_operational_account.get())
text_operational_results.delete("1.0", tk.END) 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 # Module 1 Handlers
def getStandbyAccount(): def get_standby_account():
new_wallet = getAccount(ent_standby_seed.get()) new_wallet = get_account(ent_standby_seed.get())
ent_standby_account.delete(0, tk.END) ent_standby_account.delete(0, tk.END)
ent_standby_seed.delete(0, tk.END) ent_standby_seed.delete(0, tk.END)
ent_standby_account.insert(0, new_wallet.classic_address) ent_standby_account.insert(0, new_wallet.classic_address)
ent_standby_seed.insert(0, new_wallet.seed) ent_standby_seed.insert(0, new_wallet.seed)
def getStandbyAccountInfo(): def get_standby_account_info():
accountInfo = getAccountInfo(ent_standby_account.get()) accountInfo = get_account_info(ent_standby_account.get())
ent_standby_balance.delete(0, tk.END) ent_standby_balance.delete(0, tk.END)
ent_standby_balance.insert(0,accountInfo['Balance']) ent_standby_balance.insert(0,accountInfo['Balance'])
text_standby_results.delete("1.0", tk.END) text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4)) text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
def standbySendXRP(): def standby_send_xrp():
response = sendXRP(ent_standby_seed.get(),ent_standby_amount.get(), ent_standby_destination.get()) response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get())
text_standby_results.delete("1.0", tk.END) text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(response.result, indent=4)) text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
getStandbyAccountInfo() get_standby_account_info()
getOperationalAccountInfo() get_operational_account_info()
def getOperationalAccount(): def get_operational_account():
new_wallet = getAccount(ent_operational_seed.get()) new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END) ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address) ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END) ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed) ent_operational_seed.insert(0, new_wallet.seed)
def getOperationalAccountInfo(): def get_operational_account_info():
accountInfo = getAccountInfo(ent_operational_account.get()) accountInfo = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END) ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance']) ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END) text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4)) text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operationalSendXRP(): def operational_send_xrp():
response = sendXRP(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get()) response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END) text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(response.result,indent=4)) text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
getStandbyAccountInfo() get_standby_account_info()
getOperationalAccountInfo() get_operational_account_info()
# Create a new window with the title "Quickstart Module 2" # Create a new window with the title "Quickstart Module 2"
window = tk.Tk() window = tk.Tk()
@@ -521,54 +520,80 @@ cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
lbl_operational_results.grid(row=8, column=4, sticky="ne") lbl_operational_results.grid(row=8, column=4, sticky="ne")
text_operational_results.grid(row=8, column=5, sticky="nw") text_operational_results.grid(row=8, column=5, sticky="nw")
cb_operational_allow_rippling.select() cb_operational_allow_rippling.select()
```
############################################# #############################################
## Buttons ################################## ## Buttons ##################################
############################################# #############################################
# Create the Standby Account Buttons # Create the Standby Account Buttons
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account", command = getStandbyAccount)
```python
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
command = get_standby_account)
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew") btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
btn_get_standby_account_info = tk.Button(master=frm_form, text="Get Standby Account Info", command = getStandbyAccountInfo) btn_get_standby_account_info = tk.Button(master=frm_form,
text="Get Standby Account Info",
command = get_standby_account_info)
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew") btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", command = standbySendXRP) btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
btn_standby_send_xrp.grid(row=2, column=2, sticky = "nsew") command = standby_send_xrp)
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
``` ```
Add buttons **Create Trust Line**, **Send Currency**, **Get Balances**, and **Configure Account**. Add buttons **Create Trust Line**, **Send Currency**, **Get Balances**, and **Configure Account**.
```python ```python
btn_standby_create_trustline = tk.Button(master=frm_form, text="Create Trust Line", command = standbyCreateTrustLine) btn_standby_create_trust_line = tk.Button(master=frm_form,
btn_standby_create_trustline.grid(row=3, column=2, sticky = "nsew") text="Create Trust Line",
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >", command = standbySendCurrency) command = standby_create_trust_line)
btn_standby_create_trust_line.grid(row=3, column=2, sticky = "nsew")
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
command = standby_send_currency)
btn_standby_send_currency.grid(row=4, column=2, sticky = "nsew") btn_standby_send_currency.grid(row=4, column=2, sticky = "nsew")
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances", command = getBalances) btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
command = get_balances)
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew") btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
btn_standby_configure_account = tk.Button(master=frm_form, text="Configure Account", command = standbyConfigureAccount) btn_standby_configure_account = tk.Button(master=frm_form,
text="Configure Account",
command = standby_configure_account)
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew") btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
```
# Create the Operational Account Buttons # Create the Operational Account Buttons
btn_get_operational_account = tk.Button(master=frm_form, text="Get Operational Account", command = getOperationalAccount)
```python
btn_get_operational_account = tk.Button(master=frm_form,
text="Get Operational Account",
command = get_operational_account)
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew") btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info", command = getOperationalAccountInfo) btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
command = get_operational_account_info)
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew") btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP", command = operationalSendXRP) btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
command = operational_send_xrp)
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew") btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
``` ```
Add operational buttons **Create Trust Line**, **Send Currency**, **Get Balances**, and **Configure Account**. Add operational buttons **Create Trust Line**, **Send Currency**, **Get Balances**, and **Configure Account**.
```python ```python
btn_op_create_trustline = tk.Button(master=frm_form, text="Create Trust Line", command = operationalCreateTrustLine) btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
btn_op_create_trustline.grid(row=3, column=3, sticky = "nsew") command = operational_create_trust_line)
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency", command = operationalSendCurrency) btn_op_create_trust_line.grid(row=3, column=3, sticky = "nsew")
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
command = operational_send_currency)
btn_op_send_currency.grid(row=4, column=3, sticky = "nsew") btn_op_send_currency.grid(row=4, column=3, sticky = "nsew")
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances", command = getBalances) btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
command = get_balances)
btn_op_get_balances.grid(row=5, column=3, sticky = "nsew") btn_op_get_balances.grid(row=5, column=3, sticky = "nsew")
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account", command = operationalConfigureAccount) btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
command = operational_configure_account)
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew") btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
```
# Start the application # Start the application
```python
window.mainloop() window.mainloop()
``` ```

View File

@@ -74,7 +74,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
## mod3.py ## mod3.py
This module contains the new methods `mintToken()`, `getTokens()`, and `burnToken()`. This module contains the new methods `mint_token`, `get_tokens`, and `burn_token`.
Import dependencies and set global variable. Import dependencies and set global variable.
@@ -92,7 +92,7 @@ testnet_url = "https://s.altnet.rippletest.net:51234"
Pass the arguments account seed, NFT URI, transaction flags, the transfer fee, and optional taxon. Pass the arguments account seed, NFT URI, transaction flags, the transfer fee, and optional taxon.
```python ```python
def mintToken(_seed, _uri, _flags, _transfer_fee, _taxon): def mint_token(_seed, _uri, _flags, _transfer_fee, _taxon):
``` ```
Get the account wallet and a client instance. Get the account wallet and a client instance.
@@ -134,10 +134,10 @@ Submit the transaction and return results.
## getTokens ## getTokens
```python ```python
def getTokens(_account): def get_tokens(_account):
``` ```
Import dependencies and declare variable. Import dependencies.
```python ```python
from xrpl.clients import JsonRpcClient from xrpl.clients import JsonRpcClient
@@ -166,12 +166,12 @@ Send the request and return the result.
return response.result return response.result
``` ```
## burnToken ## burn_token
Pass the owner's seed value and the NFT ID. Pass the owner's seed value and the NFT ID.
```python ```python
def burnToken(_seed, _nftoken_id): def burn_token(_seed, _nftoken_id):
``` ```
Get the owner wallet and client instance. Get the owner wallet and client instance.
@@ -222,18 +222,18 @@ import json
Import methods from `mod3.py`. Import methods from `mod3.py`.
```python ```python
from mod3 import mintToken from mod3 import mint_token
from mod3 import getTokens from mod3 import get_tokens
from mod3 import burnToken from mod3 import burn_token
from mod2 import createTrustLine from mod2 import create_trust_line
from mod2 import sendCurrency from mod2 import send_currency
from mod2 import getBalance from mod2 import get_balance
from mod2 import configureAccount from mod2 import configure_account
from mod1 import getAccount from mod1 import get_account
from mod1 import getAccountInfo from mod1 import get_account_info
from mod1 import sendXRP from mod1 import send_xrp
############################################# #############################################
## Handlers ################################# ## Handlers #################################
@@ -243,8 +243,8 @@ from mod1 import sendXRP
Module 3 Handlers Module 3 Handlers
```python ```python
def standbyMintToken(): def standby_mint_token():
results = mintToken( results = mint_token(
ent_standby_seed.get(), ent_standby_seed.get(),
ent_standby_uri.get(), ent_standby_uri.get(),
ent_standby_flags.get(), ent_standby_flags.get(),
@@ -253,19 +253,19 @@ def standbyMintToken():
) )
text_standby_results.delete("1.0", tk.END) 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 standbyGetTokens(): def standby_get_tokens():
results = getTokens(ent_standby_account.get()) results = get_tokens(ent_standby_account.get())
text_standby_results.delete("1.0", tk.END) 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 standbyBurnToken(): def standby_burn_token():
results = burnToken( results = burn_token(
ent_standby_seed.get(), ent_standby_seed.get(),
ent_standby_nft_id.get() ent_standby_nft_id.get()
) )
text_standby_results.delete("1.0", tk.END) 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 operationalMintToken(): def operational_mint_token():
results = mintToken( results = mint_token(
ent_operational_seed.get(), ent_operational_seed.get(),
ent_operational_uri.get(), ent_operational_uri.get(),
ent_operational_flags.get(), ent_operational_flags.get(),
@@ -274,12 +274,12 @@ def operationalMintToken():
) )
text_operational_results.delete("1.0", tk.END) 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 operationalGetTokens(): def operational_get_tokens():
results = getTokens(ent_operational_account.get()) results = get_tokens(ent_operational_account.get())
text_operational_results.delete("1.0", tk.END) 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 operationalBurnToken(): def operational_burn_token():
results = burnToken( results = burn_token(
ent_operational_seed.get(), ent_operational_seed.get(),
ent_operational_nft_id.get() ent_operational_nft_id.get()
) )
@@ -288,91 +288,92 @@ def operationalBurnToken():
# Module 2 Handlers # Module 2 Handlers
def standbyCreateTrustline(): def standby_create_trustline():
results = createTrustline(ent_standby_seed.get(), results = create_trustline(ent_standby_seed.get(),
ent_standby_destination.get(), ent_standby_destination.get(),
ent_standby_currency.get(), ent_standby_currency.get(),
ent_standby_amount.get()) ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END) 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 standbySendCurrency(): def standby_send_currency():
results = sendCurrency(ent_standby_seed.get(), results = send_currency(ent_standby_seed.get(),
ent_standby_destination.get(), ent_standby_destination.get(),
ent_standby_currency.get(), ent_standby_currency.get(),
ent_standby_amount.get()) ent_standby_amount.get())
text_standby_results.delete("1.0", tk.END) 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 standbyConfigureAccount(): def standby_configure_account():
results = configureAccount( results = configure_account(
ent_standby_seed.get(), ent_standby_seed.get(),
standbyRippling) standbyRippling)
text_standby_results.delete("1.0", tk.END) 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 operationalCreateTrustline(): def operational_create_trust_line():
results = createTrustline(ent_operational_seed.get(), results = create_trust_line(ent_operational_seed.get(),
ent_operational_destination.get(), ent_operational_destination.get(),
ent_operational_currency.get(), ent_operational_currency.get(),
ent_operational_amount.get()) ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END) 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 operationalSendCurrency(): def operational_send_currency():
results = sendCurrency(ent_operational_seed.get(), results = send_currency(ent_operational_seed.get(),
ent_operational_destination.get(), ent_operational_destination.get(),
ent_operational_currency.get(), ent_operational_currency.get(),
ent_operational_amount.get()) ent_operational_amount.get())
text_operational_results.delete("1.0", tk.END) 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 operationalConfigureAccount(): def operational_configure_account():
results = configureAccount( results = configure_account(
ent_operational_seed.get(), ent_operational_seed.get(),
operationalRippling) operationalRippling)
text_operational_results.delete("1.0", tk.END) 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 getBalances(): def get_balances():
results = getBalance(ent_operational_account.get(), ent_standby_account.get()) results = get_balance(ent_operational_account.get(), ent_standby_account.get())
text_standby_results.delete("1.0", tk.END) 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 = getBalance(ent_standby_account.get(), ent_operational_account.get()) results = get_balance(ent_standby_account.get(), ent_operational_account.get())
text_operational_results.delete("1.0", tk.END) 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 # Module 1 Handlers
def getStandbyAccount(): def get_standby_account():
new_wallet = getAccount(ent_standby_seed.get()) new_wallet = get_account(ent_standby_seed.get())
ent_standby_account.delete(0, tk.END) ent_standby_account.delete(0, tk.END)
ent_standby_seed.delete(0, tk.END) ent_standby_seed.delete(0, tk.END)
ent_standby_account.insert(0, new_wallet.classic_address) ent_standby_account.insert(0, new_wallet.classic_address)
ent_standby_seed.insert(0, new_wallet.seed) ent_standby_seed.insert(0, new_wallet.seed)
def getStandbyAccountInfo(): def get_standby_account_info():
accountInfo = getAccountInfo(ent_standby_account.get()) accountInfo = get_account_info(ent_standby_account.get())
ent_standby_balance.delete(0, tk.END) ent_standby_balance.delete(0, tk.END)
ent_standby_balance.insert(0,accountInfo['Balance']) ent_standby_balance.insert(0,accountInfo['Balance'])
text_standby_results.delete("1.0", tk.END) text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4)) text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
def standbySendXRP(): def standby_send_xrp():
response = sendXRP(ent_standby_seed.get(),ent_standby_amount.get(), ent_standby_destination.get()) response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
ent_standby_destination.get())
text_standby_results.delete("1.0", tk.END) text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0",json.dumps(response.result, indent=4)) text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
getStandbyAccountInfo() get_standby_account_info()
getOperationalAccountInfo() get_operational_account_info()
def getOperationalAccount(): def get_operational_account():
new_wallet = getAccount(ent_operational_seed.get()) new_wallet = get_account(ent_operational_seed.get())
ent_operational_account.delete(0, tk.END) ent_operational_account.delete(0, tk.END)
ent_operational_account.insert(0, new_wallet.classic_address) ent_operational_account.insert(0, new_wallet.classic_address)
ent_operational_seed.delete(0, tk.END) ent_operational_seed.delete(0, tk.END)
ent_operational_seed.insert(0, new_wallet.seed) ent_operational_seed.insert(0, new_wallet.seed)
def getOperationalAccountInfo(): def get_operational_account_info():
accountInfo = getAccountInfo(ent_operational_account.get()) accountInfo = get_account_info(ent_operational_account.get())
ent_operational_balance.delete(0, tk.END) ent_operational_balance.delete(0, tk.END)
ent_operational_balance.insert(0,accountInfo['Balance']) ent_operational_balance.insert(0,accountInfo['Balance'])
text_operational_results.delete("1.0", tk.END) text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4)) text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
def operationalSendXRP(): def operational_send_xrp():
response = sendXRP(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get()) response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
text_operational_results.delete("1.0", tk.END) text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0",json.dumps(response.result,indent=4)) text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
getStandbyAccountInfo() get_standby_account_info()
getOperationalAccountInfo() get_operational_account_info()
# Create a new window with the title "Quickstart Module 3" # Create a new window with the title "Quickstart Module 3"
window = tk.Tk() window = tk.Tk()
@@ -525,57 +526,80 @@ cb_operational_allow_rippling.select()
############################################# #############################################
# Create the Standby Account Buttons # Create the Standby Account Buttons
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account", command = getStandbyAccount) btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
command = get_standby_account)
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew") btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
btn_get_standby_account_info = tk.Button(master=frm_form, text="Get Standby Account Info", command = getStandbyAccountInfo) btn_get_standby_account_info = tk.Button(master=frm_form,
text="Get Standby Account Info",
command = get_standby_account_info)
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew") btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", command = standbySendXRP) btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
btn_standby_send_xrp.grid(row=2, column=2, sticky = "nsew") command = standby_send_xrp)
btn_standby_create_trustline = tk.Button(master=frm_form, text="Create Trustine", command = standbyCreateTrustline) btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
btn_standby_create_trustline.grid(row=3, column=2, sticky = "nsew") btn_standby_create_trust_line = tk.Button(master=frm_form,
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >", command = standbySendCurrency) text="Create Trust Line",
command = standby_create_trust_line)
btn_standby_create_trust_line.grid(row=3, column=2, sticky = "nsew")
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
command = standby_send_currency)
btn_standby_send_currency.grid(row=4, column=2, sticky = "nsew") btn_standby_send_currency.grid(row=4, column=2, sticky = "nsew")
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances", command = getBalances) btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
command = get_balances)
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew") btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
btn_standby_configure_account = tk.Button(master=frm_form, text="Configure Account", command = standbyConfigureAccount) btn_standby_configure_account = tk.Button(master=frm_form,
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew") text="Configure Account",
command = standby_configure_account)
``` ```
Add buttons for **Mint NFToken**, **Get NFTokens**, and **Burn NFToken**. Add buttons for **Mint NFToken**, **Get NFTokens**, and **Burn NFToken**.
```python ```python
btn_standby_mint_token = tk.Button(master=frm_form, text="Mint NFToken", command = standbyMintToken) btn_standby_mint_token = tk.Button(master=frm_form, text="Mint NFToken",
command = standby_mint_token)
btn_standby_mint_token.grid(row=8, column=2, sticky="nsew") btn_standby_mint_token.grid(row=8, column=2, sticky="nsew")
btn_standby_get_tokens = tk.Button(master=frm_form, text="Get NFTokens", command = standbyGetTokens) btn_standby_get_tokens = tk.Button(master=frm_form, text="Get NFTokens",
command = standby_get_tokens)
btn_standby_get_tokens.grid(row=9, column=2, sticky="nsew") btn_standby_get_tokens.grid(row=9, column=2, sticky="nsew")
btn_standby_burn_token = tk.Button(master=frm_form, text="Burn NFToken", command = standbyBurnToken) btn_standby_burn_token = tk.Button(master=frm_form, text="Burn NFToken",
command = standby_burn_token)
btn_standby_burn_token.grid(row=10, column=2, sticky="nsew") btn_standby_burn_token.grid(row=10, column=2, sticky="nsew")
# Create the Operational Account Buttons # Create the Operational Account Buttons
btn_get_operational_account = tk.Button(master=frm_form, text="Get Operational Account", command = getOperationalAccount) btn_get_operational_account = tk.Button(master=frm_form,
text="Get Operational Account",
command = get_operational_account)
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew") btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info", command = getOperationalAccountInfo) btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
command = get_operational_account_info)
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew") btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP", command = operationalSendXRP) btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
command = operational_send_xrp)
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew") btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
btn_op_create_trustline = tk.Button(master=frm_form, text="Create Trustine", command = operationalCreateTrustline) btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
btn_op_create_trustline.grid(row=3, column=3, sticky = "nsew") command = operational_create_trust_line)
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency", command = operationalSendCurrency) btn_op_create_trust_line.grid(row=3, column=3, sticky = "nsew")
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
command = operational_send_currency)
btn_op_send_currency.grid(row=4, column=3, sticky = "nsew") btn_op_send_currency.grid(row=4, column=3, sticky = "nsew")
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances", command = getBalances) btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
command = get_balances)
btn_op_get_balances.grid(row=5, column=3, sticky = "nsew") btn_op_get_balances.grid(row=5, column=3, sticky = "nsew")
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account", command = operationalConfigureAccount) btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
command = operational_configure_account)
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew") btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
``` ```
Add buttons for **Mint NFToken**, **Get NFTokens**, and **Burn NFToken**. Add buttons for **Mint NFToken**, **Get NFTokens**, and **Burn NFToken**.
```python ```python
btn_op_mint_token = tk.Button(master=frm_form, text="Mint NFToken", command = operationalMintToken) btn_op_mint_token = tk.Button(master=frm_form, text="Mint NFToken",
command = operational_mint_token)
btn_op_mint_token.grid(row=8, column=3, sticky="nsew") btn_op_mint_token.grid(row=8, column=3, sticky="nsew")
btn_op_get_tokens = tk.Button(master=frm_form, text="Get NFTokens", command = operationalGetTokens) btn_op_get_tokens = tk.Button(master=frm_form, text="Get NFTokens",
command = operational_get_tokens)
btn_op_get_tokens.grid(row=9, column=3, sticky="nsew") btn_op_get_tokens.grid(row=9, column=3, sticky="nsew")
btn_op_burn_token = tk.Button(master=frm_form, text="Burn NFToken", command = operationalBurnToken) btn_op_burn_token = tk.Button(master=frm_form, text="Burn NFToken",
command = operational_burn_token)
btn_op_burn_token.grid(row=10, column=3, sticky="nsew") btn_op_burn_token.grid(row=10, column=3, sticky="nsew")
# Start the application # Start the application