We should have high-level methods that predefine often used functions in combination with the public XRP Ledger Server API methods.
Structure
Topic
[ ] function, structure, addition, removal, ...
Short explanation of the change.
Short explanation how the change works.
Some particularities.
fields
type
explanation
Sources:
...
Every function has a client argument. Its type is always only one of WebsocketClient and AsyncWebsocketClient. When writing sync high-level methods use WebsocketClient, when writing async use AsyncWebsocketClient as type.
account:
[ ] does_account_exist -> bool
Queries a ledger and checks if an account exists.
The function simply calls the get_account_info function. If the Result is no error the account exists.
fields
type
explanation
account
&str
An accounts classic address.
client
WebsocketClient/AsyncWebsocketClient
A websocket client object.
ledger_index
Option<&str>
A ledger index. Must be one of "validated", "current", "closed", or an integer as str.
Queries the ledger for account info of an account's address.
The function calls the AccountInfo request method using the WebsocketClient/AsyncWebsocketClient.
The returning Response struct may not have been added yet. Keep a look at https://github.com/sephynox/xrpl-rust/issues/17, if the tick is already set.
The user can choose which ledger he wants to query using the ledger_index argument. If no ledger_index is defined (: None) the default is "validated". If a Ledger Index is defined edit the AccountInfo request as wished.
fields
type
explanation
account
&str
An accounts classic address.
client
WebsocketClient/AsyncWebsocketClient
A websocket client object.
ledger_index
Option<&str>
A ledger index. Must be one of: "validated", "current", "closed", integer as str
Queries the Ledger for the last transaction a given account has sent.
The function calls the AccountTx request method using the WebsocketClient/AsyncWebsocketClient.
The returning Response struct may not have been added yet. Keep a look at https://github.com/sephynox/xrpl-rust/issues/17, if the tick is already set.
To receive an account's latest transaction define request:
Queries the Ledger for transactions sent by a given address.
The function calls the AccountTx request method using the WebsocketClient/AsyncWebsocketClient.
If an account has send too many transactions for the node to send, the node sends as many transactions as it can and includes a marker field to tell you to how many Ledgers it looked back. You can define the marker field in AccountTx to receive the next batch of transactions.
fields
type
explanation
account
&str
An accounts classic address.
client
WebsocketClient/AsyncWebsocketClient
A websocket client object.
marker
u32
The Marker to request the next batch of transactions.
Queries the Ledger for the current transaction fee.
The function calls the Fee request method using the WebsocketClient/AsyncWebsocketClient.
The user can decide what type of fee to get. "open" would return the open_ledger_fee field; "minimum" would return the minimum_fee field; "dynamic" would return a calculated fee based on the node's transaction queue size.
fields
type
explanation
client
WebsocketClient/AsyncWebsocketClient
A websocket client object.
max_fee
Option<u32>
The max fee the user want to spend as drops.
fee_type
Option<&str>
The type of fee to return. Must be one of: "open", "minimum", "dynamic"
Bool if the provided fee defined in the transaction could be lower.
[ ] sign_and_submit_transaction
Signs a transaction locally and submits it to the network.
Simply calls the sign_transaction function and uses the submit request method to submit the transaction to the network using the WebsocketClient/AsyncWebsocketClient.
fields
type
explanation
transaction
Transaction
The transaction that needs to get signed
wallet
Wallet
The wallet used to sign the transaction.
check_fee
Option<bool>
Bool if the provided fee defined in the transaction could be lower.
client
WebsocketClient/AsyncWebsocketClient
A websocket client object.
[ ] autofill_and_sign_transaction
Autofills and locally signs a transaction.
Autofills fields like fee and signs the given transaction locally by calling sign_transaction.
The method should have a parameter to choose the get_fee calculation type. This Parameter should be optional. If None the default value should be FeeType::Open.
fields
type
explanation
transaction
Transaction
The transaction that needs to get signed
wallet
Wallet
The wallet used to sign the transaction.
client
WebsocketClient/AsyncWebsocketClient
A websocket client object.
fee_type
Option<FeeType>
A enum to determine the fee calculation type.
[ ] submit_transaction -> Response
Submits a signed transaction to the XRP Ledger.
Turns a transaction into a transaction blob and uses the SubmitOnly request method to submit it using the client.
Need to be done: https://github.com/sephynox/xrpl-rust/issues/17
AsyncWebsocketClient
Response
We should have high-level methods that predefine often used functions in combination with the public XRP Ledger Server API methods.
Structure
Topic
Short explanation how the change works.
Some particularities.
Sources:
Every function has a
client
argument. Its type is always only one ofWebsocketClient
andAsyncWebsocketClient
. When writing sync high-level methods useWebsocketClient
, when writing async useAsyncWebsocketClient
as type.account:
does_account_exist -> bool
The function simply calls the
get_account_info
function. If theResult
is no error the account exists.&str
WebsocketClient
/AsyncWebsocketClient
Option<&str>
Sources:
get_next_valid_account_seq_number -> u32
The function simply calls the
get_account_root
function and returns the AccountRoot object'sSequence
field.&str
WebsocketClient
/AsyncWebsocketClient
Option<&str>
Sources:
get_account_xrp_balance -> Currency
The function simply calls the
get_account_root
function and returns the AccountRoot object'sBalance
field.Use
drops_to_xrp
to convert the drops amount into a XRP amount.&str
WebsocketClient
/AsyncWebsocketClient
Optional<&str>
Sources:
get_account_balances -> Vec<Currency>
The function calls the
get_account_xrp_balance
and theAccountLines
request method and brings the balances in an easy-to-use format.&str
WebsocketClient
/AsyncWebsocketClient
Optional<&str>
Sources:
get_account_root -> AccountRoot
The function simply calls the
get_account_info
function and returns the result'saccount_data
field.The return type
AccountRoot
may not be defined yet.&str
WebsocketClient
/AsyncWebsocketClient
Option<&str>
Sources:
get_account_info -> Response
The function calls the
AccountInfo
request method using theWebsocketClient
/AsyncWebsocketClient
.The returning
Response
struct may not have been added yet. Keep a look at https://github.com/sephynox/xrpl-rust/issues/17, if the tick is already set. The user can choose which ledger he wants to query using theledger_index
argument. If noledger_index
is defined (: None
) the default is "validated". If a Ledger Index is defined edit theAccountInfo
request as wished.&str
WebsocketClient
/AsyncWebsocketClient
Option<&str>
Sources:
get_latest_transaction -> Response
The function calls the
AccountTx
request method using theWebsocketClient
/AsyncWebsocketClient
.The returning
Response
struct may not have been added yet. Keep a look at https://github.com/sephynox/xrpl-rust/issues/17, if the tick is already set. To receive an account's latest transaction define request:&str
WebsocketClient
/AsyncWebsocketClient
Sources:
get_account_transactions
The function calls the
AccountTx
request method using theWebsocketClient
/AsyncWebsocketClient
.If an account has send too many transactions for the node to send, the node sends as many transactions as it can and includes a
marker
field to tell you to how many Ledgers it looked back. You can define themarker
field inAccountTx
to receive the next batch of transactions.&str
WebsocketClient
/AsyncWebsocketClient
u32
Sources:
get_account_payment_transactions
TransactionType
Payment
.The function simply calls the
get_account_transactions
function and filters the list of transactions for transactions withTransactionType
Payment
.&str
WebsocketClient
/AsyncWebsocketClient
u32
Sources:
ledger:
get_fee
The function calls the
Fee
request method using theWebsocketClient
/AsyncWebsocketClient
.The user can decide what type of fee to get. "open" would return the
open_ledger_fee
field; "minimum" would return theminimum_fee
field; "dynamic" would return a calculated fee based on the node's transaction queue size.WebsocketClient
/AsyncWebsocketClient
Option<u32>
Option<&str>
Sources:
get_latest_validated_ledger_sequence
The function simply calls the
Ledger
request method and returns the resultsledger_index
fieldThe
ledger_index
field must be set to "validated".WebsocketClient
/AsyncWebsocketClient
Sources:
get_latest_open_ledger_sequence
The function simply calls the
Ledger
request method and returns the resultsledger_index
fieldThe
ledger_index
field must be set to "open".WebsocketClient
/AsyncWebsocketClient
Sources:
transaction:
get_transaction_from_hash
The function simply calls the
Tx
request method using theWebsocketClient
/AsyncWebsocketClient
.&str
WebsocketClient
/AsyncWebsocketClient
Option<bool>
Option<u32>
Option<u32>
Sources:
sign_transaction
2.
check_fee
isNone
,check_fee
is True.Transaction
Wallet
Option<bool>
sign_and_submit_transaction
sign_transaction
function and uses thesubmit
request method to submit the transaction to the network using theWebsocketClient
/AsyncWebsocketClient
.Transaction
Wallet
Option<bool>
WebsocketClient
/AsyncWebsocketClient
autofill_and_sign_transaction
Autofills fields like
fee
and signs the given transaction locally by callingsign_transaction
.The method should have a parameter to choose the
get_fee
calculation type. This Parameter should be optional. IfNone
the default value should beFeeType::Open
.Transaction
Wallet
WebsocketClient
/AsyncWebsocketClient
Option<FeeType>
submit_transaction -> Response
Turns a transaction into a transaction blob and uses the
SubmitOnly
request method to submit it using theclient
.Transaction
WebsocketClient
/AsyncWebsocketClient
Sources:
send_reliable_submission -> Response
Calls the
submit_transaction
and waits untilget_transaction_from_hash
returns a validated transaction.Transaction
WebsocketClient
/AsyncWebsocketClient
Sources:
wallet:
generate_faucet_wallet
The function uses the
destination
field to tell what account to fund.WebsocketClient
/AsyncWebsocketClient
Option<Wallet>
Option<&str>
Sources:
All these functions should be async. But we should have sync functions which simply call the async ones.