From b206decf1b540b7a1526603aafc898ece26ab988 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 01:41:34 -0700 Subject: [PATCH 01/33] Create create_check.py --- content/_code-samples/checks/py/create_check.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 content/_code-samples/checks/py/create_check.py diff --git a/content/_code-samples/checks/py/create_check.py b/content/_code-samples/checks/py/create_check.py new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/content/_code-samples/checks/py/create_check.py @@ -0,0 +1 @@ + From a38a77d802e07e63bdbd402cf8a40673a226f345 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 01:52:08 -0700 Subject: [PATCH 02/33] Rename create_check.py to create_xrp_check.py --- .../checks/py/{create_check.py => create_xrp_check.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename content/_code-samples/checks/py/{create_check.py => create_xrp_check.py} (100%) diff --git a/content/_code-samples/checks/py/create_check.py b/content/_code-samples/checks/py/create_xrp_check.py similarity index 100% rename from content/_code-samples/checks/py/create_check.py rename to content/_code-samples/checks/py/create_xrp_check.py From a8fe19f43240722b69b011ab71f587b3f06de7a8 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 03:34:55 -0700 Subject: [PATCH 03/33] Create account_xrp_checks.py --- content/_code-samples/checks/py/account_xrp_checks.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 content/_code-samples/checks/py/account_xrp_checks.py diff --git a/content/_code-samples/checks/py/account_xrp_checks.py b/content/_code-samples/checks/py/account_xrp_checks.py new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/content/_code-samples/checks/py/account_xrp_checks.py @@ -0,0 +1 @@ + From 7209285bdc71a24b7a14fba14d82f2074489a861 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 03:36:38 -0700 Subject: [PATCH 04/33] Create cash_xrp_check.py --- content/_code-samples/checks/py/cash_xrp_check.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 content/_code-samples/checks/py/cash_xrp_check.py diff --git a/content/_code-samples/checks/py/cash_xrp_check.py b/content/_code-samples/checks/py/cash_xrp_check.py new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/content/_code-samples/checks/py/cash_xrp_check.py @@ -0,0 +1 @@ + From c77f3e09ab803ceb7d19b69cc47da1840b5a9864 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 03:37:17 -0700 Subject: [PATCH 05/33] Rename create_xrp_check.py to create_check.py --- .../checks/py/{create_xrp_check.py => create_check.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename content/_code-samples/checks/py/{create_xrp_check.py => create_check.py} (100%) diff --git a/content/_code-samples/checks/py/create_xrp_check.py b/content/_code-samples/checks/py/create_check.py similarity index 100% rename from content/_code-samples/checks/py/create_xrp_check.py rename to content/_code-samples/checks/py/create_check.py From 3a45b537daa52e66f0f5a1af4ce33166802eb94f Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 03:37:46 -0700 Subject: [PATCH 06/33] Rename cash_xrp_check.py to cash_check.py --- .../_code-samples/checks/py/{cash_xrp_check.py => cash_check.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename content/_code-samples/checks/py/{cash_xrp_check.py => cash_check.py} (100%) diff --git a/content/_code-samples/checks/py/cash_xrp_check.py b/content/_code-samples/checks/py/cash_check.py similarity index 100% rename from content/_code-samples/checks/py/cash_xrp_check.py rename to content/_code-samples/checks/py/cash_check.py From 75a8b146a7f0cb46a2372df5128578e27c92a89a Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 03:38:06 -0700 Subject: [PATCH 07/33] Rename account_xrp_checks.py to account_checks.py --- .../checks/py/{account_xrp_checks.py => account_checks.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename content/_code-samples/checks/py/{account_xrp_checks.py => account_checks.py} (100%) diff --git a/content/_code-samples/checks/py/account_xrp_checks.py b/content/_code-samples/checks/py/account_checks.py similarity index 100% rename from content/_code-samples/checks/py/account_xrp_checks.py rename to content/_code-samples/checks/py/account_checks.py From b33c8e915499d4cc5bcd964f798303e1a4a47cd0 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:05:27 -0700 Subject: [PATCH 08/33] Update and rename cash_check.py to create_xrp_check.py --- content/_code-samples/checks/py/cash_check.py | 1 - .../checks/py/create_xrp_check.py | 37 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) delete mode 100644 content/_code-samples/checks/py/cash_check.py create mode 100644 content/_code-samples/checks/py/create_xrp_check.py diff --git a/content/_code-samples/checks/py/cash_check.py b/content/_code-samples/checks/py/cash_check.py deleted file mode 100644 index 8b13789179..0000000000 --- a/content/_code-samples/checks/py/cash_check.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/content/_code-samples/checks/py/create_xrp_check.py b/content/_code-samples/checks/py/create_xrp_check.py new file mode 100644 index 0000000000..d7961051b9 --- /dev/null +++ b/content/_code-samples/checks/py/create_xrp_check.py @@ -0,0 +1,37 @@ +client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork + +"""Create xrp check""" + +# check sender seed +sender_seed = "sxxxxxxxxxxxxxxxxxxxx" + +# check receiver address +receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# amount of xrp to deliver +amount = 10.00 + +# check expiry date +expiry_date = int # from xrpl.utils import datetime_to_ripple_time() + +# generate wallet from seed +sender_wallet = Wallet(seed=sender_seed, sequence=0) + +# build check create transaction +check_txn = CheckCreate(account=sender_wallet.classic_address, + destination=receiver_addr, + send_max=xrp_to_drops(amount), + expiration=expiry_date) + +# 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) + +# parse response for result +stxn_result = stxn_response.result + +# print result and transaction hash +print(stxn_result["meta"]["TransactionResult"]) +print(stxn_result["hash"]) From 364cf56b463b3c20fe70c9e12a2ea77b5516934b Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:08:17 -0700 Subject: [PATCH 09/33] Update and rename create_check.py to create_token_check.py --- .../_code-samples/checks/py/create_check.py | 1 - .../checks/py/create_token_check.py | 69 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) delete mode 100644 content/_code-samples/checks/py/create_check.py create mode 100644 content/_code-samples/checks/py/create_token_check.py diff --git a/content/_code-samples/checks/py/create_check.py b/content/_code-samples/checks/py/create_check.py deleted file mode 100644 index 8b13789179..0000000000 --- a/content/_code-samples/checks/py/create_check.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/content/_code-samples/checks/py/create_token_check.py b/content/_code-samples/checks/py/create_token_check.py new file mode 100644 index 0000000000..0b0c2c7d61 --- /dev/null +++ b/content/_code-samples/checks/py/create_token_check.py @@ -0,0 +1,69 @@ +from xrpl.wallet import Wallet +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.utils import ripple_time_to_datetime + +client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork + +"""Create a token check""" + +"""Helper methods for working with token names""" + +def symbol_to_hex(symbol: str = None) -> str: + """token symbol_to_hex.""" + if len(symbol) > 3: + bytes_string = bytes(str(symbol).encode('utf-8')) + return bytes_string.hex().upper().ljust(40, '0') + return symbol + +def hex_to_symbol(hex: str = None) -> str: + """token hex_to_symbol.""" + if len(hex) > 3: + bytes_string = bytes.fromhex(str(hex)).decode('utf-8') + return bytes_string.rstrip('\x00') + return hex + + +# check sender seed +sender_seed = "sxxxxxxxxxxxxxxxxxxxx" + +# check receiver address +receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# token name +token = "LegitXRP" + +# amount of token to deliver +amount = 10.00 + +# token issuer address +issuer = "rxxxxxxxxxxxxxxxxxxxxxxxx" + +# check expiry date +expiry_date = int # from xrpl.utils import datetime_to_ripple_time() + +# generate wallet from seed +sender_wallet = Wallet(seed=sender_seed, sequence=0) + +# build check create transaction +check_txn = CheckCreate(account=sender_wallet.classic_address, destination=receiver_addr, +send_max=IssuedCurrencyAmount( + currency=symbol_to_hex(token), + issuer=issuer, + value=amount), + expiration=expiry_date) + +# 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) + +# parse response for result +stxn_result = stxn_response.result + +# print result and transaction hash +print(stxn_result["meta"]["TransactionResult"]) +print(stxn_result["hash"]) From 26a5b640d7d24e929fee07bc77a825359c3664ee Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:09:28 -0700 Subject: [PATCH 10/33] Update create_token_check.py --- content/_code-samples/checks/py/create_token_check.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/content/_code-samples/checks/py/create_token_check.py b/content/_code-samples/checks/py/create_token_check.py index 0b0c2c7d61..06387f96de 100644 --- a/content/_code-samples/checks/py/create_token_check.py +++ b/content/_code-samples/checks/py/create_token_check.py @@ -18,13 +18,6 @@ def symbol_to_hex(symbol: str = None) -> str: return bytes_string.hex().upper().ljust(40, '0') return symbol -def hex_to_symbol(hex: str = None) -> str: - """token hex_to_symbol.""" - if len(hex) > 3: - bytes_string = bytes.fromhex(str(hex)).decode('utf-8') - return bytes_string.rstrip('\x00') - return hex - # check sender seed sender_seed = "sxxxxxxxxxxxxxxxxxxxx" From bcf26dbb9bb077dca10044bab1027f7800c7957a Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:10:37 -0700 Subject: [PATCH 11/33] Delete create_xrp_check.py --- .../checks/py/create_xrp_check.py | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 content/_code-samples/checks/py/create_xrp_check.py diff --git a/content/_code-samples/checks/py/create_xrp_check.py b/content/_code-samples/checks/py/create_xrp_check.py deleted file mode 100644 index d7961051b9..0000000000 --- a/content/_code-samples/checks/py/create_xrp_check.py +++ /dev/null @@ -1,37 +0,0 @@ -client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork - -"""Create xrp check""" - -# check sender seed -sender_seed = "sxxxxxxxxxxxxxxxxxxxx" - -# check receiver address -receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxxxxx" - -# amount of xrp to deliver -amount = 10.00 - -# check expiry date -expiry_date = int # from xrpl.utils import datetime_to_ripple_time() - -# generate wallet from seed -sender_wallet = Wallet(seed=sender_seed, sequence=0) - -# build check create transaction -check_txn = CheckCreate(account=sender_wallet.classic_address, - destination=receiver_addr, - send_max=xrp_to_drops(amount), - expiration=expiry_date) - -# 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) - -# parse response for result -stxn_result = stxn_response.result - -# print result and transaction hash -print(stxn_result["meta"]["TransactionResult"]) -print(stxn_result["hash"]) From 47844c01d2ff7ae38028e2f18dcc586f3ad3c385 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:11:48 -0700 Subject: [PATCH 12/33] Update and rename create_token_check.py to create_checks.py --- ...create_token_check.py => create_checks.py} | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) rename content/_code-samples/checks/py/{create_token_check.py => create_checks.py} (63%) diff --git a/content/_code-samples/checks/py/create_token_check.py b/content/_code-samples/checks/py/create_checks.py similarity index 63% rename from content/_code-samples/checks/py/create_token_check.py rename to content/_code-samples/checks/py/create_checks.py index 06387f96de..6459ac8522 100644 --- a/content/_code-samples/checks/py/create_token_check.py +++ b/content/_code-samples/checks/py/create_checks.py @@ -10,7 +10,6 @@ client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the """Create a token check""" """Helper methods for working with token names""" - def symbol_to_hex(symbol: str = None) -> str: """token symbol_to_hex.""" if len(symbol) > 3: @@ -18,7 +17,6 @@ def symbol_to_hex(symbol: str = None) -> str: return bytes_string.hex().upper().ljust(40, '0') return symbol - # check sender seed sender_seed = "sxxxxxxxxxxxxxxxxxxxx" @@ -60,3 +58,43 @@ stxn_result = stxn_response.result # print result and transaction hash print(stxn_result["meta"]["TransactionResult"]) print(stxn_result["hash"]) + + + + +############ CREATE XRP CHECK ################################ +"""Create xrp check""" + +# check sender seed +sender_seed = "sxxxxxxxxxxxxxxxxxxxx" + +# check receiver address +receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# amount of xrp to deliver +amount = 10.00 + +# check expiry date +expiry_date = int # from xrpl.utils import datetime_to_ripple_time() + +# generate wallet from seed +sender_wallet = Wallet(seed=sender_seed, sequence=0) + +# build check create transaction +check_txn = CheckCreate(account=sender_wallet.classic_address, + destination=receiver_addr, + send_max=xrp_to_drops(amount), + expiration=expiry_date) + +# 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) + +# parse response for result +stxn_result = stxn_response.result + +# print result and transaction hash +print(stxn_result["meta"]["TransactionResult"]) +print(stxn_result["hash"]) From b1fcf9becf6f7ee9a14b7762ac174ae258a09ad3 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:20:48 -0700 Subject: [PATCH 13/33] Create cash_check.py --- content/_code-samples/checks/py/cash_check.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 content/_code-samples/checks/py/cash_check.py diff --git a/content/_code-samples/checks/py/cash_check.py b/content/_code-samples/checks/py/cash_check.py new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/content/_code-samples/checks/py/cash_check.py @@ -0,0 +1 @@ + From 9e53576fba93acc28bee6bcd9706de5e01690311 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:45:34 -0700 Subject: [PATCH 14/33] Update cash_check.py --- content/_code-samples/checks/py/cash_check.py | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/content/_code-samples/checks/py/cash_check.py b/content/_code-samples/checks/py/cash_check.py index 8b13789179..1579d0cec9 100644 --- a/content/_code-samples/checks/py/cash_check.py +++ b/content/_code-samples/checks/py/cash_check.py @@ -1 +1,80 @@ +from xrpl.transaction import (safe_sign_and_autofill_transaction, + send_reliable_submission) +from xrpl.utils import xrp_to_drops +from xrpl.wallet import Wallet +from xrpl.clients import JsonRpcClient +from xrpl.models import CheckCreate, IssuedCurrencyAmount + +client = JsonRpcClient("https://s.altnet.rippletest.net:51234") + + +# cash an xrp check + +# check casher seed +sender_seed = "sxxxxxxxxxxxxxxxxxxxxx" + +# check id +check_id = str + +# amount to cash +amount = 10.00 + +# generate wallet from seed +sender_wallet = Wallet(seed=sender_seed, sequence=0) + +# 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) + +# submit transaction and wait for result +stxn_response = send_reliable_submission(stxn, client) + +# parse response for result +stxn_result = stxn_response.result + +# print result and transaction hash +print(stxn_result["meta"]["TransactionResult"]) +print(stxn_result["hash"]) + + + +#################### cash token check ############################# + +# cash token check + +# check casher seed +sender_seed = "sxxxxxxxxxxxxxxxxxxxxx" + +# token name +token = "LegitXRP" + +# amount of token to deliver +amount = 10.00 + +# token issuer address +issuer = "rxxxxxxxxxxxxxxxxxxxxxxxx" + +# create wallet object +sender_wallet = Wallet(seed=sender_seed, sequence=0) + +# build check cash transaction +check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=IssuedCurrencyAmount( + currency=token, + 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) + +# parse response for result +stxn_result = stxn_response.result + +# print result and transaction hash +print(stxn_result["meta"]["TransactionResult"]) +print(stxn_result["hash"]) From 44f4a967ba6e71288e1bbd96bf8d3d71625a9909 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:55:52 -0700 Subject: [PATCH 15/33] Create cancel_check.py --- .../_code-samples/checks/py/cancel_check.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 content/_code-samples/checks/py/cancel_check.py diff --git a/content/_code-samples/checks/py/cancel_check.py b/content/_code-samples/checks/py/cancel_check.py new file mode 100644 index 0000000000..f5770a8298 --- /dev/null +++ b/content/_code-samples/checks/py/cancel_check.py @@ -0,0 +1,37 @@ +from xrpl.wallet import Wallet +from xrpl.clients import JsonRpcClient +from xrpl.models import CheckCancel +from xrpl.transaction import (safe_sign_and_autofill_transaction, + send_reliable_submission) + +client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork + + +"""cancel a check""" +# sender is the check creator or recipient +# If the Check has expired, any address can cancel it + +# check casher seed +sender_seed = "sxxxxxxxxxxxxxxxxxxxxx" + +# check id +check_id = str + +# create wallet object +sender_wallet = Wallet(seed=sender_seed, sequence=0) + +# build check cancel transaction +check_txn = CheckCancel(account=sender_wallet.classic_address, check_id=check_id) + +# 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) + +# parse response for result +stxn_result = stxn_response.result + +# print result and transaction hash +print(stxn_result["meta"]["TransactionResult"]) +print(stxn_result["hash"]) From 28a2705175f7789d69f052173b94fea65c9b714d Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:58:20 -0700 Subject: [PATCH 16/33] Update create_checks.py --- content/_code-samples/checks/py/create_checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/_code-samples/checks/py/create_checks.py b/content/_code-samples/checks/py/create_checks.py index 6459ac8522..1699bd435e 100644 --- a/content/_code-samples/checks/py/create_checks.py +++ b/content/_code-samples/checks/py/create_checks.py @@ -3,7 +3,7 @@ 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.utils import ripple_time_to_datetime +from xrpl.utils import datetime_to_rippletime, xrp_to_drops client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork From dbd73bf8b80ef614b5c53468a5f2c19a98838a38 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 09:20:18 -0700 Subject: [PATCH 17/33] Update account_checks.py --- .../_code-samples/checks/py/account_checks.py | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/content/_code-samples/checks/py/account_checks.py b/content/_code-samples/checks/py/account_checks.py index 8b13789179..a3e53097c2 100644 --- a/content/_code-samples/checks/py/account_checks.py +++ b/content/_code-samples/checks/py/account_checks.py @@ -1 +1,111 @@ +from xrpl.clients import JsonRpcClient +from xrpl.models import AccountObjects +from xrpl.utils import drops_to_xrp, ripple_time_to_datetime +client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork + + + +"""Helper methods for working with token names""" + +def hex_to_symbol(hex: str = None) -> str: + """token hex_to_symbol.""" + if len(hex) > 3: + bytes_string = bytes.fromhex(str(hex)).decode('utf-8') + return bytes_string.rstrip('\x00') + return hex + + +# Query the ledger for all xrp checks an account has created or received + +# wallet address to query +wallet_addr = str + +# dict to store all the checks +checks_dict = {} + +# list of sent checks +sent = [] + +# list of received checks +receive = [] + +# build request +req = AccountObjects(account=wallet_addr, ledger_index="validated", type="check") + +# make request and return result +response = client.request(req) +result = response.result + +# parse result +if "account_objects" in result: + account_checks = result["account_objects"] + for check in account_checks: + if isinstance(check["SendMax"], str): + check_data = {} + check_data["sender"] = check["Account"] + check_data["receiver"] = check["Destination"] + if "Expiration" in check: + check_data["expiry_date"] = str(ripple_time_to_datetime(check["Expiration"])) + check_data["amount"] = str(drops_to_xrp(check["SendMax"])) + check_data["check_id"] = check["index"] + if check_data["sender"] == wallet_addr: + sent.append(check_data) + elif check_data["sender"] != wallet_addr: + receive.append(check_data) + +# sort checks +checks_dict["sent"] = sent +checks_dict["receive"] = receive +print(checks_dict) + + + +############################# Query for token checks ############################# + + + +# Query the ledger for all token checks an account has created or received + +# wallet address to query +wallet_addr = str + +# dict to store all the checks +checks_dict = {} + +# list of sent checks +sent = [] + +# list of received checks +receive = [] + +# build request +req = AccountObjects(account=wallet_addr, ledger_index="validated", type="check") + +# make request and return result +response = client.request(req) +result = response.result + +# parse result +if "account_objects" in result: + account_checks = result["account_objects"] + for check in account_checks: + if isinstance(check["SendMax"], dict): + check_data = {} + check_data["sender"] = check["Account"] + check_data["receiver"] = check["Destination"] + if "Expiration" in check: + check_data["expiry_date"] = str(ripple_time_to_datetime(check["Expiration"])) + check_data["token"] = hex_to_symbol(check["SendMax"]["currency"]) + check_data["issuer"] = check["SendMax"]["issuer"] + check_data["amount"] = check["SendMax"]["value"] + check_data["check_id"] = check["index"] + if check_data["sender"] == wallet_addr: + sent.append(check_data) + elif check_data["sender"] != wallet_addr: + receive.append(check_data) + +# sort checks +checks_dict["sent"] = sent +checks_dict["receive"] = receive +print(checks_dict) From b8d24b9ebe4f52e160cebb9ab362e7dc6ddf944b Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:03:35 -0700 Subject: [PATCH 18/33] Update cash_check.py --- content/_code-samples/checks/py/cash_check.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/content/_code-samples/checks/py/cash_check.py b/content/_code-samples/checks/py/cash_check.py index 1579d0cec9..89b5c959c6 100644 --- a/content/_code-samples/checks/py/cash_check.py +++ b/content/_code-samples/checks/py/cash_check.py @@ -1,19 +1,17 @@ from xrpl.transaction import (safe_sign_and_autofill_transaction, send_reliable_submission) from xrpl.utils import xrp_to_drops -from xrpl.wallet import Wallet +from xrpl.wallet import Wallet, generate_faucet_wallet from xrpl.clients import JsonRpcClient from xrpl.models import CheckCreate, IssuedCurrencyAmount +# create a client client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # cash an xrp check -# check casher seed -sender_seed = "sxxxxxxxxxxxxxxxxxxxxx" - # check id check_id = str @@ -21,7 +19,7 @@ check_id = str amount = 10.00 # generate wallet from seed -sender_wallet = Wallet(seed=sender_seed, sequence=0) +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)) @@ -45,9 +43,6 @@ print(stxn_result["hash"]) # cash token check -# check casher seed -sender_seed = "sxxxxxxxxxxxxxxxxxxxxx" - # token name token = "LegitXRP" @@ -58,7 +53,7 @@ amount = 10.00 issuer = "rxxxxxxxxxxxxxxxxxxxxxxxx" # create wallet object -sender_wallet = Wallet(seed=sender_seed, sequence=0) +sender_wallet = sender_wallet =generate_faucet_wallet(client=client) # build check cash transaction check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=IssuedCurrencyAmount( From 8ce19008a38e33c3a36259603be38b71081cf44c Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:07:21 -0700 Subject: [PATCH 19/33] Update create_checks.py --- content/_code-samples/checks/py/create_checks.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/content/_code-samples/checks/py/create_checks.py b/content/_code-samples/checks/py/create_checks.py index 1699bd435e..425843c657 100644 --- a/content/_code-samples/checks/py/create_checks.py +++ b/content/_code-samples/checks/py/create_checks.py @@ -1,4 +1,4 @@ -from xrpl.wallet import Wallet +from xrpl.wallet import Wallet, generate_faucet_wallet from xrpl.clients import JsonRpcClient from xrpl.models import CheckCreate, IssuedCurrencyAmount from xrpl.transaction import (safe_sign_and_autofill_transaction, @@ -17,11 +17,9 @@ def symbol_to_hex(symbol: str = None) -> str: return bytes_string.hex().upper().ljust(40, '0') return symbol -# check sender seed -sender_seed = "sxxxxxxxxxxxxxxxxxxxx" # check receiver address -receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxxxxx" +receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxx" # token name token = "LegitXRP" @@ -36,7 +34,7 @@ issuer = "rxxxxxxxxxxxxxxxxxxxxxxxx" expiry_date = int # from xrpl.utils import datetime_to_ripple_time() # generate wallet from seed -sender_wallet = Wallet(seed=sender_seed, sequence=0) +sender_wallet = generate_faucet_wallet(client=client) # build check create transaction check_txn = CheckCreate(account=sender_wallet.classic_address, destination=receiver_addr, @@ -62,14 +60,12 @@ print(stxn_result["hash"]) -############ CREATE XRP CHECK ################################ +############# CREATE XRP CHECK ################################ """Create xrp check""" -# check sender seed -sender_seed = "sxxxxxxxxxxxxxxxxxxxx" # check receiver address -receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxxxxx" +receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxxx" # amount of xrp to deliver amount = 10.00 @@ -78,7 +74,7 @@ amount = 10.00 expiry_date = int # from xrpl.utils import datetime_to_ripple_time() # generate wallet from seed -sender_wallet = Wallet(seed=sender_seed, sequence=0) +sender_wallet = generate_faucet_wallet(client=client) # build check create transaction check_txn = CheckCreate(account=sender_wallet.classic_address, From 5fdf8bb621ae480e4ab3eaf35ffb0e28df71cd73 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:08:58 -0700 Subject: [PATCH 20/33] =?UTF-8?q?I'm=20going=20through=20changesss=20?= =?UTF-8?q?=F0=9F=8E=B5=F0=9F=8E=B6=F0=9F=8E=B5=F0=9F=8E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/_code-samples/checks/py/cancel_check.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/content/_code-samples/checks/py/cancel_check.py b/content/_code-samples/checks/py/cancel_check.py index f5770a8298..45ba89c1c0 100644 --- a/content/_code-samples/checks/py/cancel_check.py +++ b/content/_code-samples/checks/py/cancel_check.py @@ -1,4 +1,4 @@ -from xrpl.wallet import Wallet +from xrpl.wallet import Wallet, generate_faucet_wallet from xrpl.clients import JsonRpcClient from xrpl.models import CheckCancel from xrpl.transaction import (safe_sign_and_autofill_transaction, @@ -11,14 +11,12 @@ client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the # sender is the check creator or recipient # If the Check has expired, any address can cancel it -# check casher seed -sender_seed = "sxxxxxxxxxxxxxxxxxxxxx" # check id check_id = str # create wallet object -sender_wallet = Wallet(seed=sender_seed, sequence=0) +sender_wallet = generate_faucet_wallet(client=client) # build check cancel transaction check_txn = CheckCancel(account=sender_wallet.classic_address, check_id=check_id) From 9808b95b2186668db735de652e3cf557f1807a8a Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:12:22 -0700 Subject: [PATCH 21/33] =?UTF-8?q?I'm=20going=20through=20changessss=20?= =?UTF-8?q?=F0=9F=8E=B6=F0=9F=8E=B5=F0=9F=8E=B5=F0=9F=8E=B6=F0=9F=8E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/_code-samples/checks/py/cancel_check.py | 1 + 1 file changed, 1 insertion(+) diff --git a/content/_code-samples/checks/py/cancel_check.py b/content/_code-samples/checks/py/cancel_check.py index 45ba89c1c0..d47fa5f8fd 100644 --- a/content/_code-samples/checks/py/cancel_check.py +++ b/content/_code-samples/checks/py/cancel_check.py @@ -33,3 +33,4 @@ stxn_result = stxn_response.result # print result and transaction hash print(stxn_result["meta"]["TransactionResult"]) print(stxn_result["hash"]) + From 9ff5421eca542c83e26186d876a65009451def7c Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:14:59 -0700 Subject: [PATCH 22/33] =?UTF-8?q?I'm=20going=20through=20changesss?= =?UTF-8?q?=F0=9F=8E=B5=F0=9F=8E=B6=F0=9F=8E=B6=F0=9F=8E=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/_code-samples/checks/py/cash_check.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/_code-samples/checks/py/cash_check.py b/content/_code-samples/checks/py/cash_check.py index 89b5c959c6..3cf8bc2254 100644 --- a/content/_code-samples/checks/py/cash_check.py +++ b/content/_code-samples/checks/py/cash_check.py @@ -18,8 +18,8 @@ check_id = str # amount to cash amount = 10.00 -# generate wallet from seed -sender_wallet =generate_faucet_wallet(client=client) +# generate wallet +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)) @@ -50,10 +50,10 @@ token = "LegitXRP" amount = 10.00 # token issuer address -issuer = "rxxxxxxxxxxxxxxxxxxxxxxxx" +issuer = generate_faucet_wallet(client=client).classic_address -# create wallet object -sender_wallet = sender_wallet =generate_faucet_wallet(client=client) +# create sender wallet object +sender_wallet = generate_faucet_wallet(client=client) # build check cash transaction check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=IssuedCurrencyAmount( From 6aeaba925fafd2a1f85d23ec70c9b22b59b4398e Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:18:46 -0700 Subject: [PATCH 23/33] Update and rename create_checks.py to create_check.py --- .../checks/py/{create_checks.py => create_check.py} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename content/_code-samples/checks/py/{create_checks.py => create_check.py} (92%) diff --git a/content/_code-samples/checks/py/create_checks.py b/content/_code-samples/checks/py/create_check.py similarity index 92% rename from content/_code-samples/checks/py/create_checks.py rename to content/_code-samples/checks/py/create_check.py index 425843c657..263978f59a 100644 --- a/content/_code-samples/checks/py/create_checks.py +++ b/content/_code-samples/checks/py/create_check.py @@ -19,7 +19,7 @@ def symbol_to_hex(symbol: str = None) -> str: # check receiver address -receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxx" +receiver_addr = generate_faucet_wallet(client=client).classic_address # token name token = "LegitXRP" @@ -28,7 +28,7 @@ token = "LegitXRP" amount = 10.00 # token issuer address -issuer = "rxxxxxxxxxxxxxxxxxxxxxxxx" +issuer = generate_faucet_wallet(client=client).classic_address # check expiry date expiry_date = int # from xrpl.utils import datetime_to_ripple_time() @@ -65,7 +65,7 @@ print(stxn_result["hash"]) # check receiver address -receiver_addr = "rxxxxxxxxxxxxxxxxxxxxxxxx" +receiver_addr = generate_faucet_wallet(client=client).classic_address # amount of xrp to deliver amount = 10.00 From ca1da63110e26279449c3fe53e0cb40d92994f68 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:19:30 -0700 Subject: [PATCH 24/33] there was a change --- content/_code-samples/checks/py/create_check.py | 1 - 1 file changed, 1 deletion(-) diff --git a/content/_code-samples/checks/py/create_check.py b/content/_code-samples/checks/py/create_check.py index 263978f59a..9342f4ba87 100644 --- a/content/_code-samples/checks/py/create_check.py +++ b/content/_code-samples/checks/py/create_check.py @@ -59,7 +59,6 @@ print(stxn_result["hash"]) - ############# CREATE XRP CHECK ################################ """Create xrp check""" From 81bd8a46e37b5428bc63054bb7712cfe9f76445f Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 21:31:35 -0700 Subject: [PATCH 25/33] Update create_check.py --- .../_code-samples/checks/py/create_check.py | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/content/_code-samples/checks/py/create_check.py b/content/_code-samples/checks/py/create_check.py index 9342f4ba87..2dbb04aece 100644 --- a/content/_code-samples/checks/py/create_check.py +++ b/content/_code-samples/checks/py/create_check.py @@ -1,25 +1,18 @@ -from xrpl.wallet import Wallet, generate_faucet_wallet +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.utils import datetime_to_rippletime, xrp_to_drops +from xrpl.utils import datetime_to_ripple_time, str_to_hex, xrp_to_drops +from xrpl.wallet import generate_faucet_wallet client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork """Create a token check""" -"""Helper methods for working with token names""" -def symbol_to_hex(symbol: str = None) -> str: - """token symbol_to_hex.""" - if len(symbol) > 3: - bytes_string = bytes(str(symbol).encode('utf-8')) - return bytes_string.hex().upper().ljust(40, '0') - return symbol - - # check receiver address -receiver_addr = generate_faucet_wallet(client=client).classic_address +receiver_addr = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Example: send back to Testnet Faucet # token name token = "LegitXRP" @@ -28,10 +21,12 @@ token = "LegitXRP" amount = 10.00 # token issuer address -issuer = generate_faucet_wallet(client=client).classic_address +issuer = "r9CEVt4Cmcjt68ME6GKyhf2DyEGo2rG8AW" # check expiry date -expiry_date = int # from xrpl.utils import datetime_to_ripple_time() +# check will expire after 5 days +expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5)) + # generate wallet from seed sender_wallet = generate_faucet_wallet(client=client) @@ -39,7 +34,7 @@ sender_wallet = generate_faucet_wallet(client=client) # build check create transaction check_txn = CheckCreate(account=sender_wallet.classic_address, destination=receiver_addr, send_max=IssuedCurrencyAmount( - currency=symbol_to_hex(token), + currency=str_to_hex(token), issuer=issuer, value=amount), expiration=expiry_date) @@ -70,7 +65,9 @@ receiver_addr = generate_faucet_wallet(client=client).classic_address amount = 10.00 # check expiry date -expiry_date = int # from xrpl.utils import datetime_to_ripple_time() +# check will expire after 5 days +expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5)) + # generate wallet from seed sender_wallet = generate_faucet_wallet(client=client) From 1bd0dbdcadadb0973c7ef10d73ab75db8589f570 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 21:40:12 -0700 Subject: [PATCH 26/33] Update account_checks.py --- .../_code-samples/checks/py/account_checks.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/content/_code-samples/checks/py/account_checks.py b/content/_code-samples/checks/py/account_checks.py index a3e53097c2..2a77db8f6e 100644 --- a/content/_code-samples/checks/py/account_checks.py +++ b/content/_code-samples/checks/py/account_checks.py @@ -1,25 +1,14 @@ from xrpl.clients import JsonRpcClient from xrpl.models import AccountObjects -from xrpl.utils import drops_to_xrp, ripple_time_to_datetime +from xrpl.utils import drops_to_xrp, hex_to_str, ripple_time_to_datetime client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork - -"""Helper methods for working with token names""" - -def hex_to_symbol(hex: str = None) -> str: - """token hex_to_symbol.""" - if len(hex) > 3: - bytes_string = bytes.fromhex(str(hex)).decode('utf-8') - return bytes_string.rstrip('\x00') - return hex - - # Query the ledger for all xrp checks an account has created or received # wallet address to query -wallet_addr = str +wallet_addr = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" # dict to store all the checks checks_dict = {} @@ -68,7 +57,7 @@ print(checks_dict) # Query the ledger for all token checks an account has created or received # wallet address to query -wallet_addr = str +wallet_addr = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" # dict to store all the checks checks_dict = {} @@ -96,7 +85,7 @@ if "account_objects" in result: check_data["receiver"] = check["Destination"] if "Expiration" in check: check_data["expiry_date"] = str(ripple_time_to_datetime(check["Expiration"])) - check_data["token"] = hex_to_symbol(check["SendMax"]["currency"]) + check_data["token"] = hex_to_str(check["SendMax"]["currency"]) check_data["issuer"] = check["SendMax"]["issuer"] check_data["amount"] = check["SendMax"]["value"] check_data["check_id"] = check["index"] From d1d5073bc54fa4145b49cdfadfcecabbc0bdfa83 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Wed, 7 Sep 2022 11:12:18 -0700 Subject: [PATCH 27/33] Update cash_check.py --- content/_code-samples/checks/py/cash_check.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/content/_code-samples/checks/py/cash_check.py b/content/_code-samples/checks/py/cash_check.py index 3cf8bc2254..915b87aa96 100644 --- a/content/_code-samples/checks/py/cash_check.py +++ b/content/_code-samples/checks/py/cash_check.py @@ -1,10 +1,9 @@ +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.utils import xrp_to_drops -from xrpl.wallet import Wallet, generate_faucet_wallet - -from xrpl.clients import JsonRpcClient -from xrpl.models import CheckCreate, IssuedCurrencyAmount +from xrpl.utils import str_to_hex, xrp_to_drops +from xrpl.wallet import generate_faucet_wallet # create a client client = JsonRpcClient("https://s.altnet.rippletest.net:51234") @@ -13,7 +12,7 @@ client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # cash an xrp check # check id -check_id = str +check_id = "F944CB379DEE18EFDA7A58A4F81AF1A98C46E54A8B9F2D268F1E26610BC0EB03" # amount to cash amount = 10.00 @@ -57,7 +56,7 @@ sender_wallet = generate_faucet_wallet(client=client) # build check cash transaction check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=IssuedCurrencyAmount( - currency=token, + currency=str_to_hex(token), issuer=issuer, value=amount)) From 76d1076cd2b9177fd39033dfb7f9fe64b57b5c59 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:14:47 -0700 Subject: [PATCH 28/33] Update account_checks.py --- content/_code-samples/checks/py/account_checks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/_code-samples/checks/py/account_checks.py b/content/_code-samples/checks/py/account_checks.py index 2a77db8f6e..cdfc3aadd7 100644 --- a/content/_code-samples/checks/py/account_checks.py +++ b/content/_code-samples/checks/py/account_checks.py @@ -7,8 +7,8 @@ client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the # Query the ledger for all xrp checks an account has created or received -# wallet address to query -wallet_addr = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" + +wallet_addr_to_query = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" # dict to store all the checks checks_dict = {} @@ -56,8 +56,8 @@ print(checks_dict) # Query the ledger for all token checks an account has created or received -# wallet address to query -wallet_addr = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" + +wallet_addr_to_query = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" # dict to store all the checks checks_dict = {} From 00b2ff0b1bfbb2017237c476fe98be3777881c79 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:16:18 -0700 Subject: [PATCH 29/33] Update account_checks.py --- .../_code-samples/checks/py/account_checks.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/content/_code-samples/checks/py/account_checks.py b/content/_code-samples/checks/py/account_checks.py index cdfc3aadd7..e629128ee7 100644 --- a/content/_code-samples/checks/py/account_checks.py +++ b/content/_code-samples/checks/py/account_checks.py @@ -2,7 +2,7 @@ from xrpl.clients import JsonRpcClient from xrpl.models import AccountObjects from xrpl.utils import drops_to_xrp, hex_to_str, ripple_time_to_datetime -client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork +client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork # Query the ledger for all xrp checks an account has created or received @@ -10,23 +10,23 @@ client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the wallet_addr_to_query = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" -# dict to store all the checks +# Dict to store all the checks checks_dict = {} -# list of sent checks +# List of sent checks sent = [] -# list of received checks +# List of received checks receive = [] -# build request +# Build request req = AccountObjects(account=wallet_addr, ledger_index="validated", type="check") -# make request and return result +# Make request and return result response = client.request(req) result = response.result -# parse result +# Parse result if "account_objects" in result: account_checks = result["account_objects"] for check in account_checks: @@ -43,7 +43,7 @@ if "account_objects" in result: elif check_data["sender"] != wallet_addr: receive.append(check_data) -# sort checks +# Sort checks checks_dict["sent"] = sent checks_dict["receive"] = receive print(checks_dict) @@ -59,23 +59,23 @@ print(checks_dict) wallet_addr_to_query = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" -# dict to store all the checks +# Dict to store all the checks checks_dict = {} -# list of sent checks +# List of sent checks sent = [] -# list of received checks +# List of received checks receive = [] -# build request +# Build request req = AccountObjects(account=wallet_addr, ledger_index="validated", type="check") -# make request and return result +# Make request and return result response = client.request(req) result = response.result -# parse result +# Parse result if "account_objects" in result: account_checks = result["account_objects"] for check in account_checks: @@ -94,7 +94,7 @@ if "account_objects" in result: elif check_data["sender"] != wallet_addr: receive.append(check_data) -# sort checks +# Sort checks checks_dict["sent"] = sent checks_dict["receive"] = receive print(checks_dict) From 810047bb821745128534e587dd29d56857c9739e Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:21:41 -0700 Subject: [PATCH 30/33] Update cancel_check.py --- .../_code-samples/checks/py/cancel_check.py | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/content/_code-samples/checks/py/cancel_check.py b/content/_code-samples/checks/py/cancel_check.py index d47fa5f8fd..b0a4cfc071 100644 --- a/content/_code-samples/checks/py/cancel_check.py +++ b/content/_code-samples/checks/py/cancel_check.py @@ -4,33 +4,29 @@ from xrpl.models import CheckCancel from xrpl.transaction import (safe_sign_and_autofill_transaction, send_reliable_submission) -client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork +client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork - -"""cancel a check""" -# sender is the check creator or recipient +"""Cancel a check""" +# Sender is the check creator or recipient # If the Check has expired, any address can cancel it +# Check id +check_id = "F944CB379DEE18EFDA7A58A4F81AF1A98C46E54A8B9F2D268F1E26610BC0EB03" -# check id -check_id = str - -# create wallet object +# Create wallet object sender_wallet = generate_faucet_wallet(client=client) -# build check cancel transaction +# Build check cancel transaction check_txn = CheckCancel(account=sender_wallet.classic_address, check_id=check_id) -# sign transaction +# Sign and submit 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) -# parse response for result +# Parse response for result stxn_result = stxn_response.result -# print result and transaction hash +# Print result and transaction hash print(stxn_result["meta"]["TransactionResult"]) print(stxn_result["hash"]) From b21677b2e671eee5e42a7390d14785d384bf8a96 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:30:19 -0700 Subject: [PATCH 31/33] Update cash_check.py --- content/_code-samples/checks/py/cash_check.py | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/content/_code-samples/checks/py/cash_check.py b/content/_code-samples/checks/py/cash_check.py index 915b87aa96..eb6e1e2f06 100644 --- a/content/_code-samples/checks/py/cash_check.py +++ b/content/_code-samples/checks/py/cash_check.py @@ -5,34 +5,34 @@ from xrpl.transaction import (safe_sign_and_autofill_transaction, from xrpl.utils import str_to_hex, xrp_to_drops from xrpl.wallet import generate_faucet_wallet -# create a client +# Connect to a network client = JsonRpcClient("https://s.altnet.rippletest.net:51234") -# cash an xrp check +# Cash an xrp check -# check id +# Check id check_id = "F944CB379DEE18EFDA7A58A4F81AF1A98C46E54A8B9F2D268F1E26610BC0EB03" -# amount to cash +# Amount to cash amount = 10.00 -# generate wallet +# Generate wallet sender_wallet = generate_faucet_wallet(client=client) -# build check cash transaction +# Build check cash transaction check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=xrp_to_drops(amount)) -# sign transaction +# Sign transaction stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client) -# submit transaction and wait for result +# Submit transaction and wait for result stxn_response = send_reliable_submission(stxn, client) -# parse response for result +# Parse response for result stxn_result = stxn_response.result -# print result and transaction hash +# Print result and transaction hash print(stxn_result["meta"]["TransactionResult"]) print(stxn_result["hash"]) @@ -40,35 +40,35 @@ print(stxn_result["hash"]) #################### cash token check ############################# -# cash token check +# Cash token check -# token name -token = "LegitXRP" +# Token name +token = "USD" -# amount of token to deliver +# Amount of token to deliver amount = 10.00 -# token issuer address +# Token issuer address issuer = generate_faucet_wallet(client=client).classic_address -# create sender wallet object +# Create sender wallet object sender_wallet = generate_faucet_wallet(client=client) -# build check cash transaction +# Build check cash transaction check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=IssuedCurrencyAmount( currency=str_to_hex(token), issuer=issuer, value=amount)) -# sign transaction +# Sign transaction stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client) -# submit transaction and wait for result +# Submit transaction and wait for result stxn_response = send_reliable_submission(stxn, client) -# parse response for result +# Parse response for result stxn_result = stxn_response.result -# print result and transaction hash +# Print result and transaction hash print(stxn_result["meta"]["TransactionResult"]) print(stxn_result["hash"]) From 1cf39391bece3e6be974994a6721b734153025ad Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:37:01 -0700 Subject: [PATCH 32/33] Update create_check.py --- .../_code-samples/checks/py/create_check.py | 54 +++++++------------ 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/content/_code-samples/checks/py/create_check.py b/content/_code-samples/checks/py/create_check.py index 2dbb04aece..274ef294f0 100644 --- a/content/_code-samples/checks/py/create_check.py +++ b/content/_code-samples/checks/py/create_check.py @@ -7,31 +7,25 @@ from xrpl.transaction import (safe_sign_and_autofill_transaction, from xrpl.utils import datetime_to_ripple_time, str_to_hex, xrp_to_drops from xrpl.wallet import generate_faucet_wallet -client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork +client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork """Create a token check""" -# check receiver address -receiver_addr = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Example: send back to Testnet Faucet +check_receiver_addr = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Example: send back to Testnet Faucet -# token name -token = "LegitXRP" +token_name = "USD" -# amount of token to deliver -amount = 10.00 +amount_to_deliver = 10.00 -# token issuer address -issuer = "r9CEVt4Cmcjt68ME6GKyhf2DyEGo2rG8AW" +token_issuer = "r9CEVt4Cmcjt68ME6GKyhf2DyEGo2rG8AW" -# check expiry date -# check will expire after 5 days +# Set check to expire after 5 days expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5)) - -# generate wallet from seed +# Generate wallet sender_wallet = generate_faucet_wallet(client=client) -# build check create transaction +# Build check create transaction check_txn = CheckCreate(account=sender_wallet.classic_address, destination=receiver_addr, send_max=IssuedCurrencyAmount( currency=str_to_hex(token), @@ -39,54 +33,46 @@ send_max=IssuedCurrencyAmount( value=amount), expiration=expiry_date) -# sign transaction +# Sign, submit transaction and wait for result stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client) - -# submit transaction and wait for result stxn_response = send_reliable_submission(stxn, client) -# parse response for result +# Parse response for result stxn_result = stxn_response.result -# print result and transaction hash +# Print result and transaction hash print(stxn_result["meta"]["TransactionResult"]) print(stxn_result["hash"]) - -############# CREATE XRP CHECK ################################ +############### CREATE XRP CHECK ################################ """Create xrp check""" -# check receiver address -receiver_addr = generate_faucet_wallet(client=client).classic_address +check_receiver_addr = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Example: send back to Testnet Faucet -# amount of xrp to deliver -amount = 10.00 +amount_to_deliver = 10.00 -# check expiry date -# check will expire after 5 days +# Set check to expire after 5 days expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5)) -# generate wallet from seed +# Generate wallet sender_wallet = generate_faucet_wallet(client=client) -# build check create transaction +# Build check create transaction check_txn = CheckCreate(account=sender_wallet.classic_address, destination=receiver_addr, send_max=xrp_to_drops(amount), expiration=expiry_date) -# sign transaction +# Sign, submit transaction and wait for result stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client) - -# submit transaction and wait for result stxn_response = send_reliable_submission(stxn, client) -# parse response for result +# Parse response for result stxn_result = stxn_response.result -# print result and transaction hash +# Print result and transaction hash print(stxn_result["meta"]["TransactionResult"]) print(stxn_result["hash"]) From 518c68f4e9a643be3acdf3f2729072ea37b73089 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:38:21 -0700 Subject: [PATCH 33/33] Update account_checks.py --- content/_code-samples/checks/py/account_checks.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/content/_code-samples/checks/py/account_checks.py b/content/_code-samples/checks/py/account_checks.py index e629128ee7..3e29cced3e 100644 --- a/content/_code-samples/checks/py/account_checks.py +++ b/content/_code-samples/checks/py/account_checks.py @@ -10,14 +10,11 @@ client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the wallet_addr_to_query = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" -# Dict to store all the checks checks_dict = {} -# List of sent checks -sent = [] +sent_checks = [] -# List of received checks -receive = [] +received_checks = [] # Build request req = AccountObjects(account=wallet_addr, ledger_index="validated", type="check") @@ -59,14 +56,11 @@ print(checks_dict) wallet_addr_to_query = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" -# Dict to store all the checks checks_dict = {} -# List of sent checks -sent = [] +sent_dict = [] -# List of received checks -receive = [] +received_dict = [] # Build request req = AccountObjects(account=wallet_addr, ledger_index="validated", type="check")