mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 19:55:54 +00:00
Snake case!
This commit is contained in:
@@ -76,14 +76,14 @@ import xrpl
|
||||
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.
|
||||
|
||||
Import required methods.
|
||||
|
||||
```python
|
||||
def getAccount(_seed):
|
||||
def get_account(_seed):
|
||||
from xrpl.clients import JsonRpcClient
|
||||
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)
|
||||
```
|
||||
|
||||
### getAccountInfo
|
||||
### get_account_info
|
||||
|
||||
Pass the account ID to the getAccountInfo method.
|
||||
Pass the account ID to the `get_account_info` method.
|
||||
|
||||
```python
|
||||
def getAccountInfo(_accountId):
|
||||
def get_account_info(_accountId):
|
||||
```
|
||||
|
||||
Import required methods and the JSON library.
|
||||
@@ -154,12 +154,12 @@ Return the 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.
|
||||
|
||||
```python
|
||||
def sendXRP(_seed, _amount, _destination):
|
||||
def send_xrp(_seed, _amount, _destination):
|
||||
```
|
||||
|
||||
Get the sending wallet.
|
||||
@@ -215,21 +215,21 @@ import json
|
||||
Import the methods from mod1.py.
|
||||
|
||||
```python
|
||||
from mod1 import getAccount
|
||||
from mod1 import getAccountInfo
|
||||
from mod1 import sendXRP
|
||||
from mod1 import get_account
|
||||
from mod1 import get_accountInfo
|
||||
from mod1 import send_xrp
|
||||
```
|
||||
|
||||
### getStandbyAccount
|
||||
|
||||
```python
|
||||
def getStandbyAccount():
|
||||
def get_standby_account():
|
||||
```
|
||||
|
||||
Use the value in the standby Seed field (or an empty value) to request a new account.
|
||||
|
||||
```python
|
||||
new_wallet = getAccount(ent_standby_seed.get())
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
```
|
||||
|
||||
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)
|
||||
```
|
||||
|
||||
### 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
|
||||
def getStandbyAccountInfo():
|
||||
accountInfo = getAccountInfo(ent_standby_account.get())
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
```
|
||||
|
||||
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))
|
||||
```
|
||||
|
||||
### standbySendXRP
|
||||
### standby_send_xrp
|
||||
|
||||
```python
|
||||
def standbySendXRP():
|
||||
def standby_send_xrp():
|
||||
```
|
||||
|
||||
Call the `send_xrp` method, passing the standby seed, the amount, and the destination value.
|
||||
|
||||
```python
|
||||
Call the sendXRP method, passing the standby seed, the amount, and the destination value.
|
||||
response = sendXRP(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.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))
|
||||
```
|
||||
|
||||
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
|
||||
getStandbyAccountInfo()
|
||||
getOperationalAccountInfo()
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
```
|
||||
|
||||
### 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.
|
||||
|
||||
```python
|
||||
def getOperationalAccount():
|
||||
new_wallet = getAccount(ent_operational_seed.get())
|
||||
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 getOperationalAccountInfo():
|
||||
accountInfo = getAccountInfo(ent_operational_account.get())
|
||||
def get_operational_account_info():
|
||||
account_info = 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 operationalSendXRP():
|
||||
response = sendXRP(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
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)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
getStandbyAccountInfo()
|
||||
getOperationalAccountInfo()
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
```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_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_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")
|
||||
```
|
||||
|
||||
Create the operational account buttons and add them to the grid.
|
||||
|
||||
```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_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_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")
|
||||
```
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ labels:
|
||||
- Payments
|
||||
- Quickstart
|
||||
- Tokens
|
||||
|
||||
---
|
||||
|
||||
# 2. Create Trust Line and Send Currency (Python)
|
||||
|
||||
This example shows how to:
|
||||
@@ -89,9 +87,9 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
## 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
|
||||
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.
|
||||
|
||||
```python
|
||||
def createTrustline(_seed, _issuer, _currency, _amount):
|
||||
def create_trust_line(_seed, _issuer, _currency, _amount):
|
||||
```
|
||||
|
||||
Get the wallet and a new client instance.
|
||||
@@ -151,12 +149,12 @@ Return the results.
|
||||
```python
|
||||
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.
|
||||
|
||||
```python
|
||||
def sendCurrency(_seed, _destination, _currency, _amount):
|
||||
def send_currency(_seed, _destination, _currency, _amount):
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
### getBalances
|
||||
### get_balance
|
||||
|
||||
Update the **XRP Balance** fields and list the balance information for issued currencies in the **Results** text areas.
|
||||
|
||||
```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
|
||||
from xrpl.models.requests.account_info import AccountInfo
|
||||
@@ -241,13 +239,13 @@ Return the 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).
|
||||
|
||||
Send the account seed and a Boolean value for whether to enable or disable rippling.
|
||||
```python
|
||||
def configureAccount(_seed, _default_setting):
|
||||
def configure_account(_seed, _default_setting):
|
||||
```
|
||||
|
||||
Get the account wallet and instantiate a client.
|
||||
@@ -307,14 +305,14 @@ import json
|
||||
Import methods from `mod2.py`.
|
||||
|
||||
```python
|
||||
from mod2 import createTrustLine
|
||||
from mod2 import sendCurrency
|
||||
from mod2 import getBalance
|
||||
from mod2 import configureAccount
|
||||
from mod2 import create_trust_line
|
||||
from mod2 import send_currency
|
||||
from mod2 import get_balance
|
||||
from mod2 import configure_account
|
||||
|
||||
from mod1 import getAccount
|
||||
from mod1 import getAccountInfo
|
||||
from mod1 import sendXRP
|
||||
from mod1 import get_account
|
||||
from mod1 import get_account_info
|
||||
from mod1 import send_xrp
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
@@ -324,91 +322,92 @@ from mod1 import sendXRP
|
||||
Module 2 Handlers.
|
||||
|
||||
```python
|
||||
def standbyCreateTrustLine():
|
||||
results = createTrustLine(ent_standby_seed.get(),
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def standbySendCurrency():
|
||||
results = sendCurrency(ent_standby_seed.get(),
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def standbyConfigureAccount():
|
||||
results = configureAccount(
|
||||
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 operationalCreateTrustLine():
|
||||
results = createTrustLine(ent_operational_seed.get(),
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def operationalSendCurrency():
|
||||
results = sendCurrency(ent_operational_seed.get(),
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def operationalConfigureAccount():
|
||||
results = configureAccount(
|
||||
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 getBalances():
|
||||
results = getBalance(ent_operational_account.get(), ent_standby_account.get())
|
||||
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))
|
||||
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.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
# Module 1 Handlers
|
||||
def getStandbyAccount():
|
||||
new_wallet = getAccount(ent_standby_seed.get())
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
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 getStandbyAccountInfo():
|
||||
accountInfo = getAccountInfo(ent_standby_account.get())
|
||||
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 standbySendXRP():
|
||||
response = sendXRP(ent_standby_seed.get(),ent_standby_amount.get(), ent_standby_destination.get())
|
||||
def standby_send_xrp():
|
||||
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.insert("1.0",json.dumps(response.result, indent=4))
|
||||
getStandbyAccountInfo()
|
||||
getOperationalAccountInfo()
|
||||
def getOperationalAccount():
|
||||
new_wallet = getAccount(ent_operational_seed.get())
|
||||
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 getOperationalAccountInfo():
|
||||
accountInfo = getAccountInfo(ent_operational_account.get())
|
||||
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 operationalSendXRP():
|
||||
response = sendXRP(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
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)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
getStandbyAccountInfo()
|
||||
getOperationalAccountInfo()
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
# Create a new window with the title "Quickstart Module 2"
|
||||
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")
|
||||
text_operational_results.grid(row=8, column=5, sticky="nw")
|
||||
cb_operational_allow_rippling.select()
|
||||
```
|
||||
|
||||
#############################################
|
||||
## 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_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_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", command = standbySendXRP)
|
||||
btn_standby_send_xrp.grid(row=2, column=2, sticky = "nsew")
|
||||
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")
|
||||
```
|
||||
|
||||
Add buttons **Create Trust Line**, **Send Currency**, **Get Balances**, and **Configure Account**.
|
||||
|
||||
```python
|
||||
btn_standby_create_trustline = tk.Button(master=frm_form, text="Create Trust Line", command = standbyCreateTrustLine)
|
||||
btn_standby_create_trustline.grid(row=3, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >", command = standbySendCurrency)
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
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 = 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_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")
|
||||
|
||||
```
|
||||
|
||||
# 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_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_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")
|
||||
```
|
||||
|
||||
Add operational buttons **Create Trust Line**, **Send Currency**, **Get Balances**, and **Configure Account**.
|
||||
|
||||
```python
|
||||
btn_op_create_trustline = tk.Button(master=frm_form, text="Create Trust Line", command = operationalCreateTrustLine)
|
||||
btn_op_create_trustline.grid(row=3, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency", command = operationalSendCurrency)
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
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_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_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")
|
||||
```
|
||||
|
||||
# Start the application
|
||||
|
||||
```python
|
||||
window.mainloop()
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
```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.
|
||||
@@ -134,10 +134,10 @@ Submit the transaction and return results.
|
||||
## getTokens
|
||||
|
||||
```python
|
||||
def getTokens(_account):
|
||||
def get_tokens(_account):
|
||||
```
|
||||
|
||||
Import dependencies and declare variable.
|
||||
Import dependencies.
|
||||
|
||||
```python
|
||||
from xrpl.clients import JsonRpcClient
|
||||
@@ -166,12 +166,12 @@ Send the request and return the result.
|
||||
return response.result
|
||||
```
|
||||
|
||||
## burnToken
|
||||
## burn_token
|
||||
|
||||
Pass the owner's seed value and the NFT ID.
|
||||
|
||||
```python
|
||||
def burnToken(_seed, _nftoken_id):
|
||||
def burn_token(_seed, _nftoken_id):
|
||||
```
|
||||
|
||||
Get the owner wallet and client instance.
|
||||
@@ -222,18 +222,18 @@ import json
|
||||
Import methods from `mod3.py`.
|
||||
|
||||
```python
|
||||
from mod3 import mintToken
|
||||
from mod3 import getTokens
|
||||
from mod3 import burnToken
|
||||
from mod3 import mint_token
|
||||
from mod3 import get_tokens
|
||||
from mod3 import burn_token
|
||||
|
||||
from mod2 import createTrustLine
|
||||
from mod2 import sendCurrency
|
||||
from mod2 import getBalance
|
||||
from mod2 import configureAccount
|
||||
from mod2 import create_trust_line
|
||||
from mod2 import send_currency
|
||||
from mod2 import get_balance
|
||||
from mod2 import configure_account
|
||||
|
||||
from mod1 import getAccount
|
||||
from mod1 import getAccountInfo
|
||||
from mod1 import sendXRP
|
||||
from mod1 import get_account
|
||||
from mod1 import get_account_info
|
||||
from mod1 import send_xrp
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
@@ -243,8 +243,8 @@ from mod1 import sendXRP
|
||||
Module 3 Handlers
|
||||
|
||||
```python
|
||||
def standbyMintToken():
|
||||
results = mintToken(
|
||||
def standby_mint_token():
|
||||
results = mint_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_uri.get(),
|
||||
ent_standby_flags.get(),
|
||||
@@ -253,19 +253,19 @@ def standbyMintToken():
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def standbyGetTokens():
|
||||
results = getTokens(ent_standby_account.get())
|
||||
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 standbyBurnToken():
|
||||
results = burnToken(
|
||||
def standby_burn_token():
|
||||
results = burn_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_id.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def operationalMintToken():
|
||||
results = mintToken(
|
||||
def operational_mint_token():
|
||||
results = mint_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_uri.get(),
|
||||
ent_operational_flags.get(),
|
||||
@@ -274,12 +274,12 @@ def operationalMintToken():
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def operationalGetTokens():
|
||||
results = getTokens(ent_operational_account.get())
|
||||
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 operationalBurnToken():
|
||||
results = burnToken(
|
||||
def operational_burn_token():
|
||||
results = burn_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_id.get()
|
||||
)
|
||||
@@ -288,91 +288,92 @@ def operationalBurnToken():
|
||||
|
||||
# Module 2 Handlers
|
||||
|
||||
def standbyCreateTrustline():
|
||||
results = createTrustline(ent_standby_seed.get(),
|
||||
def standby_create_trustline():
|
||||
results = create_trustline(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def standbySendCurrency():
|
||||
results = sendCurrency(ent_standby_seed.get(),
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def standbyConfigureAccount():
|
||||
results = configureAccount(
|
||||
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 operationalCreateTrustline():
|
||||
results = createTrustline(ent_operational_seed.get(),
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def operationalSendCurrency():
|
||||
results = sendCurrency(ent_operational_seed.get(),
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
def operationalConfigureAccount():
|
||||
results = configureAccount(
|
||||
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 getBalances():
|
||||
results = getBalance(ent_operational_account.get(), ent_standby_account.get())
|
||||
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))
|
||||
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.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
# Module 1 Handlers
|
||||
def getStandbyAccount():
|
||||
new_wallet = getAccount(ent_standby_seed.get())
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
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 getStandbyAccountInfo():
|
||||
accountInfo = getAccountInfo(ent_standby_account.get())
|
||||
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 standbySendXRP():
|
||||
response = sendXRP(ent_standby_seed.get(),ent_standby_amount.get(), ent_standby_destination.get())
|
||||
def standby_send_xrp():
|
||||
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.insert("1.0",json.dumps(response.result, indent=4))
|
||||
getStandbyAccountInfo()
|
||||
getOperationalAccountInfo()
|
||||
def getOperationalAccount():
|
||||
new_wallet = getAccount(ent_operational_seed.get())
|
||||
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 getOperationalAccountInfo():
|
||||
accountInfo = getAccountInfo(ent_operational_account.get())
|
||||
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 operationalSendXRP():
|
||||
response = sendXRP(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
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)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
getStandbyAccountInfo()
|
||||
getOperationalAccountInfo()
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
# Create a new window with the title "Quickstart Module 3"
|
||||
window = tk.Tk()
|
||||
@@ -525,57 +526,80 @@ cb_operational_allow_rippling.select()
|
||||
#############################################
|
||||
|
||||
# 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_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_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", command = standbySendXRP)
|
||||
btn_standby_send_xrp.grid(row=2, column=2, sticky = "nsew")
|
||||
btn_standby_create_trustline = tk.Button(master=frm_form, text="Create Trustine", command = standbyCreateTrustline)
|
||||
btn_standby_create_trustline.grid(row=3, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >", command = standbySendCurrency)
|
||||
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_create_trust_line = tk.Button(master=frm_form,
|
||||
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 = 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_configure_account = tk.Button(master=frm_form, text="Configure Account", command = standbyConfigureAccount)
|
||||
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
```
|
||||
|
||||
Add buttons for **Mint NFToken**, **Get NFTokens**, and **Burn NFToken**.
|
||||
|
||||
```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_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_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")
|
||||
|
||||
|
||||
# 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_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_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_create_trustline = tk.Button(master=frm_form, text="Create Trustine", command = operationalCreateTrustline)
|
||||
btn_op_create_trustline.grid(row=3, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency", command = operationalSendCurrency)
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
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_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_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")
|
||||
```
|
||||
Add buttons for **Mint NFToken**, **Get NFTokens**, and **Burn NFToken**.
|
||||
|
||||
```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_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_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")
|
||||
|
||||
# Start the application
|
||||
|
||||
Reference in New Issue
Block a user