send_reliable_submission -> submit_and_wait

This commit is contained in:
JST5000
2023-06-05 16:05:04 -07:00
parent 82a880580a
commit 676e75da16
32 changed files with 127 additions and 208 deletions

View File

@@ -1,6 +1,6 @@
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import Payment
from xrpl.transaction import send_reliable_submission
from xrpl.transaction import submit_and_wait
def connect_node(_node):
@@ -27,7 +27,7 @@ def send_transaction(transaction_dict):
# Since we manually inserted the tx blob, we need to initialize it into a Payment so xrpl-py could process it
my_tx_signed = Payment.from_dict(transaction_dict)
tx = send_reliable_submission(transaction=my_tx_signed, client=client)
tx = submit_and_wait(transaction=my_tx_signed, client=client)
tx_hash = tx.result['hash']
tx_destination = tx.result['Destination']

View File

@@ -1,8 +1,7 @@
from xrpl.wallet import Wallet, generate_faucet_wallet
from xrpl.wallet import generate_faucet_wallet
from xrpl.clients import JsonRpcClient
from xrpl.models import CheckCancel
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.transaction import submit_and_wait
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork
@@ -20,8 +19,7 @@ sender_wallet = generate_faucet_wallet(client=client)
check_txn = CheckCancel(account=sender_wallet.classic_address, check_id=check_id)
# Sign and submit transaction
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
stxn_response = send_reliable_submission(stxn, client)
stxn_response = submit_and_wait(check_txn, client, sender_wallet)
# Parse response for result
stxn_result = stxn_response.result

View File

@@ -1,7 +1,6 @@
from xrpl.clients import JsonRpcClient
from xrpl.models import CheckCash, IssuedCurrencyAmount
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.transaction import submit_and_wait
from xrpl.utils import str_to_hex, xrp_to_drops
from xrpl.wallet import generate_faucet_wallet
@@ -23,11 +22,9 @@ sender_wallet = generate_faucet_wallet(client=client)
# Build check cash transaction
check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=xrp_to_drops(amount))
# Sign transaction
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(check_txn, client, sender_wallet)
# Submit transaction and wait for result
stxn_response = send_reliable_submission(stxn, client)
# Parse response for result
stxn_result = stxn_response.result
@@ -60,11 +57,8 @@ check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id,
issuer=issuer,
value=amount))
# Sign transaction
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
# Submit transaction and wait for result
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(check_txn, client, sender_wallet)
# Parse response for result
stxn_result = stxn_response.result

View File

@@ -2,8 +2,7 @@ from datetime import datetime, timedelta
from xrpl.clients import JsonRpcClient
from xrpl.models import CheckCreate, IssuedCurrencyAmount
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.transaction import submit_and_wait
from xrpl.utils import datetime_to_ripple_time, str_to_hex, xrp_to_drops
from xrpl.wallet import generate_faucet_wallet
@@ -33,9 +32,8 @@ send_max=IssuedCurrencyAmount(
value=amount),
expiration=expiry_date)
# Sign, submit transaction and wait for result
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(check_txn, client, sender_wallet)
# Parse response for result
stxn_result = stxn_response.result
@@ -66,9 +64,8 @@ check_txn = CheckCreate(account=sender_wallet.classic_address,
send_max=xrp_to_drops(amount),
expiration=expiry_date)
# Sign, submit transaction and wait for result
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(check_txn, client, sender_wallet)
# Parse response for result
stxn_result = stxn_response.result

View File

@@ -1,6 +1,6 @@
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import AccountSet, SetRegularKey, AccountSetFlag, Payment
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.models.transactions import AccountSet, SetRegularKey, AccountSetFlag
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
from xrpl.models.requests import AccountInfo
@@ -31,9 +31,8 @@ tx_regulary_key = SetRegularKey(
regular_key=blackhole_address
)
# Sign the transaction
tx_regulary_key_signed = safe_sign_and_autofill_transaction(tx_regulary_key, wallet=test_wallet, client=client)
submit_tx_regular = send_reliable_submission(client=client, transaction=tx_regulary_key_signed)
# Sign and submit the transaction
submit_tx_regular = submit_and_wait(transaction=tx_regulary_key, client=client, wallet=test_wallet)
submit_tx_regular = submit_tx_regular.result
print(f"\n Submitted a SetRegularKey tx. Result: {submit_tx_regular['meta']['TransactionResult']}")
print(f" Tx content: {submit_tx_regular}")
@@ -45,9 +44,8 @@ tx_disable_master_key = AccountSet(
set_flag=AccountSetFlag.ASF_DISABLE_MASTER
)
# Sign the transaction
tx_disable_master_key_signed = safe_sign_and_autofill_transaction(tx_disable_master_key, wallet=test_wallet, client=client)
submit_tx_disable = send_reliable_submission(client=client, transaction=tx_disable_master_key_signed)
# Sign and submit the transaction
submit_tx_disable = submit_and_wait(transaction=tx_disable_master_key, client=client, wallet=test_wallet)
submit_tx_disable = submit_tx_disable.result
print(f"\n Submitted a DisableMasterKey tx. Result: {submit_tx_disable['meta']['TransactionResult']}")
print(f" Tx content: {submit_tx_disable}")

