Resubmit Python2 updates

This commit is contained in:
ddawson
2023-09-05 13:58:05 -07:00
parent 3de3aa68f0
commit 757bfd4c07
17 changed files with 1406 additions and 352 deletions

View File

@@ -12,7 +12,7 @@ testnet_url = "https://s.altnet.rippletest.net:51234"
def create_sell_offer(seed, amount, nftoken_id, expiration, destination):
"""create_sell_offer"""
# Get the client
owner_wallet = Wallet(seed, sequence=16237283)
owner_wallet = Wallet.from_seed(seed)
client = JsonRpcClient(testnet_url)
expiration_date = datetime.now()
if expiration != '':
@@ -20,41 +20,34 @@ def create_sell_offer(seed, amount, nftoken_id, expiration, destination):
expiration_date = expiration_date + int(expiration)
# Define the sell offer
sell_offer_tx=xrpl.models.transactions.NFTokenCreateOffer(
account=owner_wallet.classic_address,
account=owner_wallet.address,
nftoken_id=nftoken_id,
amount=amount,
destination=destination if destination != '' else None,
expiration=expiration_date if expiration != '' else None,
flags=1
)
# Sign and fill the transaction
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
sell_offer_tx, owner_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.submit_and_wait(sell_offer_tx,client,owner_wallet)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
reply=f"Submit failed: {e}"
return reply
def accept_sell_offer(seed, offer_index):
"""accept_sell_offer"""
buyer_wallet=Wallet(seed, sequence=16237283)
buyer_wallet=Wallet.from_seed(seed)
client=JsonRpcClient(testnet_url)
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
account=buyer_wallet.classic_address,
nftoken_sell_offer=offer_index
)
# Sign and fill the transaction
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
accept_offer_tx, buyer_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.submit_and_wait(accept_offer_tx,client,buyer_wallet)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
reply=f"Submit failed: {e}"
@@ -64,7 +57,7 @@ def accept_sell_offer(seed, offer_index):
def create_buy_offer(seed, amount, nft_id, owner, expiration, destination):
"""create_buy_offer"""
# Get the client
buyer_wallet=Wallet(seed, sequence=16237283)
buyer_wallet=Wallet.from_seed(seed)
client=JsonRpcClient(testnet_url)
expiration_date=datetime.now()
if (expiration!=''):
@@ -72,7 +65,7 @@ def create_buy_offer(seed, amount, nft_id, owner, expiration, destination):
expiration_date=expiration_date + int(expiration)
# Define the buy offer transaction with an expiration date
buy_offer_tx=xrpl.models.transactions.NFTokenCreateOffer(
account=buyer_wallet.classic_address,
account=buyer_wallet.address,
nftoken_id=nft_id,
amount=amount,
owner=owner,
@@ -80,13 +73,10 @@ def create_buy_offer(seed, amount, nft_id, owner, expiration, destination):
destination=destination if destination!='' else None,
flags=0
)
# Sign and fill the transaction
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
buy_offer_tx, buyer_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.submit_and_wait(buy_offer_tx,client,buyer_wallet)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
reply=f"Submit failed: {e}"
@@ -95,19 +85,16 @@ def create_buy_offer(seed, amount, nft_id, owner, expiration, destination):
def accept_buy_offer(seed, offer_index):
"""accept_buy_offer"""
buyer_wallet=Wallet(seed, sequence=16237283)
buyer_wallet=Wallet.from_seed(seed)
client=JsonRpcClient(testnet_url)
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
account=buyer_wallet.classic_address,
account=buyer_wallet.address,
nftoken_buy_offer=offer_index
)
# Sign and fill the transaction
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
accept_offer_tx, buyer_wallet, client)
# Submit the transaction and report the results
reply=""
try:
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.submit_and_wait(accept_offer_tx,client,buyer_wallet)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
reply=f"Submit failed: {e}"
@@ -130,19 +117,17 @@ def get_offers(nft_id):
def cancel_offer(seed, nftoken_offer_ids):
"""cancel_offer"""
owner_wallet=Wallet(seed, sequence=16237283)
owner_wallet=Wallet.from_seed(seed)
client=JsonRpcClient(testnet_url)
tokenOfferIDs=[nftoken_offer_ids]
nftSellOffers="No sell offers"
cancel_offer_tx=xrpl.models.transactions.NFTokenCancelOffer(
account=owner_wallet.classic_address,
nftoken_offers=tokenOfferIDs
)
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
cancel_offer_tx, owner_wallet, client)
)
reply=""
try:
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.submit_and_wait(cancel_offer_tx,client,owner_wallet)
reply=response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
reply=f"Submit failed: {e}"