View File

@@ -1,7 +1,6 @@
from xrpl.clients import JsonRpcClient
from xrpl.models import EscrowCancel
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork
@@ -17,9 +16,8 @@ sender_wallet = generate_faucet_wallet(client=client)
# Build escrow cancel transaction
cancel_txn = EscrowCancel(account=sender_wallet.classic_address, owner=sender_wallet.classic_address, offer_sequence=escrow_sequence)
# Sign and submit transaction
stxn = safe_sign_and_autofill_transaction(cancel_txn, sender_wallet, client)
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(cancel_txn, client, sender_wallet)
# Parse response and return result
stxn_result = stxn_response.result

View File

@@ -1,10 +1,8 @@
import json
from datetime import datetime, timedelta
from xrpl.clients import JsonRpcClient
from xrpl.models import EscrowCreate
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.transaction import submit_and_wait
from xrpl.utils import datetime_to_ripple_time, xrp_to_drops
from xrpl.wallet import generate_faucet_wallet
@@ -38,9 +36,8 @@ create_txn = EscrowCreate(
cancel_after=expiry_date,
condition=condition)
# Sign and send transaction
stxn = safe_sign_and_autofill_transaction(create_txn, sender_wallet, client)
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(create_txn, client, sender_wallet)
# Return result of transaction
stxn_result = stxn_response.result

View File

@@ -1,8 +1,7 @@
from xrpl.clients import JsonRpcClient
from xrpl.models import EscrowFinish
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.wallet import Wallet, generate_faucet_wallet
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork
@@ -28,11 +27,8 @@ sender_wallet = generate_faucet_wallet(client=client)
# Build escrow finish transaction
finish_txn = EscrowFinish(account=sender_wallet.classic_address, owner=escrow_creator, offer_sequence=escrow_sequence, condition=condition, fulfillment=fulfillment)
# Sign transaction with wallet
stxn = safe_sign_and_autofill_transaction(finish_txn, sender_wallet, client)
# Send transaction and wait for response
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(finish_txn, client, sender_wallet)
# Parse response and return result
stxn_result = stxn_response.result

View File

@@ -1,8 +1,7 @@
from xrpl.clients import JsonRpcClient
from xrpl.models import AccountSet, AccountSetFlag
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.wallet import Wallet, generate_faucet_wallet
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to testnet
@@ -15,13 +14,10 @@ print("Successfully generated test wallet")
# build accountset transaction to disable freezing
accountset = AccountSet(account=sender_wallet.classic_address, set_flag=AccountSetFlag.ASF_NO_FREEZE)
# sign transaction
stxn = safe_sign_and_autofill_transaction(accountset, sender_wallet, client)
print("Now sending an AccountSet transaction to set the ASF_NO_FREEZE flag...")
# submit transaction and wait for result
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(accountset, client, sender_wallet)
# parse response for result

View File

@@ -1,8 +1,7 @@
from xrpl.clients import JsonRpcClient
from xrpl.models import IssuedCurrencyAmount, TrustSet
from xrpl.models.transactions import TrustSetFlag
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to testnet
@@ -25,13 +24,10 @@ trustset = TrustSet(account=sender_wallet.classic_address, limit_amount=IssuedCu
value = value),
flags=TrustSetFlag.TF_SET_FREEZE)
# Sign transaction
stxn = safe_sign_and_autofill_transaction(trustset, sender_wallet, client)
print("Now setting a trustline with the TF_SET_FREEZE flag enabled...")
# Submit transaction and wait for result
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(trustset, client, sender_wallet)
# Parse response for result
stxn_result = stxn_response.result

View File

@@ -1,7 +1,6 @@
from xrpl.clients import JsonRpcClient
from xrpl.models import AccountSet, AccountSetFlag
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to testnet
@@ -17,9 +16,8 @@ accountset = AccountSet(account=sender_wallet.classic_address,
print("Preparing and submitting Account set transaction with ASF_GLOBAL_FREEZE ...")
# Sign and submit transaction
stxn = safe_sign_and_autofill_transaction(accountset, sender_wallet, client)
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(accountset, client, sender_wallet)
# Parse response for result
stxn_result = stxn_response.result

View File

@@ -1,7 +1,6 @@
from xrpl.clients import JsonRpcClient
from xrpl.models import IssuedCurrencyAmount, TrustSet, TrustSetFlag
from xrpl.transaction import (safe_sign_and_autofill_transaction,
send_reliable_submission)
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to testnet
@@ -32,9 +31,8 @@ flags=TrustSetFlag.TF_CLEAR_FREEZE)
print("prepared and submitting TF_CLEAR_FREEZE transaction")
# Sign and Submit transaction
stxn = safe_sign_and_autofill_transaction(trustset, sender_wallet, client)
stxn_response = send_reliable_submission(stxn, client)
# Autofill, sign, then submit transaction and wait for result
stxn_response = submit_and_wait(trustset, client, sender_wallet)
# Parse response for result
stxn_result = stxn_response.result

View File

@@ -32,18 +32,10 @@ my_tx_payment = Payment(
# print prepared payment
print(my_tx_payment)
# Sign the transaction
from xrpl.transaction import safe_sign_and_autofill_transaction
# Sign and submit the transaction
from xrpl.transaction import submit_and_wait
my_tx_payment_signed = safe_sign_and_autofill_transaction(my_tx_payment, test_wallet, client)
# Print signed tx
print("Signed tx:", my_tx_payment_signed)
# Submit and send the transaction
from xrpl.transaction import send_reliable_submission
tx_response = send_reliable_submission(my_tx_payment_signed, client)
tx_response = submit_and_wait(my_tx_payment, client, test_wallet)
# Print tx response
print("Tx response:", tx_response)

View File

@@ -25,13 +25,9 @@ cold_settings_tx = xrpl.models.transactions.AccountSet(
domain=bytes.hex("example.com".encode("ASCII")),
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE,
)
cst_prepared = xrpl.transaction.safe_sign_and_autofill_transaction(
transaction=cold_settings_tx,
wallet=cold_wallet,
client=client,
)
print("Sending cold address AccountSet transaction...")
response = xrpl.transaction.send_reliable_submission(cst_prepared, client)
response = xrpl.transaction.submit_and_wait(cold_settings_tx, client, cold_wallet)
print(response)
@@ -40,13 +36,9 @@ hot_settings_tx = xrpl.models.transactions.AccountSet(
account=hot_wallet.classic_address,
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_REQUIRE_AUTH,
)
hst_prepared = xrpl.transaction.safe_sign_and_autofill_transaction(
transaction=hot_settings_tx,
wallet=hot_wallet,
client=client,
)
print("Sending hot address AccountSet transaction...")
response = xrpl.transaction.send_reliable_submission(hst_prepared, client)
response = xrpl.transaction.submit_and_wait(hot_settings_tx, client, hot_wallet)
print(response)
@@ -60,13 +52,9 @@ trust_set_tx = xrpl.models.transactions.TrustSet(
value="10000000000", # Large limit, arbitrarily chosen
)
)
ts_prepared = xrpl.transaction.safe_sign_and_autofill_transaction(
transaction=trust_set_tx,
wallet=hot_wallet,
client=client,
)
print("Creating trust line from hot address to issuer...")
response = xrpl.transaction.send_reliable_submission(ts_prepared, client)
response = xrpl.transaction.submit_and_wait(trust_set_tx, client, hot_wallet)
print(response)
@@ -81,13 +69,9 @@ send_token_tx = xrpl.models.transactions.Payment(
value=issue_quantity
)
)
pay_prepared = xrpl.transaction.safe_sign_and_autofill_transaction(
transaction=send_token_tx,
wallet=cold_wallet,
client=client,
)
print(f"Sending {issue_quantity} {currency_code} to {hot_wallet.classic_address}...")
response = xrpl.transaction.send_reliable_submission(pay_prepared, client)
response = xrpl.transaction.submit_and_wait(send_token_tx, client, cold_wallet)
print(response)

View File

@@ -10,7 +10,7 @@ from xrpl.transaction import (
autofill,
autofill_and_sign,
multisign,
send_reliable_submission,
submit_and_wait,
sign,
)
from xrpl.utils import str_to_hex
@@ -36,7 +36,7 @@ signer_list_set_tx = SignerListSet(
signed_signer_list_set_tx = autofill_and_sign(signer_list_set_tx, master_wallet, client)
print("Constructed SignerListSet and submitting it to the ledger...")
signed_list_set_tx_response = send_reliable_submission(
signed_list_set_tx_response = submit_and_wait(
signed_signer_list_set_tx, client
)
print("SignerListSet submitted, here's the response:")

View File

@@ -1,4 +1,4 @@
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.models.transactions.nftoken_mint import NFTokenMint, NFTokenMintFlag
from xrpl.models.transactions.account_set import AccountSet, AccountSetFlag
from xrpl.wallet import generate_faucet_wallet
@@ -44,9 +44,8 @@ authorize_minter_tx = AccountSet(
nftoken_minter=minterAddr
)
# Sign authorize_minter_tx using issuer account
authorize_minter_tx_signed = safe_sign_and_autofill_transaction(transaction=authorize_minter_tx, wallet=issuer_wallet, client=client)
authorize_minter_tx_signed = send_reliable_submission(transaction=authorize_minter_tx_signed, client=client)
# Sign and submit authorize_minter_tx using issuer account
authorize_minter_tx_signed = submit_and_wait(transaction=authorize_minter_tx, client=client, wallet=issuer_wallet)
authorize_minter_tx_result = authorize_minter_tx_signed.result
print(f"\nAuthorize minter tx result: {authorize_minter_tx_result}")
@@ -67,8 +66,7 @@ mint_tx_1 = NFTokenMint(
# Sign using previously authorized minter's account, this will result in the NFT's issuer field to be the Issuer Account
# while the NFT's owner would be the Minter Account
mint_tx_1_signed = safe_sign_and_autofill_transaction(transaction=mint_tx_1, wallet=nftoken_minter_wallet, client=client)
mint_tx_1_signed = send_reliable_submission(transaction=mint_tx_1_signed, client=client)
mint_tx_1_signed = submit_and_wait(transaction=mint_tx_1, client=client, wallet=nftoken_minter_wallet)
mint_tx_1_result = mint_tx_1_signed.result
print(f"\n Mint tx result: {mint_tx_1_result['meta']['TransactionResult']}")
print(f" Tx response: {mint_tx_1_result}")

View File

@@ -1,4 +1,4 @@
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.models.transactions.nftoken_burn import NFTokenBurn
from xrpl.models.requests import AccountNFTs
from xrpl.clients import JsonRpcClient
@@ -52,10 +52,9 @@ else:
nftoken_id=get_account_nfts.result['account_nfts'][0]['NFTokenID']
)
# Sign burn_tx using the issuer account
burn_tx_signed = safe_sign_and_autofill_transaction(transaction=burn_tx, wallet=issuer_wallet, client=client)
burn_tx_signed = send_reliable_submission(transaction=burn_tx_signed, client=client)
burn_tx_result = burn_tx_signed.result
# Sign and submit burn_tx using the issuer account
burn_tx_response = submit_and_wait(transaction=burn_tx, client=client, wallet=issuer_wallet)
burn_tx_result = burn_tx_response.result
print(f"\nBurn tx result: {burn_tx_result['meta']['TransactionResult']}")
print(f" Tx response:{burn_tx_result}")

View File

@@ -1,4 +1,4 @@
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.models.transactions.nftoken_cancel_offer import NFTokenCancelOffer
from xrpl.models.requests import AccountObjects, AccountObjectType
from xrpl.clients import JsonRpcClient
@@ -60,11 +60,9 @@ else:
]
)
# Sign cancel_sell_offer_tx using minter account
cancel_sell_offer_tx_signed = safe_sign_and_autofill_transaction(transaction=cancel_sell_offer_tx, wallet=wallet,
client=client)
cancel_sell_offer_tx_signed = send_reliable_submission(transaction=cancel_sell_offer_tx_signed, client=client)
cancel_sell_offer_tx_result = cancel_sell_offer_tx_signed.result
# Sign and submit cancel_sell_offer_tx using minter account
cancel_sell_offer_tx_response = submit_and_wait(transaction=cancel_sell_offer_tx, client=client, wallet=wallet)
cancel_sell_offer_tx_result = cancel_sell_offer_tx_response.result
print(f"\n Cancel Sell Offer tx result: {cancel_sell_offer_tx_result['meta']['TransactionResult']}"
f"\n Tx response: {cancel_sell_offer_tx_result}")

View File

@@ -1,4 +1,4 @@
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.models.transactions.nftoken_create_offer import NFTokenCreateOffer
from xrpl.wallet import generate_faucet_wallet
from xrpl.models.requests import AccountNFTs
@@ -56,9 +56,8 @@ else:
amount=buy_offer_amount, # 10 XRP in drops, 1 XRP = 1,000,000 drops
)
# Sign buy_tx using the issuer account
buy_tx_signed = safe_sign_and_autofill_transaction(transaction=buy_tx, wallet=buyer_wallet, client=client)
buy_tx_signed = send_reliable_submission(transaction=buy_tx_signed, client=client)
# Sign and submit buy_tx using the issuer account
buy_tx_signed = submit_and_wait(transaction=buy_tx, client=client, wallet=buyer_wallet)
buy_tx_result = buy_tx_signed.result
print(f"\n NFTokenCreateOffer tx result: {buy_tx_result['meta']['TransactionResult']}")

View File

@@ -1,5 +1,5 @@
from xrpl.models.transactions.nftoken_create_offer import NFTokenCreateOffer, NFTokenCreateOfferFlag
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.models.requests import AccountNFTs
from xrpl.clients import JsonRpcClient
from xrpl.models import NFTSellOffers
@@ -55,9 +55,8 @@ else:
)
# Sign sell_tx using the issuer account
sell_tx_signed = safe_sign_and_autofill_transaction(transaction=sell_tx, wallet=issuer_wallet, client=client)
sell_tx_signed = send_reliable_submission(transaction=sell_tx_signed, client=client)
sell_tx_result = sell_tx_signed.result
sell_tx_response = submit_and_wait(transaction=sell_tx, client=client, wallet=issuer_wallet)
sell_tx_result = sell_tx_response.result
print(f"\n Sell Offer tx result: {sell_tx_result['meta']['TransactionResult']}")
print(f" Tx response: {sell_tx_result}")

View File

@@ -1,4 +1,4 @@
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.models.transactions.nftoken_mint import NFTokenMint, NFTokenMintFlag
from xrpl.wallet import generate_faucet_wallet
from xrpl.models.requests import AccountNFTs
@@ -39,9 +39,8 @@ mint_tx = NFTokenMint(
)
# Sign mint_tx using the issuer account
mint_tx_signed = safe_sign_and_autofill_transaction(transaction=mint_tx, wallet=issuer_wallet, client=client)
mint_tx_signed = send_reliable_submission(transaction=mint_tx_signed, client=client)
mint_tx_result = mint_tx_signed.result
mint_tx_response = submit_and_wait(transaction=mint_tx, client=client, wallet=issuer_wallet)
mint_tx_result = mint_tx_response.result
print(f"\n Mint tx result: {mint_tx_result['meta']['TransactionResult']}")
print(f" Tx response: {mint_tx_result}")

View File

@@ -1,5 +1,5 @@
from xrpl.models.transactions.nftoken_create_offer import NFTokenCreateOffer, NFTokenCreateOfferFlag
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.models.transactions.nftoken_mint import NFTokenMint, NFTokenMintFlag
from xrpl.models.transactions.nftoken_accept_offer import NFTokenAcceptOffer
from xrpl.models.transactions.nftoken_cancel_offer import NFTokenCancelOffer
@@ -57,10 +57,9 @@ mint_tx = NFTokenMint(
nftoken_taxon=0
)
# Sign mint_tx using issuer account
mint_tx_signed = safe_sign_and_autofill_transaction(transaction=mint_tx, wallet=issuer_wallet, client=client)
mint_tx_signed = send_reliable_submission(transaction=mint_tx_signed, client=client)
mint_tx_result = mint_tx_signed.result
# Sign and submit mint_tx using issuer account
mint_tx_response = submit_and_wait(transaction=mint_tx, client=client, wallet=issuer_wallet)
mint_tx_result = mint_tx_response.result
print(f"\n Mint tx result: {mint_tx_result['meta']['TransactionResult']}"
f"\n Tx response: {mint_tx_result}")
@@ -81,9 +80,8 @@ burn_tx = NFTokenBurn(
)
# Sign burn_tx using issuer account
burn_tx_signed = safe_sign_and_autofill_transaction(transaction=burn_tx, wallet=issuer_wallet, client=client)
burn_tx_signed = send_reliable_submission(transaction=burn_tx_signed, client=client)
burn_tx_result = burn_tx_signed.result
burn_tx_response = submit_and_wait(transaction=burn_tx, client=client, wallet=issuer_wallet)
burn_tx_result = burn_tx_response.result
print(f"\n Burn tx result: {burn_tx_result['meta']['TransactionResult']}"
f"\n Tx response: {burn_tx_result}")
@@ -101,9 +99,8 @@ authorize_minter_tx = AccountSet(
)
# Sign authorize_minter_tx using issuer account
authorize_minter_tx_signed = safe_sign_and_autofill_transaction(transaction=authorize_minter_tx, wallet=issuer_wallet, client=client)
authorize_minter_tx_signed = send_reliable_submission(transaction=authorize_minter_tx_signed, client=client)
authorize_minter_tx_result = authorize_minter_tx_signed.result
authorize_minter_tx_response = submit_and_wait(transaction=authorize_minter_tx, client=client, wallet=issuer_wallet)
authorize_minter_tx_result = authorize_minter_tx_response.result
print(f"\n Authorize minter tx result: {authorize_minter_tx_result['meta']['TransactionResult']}"
f"\n Tx response: {authorize_minter_tx_result}")
@@ -125,9 +122,8 @@ mint_tx_1 = NFTokenMint(
# Sign using previously authorized minter's account, this will result in the NFT's issuer field to be the Issuer Account
# while the NFT's owner would be the Minter Account
mint_tx_1_signed = safe_sign_and_autofill_transaction(transaction=mint_tx_1, wallet=nftoken_minter_wallet, client=client)
mint_tx_1_signed = send_reliable_submission(transaction=mint_tx_1_signed, client=client)
mint_tx_1_result = mint_tx_1_signed.result
mint_tx_1_response = submit_and_wait(transaction=mint_tx_1, client=client, wallet=nftoken_minter_wallet)
mint_tx_1_result = mint_tx_1_response.result
print(f"\n Mint tx result: {mint_tx_1_result['meta']['TransactionResult']}"
f"\n Tx response: {mint_tx_1_result}")
@@ -154,10 +150,9 @@ sell_tx = NFTokenCreateOffer(
flags=NFTokenCreateOfferFlag.TF_SELL_NFTOKEN,
)
# Sign sell_tx using minter account
sell_tx_signed = safe_sign_and_autofill_transaction(transaction=sell_tx, wallet=nftoken_minter_wallet, client=client)
sell_tx_signed = send_reliable_submission(transaction=sell_tx_signed, client=client)
sell_tx_result = sell_tx_signed.result
# Sign and submit sell_tx using minter account
sell_tx_response = submit_and_wait(transaction=sell_tx, client=client, wallet=nftoken_minter_wallet)
sell_tx_result = sell_tx_response.result
print(f"\n Sell Offer tx result: {sell_tx_result['meta']['TransactionResult']}"
f"\n Tx response: {sell_tx_result}")
@@ -178,9 +173,8 @@ cancel_sell_offer_tx = NFTokenCancelOffer(
)
# Sign cancel_sell_offer_tx using minter account
cancel_sell_offer_tx_signed = safe_sign_and_autofill_transaction(transaction=cancel_sell_offer_tx, wallet=nftoken_minter_wallet, client=client)
cancel_sell_offer_tx_signed = send_reliable_submission(transaction=cancel_sell_offer_tx_signed, client=client)
cancel_sell_offer_tx_result = cancel_sell_offer_tx_signed.result
cancel_sell_offer_tx_response = submit_and_wait(transaction=cancel_sell_offer_tx, client=client, wallet=nftoken_minter_wallet)
cancel_sell_offer_tx_result = cancel_sell_offer_tx_response.result
print(f"\n Cancel Sell Offer tx result: {cancel_sell_offer_tx_result['meta']['TransactionResult']}"
f"\n Tx response: {cancel_sell_offer_tx_result}")
@@ -193,10 +187,9 @@ sell_1_tx = NFTokenCreateOffer(
flags=NFTokenCreateOfferFlag.TF_SELL_NFTOKEN,
)
# Sign sell_1_tx using minter account
sell_1_tx_signed = safe_sign_and_autofill_transaction(transaction=sell_1_tx, wallet=nftoken_minter_wallet, client=client)
sell_1_tx_signed = send_reliable_submission(transaction=sell_1_tx_signed, client=client)
sell_1_tx_result = sell_1_tx_signed.result
# Sign and submit sell_1_tx using minter account
sell_1_tx_response = submit_and_wait(transaction=sell_1_tx, client=client, wallet=nftoken_minter_wallet)
sell_1_tx_result = sell_1_tx_response.result
print(f"\n Sell Offer tx result: {sell_1_tx_result['meta']['TransactionResult']}"
f"\n Tx response: {sell_1_tx_result}")
@@ -217,8 +210,7 @@ buy_tx = NFTokenAcceptOffer(
)
# Sign buy_tx using buyer account
buy_tx_signed = safe_sign_and_autofill_transaction(transaction=buy_tx, wallet=buyer_wallet, client=client)
buy_tx_signed = send_reliable_submission(transaction=buy_tx_signed, client=client)
buy_tx_result = buy_tx_signed.result
buy_tx_response = submit_and_wait(transaction=buy_tx, client=client, wallet=buyer_wallet)
buy_tx_result = buy_tx_response.result
print(f"\n Buy Offer result: {buy_tx_result['meta']['TransactionResult']}"
f"\n Tx response: {buy_tx_result}")

View File

@@ -3,7 +3,7 @@ from xrpl.clients import JsonRpcClient
from xrpl.models.amounts import IssuedCurrencyAmount
from xrpl.models.requests import AccountLines
from xrpl.models.transactions import Payment, PaymentFlag, TrustSet
from xrpl.transaction import autofill_and_sign, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
# References
@@ -30,8 +30,7 @@ trust_set_tx = TrustSet(
)
# Sign and autofill, then send transaction to the ledger
signed_trust_set_tx = autofill_and_sign(trust_set_tx, wallet2, client)
send_reliable_submission(signed_trust_set_tx, client)
signed_trust_set_tx = submit_and_wait(trust_set_tx, client, wallet2)
# Both balances should be zero since nothing has been sent yet
print("Balances after trustline is claimed:")
@@ -53,8 +52,7 @@ payment_tx = Payment(
)
# Sign and autofill, then send transaction to the ledger
signed_payment_tx = autofill_and_sign(payment_tx, wallet1, client)
payment_response = send_reliable_submission(signed_payment_tx, client)
payment_response = submit_and_wait(payment_tx, client, wallet1)
print("Initial Payment response: ", payment_response)
# Issuer (wallet1) should have -3840 FOO and destination (wallet2) should have 3840 FOO
@@ -90,8 +88,7 @@ partial_payment_tx = Payment(
)
# Sign and autofill, then send transaction to the ledger
signed_partial_payment_tx = autofill_and_sign(partial_payment_tx, wallet2, client)
partial_payment_response = send_reliable_submission(signed_partial_payment_tx, client)
partial_payment_response = submit_and_wait(partial_payment_tx, client, wallet2)
print("Partial Payment response: ", partial_payment_response)
# Tried sending 4000 of 3840 FOO -> wallet1 and wallet2 should have 0 FOO

View File

@@ -3,7 +3,7 @@ from xrpl.account import get_balance
from xrpl.clients import JsonRpcClient
from xrpl.models.requests import Tx
from xrpl.models.transactions import Payment
from xrpl.transaction import autofill_and_sign, send_reliable_submission
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
# References:
@@ -30,11 +30,8 @@ payment_tx = Payment(
destination=wallet2.classic_address,
)
# Sign and autofill the transaction (prepares it to be ready to submit)
signed_payment_tx = autofill_and_sign(payment_tx, wallet1, client)
# Submits transaction and waits for response (validated or rejected)
payment_response = send_reliable_submission(signed_payment_tx, client)
# Autofill, sign, and submit the transaction
payment_response = submit_and_wait(payment_tx, client, wallet1)
print("Transaction was submitted")
# Create a Transaction request to see transaction

View File

@@ -3,7 +3,7 @@ import asyncio
from xrpl.asyncio.clients import AsyncWebsocketClient
from xrpl.asyncio.transaction import (
safe_sign_and_autofill_transaction,
send_reliable_submission,
submit_and_wait,
)
from xrpl.asyncio.wallet import generate_faucet_wallet
from xrpl.models.requests import AccountInfo
@@ -32,7 +32,7 @@ async def main() -> int:
# Submit the transaction and wait for response (validated or rejected)
print("Submitting transaction...")
submit_result = await send_reliable_submission(signed_tx, client)
submit_result = await submit_and_wait(signed_tx, client)
print("Submit result:", submit_result)
# Confirm Account Settings --------------------------------------------------

View File

@@ -1,6 +1,6 @@
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import Payment, Memo
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.transaction import safe_sign_and_autofill_transaction, submit_and_wait
from xrpl.wallet import generate_faucet_wallet
# This code sample validates and sends a transaction with a Memo attached
@@ -46,7 +46,7 @@ payment_tx_signed = safe_sign_and_autofill_transaction(payment_tx, wallet=test_w
print(f"\n Encoded Transaction MEMO: {payment_tx_signed.memos}")
# Send the transaction to the node
submit_tx_regular = send_reliable_submission(client=client, transaction=payment_tx_signed)
submit_tx_regular = submit_and_wait(transaction=payment_tx_signed, client=client)
submit_tx_regular = submit_tx_regular.result
tx_MemoData = bytes.fromhex(submit_tx_regular['Memos'][0]['Memo']['MemoData']).decode('utf-8')

View File

@@ -35,12 +35,12 @@ print("Identifying hash:", tx_id)
# Submit transaction -----------------------------------------------------------
try:
tx_response = xrpl.transaction.send_reliable_submission(signed_tx, client)
tx_response = xrpl.transaction.submit_and_wait(signed_tx, client)
except xrpl.transaction.XRPLReliableSubmissionException as e:
exit(f"Submit failed: {e}")
# Wait for validation ----------------------------------------------------------
# send_reliable_submission() handles this automatically, but it can take 4-7s.
# submit_and_wait() handles this automatically, but it can take 4-7s.
# Check transaction results ----------------------------------------------------
import json

View File

@@ -2,7 +2,7 @@
from xrpl.account import get_balance
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import Payment, SetRegularKey
from xrpl.transaction import autofill_and_sign, send_reliable_submission
from xrpl.transaction import autofill_and_sign, submit_and_wait
from xrpl.wallet import generate_faucet_wallet
# References
@@ -28,8 +28,7 @@ tx = SetRegularKey(
account=wallet1.classic_address, regular_key=regular_key_wallet.classic_address
)
signed_tx = autofill_and_sign(tx, wallet1, client)
set_regular_key_response = send_reliable_submission(signed_tx, client)
set_regular_key_response = submit_and_wait(tx, client, wallet1)
print("Response for successful SetRegularKey tx:")
print(set_regular_key_response)
@@ -42,8 +41,7 @@ payment = Payment(
amount="1000",
)
signed_payment = autofill_and_sign(payment, regular_key_wallet, client)
payment_response = send_reliable_submission(signed_payment, client)
payment_response = submit_and_wait(payment, client, regular_key_wallet)
print("Response for tx signed using Regular Key:")
print(payment_response)

View File

@@ -1,7 +1,7 @@
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import AccountSet
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.wallet import Wallet, generate_faucet_wallet
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
# Connect to a testnet node
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
@@ -16,10 +16,8 @@ tx = AccountSet(
account=myAddr
)
# Sign the transaction locally
my_tx_payment_signed = safe_sign_and_autofill_transaction(transaction=tx, wallet=test_wallet, client=client)
# Submit transaction and verify its validity on the ledger
response = send_reliable_submission(transaction=my_tx_payment_signed, client=client)
response = submit_and_wait(transaction=tx, client=client, wallet=test_wallet)
result = response.result["meta"]["TransactionResult"]
print(f"Account: {myAddr}")

View File

@@ -5,7 +5,7 @@ from decimal import Decimal
from xrpl.asyncio.clients import AsyncWebsocketClient
from xrpl.asyncio.transaction import (
safe_sign_and_autofill_transaction,
send_reliable_submission,
submit_and_wait,
)
from xrpl.asyncio.wallet import generate_faucet_wallet
from xrpl.models.currencies import (
@@ -175,7 +175,7 @@ async def main() -> int:
# Submit the transaction and wait for response (validated or rejected)
print("Sending OfferCreate transaction...")
result = await send_reliable_submission(signed_tx, client)
result = await submit_and_wait(signed_tx, client)
if result.is_successful():
print(f"Transaction succeeded: "
f"https://testnet.xrpl.org/transactions/{signed_tx.get_hash()}")

View File

@@ -196,6 +196,7 @@ The result of the signing operation is a transaction object containing a signatu
Now that you have a signed transaction, you can submit it to an XRP Ledger server, which relays it through the network. It's also a good idea to take note of the latest validated ledger index before you submit. The earliest ledger version that your transaction could get into as a result of this submission is one higher than the latest validated ledger when you submit it. Of course, if the same transaction was previously submitted, it could already be in a previous ledger. (It can't succeed a second time, but you may not realize it succeeded if you aren't looking in the right ledger versions.)
- **JavaScript:** Use the [`submitAndWait()` method of the Client](https://js.xrpl.org/classes/Client.html#submitAndWait) to submit a signed transaction to the network and wait for the response, or use [`submitSigned()`](https://js.xrpl.org/classes/Client.html#submitSigned) to submit a transaction and get only the preliminary response.
<!-- TODO: Update this to point to `submit_and_wait` once the refernce docs for submit_and_wait are live -->
- **Python:** Use the [`xrpl.transaction.send_reliable_submission()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.send_reliable_submission) to submit a transaction to the network and wait for a response.
- **Java:** Use the [`XrplClient.submit(SignedTransaction)` method](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#submit(org.xrpl.xrpl4j.crypto.signing.SignedTransaction)) to submit a transaction to the network. Use the [`XrplClient.ledger()`](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#ledger(org.xrpl.xrpl4j.model.client.ledger.LedgerRequestParams)) method to get the latest validated ledger index.
@@ -239,6 +240,7 @@ Most transactions are accepted into the next ledger version after they're submit
- **JavaScript:** If you used the [`.submitAndWait()` method](https://js.xrpl.org/classes/Client.html#submitAndWait), you can wait until the returned Promise resolves. Other, more asynchronous approaches are also possible.
<!-- TODO: Update this to point to `submit_and_wait` once the reference docs for it go live -->
- **Python:** If you used the [`xrpl.transaction.send_reliable_submission()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.send_reliable_submission), you can wait for the function to return. Other approaches, including asynchronous ones using the WebSocket client, are also possible.
- **Java** Poll the [`XrplClient.transaction()` method](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#transaction(org.xrpl.xrpl4j.model.client.transactions.TransactionRequestParams,java.lang.Class)) to see if your transaction has a final result. Periodically check that the latest validated ledger index has not passed the `LastLedgerIndex` of the transaction using the [`XrplClient.ledger()`](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#ledger(org.xrpl.xrpl4j.model.client.ledger.LedgerRequestParams)) method.
@@ -272,7 +274,7 @@ To know for sure what a transaction did, you must look up the outcome of the tra
**Tip:** In **TypeScript** you can pass a [`TxRequest`](https://js.xrpl.org/interfaces/TxRequest.html) to the [`Client.request()`](https://js.xrpl.org/classes/Client.html#request) method.
- **Python:** Use the response from `send_reliable_submission()` or call the [`xrpl.transaction.get_transaction_from_hash()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.get_transaction_from_hash). (See the [tx method response format](tx.html#response-format) for a detailed reference of the fields this can contain.)
- **Python:** Use the response from `submit_and_wait()` or call the [`xrpl.transaction.get_transaction_from_hash()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.get_transaction_from_hash). (See the [tx method response format](tx.html#response-format) for a detailed reference of the fields this can contain.)
- **Java:** Use the [`XrplClient.transaction()`](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#transaction(org.xrpl.xrpl4j.model.client.transactions.TransactionRequestParams,java.lang.Class)) method to check the status of a transaction.

View File

@@ -202,6 +202,7 @@ Most transactions are accepted into the next ledger version after they're submit
The code samples in this tutorial use helper functions to wait for validation when submitting a transaction:
- **JavaScript:** The `submit_and_verify()` function, as defined in the [submit-and-verify code sample](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/submit-and-verify).
<!-- TODO: Update this to point to `submit_and_wait` once the reference docs for it go live -->
- **Python:** The `send_reliable_submission()` [method of the xrpl-py library](https://xrpl-py.readthedocs.io/en/stable/source/xrpl.transaction.html#xrpl.transaction.send_reliable_submission).
- **Java:** The `submitAndWaitForValidation()` method in the [sample Java class](https://github.com/XRPLF/xrpl-dev-portal/blob/master/content/_code-samples/issue-a-token/java/IssueToken.java).