From fe6c399669cc0f01b9c8a5a2fb65cb096b7f0e79 Mon Sep 17 00:00:00 2001 From: LimpidCrypto Date: Fri, 27 Oct 2023 17:13:23 +0200 Subject: [PATCH 01/58] add ledger objects --- tests/unit/models/test_ledger_object.py | 634 ++++++++++++++++++ xrpl/models/ledger_objects/__init__.py | 91 +++ xrpl/models/ledger_objects/account_root.py | 86 +++ xrpl/models/ledger_objects/amendments.py | 50 ++ xrpl/models/ledger_objects/check.py | 61 ++ xrpl/models/ledger_objects/deposit_preauth.py | 46 ++ xrpl/models/ledger_objects/directory_node.py | 56 ++ xrpl/models/ledger_objects/escrow.py | 59 ++ xrpl/models/ledger_objects/fee_settings.py | 43 ++ .../ledger_objects/ledger_entry_type.py | 24 + xrpl/models/ledger_objects/ledger_hashes.py | 42 ++ xrpl/models/ledger_objects/ledger_object.py | 137 ++++ xrpl/models/ledger_objects/negative_unl.py | 49 ++ xrpl/models/ledger_objects/nftoken_offer.py | 69 ++ xrpl/models/ledger_objects/nftoken_page.py | 46 ++ xrpl/models/ledger_objects/offer.py | 63 ++ xrpl/models/ledger_objects/pay_channel.py | 64 ++ xrpl/models/ledger_objects/ripple_state.py | 71 ++ xrpl/models/ledger_objects/signer_list.py | 54 ++ xrpl/models/ledger_objects/ticket.py | 46 ++ 20 files changed, 1791 insertions(+) create mode 100644 tests/unit/models/test_ledger_object.py create mode 100644 xrpl/models/ledger_objects/__init__.py create mode 100644 xrpl/models/ledger_objects/account_root.py create mode 100644 xrpl/models/ledger_objects/amendments.py create mode 100644 xrpl/models/ledger_objects/check.py create mode 100644 xrpl/models/ledger_objects/deposit_preauth.py create mode 100644 xrpl/models/ledger_objects/directory_node.py create mode 100644 xrpl/models/ledger_objects/escrow.py create mode 100644 xrpl/models/ledger_objects/fee_settings.py create mode 100644 xrpl/models/ledger_objects/ledger_entry_type.py create mode 100644 xrpl/models/ledger_objects/ledger_hashes.py create mode 100644 xrpl/models/ledger_objects/ledger_object.py create mode 100644 xrpl/models/ledger_objects/negative_unl.py create mode 100644 xrpl/models/ledger_objects/nftoken_offer.py create mode 100644 xrpl/models/ledger_objects/nftoken_page.py create mode 100644 xrpl/models/ledger_objects/offer.py create mode 100644 xrpl/models/ledger_objects/pay_channel.py create mode 100644 xrpl/models/ledger_objects/ripple_state.py create mode 100644 xrpl/models/ledger_objects/signer_list.py create mode 100644 xrpl/models/ledger_objects/ticket.py diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py new file mode 100644 index 000000000..b2983f91b --- /dev/null +++ b/tests/unit/models/test_ledger_object.py @@ -0,0 +1,634 @@ +from unittest import TestCase + +from xrpl.models import IssuedCurrencyAmount +from xrpl.models.ledger_objects import ( # NFTokenOffer, + AccountRoot, + Amendments, + Check, + DepositPreauth, + DirectoryNode, + DisabledValidator, + Escrow, + FeeSettings, + LedgerHashes, + Majority, + NegativeUNL, + NFToken, + NFTokenPage, + Offer, + PayChannel, + RippleState, + SignerEntry, + SignerList, + Ticket, +) + +account_root_json = { + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "account_txn_id": "0D5FB50FA65C9FE1538FD7E398FFFE9D190" + "8DFA4576D8D7A020040686F93C77D", + "balance": "148446663", + "domain": "6D64756F31332E636F6D", + "email_hash": "98B4375E1D753E5B91627516F6D70977", + "flags": 8388608, + "ledger_entry_type": "AccountRoot", + "message_key": "0000000000000000000000070000000300", + "owner_count": 3, + "nftoken_minter": "rHello", + "previous_txn_id": "0D5FB50FA65C9FE1538FD7E398FFFE9D1908DFA4576D8D7A0200" + "40686F93C77D", + "previous_txn_lgr_seq": 14091160, + "sequence": 336, + "transfer_rate": 1004999999, + "index": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", +} + +amendment_json = { + "majorities": [ + { + "majority": { + "amendment": "1562511F573A19AE9BD103B5D6B9E01B3B46805AEC5D3C4805C902B51" + "4399146", + "close_time": 535589001, + } + } + ], + "amendments": [ + "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE", + "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373", + "6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC", + "740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D628A06927F11", + ], + "flags": 0, + "ledger_entry_type": "Amendments", + "index": "7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", +} + +check_json = { + "account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + "destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + "destination_node": "0000000000000000", + "destination_tag": 1, + "expiration": 570113521, + "flags": 0, + "invoice_id": "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291", + "ledger_entry_type": "Check", + "owner_node": "0000000000000000", + "previous_txn_id": "5463C6E08862A1FAE5EDAC12D70ADB16546A1F67" + "4930521295BC082494B62924", + "previous_txn_lgr_seq": 6, + "send_max": "100000000", + "sequence": 2, + "index": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", +} + +deposit_preauth_json = { + "ledger_entry_type": "DepositPreauth", + "account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", + "authorize": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + "flags": 0, + "owner_node": "0000000000000000", + "previous_txn_id": "3E8964D5A86B3CD6B9ECB33310D4E073D64C865A5B866200" + "AD2B7E29F8326702", + "previous_txn_lgr_seq": 7, + "index": "4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", +} + +directory_node_json = { + "exchange_rate": "4F069BA8FF484000", + "flags": 0, + "indexes": ["AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD"], + "ledger_entry_type": "DirectoryNode", + "root_index": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", + "taker_gets_currency": "0000000000000000000000000000000000000000", + "taker_gets_issuer": "0000000000000000000000000000000000000000", + "taker_pays_currency": "0000000000000000000000004A50590000000000", + "taker_pays_issuer": "5BBC0F22F61D9224A110650CFE21CC0C4BE13098", + "index": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", +} + +escrow_json = { + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "amount": "10000", + "cancel_after": 545440232, + "condition": "A0258020A82A88B2DF843A54F58772E4A3861866ECDB4157645DD9AE528C1D3AEEDAB" + "AB6810120", + "destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + "destination_tag": 23480, + "finish_after": 545354132, + "flags": 0, + "ledger_entry_type": "Escrow", + "owner_node": "0000000000000000", + "destination_node": "0000000000000000", + "previous_txn_id": "C44F2EB84196B9AD820313DBEBA6316A15C9A2" + "D35787579ED172B87A30131DA7", + "previous_txn_lgr_seq": 28991004, + "source_tag": 11747, + "index": "DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", +} + +fee_settings_json = { + "base_fee": "000000000000000A", + "flags": 0, + "ledger_entry_type": "FeeSettings", + "reference_fee_units": 10, + "reserve_base": 20000000, + "reserve_increment": 5000000, + "index": "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", +} + +ledger_hashes_json = { + "ledger_entry_type": "LedgerHashes", + "flags": 0, + "first_ledger_sequence": 2, + "last_ledger_sequence": 33872029, + "hashes": [ + "D638208ADBD04CBB10DE7B645D3AB4BA31489379411A3A347151702B6401AA78", + "254D690864E418DDD9BCAC93F41B1F53B1AE693FC5FE667CE40205C322D1BE3B", + "A2B31D28905E2DEF926362822BC412B12ABF6942B73B72A32D46ED2ABB7ACCFA", + "AB4014846DF818A4B43D6B1686D0DE0644FE711577C5AB6F0B2A21CCEE280140", + "3383784E82A8BA45F4DD5EF4EE90A1B2D3B4571317DBAC37B859836ADDE644C1", + ], + "index": "B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B", +} + +negative_unl_json = { + "disabled_validators": [ + { + "disabled_validator": { + "first_ledger_sequence": 1609728, + "public_key": "ED6629D456285AE3613B285F65BBFF168D695BA" + "3921F309949AFCD2CA7AFEC16FE", + } + } + ], + "flags": 0, + "ledger_entry_type": "NegativeUNL", + "index": "2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", +} + +# TODO: Find example +# nftoken_offer_json = {} + +nftoken_page_json = { + "ledger_entry_type": "NFTokenPage", + "previous_token_page": "598EDFD7CF73460FB8C695d6a9397E" + "907378C8A841F7204C793DCBEF5406", + "previous_token_next": "598EDFD7CF73460FB8C695d6a9397E90" + "73781BA3B78198904F659AAA252A", + "previous_txn_id": "95C8761B22894E328646F7A70035E9DFBECC9" + "0EDD83E43B7B973F626D21A0822", + "previous_txn_lgr_seq": 42891441, + "nftokens": [ + { + "nftoken_id": "000B013A95F14B0044F78A264E41713" + "C64B5F89242540EE208C3098E00000D65", + "uri": "697066733A2F2F62616679626569676479727A74357366703775646D3768753736" + "7568377932366E6634646675796C71616266336F636C67747179353566627A6469", + }, + ], + "index": "", # TODO: Find out if there is unique index +} + +offer_json = { + "account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + "book_directory": "ACC27DE91DBA86FC509069EAF4BC511D7" + "3128B780F2E54BF5E07A369E2446000", + "book_node": "0000000000000000", + "flags": 131072, + "ledger_entry_type": "Offer", + "owner_node": "0000000000000000", + "previous_txn_id": "F0AB71E777B2DA54B86231E19B82554EF1" + "F8211F92ECA473121C655BFC5329BF", + "previous_txn_lgr_seq": 14524914, + "sequence": 866, + "taker_gets": { + "currency": "XAG", + "issuer": "r9Dr5xwkeLegBeXq6ujinjSBLQzQ1zQGjH", + "value": "37", + }, + "taker_pays": "79550000000", + "index": "96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", +} + +pay_channel_json = { + "account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + "destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "amount": "4325800", + "balance": "2323423", + "public_key": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A", + "settle_delay": 3600, + "expiration": 536027313, + "cancel_after": 536891313, + "source_tag": 0, + "destination_tag": 1002341, + "destination_node": "0000000000000000", + "flags": 0, + "ledger_entry_type": "PayChannel", + "owner_node": "0000000000000000", + "previous_txn_id": "F0AB71E777B2DA54B86231E19B82554E" + "F1F8211F92ECA473121C655BFC5329BF", + "previous_txn_lgr_seq": 14524914, + "index": "96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", +} + +ripple_state_json = { + "balance": { + "currency": "USD", + "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value": "-10", + }, + "flags": 393216, + "high_limit": { + "currency": "USD", + "issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "value": "110", + }, + "high_node": "0000000000000000", + "ledger_entry_type": "RippleState", + "low_limit": { + "currency": "USD", + "issuer": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", + "value": "0", + }, + "low_node": "0000000000000000", + "previous_txn_id": "E3FE6EA3D48F0C2B639448020EA4F03D" + "4F4F8FFDB243A852A0F59177921B4879", + "previous_txn_lgr_seq": 14090896, + "index": "9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", +} + +signer_list_json = { + "flags": 0, + "ledger_entry_type": "SignerList", + "owner_node": "0000000000000000", + "previous_txn_id": "5904C0DC72C58A83AEFED2FFC5386356" + "AA83FCA6A88C89D00646E51E687CDBE4", + "previous_txn_lgr_seq": 16061435, + "signer_entries": [ + { + "signer_entry": { + "account": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", + "signer_weight": 2, + } + }, + { + "signer_entry": { + "account": "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n", + "signer_weight": 1, + } + }, + { + "signer_entry": { + "account": "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v", + "signer_weight": 1, + } + }, + ], + "signer_list_id": 0, + "signer_quorum": 3, + "index": "A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", +} + +ticket_json = { + "account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + "flags": 0, + "ledger_entry_type": "Ticket", + "owner_node": "0000000000000000", + "previous_txn_id": "F19AD4577212D3BEACA0F75FE1BA1" + "644F2E854D46E8D62E9C95D18E9708CBFB1", + "previous_txn_lgr_seq": 4, + "ticket_sequence": 3, + "index": "", # TODO: Find out if there is an unique index +} + + +class TestFromTODict(TestCase): + def test_account_root(self): + actual = AccountRoot.from_dict(account_root_json) + expected = AccountRoot( + index="13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", + account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + balance="148446663", + flags=8388608, + owner_count=3, + previous_txn_id="0D5FB50FA65C9FE1538FD7E398FFFE9D" + "1908DFA4576D8D7A020040686F93C77D", + previous_txn_lgr_seq=14091160, + sequence=336, + account_txn_id="0D5FB50FA65C9FE1538FD7E398FFFE9D1" + "908DFA4576D8D7A020040686F93C77D", + burned_nftokens=None, + domain="6D64756F31332E636F6D", + email_hash="98B4375E1D753E5B91627516F6D70977", + message_key="0000000000000000000000070000000300", + minted_nftokens=None, + nftoken_minter="rHello", + regular_key=None, + ticket_count=None, + ticket_size=None, + transfer_rate=1004999999, + wallet_locator=None, + wallet_size=None, + ) + self.assertEqual(actual, expected) + self.assertEqual(account_root_json, expected.to_dict()) + + def test_amendments(self): + actual = Amendments.from_dict(amendment_json) + expected = Amendments( + index="7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", + flags=0, + amendments=[ + "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE", + "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373", + "6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC", + "740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D628A06927F11", + ], + majorities=[ + Majority( + amendment="1562511F573A19AE9BD103B5D6B9E01B3B46805AEC5D3C" + "4805C902B514399146", + close_time=535589001, + ) + ], + ) + self.assertEqual(actual, expected) + self.assertEqual(amendment_json, expected.to_dict()) + + def test_check(self): + actual = Check.from_dict(check_json) + expected = Check( + index="49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", + account="rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + destination="rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + flags=0, + owner_node="0000000000000000", + previous_txn_id="5463C6E08862A1FAE5EDAC12D70ADB16546A" + "1F674930521295BC082494B62924", + previous_txn_lgr_seq=6, + send_max="100000000", + sequence=2, + destination_node="0000000000000000", + destination_tag=1, + expiration=570113521, + invoice_id="46060241FABCF692D4D934BA2A6C4427CD427" + "9083E38C77CBE642243E43BE291", + source_tag=None, + ) + self.assertEqual(actual, expected) + self.assertEqual(check_json, expected.to_dict()) + + def test_deposit_preauth(self): + actual = DepositPreauth.from_dict(deposit_preauth_json) + expected = DepositPreauth( + index="4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", + account="rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", + authorize="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + flags=0, + owner_node="0000000000000000", + previous_txn_id="3E8964D5A86B3CD6B9ECB33310D4E073D64C8" + "65A5B866200AD2B7E29F8326702", + previous_txn_lgr_seq=7, + ) + self.assertEqual(actual, expected) + self.assertEqual(deposit_preauth_json, expected.to_dict()) + + def test_directory_node(self): + actual = DirectoryNode.from_dict(directory_node_json) + expected = DirectoryNode( + index="1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", + flags=0, + root_index="1BBEF97EDE88D40CEE2ADE6FEF121166A" + "FE80D99EBADB01A4F069BA8FF484000", + indexes=[ + "AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD" + ], + index_next=None, + index_previous=None, + owner=None, + exchange_rate="4F069BA8FF484000", + taker_pays_currency="0000000000000000000000004A50590000000000", + taker_pays_issuer="5BBC0F22F61D9224A110650CFE21CC0C4BE13098", + taker_gets_currency="0000000000000000000000000000000000000000", + taker_gets_issuer="0000000000000000000000000000000000000000", + ) + self.assertEqual(actual, expected) + self.assertEqual(directory_node_json, expected.to_dict()) + + def test_escrow(self): + actual = Escrow.from_dict(escrow_json) + expected = Escrow( + index="DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", + account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + amount="10000", + destination="ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + flags=0, + owner_node="0000000000000000", + previous_txn_id="C44F2EB84196B9AD820313DBEBA6316A15" + "C9A2D35787579ED172B87A30131DA7", + previous_txn_lgr_seq=28991004, + condition="A0258020A82A88B2DF843A54F58772E4A3861866EC" + "DB4157645DD9AE528C1D3AEEDABAB6810120", + cancel_after=545440232, + destination_node="0000000000000000", + destination_tag=23480, + finish_after=545354132, + source_tag=11747, + ) + self.assertEqual(actual, expected) + self.assertEqual(escrow_json, expected.to_dict()) + + def test_fee_settings(self): + actual = FeeSettings.from_dict(fee_settings_json) + expected = FeeSettings( + index="4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", + base_fee="000000000000000A", + flags=0, + reference_fee_units=10, + reserve_base=20000000, + reserve_increment=5000000, + ) + self.assertEqual(actual, expected) + self.assertEqual(fee_settings_json, expected.to_dict()) + + def test_ledger_hashes(self): + actual = LedgerHashes.from_dict(ledger_hashes_json) + expected = LedgerHashes( + index="B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B", + first_ledger_sequence=2, + last_ledger_sequence=33872029, + hashes=[ + "D638208ADBD04CBB10DE7B645D3AB4BA31489379411A3A347151702B6401AA78", + "254D690864E418DDD9BCAC93F41B1F53B1AE693FC5FE667CE40205C322D1BE3B", + "A2B31D28905E2DEF926362822BC412B12ABF6942B73B72A32D46ED2ABB7ACCFA", + "AB4014846DF818A4B43D6B1686D0DE0644FE711577C5AB6F0B2A21CCEE280140", + "3383784E82A8BA45F4DD5EF4EE90A1B2D3B4571317DBAC37B859836ADDE644C1", + ], + flags=0, + ) + self.assertEqual(actual, expected) + self.assertEqual(ledger_hashes_json, expected.to_dict()) + + def test_negative_unl(self): + actual = NegativeUNL.from_dict(negative_unl_json) + expected = NegativeUNL( + index="2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", + flags=0, + disabled_validators=[ + DisabledValidator( + first_ledger_sequence=1609728, + public_key="ED6629D456285AE3613B285F65BBFF168D695BA" + "3921F309949AFCD2CA7AFEC16FE", + ) + ], + validator_to_disable=None, + validator_to_enable=None, + ) + self.assertEqual(actual, expected) + self.assertEqual(negative_unl_json, expected.to_dict()) + + def test_nftoken_page(self): + actual = NFTokenPage.from_dict(nftoken_page_json) + expected = NFTokenPage( + index="", + previous_page_min=None, + next_page_min=None, + previous_token_page="598EDFD7CF73460FB8C695d6a9397E9" + "07378C8A841F7204C793DCBEF5406", + previous_token_next="598EDFD7CF73460FB8C695d6a9397E90" + "73781BA3B78198904F659AAA252A", + previous_txn_id="95C8761B22894E328646F7A70035E9DFBEC" + "C90EDD83E43B7B973F626D21A0822", + previous_txn_lgr_seq=42891441, + nftokens=[ + NFToken( + nftoken_id="000B013A95F14B0044F78A264E41713" + "C64B5F89242540EE208C3098E00000D65", + uri="697066733A2F2F62616679626569676479727A" + "74357366703775646D37687537367568377932366E" + "6634646675796C71616266336F636C67747179353566627A6469", + ) + ], + ) + self.assertEqual(actual, expected) + self.assertEqual(nftoken_page_json, expected.to_dict()) + + def test_offer(self): + actual = Offer.from_dict(offer_json) + expected = Offer( + index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", + account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + taker_gets=IssuedCurrencyAmount( + currency="XAG", issuer="r9Dr5xwkeLegBeXq6ujinjSBLQzQ1zQGjH", value="37" + ), + taker_pays="79550000000", + sequence=866, + flags=131072, + book_directory="ACC27DE91DBA86FC509069EAF4BC511D7" + "3128B780F2E54BF5E07A369E2446000", + book_node="0000000000000000", + owner_node="0000000000000000", + previous_txn_id="F0AB71E777B2DA54B86231E19B82554EF1F821" + "1F92ECA473121C655BFC5329BF", + previous_txn_lgr_seq=14524914, + expiration=None, + ) + self.assertEqual(actual, expected) + self.assertEqual(offer_json, expected.to_dict()) + + def test_pay_channel(self): + actual = PayChannel.from_dict(pay_channel_json) + expected = PayChannel( + index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", + account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + amount="4325800", + balance="2323423", + destination="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + flags=0, + owner_node="0000000000000000", + public_key="32D2471DB72B27E3310F355BB33E339BF26F83" + "92D5A93D3BC0FC3B566612DA0F0A", + previous_txn_id="F0AB71E777B2DA54B86231E19B82554EF1" + "F8211F92ECA473121C655BFC5329BF", + previous_txn_lgr_seq=14524914, + settle_delay=3600, + destination_node="0000000000000000", + destination_tag=1002341, + expiration=536027313, + cancel_after=536891313, + source_tag=0, + ) + self.assertEqual(actual, expected) + self.assertEqual(pay_channel_json, expected.to_dict()) + + def test_ripple_state(self): + actual = RippleState.from_dict(ripple_state_json) + expected = RippleState( + index="9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", + balance=IssuedCurrencyAmount( + currency="USD", issuer="rrrrrrrrrrrrrrrrrrrrBZbvji", value="-10" + ), + flags=393216, + low_limit=IssuedCurrencyAmount( + currency="USD", issuer="rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", value="0" + ), + high_limit=IssuedCurrencyAmount( + currency="USD", issuer="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", value="110" + ), + previous_txn_id="E3FE6EA3D48F0C2B639448020EA4F03D4F4" + "F8FFDB243A852A0F59177921B4879", + previous_txn_lgr_seq=14090896, + high_node="0000000000000000", + low_node="0000000000000000", + high_quality_in=None, + high_quality_out=None, + low_quality_in=None, + low_quality_out=None, + ) + self.assertEqual(actual, expected) + self.assertEqual(ripple_state_json, expected.to_dict()) + + def test_signer_list(self): + actual = SignerList.from_dict(signer_list_json) + expected = SignerList( + index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", + flags=0, + owner_node="0000000000000000", + previous_txn_id="5904C0DC72C58A83AEFED2FFC5386356" + "AA83FCA6A88C89D00646E51E687CDBE4", + previous_txn_lgr_seq=16061435, + signer_entries=[ + SignerEntry( + account="rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", + signer_weight=2, + ), + SignerEntry( + account="raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n", + signer_weight=1, + ), + SignerEntry( + account="rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v", + signer_weight=1, + ), + ], + signer_list_id=0, + signer_quorum=3, + ) + self.assertEqual(actual, expected) + self.assertEqual(signer_list_json, expected.to_dict()) + + def test_ticket(self): + actual = Ticket.from_dict(ticket_json) + expected = Ticket( + index="", + account="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + flags=0, + owner_node="0000000000000000", + previous_txn_id="F19AD4577212D3BEACA0F75FE1BA1644F2E85" + "4D46E8D62E9C95D18E9708CBFB1", + previous_txn_lgr_seq=4, + ticket_sequence=3, + ) + self.assertEqual(actual, expected) + self.assertEqual(ticket_json, expected.to_dict()) diff --git a/xrpl/models/ledger_objects/__init__.py b/xrpl/models/ledger_objects/__init__.py new file mode 100644 index 000000000..7ee39337e --- /dev/null +++ b/xrpl/models/ledger_objects/__init__.py @@ -0,0 +1,91 @@ +"""The models for Ledger Objects""" + +from xrpl.models.ledger_objects.account_root import ( + AccountRoot, + AccountRootFlags, + MDAccountRootFields, +) +from xrpl.models.ledger_objects.amendments import ( + Amendments, + Majority, + MDAmendmentsFields, +) +from xrpl.models.ledger_objects.check import Check, MDCheckFields +from xrpl.models.ledger_objects.deposit_preauth import ( + DepositPreauth, + MDDepositPreauthFields, +) +from xrpl.models.ledger_objects.directory_node import ( + DirectoryNode, + MDDirectoryNodeFields, +) +from xrpl.models.ledger_objects.escrow import Escrow, MDEscrowFields +from xrpl.models.ledger_objects.fee_settings import FeeSettings, MDFeeSettingsFields +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_hashes import LedgerHashes, MDLedgerHashesFields +from xrpl.models.ledger_objects.negative_unl import ( + DisabledValidator, + MDNegativeUNLFields, + NegativeUNL, +) +from xrpl.models.ledger_objects.nftoken_offer import ( + MDNFTokenOfferFields, + NFToken, + NFTokenOffer, + NFTokenOfferFlags, +) +from xrpl.models.ledger_objects.nftoken_page import MDNFTokenPageFields, NFTokenPage +from xrpl.models.ledger_objects.offer import MDOfferFields, Offer, OfferFlag +from xrpl.models.ledger_objects.pay_channel import MDPayChannelFields, PayChannel +from xrpl.models.ledger_objects.ripple_state import MDRippleStateFields, RippleState +from xrpl.models.ledger_objects.signer_list import ( + MDSignerListFields, + SignerEntry, + SignerList, + SignerListFlag, +) +from xrpl.models.ledger_objects.ticket import MDTicketFields, Ticket + +__all__ = [ + "AccountRoot", + "MDAccountRootFields", + "AccountRootFlags", + "Amendments", + "MDAmendmentsFields", + "Check", + "MDCheckFields", + "DepositPreauth", + "MDDepositPreauthFields", + "DirectoryNode", + "MDDirectoryNodeFields", + "DisabledValidator", + "Escrow", + "MDEscrowFields", + "FeeSettings", + "MDFeeSettingsFields", + "LedgerEntryType", + "LedgerHashes", + "MDLedgerHashesFields", + "Majority", + "NegativeUNL", + "MDNegativeUNLFields", + "NFToken", + "NFTokenOffer", + "MDNFTokenOfferFields", + "NFTokenOfferFlags", + "NFTokenPage", + "MDNFTokenPageFields", + "Offer", + "MDOfferFields", + "OfferFlag", + "PayChannel", + "MDPayChannelFields", + "RippleState", + "MDRippleStateFields", + "SignerEntry", + "SignerList", + "MDSignerListFields", + "SignerListFlag", + "Ticket", + "MDTicketFields", +] diff --git a/xrpl/models/ledger_objects/account_root.py b/xrpl/models/ledger_objects/account_root.py new file mode 100644 index 000000000..0f45a6c6d --- /dev/null +++ b/xrpl/models/ledger_objects/account_root.py @@ -0,0 +1,86 @@ +"""Models for the Ledger Object `AccountRoot`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from enum import Enum +from typing import Optional, Union + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class AccountRoot(LedgerObject): + """The model for the `AccountRoot` Ledger Object""" + + account: str = REQUIRED # type: ignore + balance: str = REQUIRED # type: ignore + flags: Union[int, AccountRootFlags] = REQUIRED # type: ignore + owner_count: int = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + sequence: int = REQUIRED # type: ignore + account_txn_id: Optional[str] = None + burned_nftokens: Optional[int] = None + domain: Optional[str] = None + email_hash: Optional[str] = None + message_key: Optional[str] = None + minted_nftokens: Optional[int] = None + nftoken_minter: Optional[str] = None + regular_key: Optional[str] = None + ticket_count: Optional[int] = None + ticket_size: Optional[int] = None + transfer_rate: Optional[int] = None + wallet_locator: Optional[str] = None + wallet_size: Optional[int] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.ACCOUNT_ROOT, init=False + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDAccountRootFields(LedgerObject): + """ + The model for the `AccountRoot` Ledger Object when + represented in a transaction's metadata. + """ + + account: Optional[str] = None + balance: Optional[str] = None + flags: Optional[Union[int, AccountRootFlags]] = None + owner_count: Optional[int] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + sequence: Optional[int] = None + account_txn_id: Optional[str] = None + burned_nftokens: Optional[int] = None + domain: Optional[str] = None + email_hash: Optional[str] = None + message_key: Optional[str] = None + minted_nftokens: Optional[int] = None + nftoken_minter: Optional[str] = None + regular_key: Optional[str] = None + ticket_count: Optional[int] = None + ticket_size: Optional[int] = None + transfer_rate: Optional[int] = None + wallet_locator: Optional[str] = None + wallet_size: Optional[int] = None + + +class AccountRootFlags(Enum): + """The flags for the `AccountRoot` Ledger Object""" + + LSF_DEFAULT_RIPPLE = 0x00800000 + LSF_DEPOSIT_AUTH = 0x01000000 + LSF_DISABLE_MASTER = 0x00100000 + LSF_DISALLOW_XRP = 0x00080000 + LSF_GLOBAL_FREEZE = 0x00400000 + LSF_NO_FREEZE = 0x00200000 + LSF_PASSWORD_SPENT = 0x00010000 + LSF_REQUIRE_AUTH = 0x00040000 + LSF_REQUIRE_DEST_TAG = 0x00020000 diff --git a/xrpl/models/ledger_objects/amendments.py b/xrpl/models/ledger_objects/amendments.py new file mode 100644 index 000000000..5036c8c93 --- /dev/null +++ b/xrpl/models/ledger_objects/amendments.py @@ -0,0 +1,50 @@ +"""Models for the Ledger Object `Amendments`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import List, Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.nested_model import NestedModel +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class Amendments(LedgerObject): + """The model for the `Amendments` Ledger Object""" + + # always 0 + flags: int = REQUIRED # type: ignore + amendments: Optional[List[str]] = None + majorities: Optional[List[Majority]] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.AMENDMENTS, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDAmendmentsFields(LedgerObject): + """ + The model for the `Amendments` Ledger Object when + represented in a transaction's metadata. + """ + + # always 0 + flags: Optional[int] = None + amendments: Optional[List[str]] = None + majorities: Optional[List[Majority]] = None + + +@require_kwargs_on_init +@dataclass(frozen=True) +class Majority(NestedModel): + """A model for the `Majority` object""" + + amendment: str = REQUIRED # type: ignore + close_time: int = REQUIRED # type: ignore diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py new file mode 100644 index 000000000..777d4fe7a --- /dev/null +++ b/xrpl/models/ledger_objects/check.py @@ -0,0 +1,61 @@ +"""Models for the Ledger Object `Check`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional, Union + +from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class Check(LedgerObject): + """The model for the `Check` Ledger Object""" + + account: str = REQUIRED # type: ignore + destination: str = REQUIRED # type: ignore + # always 0 + flags: int = REQUIRED # type: ignore + owner_node: str = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + send_max: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore + sequence: int = REQUIRED # type: ignore + destination_node: Optional[str] = None + destination_tag: Optional[int] = None + expiration: Optional[int] = None + invoice_id: Optional[str] = None + source_tag: Optional[int] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.CHECK, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDCheckFields(LedgerObject): + """ + The model for the `Check` Ledger Object when + represented in a transaction's metadata. + """ + + account: Optional[str] = None + destination: Optional[str] = None + # always 0 + flags: Optional[int] = None + owner_node: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + send_max: Optional[Union[str, IssuedCurrencyAmount]] = None + sequence: Optional[int] = None + destination_node: Optional[str] = None + destination_tag: Optional[int] = None + expiration: Optional[int] = None + invoice_id: Optional[str] = None + source_tag: Optional[int] = None diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py new file mode 100644 index 000000000..3c67c1eaa --- /dev/null +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -0,0 +1,46 @@ +"""Models for the Ledger Object `DepositPreauth`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class DepositPreauth(LedgerObject): + """The model for the `DepositPreauth` Ledger Object""" + + account: str = REQUIRED # type: ignore + authorize: str = REQUIRED # type: ignore + # always 0 + flags: int = REQUIRED # type: ignore + owner_node: str = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.DEPOSIT_PREAUTH, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDDepositPreauthFields(LedgerObject): + """ + The model for the `DepositPreauth` Ledger Object when + represented in a transaction's metadata. + """ + + account: Optional[str] = None + authorize: Optional[str] = None + # always 0 + flags: Optional[int] = None + owner_node: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None diff --git a/xrpl/models/ledger_objects/directory_node.py b/xrpl/models/ledger_objects/directory_node.py new file mode 100644 index 000000000..38c5f14f5 --- /dev/null +++ b/xrpl/models/ledger_objects/directory_node.py @@ -0,0 +1,56 @@ +"""Models for the Ledger Object `DirectoryNode`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import List, Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class DirectoryNode(LedgerObject): + """The model for the `DirectoryNode` Ledger Object""" + + # always 0 + flags: int = REQUIRED # type: ignore + root_index: str = REQUIRED # type: ignore + indexes: List[str] = REQUIRED # type: ignore + index_next: Optional[int] = None + index_previous: Optional[int] = None + owner: Optional[str] = None + exchange_rate: Optional[str] = None + taker_pays_currency: Optional[str] = None + taker_pays_issuer: Optional[str] = None + taker_gets_currency: Optional[str] = None + taker_gets_issuer: Optional[str] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.DIRECTORY_NODE, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDDirectoryNodeFields(LedgerObject): + """ + The model for the `DirectoryNode` Ledger Object when + represented in a transaction's metadata. + """ + + # always 0 + flags: Optional[int] = None + root_index: Optional[str] = None + indexes: Optional[List[str]] = None + index_next: Optional[int] = None + index_previous: Optional[int] = None + owner: Optional[str] = None + exchange_rate: Optional[str] = None + taker_pays_currency: Optional[str] = None + taker_pays_issuer: Optional[str] = None + taker_gets_currency: Optional[str] = None + taker_gets_issuer: Optional[str] = None diff --git a/xrpl/models/ledger_objects/escrow.py b/xrpl/models/ledger_objects/escrow.py new file mode 100644 index 000000000..4ee7211a4 --- /dev/null +++ b/xrpl/models/ledger_objects/escrow.py @@ -0,0 +1,59 @@ +"""Models for the Ledger Object `Escrow`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class Escrow(LedgerObject): + """The model for the `Escrow` Ledger Object""" + + account: str = REQUIRED # type: ignore + amount: str = REQUIRED # type: ignore + destination: str = REQUIRED # type: ignore + # always 0 + flags: int = REQUIRED # type: ignore + owner_node: str = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + condition: Optional[str] = None + cancel_after: Optional[int] = None + destination_node: Optional[str] = None + destination_tag: Optional[int] = None + finish_after: Optional[int] = None + source_tag: Optional[int] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.ESCROW, init=False + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDEscrowFields(LedgerObject): + """ + The model for the `Escrow` Ledger Object when + represented in a transaction's metadata. + """ + + account: Optional[str] = None + amount: Optional[str] = None + destination: Optional[str] = None + # always 0 + flags: Optional[int] = None + owner_node: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + condition: Optional[str] = None + cancel_after: Optional[int] = None + destination_node: Optional[str] = None + destination_tag: Optional[int] = None + finish_after: Optional[int] = None + source_tag: Optional[int] = None diff --git a/xrpl/models/ledger_objects/fee_settings.py b/xrpl/models/ledger_objects/fee_settings.py new file mode 100644 index 000000000..0ccdbb877 --- /dev/null +++ b/xrpl/models/ledger_objects/fee_settings.py @@ -0,0 +1,43 @@ +"""Models for the Ledger Object `FeeSettings`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class FeeSettings(LedgerObject): + """The model for the `FeeSettings` Ledger Object""" + + base_fee: str = REQUIRED # type: ignore + # always 0 + flags: int = REQUIRED # type: ignore + reference_fee_units: int = REQUIRED # type: ignore + reserve_base: int = REQUIRED # type: ignore + reserve_increment: int = REQUIRED # type: ignore + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.FEE_SETTINGS, init=False + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDFeeSettingsFields(LedgerObject): + """ + The model for the `FeeSettings` Ledger Object when + represented in a transaction's metadata. + """ + + base_fee: Optional[str] = None + # always 0 + flags: Optional[int] = None + reference_fee_units: Optional[int] = None + reserve_base: Optional[int] = None + reserve_increment: Optional[int] = None diff --git a/xrpl/models/ledger_objects/ledger_entry_type.py b/xrpl/models/ledger_objects/ledger_entry_type.py new file mode 100644 index 000000000..63b92f6f3 --- /dev/null +++ b/xrpl/models/ledger_objects/ledger_entry_type.py @@ -0,0 +1,24 @@ +"""The different ledger entry types""" + +from enum import Enum + + +class LedgerEntryType(str, Enum): + """The different ledger entry types""" + + ACCOUNT_ROOT = "AccountRoot" + AMENDMENTS = "Amendments" + CHECK = "Check" + DEPOSIT_PREAUTH = "DepositPreauth" + DIRECTORY_NODE = "DirectoryNode" + ESCROW = "Escrow" + FEE_SETTINGS = "FeeSettings" + LEDGER_HASHES = "LedgerHashes" + NEGATIVE_UNL = "NegativeUNL" + NFTOKEN_OFFER = "NFTokenOffer" + NFTOKEN_PAGE = "NFTokenPage" + OFFER = "Offer" + PAY_CHANNEL = "PayChannel" + RIPPLE_STATE = "RippleState" + SIGNER_LIST = "SignerList" + TICKET = "Ticket" diff --git a/xrpl/models/ledger_objects/ledger_hashes.py b/xrpl/models/ledger_objects/ledger_hashes.py new file mode 100644 index 000000000..e9889c76c --- /dev/null +++ b/xrpl/models/ledger_objects/ledger_hashes.py @@ -0,0 +1,42 @@ +"""Models for the Ledger Object `LedgerHashes`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import List, Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class LedgerHashes(LedgerObject): + """The model for the `LedgerHashes` Ledger Object""" + + first_ledger_sequence: int = REQUIRED # type: ignore + last_ledger_sequence: int = REQUIRED # type: ignore + hashes: List[str] = REQUIRED # type: ignore + # always 0 + flags: int = REQUIRED # type: ignore + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.LEDGER_HASHES, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDLedgerHashesFields(LedgerObject): + """ + The model for the `LedgerHashes` Ledger Object when + represented in a transaction's metadata. + """ + + first_ledger_sequence: Optional[int] = None + last_ledger_sequence: Optional[int] = None + hashes: Optional[List[str]] = None + # always 0 + flags: Optional[int] = None diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py new file mode 100644 index 000000000..428b691f5 --- /dev/null +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -0,0 +1,137 @@ +"""A model for Ledger Objects""" + +from __future__ import annotations + +from dataclasses import dataclass +from typing import Any, Dict, Optional, Type, TypeVar + +from xrpl.models.base_model import BaseModel +from xrpl.models.exceptions import XRPLModelException +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType + +# TODO: REMOVE if optional is needed +# from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + +L = TypeVar("L", bound="LedgerObject") + + +@require_kwargs_on_init +@dataclass(frozen=True) +class LedgerObject(BaseModel): + """The base model for a Ledger Object.""" + + # TODO: Try without optional + ledger_entry_type: Optional[LedgerEntryType] = None + index: Optional[str] = None + + @classmethod + def from_dict(cls: Type[L], value: Dict[str, Any]) -> L: + """Derive the model from a dict. + + Args: + value: The dictionary to derive from. + + Returns: + L: The Ledger Object. + + Raises: + XRPLModelException: If there is no Ledger Object type is + provided or the type mismatches the constructor type. + """ + if cls.__name__ == "LedgerObject": + if "ledger_entry_type" not in value: + raise XRPLModelException( + "Ledger Object does not include ledger_entry_type." + ) + correct_type = cls.get_ledger_object_type(value["ledger_entry_type"]) + return correct_type.from_dict(value) # type: ignore + elif cls.__name__ in ["FinalFields", "PreviousFields", "NewFields"]: + if "ledger_entry_type" not in value: + raise XRPLModelException( + "Ledger Object does not include ledger_entry_type." + ) + correct_type = cls.get_md_ledger_object_type(value["ledger_entry_type"]) + del value["ledger_entry_type"] + return correct_type.from_dict(value) # type: ignore + else: + if "ledger_entry_type" in value: + ledger_entry_type = value["ledger_entry_type"] + if ( + cls.get_ledger_object_type(ledger_entry_type).__name__ + != cls.__name__ + and cls.get_md_ledger_object_type(ledger_entry_type).__name__ + != cls.__name__ + ): + raise XRPLModelException( + f"Using wrong constructor: using {cls.__name__} constructor " + f"with ledger object type {value['ledger_entry_type']}." + ) + value = {**value} + del value["ledger_entry_type"] + return super(LedgerObject, cls).from_dict(value) + + @classmethod + def get_ledger_object_type( + cls: Type[LedgerObject], ledger_object_type: str + ) -> Type[LedgerObject]: + """Get the correct model + + Args: + ledger_object_type: The ledger object type willing to get. + + Returns: + Type[AffectedNode]: The correct ledger object type. + + Raises: + XRPLModelException: If the Ledger Object type does not exist. + """ + import xrpl.models.ledger_objects as ledger_object_models + + ledger_object_types: Dict[str, Type[LedgerObject]] = { + lgr_obj.value: getattr(ledger_object_models, lgr_obj) + for lgr_obj in ledger_object_models.ledger_entry_type.LedgerEntryType + } + if ledger_object_type in ledger_object_types: + return ledger_object_types[ledger_object_type] + + raise XRPLModelException( + f"{ledger_object_type} is not a valid Ledger Object type." + ) + + @classmethod + def get_md_ledger_object_type( + cls: Type[LedgerObject], ledger_object_type: str + ) -> Type[LedgerObject]: + """ + Get the correct model + + Args: + ledger_object_type: The object type willing to get. + + Returns: + Type[LedgerObject]: The correct ledger object type. + + Raises: + XRPLModelException: If the Ledger Object type does not exist. + """ + import xrpl.models.ledger_objects as ledger_object_models + + ledger_object_types: Dict[str, Type[LedgerObject]] = { + lgr_obj.value: getattr(ledger_object_models, f"MD{lgr_obj}Fields") + for lgr_obj in ledger_object_models.ledger_entry_type.LedgerEntryType + } + if ledger_object_type in ledger_object_types: + return ledger_object_types[ledger_object_type] + + raise XRPLModelException( + f"{ledger_object_type} is not a valid Ledger Object type." + ) + + def __getitem__(self: LedgerObject, field_name: str) -> Any: + """Enable to get the fields like from a `dict`""" + if field_name == self.__class__.__name__ or self.__class__.__name__ == "".join( + [word.capitalize() for word in field_name.split("_")] + ): + return self + return self.__getattribute__(field_name) diff --git a/xrpl/models/ledger_objects/negative_unl.py b/xrpl/models/ledger_objects/negative_unl.py new file mode 100644 index 000000000..57d95f827 --- /dev/null +++ b/xrpl/models/ledger_objects/negative_unl.py @@ -0,0 +1,49 @@ +"""Models for the Ledger Object `NegativeUNL`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import List, Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.nested_model import NestedModel +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class NegativeUNL(LedgerObject): + """The model for the `NegativeUNL` Ledger Object""" + + flags: int = REQUIRED # type: ignore + disabled_validators: Optional[List[DisabledValidator]] = None + validator_to_disable: Optional[str] = None + validator_to_enable: Optional[str] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.NEGATIVE_UNL, init=False + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDNegativeUNLFields(LedgerObject): + """ + The model for the `NegativeUNL` Ledger Object when + represented in a transaction's metadata. + """ + + flags: Optional[int] = None + disabled_validators: Optional[List[DisabledValidator]] = None + validator_to_disable: Optional[str] = None + validator_to_enable: Optional[str] = None + + +@require_kwargs_on_init +@dataclass(frozen=True) +class DisabledValidator(NestedModel): + """A model for the `DisabledValidator` object""" + + first_ledger_sequence: int = REQUIRED # type: ignore + public_key: str = REQUIRED # type: ignore diff --git a/xrpl/models/ledger_objects/nftoken_offer.py b/xrpl/models/ledger_objects/nftoken_offer.py new file mode 100644 index 000000000..8f1810d26 --- /dev/null +++ b/xrpl/models/ledger_objects/nftoken_offer.py @@ -0,0 +1,69 @@ +"""Models for the Ledger Object `NFTokenOffer`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from enum import Enum +from typing import Optional, Union + +from xrpl.models.base_model import BaseModel +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class NFTokenOffer(LedgerObject): + """The model for the `NFTokenOffer` Ledger Object""" + + amount: Union[str, NFToken] = REQUIRED # type: ignore + flags: int = REQUIRED # type: ignore + nftoken_id: str = REQUIRED # type: ignore + owner: str = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + destination: Optional[str] = None + expiration: Optional[int] = None + owner_node: Optional[str] = None + nftoken_offer_node: Optional[str] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.NFTOKEN_OFFER, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDNFTokenOfferFields(LedgerObject): + """ + The model for the `NFTokenOffer` Ledger Object when + represented in a transaction's metadata. + """ + + amount: Optional[Union[str, NFToken]] = None + flags: Optional[int] = None + nftoken_id: Optional[str] = None + owner: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + destination: Optional[str] = None + expiration: Optional[int] = None + owner_node: Optional[str] = None + nftoken_offer_node: Optional[str] = None + + +@require_kwargs_on_init +@dataclass(frozen=True) +class NFToken(BaseModel): # + """A model for the `NFToken` object""" + + nftoken_id: str = REQUIRED # type: ignore + uri: str = REQUIRED # type: ignore + + +class NFTokenOfferFlags(Enum): + """The flags for the `NFTokenOffer` Ledger Object""" + + LSF_SELL_NFTOKEN = 0x00000001 diff --git a/xrpl/models/ledger_objects/nftoken_page.py b/xrpl/models/ledger_objects/nftoken_page.py new file mode 100644 index 000000000..f9fa29798 --- /dev/null +++ b/xrpl/models/ledger_objects/nftoken_page.py @@ -0,0 +1,46 @@ +"""Models for the Ledger Object `NFTokenPage`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import List, Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.nftoken_offer import NFToken +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class NFTokenPage(LedgerObject): + """The model for the `NFTokenPage` Ledger Object""" + + previous_page_min: Optional[str] = None + next_page_min: Optional[str] = None + previous_token_page: Optional[str] = None + previous_token_next: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + nftokens: Optional[List[NFToken]] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.NFTOKEN_PAGE, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDNFTokenPageFields(LedgerObject): + """ + The model for the `NFTokenPage` Ledger Object when + represented in a transaction's metadata. + """ + + previous_page_min: Optional[str] = None + next_page_min: Optional[str] = None + previous_token_page: Optional[str] = None + previous_token_next: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + nftokens: Optional[List[NFToken]] = None diff --git a/xrpl/models/ledger_objects/offer.py b/xrpl/models/ledger_objects/offer.py new file mode 100644 index 000000000..5c1afd382 --- /dev/null +++ b/xrpl/models/ledger_objects/offer.py @@ -0,0 +1,63 @@ +"""Models for the Ledger Object `Offer`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from enum import Enum +from typing import Optional, Union + +from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class Offer(LedgerObject): + """The model for the `Offer` Ledger Object""" + + account: str = REQUIRED # type: ignore + taker_gets: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore + taker_pays: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore + sequence: int = REQUIRED # type: ignore + flags: int = REQUIRED # type: ignore + book_directory: str = REQUIRED # type: ignore + book_node: str = REQUIRED # type: ignore + owner_node: str = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + expiration: Optional[int] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.OFFER, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDOfferFields(LedgerObject): + """ + The model for the `Offer` Ledger Object when + represented in a transaction's metadata. + """ + + account: Optional[str] = None + taker_gets: Optional[Union[str, IssuedCurrencyAmount]] = None + taker_pays: Optional[Union[str, IssuedCurrencyAmount]] = None + sequence: Optional[int] = None + flags: Optional[int] = None + book_directory: Optional[str] = None + book_node: Optional[str] = None + owner_node: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + expiration: Optional[int] = None + + +class OfferFlag(Enum): + """The flags for the `Offer` Ledger Object""" + + LSF_PASSIVE = 0x00010000 + LSF_SELL = 0x00020000 diff --git a/xrpl/models/ledger_objects/pay_channel.py b/xrpl/models/ledger_objects/pay_channel.py new file mode 100644 index 000000000..9f9e3375f --- /dev/null +++ b/xrpl/models/ledger_objects/pay_channel.py @@ -0,0 +1,64 @@ +"""Models for the Ledger Object `PayChannel`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class PayChannel(LedgerObject): + """The model for the `PayChannel` Ledger Object""" + + account: str = REQUIRED # type: ignore + amount: str = REQUIRED # type: ignore + balance: str = REQUIRED # type: ignore + destination: str = REQUIRED # type: ignore + # always 0 + flags: int = REQUIRED # type: ignore + owner_node: str = REQUIRED # type: ignore + public_key: str = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + settle_delay: int = REQUIRED # type: ignore + destination_node: Optional[str] = None + destination_tag: Optional[int] = None + expiration: Optional[int] = None + cancel_after: Optional[int] = None + source_tag: Optional[int] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.PAY_CHANNEL, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDPayChannelFields(LedgerObject): + """ + The model for the `PayChannel` Ledger Object when + represented in a transaction's metadata. + """ + + account: Optional[str] = None + amount: Optional[str] = None + balance: Optional[str] = None + destination: Optional[str] = None + # always 0 + flags: Optional[int] = None + owner_node: Optional[str] = None + public_key: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + settle_delay: Optional[int] = None + destination_node: Optional[str] = None + destination_tag: Optional[int] = None + expiration: Optional[int] = None + cancel_after: Optional[int] = None + source_tag: Optional[int] = None diff --git a/xrpl/models/ledger_objects/ripple_state.py b/xrpl/models/ledger_objects/ripple_state.py new file mode 100644 index 000000000..97df04cda --- /dev/null +++ b/xrpl/models/ledger_objects/ripple_state.py @@ -0,0 +1,71 @@ +"""Models for the Ledger Object `RippleState`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from enum import Enum +from typing import Optional + +from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class RippleState(LedgerObject): + """The model for the `RippleState` Ledger Object""" + + balance: IssuedCurrencyAmount = REQUIRED # type: ignore + flags: int = REQUIRED # type: ignore + low_limit: IssuedCurrencyAmount = REQUIRED # type: ignore + high_limit: IssuedCurrencyAmount = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + high_node: Optional[str] = None + low_node: Optional[str] = None + high_quality_in: Optional[int] = None + high_quality_out: Optional[int] = None + low_quality_in: Optional[int] = None + low_quality_out: Optional[int] = None + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.RIPPLE_STATE, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDRippleStateFields(LedgerObject): + """ + The model for the `RippleState` Ledger Object when + represented in a transaction's metadata. + """ + + balance: Optional[IssuedCurrencyAmount] = None + flags: Optional[int] = None + low_limit: Optional[IssuedCurrencyAmount] = None + high_limit: Optional[IssuedCurrencyAmount] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + high_node: Optional[str] = None + low_node: Optional[str] = None + high_quality_in: Optional[int] = None + high_quality_out: Optional[int] = None + low_quality_in: Optional[int] = None + low_quality_out: Optional[int] = None + + +class RippleStateFlag(Enum): + """The flags for the `RippleState` Ledger Object""" + + LSF_LOW_RESERVE = 0x00010000 + LSF_HIGH_RESERVE = 0x00020000 + LSF_LOW_AUTH = 0x00040000 + LSF_HIGH_AUTH = 0x00080000 + LSF_LOW_NO_RIPPLE = 0x00100000 + LSF_HIGH_NO_RIPPLE = 0x00200000 + LSF_LOW_FREEZE = 0x00400000 + LSF_HIGH_FREEZE = 0x00800000 diff --git a/xrpl/models/ledger_objects/signer_list.py b/xrpl/models/ledger_objects/signer_list.py new file mode 100644 index 000000000..2aa85a43d --- /dev/null +++ b/xrpl/models/ledger_objects/signer_list.py @@ -0,0 +1,54 @@ +"""Models for the Ledger Object `SignerList`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from enum import Enum +from typing import List, Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.signer_list_set import SignerEntry +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class SignerList(LedgerObject): + """The model for the `SignerList` Ledger Object""" + + flags: int = REQUIRED # type: ignore + owner_node: str = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + signer_entries: List[SignerEntry] = REQUIRED # type: ignore + signer_list_id: int = REQUIRED # type: ignore + signer_quorum: int = REQUIRED # type: ignore + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.SIGNER_LIST, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDSignerListFields(LedgerObject): + """ + The model for the `SignerList` Ledger Object when + represented in a transaction's metadata. + """ + + flags: Optional[int] = None + owner_node: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + signer_entries: Optional[List[SignerEntry]] = None + signer_list_id: Optional[int] = None + signer_quorum: Optional[int] = None + + +class SignerListFlag(Enum): + """The flags for the `SignerList` Ledger Object""" + + LSF_ONE_OWNER_COUNT = 0x00010000 diff --git a/xrpl/models/ledger_objects/ticket.py b/xrpl/models/ledger_objects/ticket.py new file mode 100644 index 000000000..4fbed5790 --- /dev/null +++ b/xrpl/models/ledger_objects/ticket.py @@ -0,0 +1,46 @@ +"""Models for the Ledger Object `Ticket`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class Ticket(LedgerObject): + """The model for the `Ticket` Ledger Object""" + + account: str = REQUIRED # type: ignore + # always 0 + flags: int = REQUIRED # type: ignore + owner_node: str = REQUIRED # type: ignore + previous_txn_id: str = REQUIRED # type: ignore + previous_txn_lgr_seq: int = REQUIRED # type: ignore + ticket_sequence: int = REQUIRED # type: ignore + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.TICKET, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class MDTicketFields(LedgerObject): + """ + The model for the `Ticket` Ledger Object when + represented in a transaction's metadata. + """ + + account: Optional[str] = None + # always 0 + flags: Optional[int] = None + owner_node: Optional[str] = None + previous_txn_id: Optional[str] = None + previous_txn_lgr_seq: Optional[int] = None + ticket_sequence: Optional[int] = None From 6b9fb7f4c0bc40f0f4b4295abb627b57a9b9ce27 Mon Sep 17 00:00:00 2001 From: LimpidCrypto Date: Fri, 27 Oct 2023 18:11:36 +0200 Subject: [PATCH 02/58] add NFTokenOffer test --- docs/source/xrpl.models.ledger_objects.rst | 157 ++++++++++++++++++++ tests/unit/models/test_ledger_object.py | 37 ++++- xrpl/models/ledger_objects/nftoken_offer.py | 2 +- 3 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 docs/source/xrpl.models.ledger_objects.rst diff --git a/docs/source/xrpl.models.ledger_objects.rst b/docs/source/xrpl.models.ledger_objects.rst new file mode 100644 index 000000000..3f40a2ff0 --- /dev/null +++ b/docs/source/xrpl.models.ledger_objects.rst @@ -0,0 +1,157 @@ +xrpl.models.ledger\_objects package +=================================== + +Submodules +---------- + +xrpl.models.ledger\_objects.account\_root module +------------------------------------------------ + +.. automodule:: xrpl.models.ledger_objects.account_root + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.amendments module +--------------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.amendments + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.check module +---------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.check + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.deposit\_preauth module +--------------------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.deposit_preauth + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.directory\_node module +-------------------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.directory_node + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.escrow module +----------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.escrow + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.fee\_settings module +------------------------------------------------ + +.. automodule:: xrpl.models.ledger_objects.fee_settings + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.ledger\_entry\_type module +------------------------------------------------------ + +.. automodule:: xrpl.models.ledger_objects.ledger_entry_type + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.ledger\_hashes module +------------------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.ledger_hashes + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.ledger\_object module +------------------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.ledger_object + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.negative\_unl module +------------------------------------------------ + +.. automodule:: xrpl.models.ledger_objects.negative_unl + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.nftoken\_offer module +------------------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.nftoken_offer + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.nftoken\_page module +------------------------------------------------ + +.. automodule:: xrpl.models.ledger_objects.nftoken_page + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.offer module +---------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.offer + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.pay\_channel module +----------------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.pay_channel + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.ripple\_state module +------------------------------------------------ + +.. automodule:: xrpl.models.ledger_objects.ripple_state + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.signer\_list module +----------------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.signer_list + :members: + :undoc-members: + :show-inheritance: + +xrpl.models.ledger\_objects.ticket module +----------------------------------------- + +.. automodule:: xrpl.models.ledger_objects.ticket + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: xrpl.models.ledger_objects + :members: + :undoc-members: + :show-inheritance: diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index b2983f91b..699a2c511 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -14,6 +14,8 @@ Majority, NegativeUNL, NFToken, + NFTokenOffer, + NFTokenOfferFlags, NFTokenPage, Offer, PayChannel, @@ -167,8 +169,19 @@ "index": "2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", } -# TODO: Find example -# nftoken_offer_json = {} +nftoken_offer_json = { + "ledger_entry_type": "NFTokenOffer", + "index": "AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", + "amount": "1000000", + "flags": 1, + "nftoken_id": "00081B5825A08C22787716FA031B432EBBC1B101BB54875F0002D2A400000000", + "owner": "rhRxL3MNvuKEjWjL7TBbZSDacb8PmzAd7m", + "previous_txn_id": "BFA9BE27383FA315651E26FDE1FA30815C5A5D0544EE10EC33D3E92532993" + "769", + "previous_txn_lgr_seq": 75443565, + "owner_node": "17", + "nftoken_offer_node": "0" +} nftoken_page_json = { "ledger_entry_type": "NFTokenPage", @@ -187,7 +200,7 @@ "7568377932366E6634646675796C71616266336F636C67747179353566627A6469", }, ], - "index": "", # TODO: Find out if there is unique index + "index": "", } offer_json = { @@ -488,6 +501,24 @@ def test_negative_unl(self): self.assertEqual(actual, expected) self.assertEqual(negative_unl_json, expected.to_dict()) + def test_nftoken_offer(self): + actual = NFTokenOffer.from_dict(nftoken_offer_json) + expected = NFTokenOffer( + index="AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", + amount="1000000", + flags=1, + nftoken_id="00081B5825A08C22787716FA031B432EBBC1B101BB54875F0002D2A400000" + "000", + owner="rhRxL3MNvuKEjWjL7TBbZSDacb8PmzAd7m", + previous_txn_id="BFA9BE27383FA315651E26FDE1FA30815C5A5D0544EE10EC33D3E925" + "32993769", + previous_txn_lgr_seq=75443565, + owner_node="17", + nftoken_offer_node="0", + ) + self.assertEqual(actual, expected) + self.assertEqual(nftoken_offer_json, expected.to_dict()) + def test_nftoken_page(self): actual = NFTokenPage.from_dict(nftoken_page_json) expected = NFTokenPage( diff --git a/xrpl/models/ledger_objects/nftoken_offer.py b/xrpl/models/ledger_objects/nftoken_offer.py index 8f1810d26..b6a64c666 100644 --- a/xrpl/models/ledger_objects/nftoken_offer.py +++ b/xrpl/models/ledger_objects/nftoken_offer.py @@ -19,7 +19,7 @@ class NFTokenOffer(LedgerObject): """The model for the `NFTokenOffer` Ledger Object""" amount: Union[str, NFToken] = REQUIRED # type: ignore - flags: int = REQUIRED # type: ignore + flags: Union[int, NFTokenOfferFlags] = REQUIRED # type: ignore nftoken_id: str = REQUIRED # type: ignore owner: str = REQUIRED # type: ignore previous_txn_id: str = REQUIRED # type: ignore From 752cea21b5969b9993c4f7bc76d454b7c7f5b023 Mon Sep 17 00:00:00 2001 From: LimpidCrypto Date: Fri, 27 Oct 2023 18:14:19 +0200 Subject: [PATCH 03/58] add NFTokenOffer test --- tests/unit/models/test_ledger_object.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 699a2c511..70141b876 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -1,7 +1,7 @@ from unittest import TestCase from xrpl.models import IssuedCurrencyAmount -from xrpl.models.ledger_objects import ( # NFTokenOffer, +from xrpl.models.ledger_objects import ( AccountRoot, Amendments, Check, @@ -15,7 +15,6 @@ NegativeUNL, NFToken, NFTokenOffer, - NFTokenOfferFlags, NFTokenPage, Offer, PayChannel, @@ -180,7 +179,7 @@ "769", "previous_txn_lgr_seq": 75443565, "owner_node": "17", - "nftoken_offer_node": "0" + "nftoken_offer_node": "0", } nftoken_page_json = { From 84a9241fa2201ca9949369a649b28e30dd7cce7f Mon Sep 17 00:00:00 2001 From: LimpidCrypto Date: Fri, 27 Oct 2023 19:01:55 +0200 Subject: [PATCH 04/58] remove metadata models --- xrpl/models/ledger_objects/__init__.py | 64 ++++--------------- xrpl/models/ledger_objects/account_root.py | 30 --------- xrpl/models/ledger_objects/amendments.py | 14 ---- xrpl/models/ledger_objects/check.py | 24 ------- xrpl/models/ledger_objects/deposit_preauth.py | 18 ------ xrpl/models/ledger_objects/directory_node.py | 22 ------- xrpl/models/ledger_objects/escrow.py | 24 ------- xrpl/models/ledger_objects/fee_settings.py | 17 ----- xrpl/models/ledger_objects/ledger_hashes.py | 17 +---- xrpl/models/ledger_objects/negative_unl.py | 14 ---- xrpl/models/ledger_objects/nftoken_offer.py | 20 ------ xrpl/models/ledger_objects/nftoken_page.py | 17 ----- xrpl/models/ledger_objects/offer.py | 21 ------ xrpl/models/ledger_objects/pay_channel.py | 26 -------- xrpl/models/ledger_objects/ripple_state.py | 22 ------- xrpl/models/ledger_objects/signer_list.py | 19 +----- xrpl/models/ledger_objects/ticket.py | 18 ------ 17 files changed, 16 insertions(+), 371 deletions(-) diff --git a/xrpl/models/ledger_objects/__init__.py b/xrpl/models/ledger_objects/__init__.py index 7ee39337e..6d8a5ab1c 100644 --- a/xrpl/models/ledger_objects/__init__.py +++ b/xrpl/models/ledger_objects/__init__.py @@ -1,91 +1,55 @@ """The models for Ledger Objects""" -from xrpl.models.ledger_objects.account_root import ( - AccountRoot, - AccountRootFlags, - MDAccountRootFields, -) -from xrpl.models.ledger_objects.amendments import ( - Amendments, - Majority, - MDAmendmentsFields, -) -from xrpl.models.ledger_objects.check import Check, MDCheckFields -from xrpl.models.ledger_objects.deposit_preauth import ( - DepositPreauth, - MDDepositPreauthFields, -) -from xrpl.models.ledger_objects.directory_node import ( - DirectoryNode, - MDDirectoryNodeFields, -) -from xrpl.models.ledger_objects.escrow import Escrow, MDEscrowFields -from xrpl.models.ledger_objects.fee_settings import FeeSettings, MDFeeSettingsFields +from xrpl.models.ledger_objects.account_root import AccountRoot, AccountRootFlags +from xrpl.models.ledger_objects.amendments import Amendments, Majority +from xrpl.models.ledger_objects.check import Check +from xrpl.models.ledger_objects.deposit_preauth import DepositPreauth +from xrpl.models.ledger_objects.directory_node import DirectoryNode +from xrpl.models.ledger_objects.escrow import Escrow +from xrpl.models.ledger_objects.fee_settings import FeeSettings from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_hashes import LedgerHashes, MDLedgerHashesFields -from xrpl.models.ledger_objects.negative_unl import ( - DisabledValidator, - MDNegativeUNLFields, - NegativeUNL, -) +from xrpl.models.ledger_objects.ledger_hashes import LedgerHashes +from xrpl.models.ledger_objects.negative_unl import DisabledValidator, NegativeUNL from xrpl.models.ledger_objects.nftoken_offer import ( - MDNFTokenOfferFields, NFToken, NFTokenOffer, NFTokenOfferFlags, ) -from xrpl.models.ledger_objects.nftoken_page import MDNFTokenPageFields, NFTokenPage -from xrpl.models.ledger_objects.offer import MDOfferFields, Offer, OfferFlag -from xrpl.models.ledger_objects.pay_channel import MDPayChannelFields, PayChannel -from xrpl.models.ledger_objects.ripple_state import MDRippleStateFields, RippleState +from xrpl.models.ledger_objects.nftoken_page import NFTokenPage +from xrpl.models.ledger_objects.offer import Offer, OfferFlag +from xrpl.models.ledger_objects.pay_channel import PayChannel +from xrpl.models.ledger_objects.ripple_state import RippleState from xrpl.models.ledger_objects.signer_list import ( - MDSignerListFields, SignerEntry, SignerList, SignerListFlag, ) -from xrpl.models.ledger_objects.ticket import MDTicketFields, Ticket +from xrpl.models.ledger_objects.ticket import Ticket __all__ = [ "AccountRoot", - "MDAccountRootFields", "AccountRootFlags", "Amendments", - "MDAmendmentsFields", "Check", - "MDCheckFields", "DepositPreauth", - "MDDepositPreauthFields", "DirectoryNode", - "MDDirectoryNodeFields", "DisabledValidator", "Escrow", - "MDEscrowFields", "FeeSettings", - "MDFeeSettingsFields", "LedgerEntryType", "LedgerHashes", - "MDLedgerHashesFields", "Majority", "NegativeUNL", - "MDNegativeUNLFields", "NFToken", "NFTokenOffer", - "MDNFTokenOfferFields", "NFTokenOfferFlags", "NFTokenPage", - "MDNFTokenPageFields", "Offer", - "MDOfferFields", "OfferFlag", "PayChannel", - "MDPayChannelFields", "RippleState", - "MDRippleStateFields", "SignerEntry", "SignerList", - "MDSignerListFields", "SignerListFlag", "Ticket", - "MDTicketFields", ] diff --git a/xrpl/models/ledger_objects/account_root.py b/xrpl/models/ledger_objects/account_root.py index 0f45a6c6d..de7b5e201 100644 --- a/xrpl/models/ledger_objects/account_root.py +++ b/xrpl/models/ledger_objects/account_root.py @@ -42,36 +42,6 @@ class AccountRoot(LedgerObject): ) -@require_kwargs_on_init -@dataclass(frozen=True) -class MDAccountRootFields(LedgerObject): - """ - The model for the `AccountRoot` Ledger Object when - represented in a transaction's metadata. - """ - - account: Optional[str] = None - balance: Optional[str] = None - flags: Optional[Union[int, AccountRootFlags]] = None - owner_count: Optional[int] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - sequence: Optional[int] = None - account_txn_id: Optional[str] = None - burned_nftokens: Optional[int] = None - domain: Optional[str] = None - email_hash: Optional[str] = None - message_key: Optional[str] = None - minted_nftokens: Optional[int] = None - nftoken_minter: Optional[str] = None - regular_key: Optional[str] = None - ticket_count: Optional[int] = None - ticket_size: Optional[int] = None - transfer_rate: Optional[int] = None - wallet_locator: Optional[str] = None - wallet_size: Optional[int] = None - - class AccountRootFlags(Enum): """The flags for the `AccountRoot` Ledger Object""" diff --git a/xrpl/models/ledger_objects/amendments.py b/xrpl/models/ledger_objects/amendments.py index 5036c8c93..9c21010f9 100644 --- a/xrpl/models/ledger_objects/amendments.py +++ b/xrpl/models/ledger_objects/amendments.py @@ -27,20 +27,6 @@ class Amendments(LedgerObject): ) -@require_kwargs_on_init -@dataclass(frozen=True) -class MDAmendmentsFields(LedgerObject): - """ - The model for the `Amendments` Ledger Object when - represented in a transaction's metadata. - """ - - # always 0 - flags: Optional[int] = None - amendments: Optional[List[str]] = None - majorities: Optional[List[Majority]] = None - - @require_kwargs_on_init @dataclass(frozen=True) class Majority(NestedModel): diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index 777d4fe7a..8daf794ef 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -35,27 +35,3 @@ class Check(LedgerObject): default=LedgerEntryType.CHECK, init=False, ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDCheckFields(LedgerObject): - """ - The model for the `Check` Ledger Object when - represented in a transaction's metadata. - """ - - account: Optional[str] = None - destination: Optional[str] = None - # always 0 - flags: Optional[int] = None - owner_node: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - send_max: Optional[Union[str, IssuedCurrencyAmount]] = None - sequence: Optional[int] = None - destination_node: Optional[str] = None - destination_tag: Optional[int] = None - expiration: Optional[int] = None - invoice_id: Optional[str] = None - source_tag: Optional[int] = None diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py index 3c67c1eaa..ae2086235 100644 --- a/xrpl/models/ledger_objects/deposit_preauth.py +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -3,7 +3,6 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject @@ -27,20 +26,3 @@ class DepositPreauth(LedgerObject): default=LedgerEntryType.DEPOSIT_PREAUTH, init=False, ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDDepositPreauthFields(LedgerObject): - """ - The model for the `DepositPreauth` Ledger Object when - represented in a transaction's metadata. - """ - - account: Optional[str] = None - authorize: Optional[str] = None - # always 0 - flags: Optional[int] = None - owner_node: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None diff --git a/xrpl/models/ledger_objects/directory_node.py b/xrpl/models/ledger_objects/directory_node.py index 38c5f14f5..ac15d879d 100644 --- a/xrpl/models/ledger_objects/directory_node.py +++ b/xrpl/models/ledger_objects/directory_node.py @@ -32,25 +32,3 @@ class DirectoryNode(LedgerObject): default=LedgerEntryType.DIRECTORY_NODE, init=False, ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDDirectoryNodeFields(LedgerObject): - """ - The model for the `DirectoryNode` Ledger Object when - represented in a transaction's metadata. - """ - - # always 0 - flags: Optional[int] = None - root_index: Optional[str] = None - indexes: Optional[List[str]] = None - index_next: Optional[int] = None - index_previous: Optional[int] = None - owner: Optional[str] = None - exchange_rate: Optional[str] = None - taker_pays_currency: Optional[str] = None - taker_pays_issuer: Optional[str] = None - taker_gets_currency: Optional[str] = None - taker_gets_issuer: Optional[str] = None diff --git a/xrpl/models/ledger_objects/escrow.py b/xrpl/models/ledger_objects/escrow.py index 4ee7211a4..4f76a2dc0 100644 --- a/xrpl/models/ledger_objects/escrow.py +++ b/xrpl/models/ledger_objects/escrow.py @@ -33,27 +33,3 @@ class Escrow(LedgerObject): ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.ESCROW, init=False ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDEscrowFields(LedgerObject): - """ - The model for the `Escrow` Ledger Object when - represented in a transaction's metadata. - """ - - account: Optional[str] = None - amount: Optional[str] = None - destination: Optional[str] = None - # always 0 - flags: Optional[int] = None - owner_node: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - condition: Optional[str] = None - cancel_after: Optional[int] = None - destination_node: Optional[str] = None - destination_tag: Optional[int] = None - finish_after: Optional[int] = None - source_tag: Optional[int] = None diff --git a/xrpl/models/ledger_objects/fee_settings.py b/xrpl/models/ledger_objects/fee_settings.py index 0ccdbb877..891ef32f9 100644 --- a/xrpl/models/ledger_objects/fee_settings.py +++ b/xrpl/models/ledger_objects/fee_settings.py @@ -3,7 +3,6 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject @@ -25,19 +24,3 @@ class FeeSettings(LedgerObject): ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.FEE_SETTINGS, init=False ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDFeeSettingsFields(LedgerObject): - """ - The model for the `FeeSettings` Ledger Object when - represented in a transaction's metadata. - """ - - base_fee: Optional[str] = None - # always 0 - flags: Optional[int] = None - reference_fee_units: Optional[int] = None - reserve_base: Optional[int] = None - reserve_increment: Optional[int] = None diff --git a/xrpl/models/ledger_objects/ledger_hashes.py b/xrpl/models/ledger_objects/ledger_hashes.py index e9889c76c..4d668440e 100644 --- a/xrpl/models/ledger_objects/ledger_hashes.py +++ b/xrpl/models/ledger_objects/ledger_hashes.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import List, Optional +from typing import List from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject @@ -25,18 +25,3 @@ class LedgerHashes(LedgerObject): default=LedgerEntryType.LEDGER_HASHES, init=False, ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDLedgerHashesFields(LedgerObject): - """ - The model for the `LedgerHashes` Ledger Object when - represented in a transaction's metadata. - """ - - first_ledger_sequence: Optional[int] = None - last_ledger_sequence: Optional[int] = None - hashes: Optional[List[str]] = None - # always 0 - flags: Optional[int] = None diff --git a/xrpl/models/ledger_objects/negative_unl.py b/xrpl/models/ledger_objects/negative_unl.py index 57d95f827..99f252394 100644 --- a/xrpl/models/ledger_objects/negative_unl.py +++ b/xrpl/models/ledger_objects/negative_unl.py @@ -26,20 +26,6 @@ class NegativeUNL(LedgerObject): ) -@require_kwargs_on_init -@dataclass(frozen=True) -class MDNegativeUNLFields(LedgerObject): - """ - The model for the `NegativeUNL` Ledger Object when - represented in a transaction's metadata. - """ - - flags: Optional[int] = None - disabled_validators: Optional[List[DisabledValidator]] = None - validator_to_disable: Optional[str] = None - validator_to_enable: Optional[str] = None - - @require_kwargs_on_init @dataclass(frozen=True) class DisabledValidator(NestedModel): diff --git a/xrpl/models/ledger_objects/nftoken_offer.py b/xrpl/models/ledger_objects/nftoken_offer.py index b6a64c666..4f6c9c838 100644 --- a/xrpl/models/ledger_objects/nftoken_offer.py +++ b/xrpl/models/ledger_objects/nftoken_offer.py @@ -34,26 +34,6 @@ class NFTokenOffer(LedgerObject): ) -@require_kwargs_on_init -@dataclass(frozen=True) -class MDNFTokenOfferFields(LedgerObject): - """ - The model for the `NFTokenOffer` Ledger Object when - represented in a transaction's metadata. - """ - - amount: Optional[Union[str, NFToken]] = None - flags: Optional[int] = None - nftoken_id: Optional[str] = None - owner: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - destination: Optional[str] = None - expiration: Optional[int] = None - owner_node: Optional[str] = None - nftoken_offer_node: Optional[str] = None - - @require_kwargs_on_init @dataclass(frozen=True) class NFToken(BaseModel): # diff --git a/xrpl/models/ledger_objects/nftoken_page.py b/xrpl/models/ledger_objects/nftoken_page.py index f9fa29798..ff8e68f46 100644 --- a/xrpl/models/ledger_objects/nftoken_page.py +++ b/xrpl/models/ledger_objects/nftoken_page.py @@ -27,20 +27,3 @@ class NFTokenPage(LedgerObject): default=LedgerEntryType.NFTOKEN_PAGE, init=False, ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDNFTokenPageFields(LedgerObject): - """ - The model for the `NFTokenPage` Ledger Object when - represented in a transaction's metadata. - """ - - previous_page_min: Optional[str] = None - next_page_min: Optional[str] = None - previous_token_page: Optional[str] = None - previous_token_next: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - nftokens: Optional[List[NFToken]] = None diff --git a/xrpl/models/ledger_objects/offer.py b/xrpl/models/ledger_objects/offer.py index 5c1afd382..1a7055bd7 100644 --- a/xrpl/models/ledger_objects/offer.py +++ b/xrpl/models/ledger_objects/offer.py @@ -35,27 +35,6 @@ class Offer(LedgerObject): ) -@require_kwargs_on_init -@dataclass(frozen=True) -class MDOfferFields(LedgerObject): - """ - The model for the `Offer` Ledger Object when - represented in a transaction's metadata. - """ - - account: Optional[str] = None - taker_gets: Optional[Union[str, IssuedCurrencyAmount]] = None - taker_pays: Optional[Union[str, IssuedCurrencyAmount]] = None - sequence: Optional[int] = None - flags: Optional[int] = None - book_directory: Optional[str] = None - book_node: Optional[str] = None - owner_node: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - expiration: Optional[int] = None - - class OfferFlag(Enum): """The flags for the `Offer` Ledger Object""" diff --git a/xrpl/models/ledger_objects/pay_channel.py b/xrpl/models/ledger_objects/pay_channel.py index 9f9e3375f..e0c672058 100644 --- a/xrpl/models/ledger_objects/pay_channel.py +++ b/xrpl/models/ledger_objects/pay_channel.py @@ -36,29 +36,3 @@ class PayChannel(LedgerObject): default=LedgerEntryType.PAY_CHANNEL, init=False, ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDPayChannelFields(LedgerObject): - """ - The model for the `PayChannel` Ledger Object when - represented in a transaction's metadata. - """ - - account: Optional[str] = None - amount: Optional[str] = None - balance: Optional[str] = None - destination: Optional[str] = None - # always 0 - flags: Optional[int] = None - owner_node: Optional[str] = None - public_key: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - settle_delay: Optional[int] = None - destination_node: Optional[str] = None - destination_tag: Optional[int] = None - expiration: Optional[int] = None - cancel_after: Optional[int] = None - source_tag: Optional[int] = None diff --git a/xrpl/models/ledger_objects/ripple_state.py b/xrpl/models/ledger_objects/ripple_state.py index 97df04cda..bc8985b9b 100644 --- a/xrpl/models/ledger_objects/ripple_state.py +++ b/xrpl/models/ledger_objects/ripple_state.py @@ -36,28 +36,6 @@ class RippleState(LedgerObject): ) -@require_kwargs_on_init -@dataclass(frozen=True) -class MDRippleStateFields(LedgerObject): - """ - The model for the `RippleState` Ledger Object when - represented in a transaction's metadata. - """ - - balance: Optional[IssuedCurrencyAmount] = None - flags: Optional[int] = None - low_limit: Optional[IssuedCurrencyAmount] = None - high_limit: Optional[IssuedCurrencyAmount] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - high_node: Optional[str] = None - low_node: Optional[str] = None - high_quality_in: Optional[int] = None - high_quality_out: Optional[int] = None - low_quality_in: Optional[int] = None - low_quality_out: Optional[int] = None - - class RippleStateFlag(Enum): """The flags for the `RippleState` Ledger Object""" diff --git a/xrpl/models/ledger_objects/signer_list.py b/xrpl/models/ledger_objects/signer_list.py index 2aa85a43d..ab71d631f 100644 --- a/xrpl/models/ledger_objects/signer_list.py +++ b/xrpl/models/ledger_objects/signer_list.py @@ -4,7 +4,7 @@ from dataclasses import dataclass, field from enum import Enum -from typing import List, Optional +from typing import List from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject @@ -31,23 +31,6 @@ class SignerList(LedgerObject): ) -@require_kwargs_on_init -@dataclass(frozen=True) -class MDSignerListFields(LedgerObject): - """ - The model for the `SignerList` Ledger Object when - represented in a transaction's metadata. - """ - - flags: Optional[int] = None - owner_node: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - signer_entries: Optional[List[SignerEntry]] = None - signer_list_id: Optional[int] = None - signer_quorum: Optional[int] = None - - class SignerListFlag(Enum): """The flags for the `SignerList` Ledger Object""" diff --git a/xrpl/models/ledger_objects/ticket.py b/xrpl/models/ledger_objects/ticket.py index 4fbed5790..fcd000bdb 100644 --- a/xrpl/models/ledger_objects/ticket.py +++ b/xrpl/models/ledger_objects/ticket.py @@ -3,7 +3,6 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject @@ -27,20 +26,3 @@ class Ticket(LedgerObject): default=LedgerEntryType.TICKET, init=False, ) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class MDTicketFields(LedgerObject): - """ - The model for the `Ticket` Ledger Object when - represented in a transaction's metadata. - """ - - account: Optional[str] = None - # always 0 - flags: Optional[int] = None - owner_node: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - ticket_sequence: Optional[int] = None From da60b009227ba031162bb978a0f1967f397d44aa Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Tue, 16 Jan 2024 11:51:47 -0500 Subject: [PATCH 05/58] remove optional type from ledger_entry_type --- xrpl/models/ledger_objects/ledger_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index 428b691f5..c310a1f9f 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -22,7 +22,7 @@ class LedgerObject(BaseModel): """The base model for a Ledger Object.""" # TODO: Try without optional - ledger_entry_type: Optional[LedgerEntryType] = None + ledger_entry_type: LedgerEntryType = None index: Optional[str] = None @classmethod From 361d429b87ed0d97773384d13905ad0edabe24d2 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 18 Jan 2024 21:29:28 -0500 Subject: [PATCH 06/58] add AMM ledger object --- tests/unit/models/test_ledger_object.py | 84 +++++++++++ xrpl/models/ledger_objects/__init__.py | 2 + xrpl/models/ledger_objects/amm.py | 135 ++++++++++++++++++ .../ledger_objects/ledger_entry_type.py | 1 + 4 files changed, 222 insertions(+) create mode 100644 xrpl/models/ledger_objects/amm.py diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 70141b876..68e90f03f 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -1,7 +1,11 @@ from unittest import TestCase from xrpl.models import IssuedCurrencyAmount +from xrpl.models.auth_account import AuthAccount +from xrpl.models.currencies.issued_currency import IssuedCurrency +from xrpl.models.currencies.xrp import XRP from xrpl.models.ledger_objects import ( + AMM, AccountRoot, Amendments, Check, @@ -23,6 +27,7 @@ SignerList, Ticket, ) +from xrpl.models.ledger_objects.amm import AuctionSlot, VoteEntry account_root_json = { "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", @@ -65,6 +70,43 @@ "index": "7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", } +amm_json = { + "account": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + "asset": {"currency": "XRP"}, + "asset2": {"currency": "TST", "issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"}, + "auction_slot": { + "account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + "auth_accounts": [ + {"auth_account": {"account": "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"}}, + {"auth_account": {"account": "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"}}, + ], + "discounted_fee": 0, + "expiration": 721870180, + "price": { + "currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2", + "issuer": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + "value": "0.8696263565463045", + }, + }, + "lptoken_balance": { + "currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2", + "issuer": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + "value": "71150.53584131501", + }, + "trading_fee": 600, + "vote_slots": [ + { + "vote_entry": { + "account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + "trading_fee": 600, + "vote_weight": 100000, + } + } + ], + "flags": 0, + "ledger_entry_type": "AMM", +} + check_json = { "account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", "destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", @@ -368,6 +410,48 @@ def test_amendments(self): self.assertEqual(actual, expected) self.assertEqual(amendment_json, expected.to_dict()) + def test_amm(self): + actual = AMM.from_dict(amm_json) + expected = AMM( + account="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + asset=XRP(), + asset2=IssuedCurrency( + currency="TST", + issuer="rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd", + ), + auction_slot=AuctionSlot( + account="rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + auth_accounts=[ + AuthAccount(account="rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"), + AuthAccount(account="rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"), + ], + discounted_fee=0, + expiration=721870180, + price=IssuedCurrencyAmount( + currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", + issuer="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + value="0.8696263565463045", + ), + ), + flags=0, + lptoken_balance=IssuedCurrencyAmount( + currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", + issuer="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + value="71150.53584131501", + ), + trading_fee=600, + vote_slots=[ + VoteEntry( + account="rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + trading_fee=600, + vote_weight=100000, + ), + ], + ) + self.maxDiff = None + self.assertEqual(actual, expected) + self.assertEqual(amm_json, expected.to_dict()) + def test_check(self): actual = Check.from_dict(check_json) expected = Check( diff --git a/xrpl/models/ledger_objects/__init__.py b/xrpl/models/ledger_objects/__init__.py index 6d8a5ab1c..623df86a9 100644 --- a/xrpl/models/ledger_objects/__init__.py +++ b/xrpl/models/ledger_objects/__init__.py @@ -2,6 +2,7 @@ from xrpl.models.ledger_objects.account_root import AccountRoot, AccountRootFlags from xrpl.models.ledger_objects.amendments import Amendments, Majority +from xrpl.models.ledger_objects.amm import AMM from xrpl.models.ledger_objects.check import Check from xrpl.models.ledger_objects.deposit_preauth import DepositPreauth from xrpl.models.ledger_objects.directory_node import DirectoryNode @@ -30,6 +31,7 @@ "AccountRoot", "AccountRootFlags", "Amendments", + "AMM", "Check", "DepositPreauth", "DirectoryNode", diff --git a/xrpl/models/ledger_objects/amm.py b/xrpl/models/ledger_objects/amm.py new file mode 100644 index 000000000..6e08dfd01 --- /dev/null +++ b/xrpl/models/ledger_objects/amm.py @@ -0,0 +1,135 @@ +"""Models for the Ledger Object `Amendments`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import List, Optional + +from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount +from xrpl.models.auth_account import AuthAccount +from xrpl.models.base_model import BaseModel +from xrpl.models.currencies import Currency +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.nested_model import NestedModel +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class AMM(LedgerObject): + """The model for the `AMM` Ledger Object""" + + account: str = REQUIRED # type: ignore + """ + The address of the special account that holds this AMM's assets. + This field is required. + """ + + asset: Currency = REQUIRED # type: ignore + """ + The definition for one of the two assets this AMM holds. This field is required. + """ + + asset2: Currency = REQUIRED # type: ignore + """ + The definition for the other asset this AMM holds. This field is required. + """ + + auction_slot: Optional[AuctionSlot] = None + + lptoken_balance: IssuedCurrencyAmount = REQUIRED # type: ignore + """ + The total outstanding balance of liquidity provider tokens from this AMM instance. + The holders of these tokens can vote on the AMM's trading fee in proportion to + their holdings, or redeem the tokens for a share of the AMM's assets which grows + with the trading fees collected. This field is required. + """ + + trading_fee: int = REQUIRED # type: ignore + """ + The percentage fee to be charged for trades against this AMM instance, in units + of 1/100,000. The maximum value is 1000, for a 1% fee. This field is required. + """ + + vote_slots: Optional[List[VoteEntry]] = None + """ + A list of vote objects, representing votes on the pool's trading fee. + """ + + flags: int = REQUIRED # type: ignore + """ + A bit-map of boolean flags. No flags are defined for the AMM object + type, so this value is always 0. This field is required. + """ + + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.AMM, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class AuctionSlot(BaseModel): + """ + The model for the `AuctionSlot` object + Details of the current owner of the auction slot. + """ + + account: str = REQUIRED # type: ignore + """ + The current owner of this auction slot. This field is required. + """ + + auth_accounts: Optional[List[AuthAccount]] = None + """ + A list of at most 4 additional accounts that are authorized to trade at the + discounted fee for this AMM instance. + """ + + discounted_fee: int = REQUIRED # type: ignore + """ + The trading fee to be charged to the auction owner, in the same format as + TradingFee. + By default this is 0, meaning that the auction owner can trade at no fee instead of + the standard fee for this AMM. This field is required. + """ + + expiration: int = REQUIRED # type: ignore + """ + The time when this slot expires, in seconds since the Ripple Epoch. + This field is required. + """ + + price: IssuedCurrencyAmount = REQUIRED # type: ignore + """ + The amount the auction owner paid to win this slot, in LP Tokens. + This field is required. + """ + + +@require_kwargs_on_init +@dataclass(frozen=True) +class VoteEntry(NestedModel): + """A model for the `VoteEntry` object""" + + account: str = REQUIRED # type: ignore + """ + The account that cast the vote. This field is required. + """ + + trading_fee: int = REQUIRED # type: ignore + """ + The proposed trading fee, in units of 1/100,000; a value of 1 is equivalent + to 0.001%. The maximum value is 1000, indicating a 1% fee. This field is required. + """ + + vote_weight: int = REQUIRED # type: ignore + """ + The weight of the vote, in units of 1/100,000. For example, a value of 1234 means + this vote counts as 1.234% of the weighted total vote. The weight is determined by + the percentage of this AMM's LP Tokens the account owns. The maximum value is + 100000. This field is required. + """ diff --git a/xrpl/models/ledger_objects/ledger_entry_type.py b/xrpl/models/ledger_objects/ledger_entry_type.py index 63b92f6f3..7fe89778a 100644 --- a/xrpl/models/ledger_objects/ledger_entry_type.py +++ b/xrpl/models/ledger_objects/ledger_entry_type.py @@ -8,6 +8,7 @@ class LedgerEntryType(str, Enum): ACCOUNT_ROOT = "AccountRoot" AMENDMENTS = "Amendments" + AMM = "AMM" CHECK = "Check" DEPOSIT_PREAUTH = "DepositPreauth" DIRECTORY_NODE = "DirectoryNode" From 92e435af61b5f44a0d66e9df1a508e7fd292fc55 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Fri, 19 Jan 2024 13:09:58 -0500 Subject: [PATCH 07/58] add DID ledger object --- tests/unit/models/test_ledger_object.py | 33 ++++++++- xrpl/models/ledger_objects/__init__.py | 2 + xrpl/models/ledger_objects/did.py | 70 +++++++++++++++++++ .../ledger_objects/ledger_entry_type.py | 1 + 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 xrpl/models/ledger_objects/did.py diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 68e90f03f..0bc5e1092 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -6,6 +6,7 @@ from xrpl.models.currencies.xrp import XRP from xrpl.models.ledger_objects import ( AMM, + DID, AccountRoot, Amendments, Check, @@ -137,6 +138,20 @@ "index": "4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", } +did_json = { + "account": "rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", + "did_document": "646F63", + "data": "617474657374", + "flags": 0, + "ledger_entry_type": "DID", + "owner_node": "0", + "previous_txn_id": "A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B0" + "9F708778E41120", + "previous_txn_lgr_seq": 4, + "uri": "6469645F6578616D706C65", + "index": "46813BE38B798B3752CA590D44E7FEADB17485649074403AD1761A2835CE91FF", +} + directory_node_json = { "exchange_rate": "4F069BA8FF484000", "flags": 0, @@ -448,7 +463,6 @@ def test_amm(self): ), ], ) - self.maxDiff = None self.assertEqual(actual, expected) self.assertEqual(amm_json, expected.to_dict()) @@ -490,6 +504,23 @@ def test_deposit_preauth(self): self.assertEqual(actual, expected) self.assertEqual(deposit_preauth_json, expected.to_dict()) + def test_did(self): + actual = DID.from_dict(did_json) + expected = DID( + account="rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", + did_document="646F63", + data="617474657374", + flags=0, + owner_node="0", + previous_txn_id="A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B09F" + "708778E41120", + previous_txn_lgr_seq=4, + uri="6469645F6578616D706C65", + index="46813BE38B798B3752CA590D44E7FEADB17485649074403AD1761A2835CE91FF", + ) + self.assertEqual(actual, expected) + self.assertEqual(did_json, expected.to_dict()) + def test_directory_node(self): actual = DirectoryNode.from_dict(directory_node_json) expected = DirectoryNode( diff --git a/xrpl/models/ledger_objects/__init__.py b/xrpl/models/ledger_objects/__init__.py index 623df86a9..6dd3e5a76 100644 --- a/xrpl/models/ledger_objects/__init__.py +++ b/xrpl/models/ledger_objects/__init__.py @@ -5,6 +5,7 @@ from xrpl.models.ledger_objects.amm import AMM from xrpl.models.ledger_objects.check import Check from xrpl.models.ledger_objects.deposit_preauth import DepositPreauth +from xrpl.models.ledger_objects.did import DID from xrpl.models.ledger_objects.directory_node import DirectoryNode from xrpl.models.ledger_objects.escrow import Escrow from xrpl.models.ledger_objects.fee_settings import FeeSettings @@ -34,6 +35,7 @@ "AMM", "Check", "DepositPreauth", + "DID", "DirectoryNode", "DisabledValidator", "Escrow", diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py new file mode 100644 index 000000000..ec929c778 --- /dev/null +++ b/xrpl/models/ledger_objects/did.py @@ -0,0 +1,70 @@ +"""Models for the Ledger Object `Amendments`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class DID(LedgerObject): + """The model for the `DID` Ledger Object""" + + account: str = REQUIRED # type: ignore + """ + The account that controls the DID. This field is required. + """ + + did_document: Optional[str] = None + """ + The W3C standard DID document associated with the DID. The DIDDocument field isn't + checked for validity and is limited to a maximum length of 256 bytes. + """ + + data: Optional[str] = None + """ + The public attestations of identity credentials associated with the DID. The Data + field isn't checked for validity and is limited to a maximum length of 256 bytes. + """ + + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the sender's owner directory links to this entry, + in case the directory consists of multiple pages. + """ + + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this object. + This field is required. + """ + + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this object. + """ + + flags: int = REQUIRED # type: ignore + """ + Flags is always 0 since there are no flags defined for DID entries. + """ + + uri: Optional[str] = None + """ + The Universal Resource Identifier that points to the corresponding DID document or + the data associated with the DID. This field can be an HTTP(S) URL or IPFS URI. + This field isn't checked for validity and is limited to a maximum length of 256 + bytes. + """ + + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.DID, + init=False, + ) diff --git a/xrpl/models/ledger_objects/ledger_entry_type.py b/xrpl/models/ledger_objects/ledger_entry_type.py index 7fe89778a..9c9656d5b 100644 --- a/xrpl/models/ledger_objects/ledger_entry_type.py +++ b/xrpl/models/ledger_objects/ledger_entry_type.py @@ -11,6 +11,7 @@ class LedgerEntryType(str, Enum): AMM = "AMM" CHECK = "Check" DEPOSIT_PREAUTH = "DepositPreauth" + DID = "DID" DIRECTORY_NODE = "DirectoryNode" ESCROW = "Escrow" FEE_SETTINGS = "FeeSettings" From 182aa4e9ebe0b5bc3d5e60b1b1ca4d0fc1cfc8fb Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 22 Jan 2024 21:19:30 -0500 Subject: [PATCH 08/58] add Bridge ledger object --- tests/unit/models/test_ledger_object.py | 49 ++++++++++ xrpl/models/ledger_objects/__init__.py | 1 + xrpl/models/ledger_objects/bridge.py | 97 +++++++++++++++++++ .../ledger_objects/ledger_entry_type.py | 1 + 4 files changed, 148 insertions(+) create mode 100644 xrpl/models/ledger_objects/bridge.py diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 0bc5e1092..ad31fe0e2 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -29,6 +29,8 @@ Ticket, ) from xrpl.models.ledger_objects.amm import AuctionSlot, VoteEntry +from xrpl.models.ledger_objects.bridge import Bridge +from xrpl.models.xchain_bridge import XChainBridge account_root_json = { "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", @@ -108,6 +110,28 @@ "ledger_entry_type": "AMM", } +bridge_json = { + "account": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + "flags": 0, + "ledger_entry_type": "Bridge", + "min_account_create_amount": "2000000000", + "owner_node": "0", + "previous_txn_id": "67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE917FD1A71919EAE7548E56" + "36", + "previous_txn_lgr_seq": 102, + "signature_reward": "204", + "xchain_account_claim_count": "0", + "xchain_account_create_count": "0", + "xchain_bridge": { + "issuing_chain_door": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "issuing_chain_issue": {"currency": "XRP"}, + "locking_chain_door": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + "locking_chain_issue": {"currency": "XRP"}, + }, + "xchain_claim_id": "1", + "index": "9F2C9E23343852036AFD323025A8506018ABF9D4DBAA746D61BF1CFB5C297D10", +} + check_json = { "account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", "destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", @@ -466,6 +490,31 @@ def test_amm(self): self.assertEqual(actual, expected) self.assertEqual(amm_json, expected.to_dict()) + def test_bridge(self): + actual = Bridge.from_dict(bridge_json) + expected = Bridge( + account="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + flags=0, + min_account_create_amount="2000000000", + owner_node="0", + previous_txn_id="67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE917FD1A71919EAE75" + "48E5636", + previous_txn_lgr_seq=102, + signature_reward="204", + xchain_account_claim_count="0", + xchain_account_create_count="0", + xchain_bridge=XChainBridge( + issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + issuing_chain_issue=XRP(), + locking_chain_door="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + locking_chain_issue=XRP(), + ), + xchain_claim_id="1", + index="9F2C9E23343852036AFD323025A8506018ABF9D4DBAA746D61BF1CFB5C297D10", + ) + self.assertEqual(actual, expected) + self.assertEqual(bridge_json, expected.to_dict()) + def test_check(self): actual = Check.from_dict(check_json) expected = Check( diff --git a/xrpl/models/ledger_objects/__init__.py b/xrpl/models/ledger_objects/__init__.py index 6dd3e5a76..97ac77c8a 100644 --- a/xrpl/models/ledger_objects/__init__.py +++ b/xrpl/models/ledger_objects/__init__.py @@ -3,6 +3,7 @@ from xrpl.models.ledger_objects.account_root import AccountRoot, AccountRootFlags from xrpl.models.ledger_objects.amendments import Amendments, Majority from xrpl.models.ledger_objects.amm import AMM +from xrpl.models.ledger_objects.bridge import Bridge from xrpl.models.ledger_objects.check import Check from xrpl.models.ledger_objects.deposit_preauth import DepositPreauth from xrpl.models.ledger_objects.did import DID diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py new file mode 100644 index 000000000..34d828ff1 --- /dev/null +++ b/xrpl/models/ledger_objects/bridge.py @@ -0,0 +1,97 @@ +"""Models for the Ledger Object `Amendments`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional, Union + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge + + +@require_kwargs_on_init +@dataclass(frozen=True) +class Bridge(LedgerObject): + """The model for the `DID` Ledger Object""" + + account: str = REQUIRED # type: ignore + """ + The account that submitted the XChainCreateBridge transaction on the blockchain. + This field is required. + """ + + min_account_create_amount: Optional[str] = None + """ + The minimum amount, in XRP, required for an XChainAccountCreateCommit transaction. + If this isn't present, the XChainAccountCreateCommit transaction will fail. + This field can only be present on XRP-XRP bridges. + """ + + signature_reward: str = REQUIRED # type: ignore + """ + The total amount, in XRP, to be rewarded for providing a signature for cross-chain + transfer or for signing for the cross-chain reward. This amount will be split among + the signers. This field is required. + """ + + xchain_account_claim_count: Union[int, str] = REQUIRED # type: ignore + """ + A counter used to order the execution of account create transactions. It is + incremented every time a XChainAccountCreateCommit transaction is "claimed" on the + destination chain. When the "claim" transaction is run on the destination chain, + the XChainAccountClaimCount must match the value that the XChainAccountCreateCount + had at the time the XChainAccountClaimCount was run on the source chain. This + orders the claims so that they run in the same order that the + XChainAccountCreateCommit transactions ran on the source chain, to prevent + transaction replay. This field is required. + """ + + xchain_account_create_count: Union[int, str] = REQUIRED # type: ignore + """ + A counter used to order the execution of account create transactions. It is + incremented every time a successful XChainAccountCreateCommit transaction is run + for the source chain. This field is required. + """ + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + A counter used to order the execution of account create transactions. It is + incremented every time a successful XChainAccountCreateCommit transaction is run + for the source chain. This field is required. + """ + + xchain_claim_id: Union[int, str] = REQUIRED # type: ignore + """ + The value of the next XChainClaimID to be created. This field is required. + """ + + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the sender's owner directory links to this entry, + in case the directory consists of multiple pages. + """ + + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this object. + This field is required. + """ + + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this object. + """ + + flags: int = REQUIRED # type: ignore + """ + Flags is always 0 since there are no flags defined for Chain entries. + """ + + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.BRIDGE, + init=False, + ) diff --git a/xrpl/models/ledger_objects/ledger_entry_type.py b/xrpl/models/ledger_objects/ledger_entry_type.py index 9c9656d5b..33921d15c 100644 --- a/xrpl/models/ledger_objects/ledger_entry_type.py +++ b/xrpl/models/ledger_objects/ledger_entry_type.py @@ -9,6 +9,7 @@ class LedgerEntryType(str, Enum): ACCOUNT_ROOT = "AccountRoot" AMENDMENTS = "Amendments" AMM = "AMM" + BRIDGE = "Bridge" CHECK = "Check" DEPOSIT_PREAUTH = "DepositPreauth" DID = "DID" From 2209fc0b036f60719e6503bb65f90fea1d5c8075 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 22 Jan 2024 21:23:45 -0500 Subject: [PATCH 09/58] fix doctring --- xrpl/models/ledger_objects/bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index 34d828ff1..20d18b8b8 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -15,7 +15,7 @@ @require_kwargs_on_init @dataclass(frozen=True) class Bridge(LedgerObject): - """The model for the `DID` Ledger Object""" + """The model for the `Bridge` Ledger Object""" account: str = REQUIRED # type: ignore """ From 167d5d5ad3ffcd4f0f6144d724e2213bd0afa7a0 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 22 Jan 2024 21:28:00 -0500 Subject: [PATCH 10/58] fix typos --- xrpl/models/ledger_objects/amm.py | 2 +- xrpl/models/ledger_objects/bridge.py | 2 +- xrpl/models/ledger_objects/did.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xrpl/models/ledger_objects/amm.py b/xrpl/models/ledger_objects/amm.py index 6e08dfd01..ac8214a93 100644 --- a/xrpl/models/ledger_objects/amm.py +++ b/xrpl/models/ledger_objects/amm.py @@ -1,4 +1,4 @@ -"""Models for the Ledger Object `Amendments`""" +"""Models for the Ledger Object `AMM`""" from __future__ import annotations diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index 20d18b8b8..3fc323be2 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -1,4 +1,4 @@ -"""Models for the Ledger Object `Amendments`""" +"""Models for the Ledger Object `Bridge`""" from __future__ import annotations diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index ec929c778..f24f87284 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -1,4 +1,4 @@ -"""Models for the Ledger Object `Amendments`""" +"""Models for the Ledger Object `DID`""" from __future__ import annotations From d9b44b23150b48eaafff4dd1cfd6143072952159 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Tue, 23 Jan 2024 12:22:18 -0500 Subject: [PATCH 11/58] add XChainOwnedClaimID ledger object --- tests/unit/models/test_ledger_object.py | 92 ++++++++++++ xrpl/models/ledger_objects/__init__.py | 3 + .../ledger_objects/ledger_entry_type.py | 1 + .../ledger_objects/xchain_owned_claim_id.py | 134 ++++++++++++++++++ 4 files changed, 230 insertions(+) create mode 100644 xrpl/models/ledger_objects/xchain_owned_claim_id.py diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index ad31fe0e2..6e4718c8c 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -30,6 +30,10 @@ ) from xrpl.models.ledger_objects.amm import AuctionSlot, VoteEntry from xrpl.models.ledger_objects.bridge import Bridge +from xrpl.models.ledger_objects.xchain_owned_claim_id import ( + XChainClaimProofSig, + XChainOwnedClaimID, +) from xrpl.models.xchain_bridge import XChainBridge account_root_json = { @@ -395,6 +399,50 @@ "index": "", # TODO: Find out if there is an unique index } +xchain_owned_claim_id_json = { + "account": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "flags": 0, + "other_chain_source": "r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", + "owner_node": "0", + "previous_txn_id": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E660" + "70A6", + "previous_txn_lgr_seq": 58673, + "signature_reward": "100", + "xchain_bridge": { + "issuing_chain_door": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "issuing_chain_issue": {"currency": "XRP"}, + "locking_chain_door": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "locking_chain_issue": {"currency": "XRP"}, + }, + "xchain_claim_attestations": [ + { + "xchain_claim_proof_sig": { + "amount": "1000000", + "attestation_reward_account": "rfgjrgEJGDxfUY2U8VEDs7BnB1jiH3ofu6", + "attestation_signer_account": "rfsxNxZ6xB1nTPhTMwQajNnkCxWG8B714n", + "destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "public_key": "025CA526EF20567A50FEC504589F949E0E3401C13EF76DD5FD1CC285" + "0FA485BD7B", + "was_locking_chain_send": 1, + } + }, + { + "xchain_claim_proof_sig": { + "amount": "1000000", + "attestation_reward_account": "rUUL1tP523M8KimERqVS7sxb1tLLmpndyv", + "attestation_signer_account": "rEg5sHxZVTNwRL3BAdMwJatkmWDzHMmzDF", + "destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "public_key": "03D40434A6843638681E2F215310EBC4131AFB12EA85985DA073183B" + "732525F7C9", + "was_locking_chain_send": 1, + }, + }, + ], + "xchain_claim_id": "b5", + "ledger_entry_type": "XChainOwnedClaimID", + "ledger_index": "20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BACB1388F5", +} + class TestFromTODict(TestCase): def test_account_root(self): @@ -826,3 +874,47 @@ def test_ticket(self): ) self.assertEqual(actual, expected) self.assertEqual(ticket_json, expected.to_dict()) + + def test_xchain_owned_claim_id(self): + actual = XChainOwnedClaimID.from_dict(xchain_owned_claim_id_json) + expected = XChainOwnedClaimID( + account="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + flags=0, + other_chain_source="r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", + owner_node="0", + previous_txn_id="1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E6" + "6070A6", + previous_txn_lgr_seq=58673, + signature_reward="100", + xchain_bridge=XChainBridge( + issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + issuing_chain_issue=XRP(), + locking_chain_door="rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + locking_chain_issue=XRP(), + ), + xchain_claim_attestations=[ + XChainClaimProofSig( + amount="1000000", + attestation_reward_account="rfgjrgEJGDxfUY2U8VEDs7BnB1jiH3ofu6", + attestation_signer_account="rfsxNxZ6xB1nTPhTMwQajNnkCxWG8B714n", + destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + public_key="025CA526EF20567A50FEC504589F949E0E3401C13EF76DD5FD1CC2" + "850FA485BD7B", + was_locking_chain_send=1, + ), + XChainClaimProofSig( + amount="1000000", + attestation_reward_account="rUUL1tP523M8KimERqVS7sxb1tLLmpndyv", + attestation_signer_account="rEg5sHxZVTNwRL3BAdMwJatkmWDzHMmzDF", + destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + public_key="03D40434A6843638681E2F215310EBC4131AFB12EA85985DA07318" + "3B732525F7C9", + was_locking_chain_send=1, + ), + ], + xchain_claim_id="b5", + ledger_index="20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BACB13" + "88F5", + ) + self.assertEqual(actual, expected) + self.assertEqual(xchain_owned_claim_id_json, expected.to_dict()) diff --git a/xrpl/models/ledger_objects/__init__.py b/xrpl/models/ledger_objects/__init__.py index 97ac77c8a..21d9a8974 100644 --- a/xrpl/models/ledger_objects/__init__.py +++ b/xrpl/models/ledger_objects/__init__.py @@ -28,12 +28,14 @@ SignerListFlag, ) from xrpl.models.ledger_objects.ticket import Ticket +from xrpl.models.ledger_objects.xchain_owned_claim_id import XChainOwnedClaimID __all__ = [ "AccountRoot", "AccountRootFlags", "Amendments", "AMM", + "Bridge", "Check", "DepositPreauth", "DID", @@ -57,4 +59,5 @@ "SignerList", "SignerListFlag", "Ticket", + "XChainOwnedClaimID", ] diff --git a/xrpl/models/ledger_objects/ledger_entry_type.py b/xrpl/models/ledger_objects/ledger_entry_type.py index 33921d15c..6f71fbcdb 100644 --- a/xrpl/models/ledger_objects/ledger_entry_type.py +++ b/xrpl/models/ledger_objects/ledger_entry_type.py @@ -25,3 +25,4 @@ class LedgerEntryType(str, Enum): RIPPLE_STATE = "RippleState" SIGNER_LIST = "SignerList" TICKET = "Ticket" + XCHAIN_OWNED_CLAIM_ID = "XChainOwnedClaimID" diff --git a/xrpl/models/ledger_objects/xchain_owned_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_claim_id.py new file mode 100644 index 000000000..adf934ff4 --- /dev/null +++ b/xrpl/models/ledger_objects/xchain_owned_claim_id.py @@ -0,0 +1,134 @@ +"""Models for the Ledger Object `XChainOwnedClaimID`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import List, Optional, Union + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.nested_model import NestedModel +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainOwnedClaimID(LedgerObject): + """The model for the `XChainOwnedClaimID` Ledger Object""" + + account: str = REQUIRED # type: ignore + """ + The account that owns this object. This field is required. + """ + + ledger_index: str = REQUIRED # type: ignore + """ + The ledger index is a hash of a unique prefix for XChainOwnedClaimIDs, the actual + XChainClaimID value, and the fields in XChainBridge. This field is required. + """ + + other_chain_source: str = REQUIRED # type: ignore + """ + The account that must send the corresponding XChainCommit on the source chain. The + destination may be specified in the XChainCommit transaction, which means that if + the OtherChainSource isn't specified, another account can try to specify a + different destination and steal the funds. This also allows tracking only a single + set of signatures, since we know which account will send the XChainCommit + transaction. This field is required. + """ + + signature_reward: str = REQUIRED # type: ignore + """ + The total amount to pay the witness servers for their signatures. It must be at + least the value of SignatureReward in the Bridge ledger object. + This field is required. + """ + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The door accounts and assets of the bridge this object correlates to. + This field is required. + """ + + xchain_claim_attestations: List[XChainClaimProofSig] = REQUIRED # type: ignore + """ + Attestations collected from the witness servers. This includes the parameters + needed to recreate the message that was signed, including the amount, which chain + (locking or issuing), optional destination, and reward account for that signature. + This field is required. + """ + + xchain_claim_id: Union[int, str] = REQUIRED # type: ignore + """ + The unique sequence number for a cross-chain transfer. This field is required. + """ + + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the sender's owner directory links to this entry, + in case the directory consists of multiple pages. + """ + + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this object. + This field is required. + """ + + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this object. + """ + + flags: int = REQUIRED # type: ignore + """ + Flags is always 0 since there are no flags defined for Chain entries. + """ + + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.XCHAIN_OWNED_CLAIM_ID, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainClaimProofSig(NestedModel): + """A model for the `XChainClaimProofSig` object""" + + amount: str = REQUIRED # type: ignore + """ + The amount to claim in the `XChainCommit` transaction on the destination chain. + This field is required. + """ + + attestation_reward_account: str = REQUIRED # type: ignore + """ + The account that should receive this signer's share of the `SignatureReward`. + This field is required. + """ + + attestation_signer_account: str = REQUIRED # type: ignore + """ + The account on the door account's signer list that is signing the transaction. + This field is required. + """ + + destination: Optional[str] = None + """ + The destination account for the funds on the destination chain. + """ + + public_key: str = REQUIRED # type: ignore + """ + The public key used to verify the signature. This field is required. + """ + + was_locking_chain_send: int = REQUIRED # type: ignore + """ + A boolean representing the chain where the event occurred. + This field is required. + """ From e51e1708c793ef1178cf5e6a1f4d2ce15f6b796c Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Wed, 24 Jan 2024 22:31:30 -0500 Subject: [PATCH 12/58] add XChainOwnedCreateAccountClaimID ledger object --- tests/unit/models/test_ledger_object.py | 69 ++++++++++ xrpl/models/ledger_objects/__init__.py | 4 + .../ledger_objects/ledger_entry_type.py | 1 + .../ledger_objects/xchain_owned_claim_id.py | 14 +- .../xchain_owned_create_account_claim_id.py | 122 ++++++++++++++++++ 5 files changed, 203 insertions(+), 7 deletions(-) create mode 100644 xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 6e4718c8c..7bcccf94c 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -34,6 +34,10 @@ XChainClaimProofSig, XChainOwnedClaimID, ) +from xrpl.models.ledger_objects.xchain_owned_create_account_claim_id import ( + XChainCreateAccountProofSig, + XChainOwnedCreateAccountClaimID, +) from xrpl.models.xchain_bridge import XChainBridge account_root_json = { @@ -443,6 +447,36 @@ "ledger_index": "20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BACB1388F5", } +xchain_owned_create_account_claim_id_json = { + "ledger_entry_type": "XChainOwnedCreateAccountClaimID", + "ledger_index": "5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166BB6F0C", + "owner_node": "0", + "previous_txn_id": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E660", + "previous_txn_lgr_seq": 58673, + "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "xchain_account_create_count": "66", + "xchain_bridge": { + "issuing_chain_door": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "issuing_chain_issue": {"currency": "XRP"}, + "locking_chain_door": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "locking_chain_issue": {"currency": "XRP"}, + }, + "xchain_create_account_attestations": [ + { + "xchain_create_account_proof_sig": { + "amount": "20000000", + "attestation_reward_account": "rMtYb1vNdeMDpD9tA5qSFm8WXEBdEoKKVw", + "attestation_signer_account": "rL8qTrAvZ8Q1o1H9H9Ahpj3xjgmRvFLvJ3", + "destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "public_key": "021F7CC4033EFBE5E8214B04D1BAAEC14808DC6C02F4ACE930A8" + "EF0F5909B0C438", + "signature_reward": "100", + "was_locking_chain_send": 1, + } + } + ], +} + class TestFromTODict(TestCase): def test_account_root(self): @@ -918,3 +952,38 @@ def test_xchain_owned_claim_id(self): ) self.assertEqual(actual, expected) self.assertEqual(xchain_owned_claim_id_json, expected.to_dict()) + + def test_xchain_owned_create_account_claim_id(self): + actual = XChainOwnedCreateAccountClaimID.from_dict( + xchain_owned_create_account_claim_id_json + ) + expected = XChainOwnedCreateAccountClaimID( + account="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + owner_node="0", + previous_txn_id="1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81D" + "EFA6E660", + previous_txn_lgr_seq=58673, + ledger_index="5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166B" + "B6F0C", + xchain_account_create_count="66", + xchain_bridge=XChainBridge( + issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + issuing_chain_issue=XRP(), + locking_chain_door="rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + locking_chain_issue=XRP(), + ), + xchain_create_account_attestations=[ + XChainCreateAccountProofSig( + amount="20000000", + attestation_reward_account="rMtYb1vNdeMDpD9tA5qSFm8WXEBdEoKKVw", + attestation_signer_account="rL8qTrAvZ8Q1o1H9H9Ahpj3xjgmRvFLvJ3", + destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + public_key="021F7CC4033EFBE5E8214B04D1BAAEC14808DC6C02F4ACE930A8E" + "F0F5909B0C438", + signature_reward="100", + was_locking_chain_send=1, + ) + ], + ) + self.assertEqual(actual, expected) + self.assertEqual(xchain_owned_create_account_claim_id_json, expected.to_dict()) diff --git a/xrpl/models/ledger_objects/__init__.py b/xrpl/models/ledger_objects/__init__.py index 21d9a8974..c3dd96338 100644 --- a/xrpl/models/ledger_objects/__init__.py +++ b/xrpl/models/ledger_objects/__init__.py @@ -29,6 +29,9 @@ ) from xrpl.models.ledger_objects.ticket import Ticket from xrpl.models.ledger_objects.xchain_owned_claim_id import XChainOwnedClaimID +from xrpl.models.ledger_objects.xchain_owned_create_account_claim_id import ( + XChainOwnedCreateAccountClaimID, +) __all__ = [ "AccountRoot", @@ -60,4 +63,5 @@ "SignerListFlag", "Ticket", "XChainOwnedClaimID", + "XChainOwnedCreateAccountClaimID", ] diff --git a/xrpl/models/ledger_objects/ledger_entry_type.py b/xrpl/models/ledger_objects/ledger_entry_type.py index 6f71fbcdb..c19b3bce0 100644 --- a/xrpl/models/ledger_objects/ledger_entry_type.py +++ b/xrpl/models/ledger_objects/ledger_entry_type.py @@ -26,3 +26,4 @@ class LedgerEntryType(str, Enum): SIGNER_LIST = "SignerList" TICKET = "Ticket" XCHAIN_OWNED_CLAIM_ID = "XChainOwnedClaimID" + XCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID = "XChainOwnedCreateAccountClaimID" diff --git a/xrpl/models/ledger_objects/xchain_owned_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_claim_id.py index adf934ff4..e07f2f24c 100644 --- a/xrpl/models/ledger_objects/xchain_owned_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_claim_id.py @@ -25,24 +25,24 @@ class XChainOwnedClaimID(LedgerObject): ledger_index: str = REQUIRED # type: ignore """ - The ledger index is a hash of a unique prefix for XChainOwnedClaimIDs, the actual - XChainClaimID value, and the fields in XChainBridge. This field is required. + The ledger index is a hash of a unique prefix for `XChainOwnedClaimID`s, the actual + `XChainClaimID` value, and the fields in `XChainBridge`. This field is required. """ other_chain_source: str = REQUIRED # type: ignore """ - The account that must send the corresponding XChainCommit on the source chain. The - destination may be specified in the XChainCommit transaction, which means that if - the OtherChainSource isn't specified, another account can try to specify a + The account that must send the corresponding `XChainCommit` on the source chain. The + destination may be specified in the `XChainCommit` transaction, which means that if + the `OtherChainSource` isn't specified, another account can try to specify a different destination and steal the funds. This also allows tracking only a single - set of signatures, since we know which account will send the XChainCommit + set of signatures, since we know which account will send the `XChainCommit` transaction. This field is required. """ signature_reward: str = REQUIRED # type: ignore """ The total amount to pay the witness servers for their signatures. It must be at - least the value of SignatureReward in the Bridge ledger object. + least the value of `SignatureReward` in the `Bridge` ledger object. This field is required. """ diff --git a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py new file mode 100644 index 000000000..bad8e11ae --- /dev/null +++ b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py @@ -0,0 +1,122 @@ +"""Models for the Ledger Object `XChainOwnedCreateAccountClaimID`""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import List, Optional, Union + +from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.nested_model import NestedModel +from xrpl.models.required import REQUIRED +from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainOwnedCreateAccountClaimID(LedgerObject): + """The model for the `XChainOwnedCreateAccountClaimID` Ledger Object""" + + account: str = REQUIRED # type: ignore + """ + The account that owns this object. This field is required. + """ + + ledger_index: str = REQUIRED # type: ignore + """ + The ledger index is a hash of a unique prefix for `XChainOwnedClaimID`s, the actual + `XChainClaimID` value, and the fields in `XChainBridge`. This field is required. + """ + + xchain_account_create_count: Union[int, str] = REQUIRED # type: ignore + """ + An integer that determines the order that accounts created through cross-chain + transfers must be performed. Smaller numbers must execute before larger numbers. + This field is required. + """ + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The door accounts and assets of the bridge this object correlates to. + This field is required. + """ + + xchain_create_account_attestations: List[XChainCreateAccountProofSig] = REQUIRED + # type: ignore + """ + Attestations collected from the witness servers. This includes the parameters + needed to recreate the message that was signed, including the amount, which chain + (locking or issuing), optional destination, and reward account for that signature. + This field is required. + """ + + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the sender's owner directory links to this entry, + in case the directory consists of multiple pages. + """ + + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this object. + This field is required. + """ + + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this object. + """ + + ledger_entry_type: LedgerEntryType = field( + default=LedgerEntryType.XCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, + init=False, + ) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainCreateAccountProofSig(NestedModel): + """A model for the `XChainCreateAccountProofSig` object""" + + amount: str = REQUIRED # type: ignore + """ + The amount to claim in the `XChainCommit` transaction on the destination chain. + This field is required. + """ + + attestation_reward_account: str = REQUIRED # type: ignore + """ + The account that should receive this signer's share of the `SignatureReward`. + This field is required. + """ + + attestation_signer_account: str = REQUIRED # type: ignore + """ + The account on the door account's signer list that is signing the transaction. + This field is required. + """ + + destination: Optional[str] = None + """ + The destination account for the funds on the destination chain. + """ + + public_key: str = REQUIRED # type: ignore + """ + The public key used to verify the signature. This field is required. + """ + + signature_reward: str = REQUIRED # type: ignore + """ + The total amount to pay the witness servers for their signatures. It must be at + least the value of `SignatureReward` in the `Bridge` ledger object. + This field is required. + """ + + was_locking_chain_send: int = REQUIRED # type: ignore + """ + A boolean representing the chain where the event occurred. + This field is required. + """ From 81afbcda23d64f6de246513eb6d2eec32aca5ad6 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Wed, 24 Jan 2024 22:36:10 -0500 Subject: [PATCH 13/58] small docstring updates --- xrpl/models/ledger_objects/bridge.py | 16 ++++++++-------- xrpl/models/ledger_objects/did.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index 3fc323be2..a1bcc68f8 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -19,14 +19,14 @@ class Bridge(LedgerObject): account: str = REQUIRED # type: ignore """ - The account that submitted the XChainCreateBridge transaction on the blockchain. + The account that submitted the `XChainCreateBridge` transaction on the blockchain. This field is required. """ min_account_create_amount: Optional[str] = None """ - The minimum amount, in XRP, required for an XChainAccountCreateCommit transaction. - If this isn't present, the XChainAccountCreateCommit transaction will fail. + The minimum amount, in XRP, required for an `XChainAccountCreateCommit` transaction. + If this isn't present, the `XChainAccountCreateCommit` transaction will fail. This field can only be present on XRP-XRP bridges. """ @@ -40,32 +40,32 @@ class Bridge(LedgerObject): xchain_account_claim_count: Union[int, str] = REQUIRED # type: ignore """ A counter used to order the execution of account create transactions. It is - incremented every time a XChainAccountCreateCommit transaction is "claimed" on the + incremented every time a `XChainAccountCreateCommit` transaction is "claimed" on the destination chain. When the "claim" transaction is run on the destination chain, the XChainAccountClaimCount must match the value that the XChainAccountCreateCount had at the time the XChainAccountClaimCount was run on the source chain. This orders the claims so that they run in the same order that the - XChainAccountCreateCommit transactions ran on the source chain, to prevent + `XChainAccountCreateCommit` transactions ran on the source chain, to prevent transaction replay. This field is required. """ xchain_account_create_count: Union[int, str] = REQUIRED # type: ignore """ A counter used to order the execution of account create transactions. It is - incremented every time a successful XChainAccountCreateCommit transaction is run + incremented every time a successful `XChainAccountCreateCommit` transaction is run for the source chain. This field is required. """ xchain_bridge: XChainBridge = REQUIRED # type: ignore """ A counter used to order the execution of account create transactions. It is - incremented every time a successful XChainAccountCreateCommit transaction is run + incremented every time a successful `XChainAccountCreateCommit` transaction is run for the source chain. This field is required. """ xchain_claim_id: Union[int, str] = REQUIRED # type: ignore """ - The value of the next XChainClaimID to be created. This field is required. + The value of the next `XChainClaimID` to be created. This field is required. """ owner_node: str = REQUIRED # type: ignore diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index f24f87284..b023fcb61 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -23,13 +23,13 @@ class DID(LedgerObject): did_document: Optional[str] = None """ - The W3C standard DID document associated with the DID. The DIDDocument field isn't + The W3C standard DID document associated with the DID. The `DIDDocument` field isn't checked for validity and is limited to a maximum length of 256 bytes. """ data: Optional[str] = None """ - The public attestations of identity credentials associated with the DID. The Data + The public attestations of identity credentials associated with the DID. The `Data` field isn't checked for validity and is limited to a maximum length of 256 bytes. """ From cb13e9d6a0f7bf654a761d69ee483f5155eb6971 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Wed, 24 Jan 2024 23:07:41 -0500 Subject: [PATCH 14/58] update AccountRoot --- tests/unit/models/test_ledger_object.py | 4 +- xrpl/models/ledger_objects/account_root.py | 128 +++++++++++++++++++-- 2 files changed, 124 insertions(+), 8 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 7bcccf94c..38c5949aa 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -484,6 +484,7 @@ def test_account_root(self): expected = AccountRoot( index="13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + amm_id=None, balance="148446663", flags=8388608, owner_count=3, @@ -494,6 +495,7 @@ def test_account_root(self): account_txn_id="0D5FB50FA65C9FE1538FD7E398FFFE9D1" "908DFA4576D8D7A020040686F93C77D", burned_nftokens=None, + first_nftoken_sequence=None, domain="6D64756F31332E636F6D", email_hash="98B4375E1D753E5B91627516F6D70977", message_key="0000000000000000000000070000000300", @@ -501,7 +503,7 @@ def test_account_root(self): nftoken_minter="rHello", regular_key=None, ticket_count=None, - ticket_size=None, + tick_size=None, transfer_rate=1004999999, wallet_locator=None, wallet_size=None, diff --git a/xrpl/models/ledger_objects/account_root.py b/xrpl/models/ledger_objects/account_root.py index de7b5e201..1e75b554d 100644 --- a/xrpl/models/ledger_objects/account_root.py +++ b/xrpl/models/ledger_objects/account_root.py @@ -18,25 +18,134 @@ class AccountRoot(LedgerObject): """The model for the `AccountRoot` Ledger Object""" account: str = REQUIRED # type: ignore - balance: str = REQUIRED # type: ignore - flags: Union[int, AccountRootFlags] = REQUIRED # type: ignore - owner_count: int = REQUIRED # type: ignore - previous_txn_id: str = REQUIRED # type: ignore - previous_txn_lgr_seq: int = REQUIRED # type: ignore - sequence: int = REQUIRED # type: ignore + """ + The identifying (classic) address of this account. This field is required. + """ + account_txn_id: Optional[str] = None + """ + The identifying hash of the transaction most recently sent by this account. This + field must be enabled to use the `AccountTxnID` transaction field. To enable it, + send an AccountSet transaction with the `asfAccountTxnID` flag enabled. + """ + + amm_id: Optional[str] = None + """ + The ledger entry ID of the corresponding AMM ledger entry. Set during account + creation; cannot be modified. If present, indicates that this is a special AMM + AccountRoot; always omitted on non-AMM accounts. + """ + + balance: str = REQUIRED # type: ignore + """ + The account's current XRP balance in drops, represented as a string. This field is + required. + """ + burned_nftokens: Optional[int] = None + """ + How many total of this account's issued non-fungible tokens have been burned. This + number is always equal or less than `MintedNFTokens`. + """ + domain: Optional[str] = None + """ + A domain associated with this account. In JSON, this is the hexadecimal for the + ASCII representation of the domain. Cannot be more than 256 bytes in length. + """ + email_hash: Optional[str] = None + """ + The md5 hash of an email address. Clients can use this to look up an avatar through + services such as Gravatar. + """ + + first_nftoken_sequence: Optional[int] = None + """ + The account's Sequence Number at the time it minted its first non-fungible-token. + """ + message_key: Optional[str] = None + """ + A public key that may be used to send encrypted messages to this account. In JSON, + uses hexadecimal. Must be exactly 33 bytes, with the first byte indicating the key + type: `0x02` or `0x03` for secp256k1 keys, `0xED` for Ed25519 keys. + """ + minted_nftokens: Optional[int] = None + """ + How many total non-fungible tokens have been minted by and on behalf of this + account. + """ + nftoken_minter: Optional[str] = None + """ + Another account that can mint non-fungible tokens on behalf of this account. + """ + + owner_count: int = REQUIRED # type: ignore + """ + The number of objects this account owns in the ledger, which contributes to its + owner reserve. + """ + + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this object. + This field is required. + """ + + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this object. This field is required. + """ + regular_key: Optional[str] = None + """ + The address of a key pair that can be used to sign transactions for this account + instead of the master key. Use a `SetRegularKey` transaction to change this value. + """ + + sequence: int = REQUIRED # type: ignore + """ + The sequence number of the next valid transaction for this account. + """ + ticket_count: Optional[int] = None - ticket_size: Optional[int] = None + """ + How many Tickets this account owns in the ledger. This is updated automatically to + ensure that the account stays within the hard limit of 250 Tickets at a time. This + field is omitted if the account has zero Tickets. + """ + + tick_size: Optional[int] = None + """ + How many significant digits to use for exchange rates of Offers involving + currencies issued by this address. Valid values are 3 to 15, inclusive. + """ + transfer_rate: Optional[int] = None + """ + A transfer fee to charge other users for sending currency issued by this account to + each other. + """ + wallet_locator: Optional[str] = None + """ + An arbitrary 256-bit value that users can set. + """ + wallet_size: Optional[int] = None + """ + Unused. (The code supports this field but there is no way to set it.) + """ + + flags: Union[int, AccountRootFlags] = REQUIRED # type: ignore + """ + A bit-map of boolean flags. This field is required. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.ACCOUNT_ROOT, init=False ) @@ -45,9 +154,14 @@ class AccountRoot(LedgerObject): class AccountRootFlags(Enum): """The flags for the `AccountRoot` Ledger Object""" + LSF_ALLOW_TRUSTLINE_CLAWBACK = 0x80000000 LSF_DEFAULT_RIPPLE = 0x00800000 LSF_DEPOSIT_AUTH = 0x01000000 LSF_DISABLE_MASTER = 0x00100000 + LSF_DISALLOW_INCOMING_CHECK = 0x08000000 + LSF_DISALLOW_INCOMING_NFTOKEN_OFFER = 0x04000000 + LSF_DISALLOW_INCOMING_PAY_CHAN = 0x10000000 + LSF_DISALLOW_INCOMING_TRUSTLINE = 0x20000000 LSF_DISALLOW_XRP = 0x00080000 LSF_GLOBAL_FREEZE = 0x00400000 LSF_NO_FREEZE = 0x00200000 From f3f3c82109efd71a7bf5e09bd296d583b40fdc50 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Wed, 24 Jan 2024 23:14:07 -0500 Subject: [PATCH 15/58] update Amendments --- xrpl/models/ledger_objects/amendments.py | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/xrpl/models/ledger_objects/amendments.py b/xrpl/models/ledger_objects/amendments.py index 9c21010f9..1791df567 100644 --- a/xrpl/models/ledger_objects/amendments.py +++ b/xrpl/models/ledger_objects/amendments.py @@ -17,14 +17,33 @@ class Amendments(LedgerObject): """The model for the `Amendments` Ledger Object""" - # always 0 - flags: int = REQUIRED # type: ignore amendments: Optional[List[str]] = None - majorities: Optional[List[Majority]] = None + """ + Array of 256-bit amendment IDs for all currently enabled amendments. If omitted, + there are no enabled amendments. + """ + + flags: int = REQUIRED # type: ignore + """ + A bit-map of boolean flags enabled for this object. Currently, the protocol defines + no flags for `Amendments` objects. The value is always 0. This field is required. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.AMENDMENTS, init=False, ) + """ + The value `0x0066`, mapped to the string `Amendments`, indicates that this object + describes the status of amendments to the XRP Ledger. + """ + + majorities: Optional[List[Majority]] = None + """ + Array of objects describing the status of amendments that have majority support but + are not yet enabled. If omitted, there are no pending amendments with majority + support. + """ @require_kwargs_on_init From 3d25c011304b76903c3f6a3f6436ec084a3ccfa0 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Wed, 24 Jan 2024 23:17:52 -0500 Subject: [PATCH 16/58] update AMM --- tests/unit/models/test_ledger_object.py | 2 ++ xrpl/models/ledger_objects/amm.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 38c5949aa..d16b4bc7c 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -114,6 +114,7 @@ } } ], + "owner_node": "0", "flags": 0, "ledger_entry_type": "AMM", } @@ -556,6 +557,7 @@ def test_amm(self): value="0.8696263565463045", ), ), + owner_node="0", flags=0, lptoken_balance=IssuedCurrencyAmount( currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", diff --git a/xrpl/models/ledger_objects/amm.py b/xrpl/models/ledger_objects/amm.py index ac8214a93..b9577ebfe 100644 --- a/xrpl/models/ledger_objects/amm.py +++ b/xrpl/models/ledger_objects/amm.py @@ -38,6 +38,9 @@ class AMM(LedgerObject): """ auction_slot: Optional[AuctionSlot] = None + """ + Details of the current owner of the auction slot, as an Auction Slot object. + """ lptoken_balance: IssuedCurrencyAmount = REQUIRED # type: ignore """ @@ -58,6 +61,12 @@ class AMM(LedgerObject): A list of vote objects, representing votes on the pool's trading fee. """ + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the sender's owner directory links to this entry, + in case the directory consists of multiple pages. + """ + flags: int = REQUIRED # type: ignore """ A bit-map of boolean flags. No flags are defined for the AMM object From e0c59b7362508fe0b7bdd8c715eedf53e016d22f Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 12:55:07 -0500 Subject: [PATCH 17/58] update Check --- xrpl/models/ledger_objects/check.py | 80 ++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 6 deletions(-) diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index 8daf794ef..35fef129e 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -18,20 +18,88 @@ class Check(LedgerObject): """The model for the `Check` Ledger Object""" account: str = REQUIRED # type: ignore + """ + The sender of the Check. Cashing the Check debits this address's balance. + This field is required. + """ + destination: str = REQUIRED # type: ignore - # always 0 - flags: int = REQUIRED # type: ignore + """ + The intended recipient of the Check. Only this address can cash the Check, using a + `CheckCash` transaction. This field is required. + """ + + destination_node: Optional[str] = None + """ + A hint indicating which page of the destination's owner directory links to this + object, in case the directory consists of multiple pages. + """ + + destination_tag: Optional[int] = None + """ + An arbitrary tag to further specify the destination for this Check, such as a + hosted recipient at the destination address. + """ + + expiration: Optional[int] = None + """ + Indicates the time after which this Check is considered expired. See Specifying + Time for details. + """ + + invoice_id: Optional[str] = None + """ + Arbitrary 256-bit hash provided by the sender as a specific reason or identifier + for this Check. + """ + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the sender's owner directory links to this object, + in case the directory consists of multiple pages. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this object. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this object. This field is required. + """ + send_max: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore + """ + The maximum amount of currency this Check can debit the sender. If the Check is + successfully cashed, the destination is credited in the same currency for up to + this amount. This field is required. + """ + sequence: int = REQUIRED # type: ignore - destination_node: Optional[str] = None - destination_tag: Optional[int] = None - expiration: Optional[int] = None - invoice_id: Optional[str] = None + """ + The sequence number of the `CheckCreate` transaction that created this check. + This field is required. + """ + source_tag: Optional[int] = None + """ + An arbitrary tag to further specify the source for this Check, such as a hosted + recipient at the sender's address. + """ + + flags: int = REQUIRED # type: ignore + """ + Flags is always 0 since there are no flags defined for Check entries. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.CHECK, init=False, ) + """ + The value 0x0043, mapped to the string `Check`, indicates that this object is a + Check object. + """ From 7508dce06c162d267f7e7c4673e9855ef18e6e88 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 12:58:08 -0500 Subject: [PATCH 18/58] fix Check field --- xrpl/models/ledger_objects/check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index 35fef129e..e11432edd 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -29,7 +29,7 @@ class Check(LedgerObject): `CheckCash` transaction. This field is required. """ - destination_node: Optional[str] = None + destination_node: str = REQUIRED # type: ignore """ A hint indicating which page of the destination's owner directory links to this object, in case the directory consists of multiple pages. From 655e53fe60cdd9aa34f59330008d7415dd5623f2 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 13:03:53 -0500 Subject: [PATCH 19/58] update DepositPreauth --- xrpl/models/ledger_objects/deposit_preauth.py | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py index ae2086235..1afb730ae 100644 --- a/xrpl/models/ledger_objects/deposit_preauth.py +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -16,13 +16,48 @@ class DepositPreauth(LedgerObject): """The model for the `DepositPreauth` Ledger Object""" account: str = REQUIRED # type: ignore + """ + The account that granted the preauthorization. (The destination of the + preauthorized payments.) This field is required. + """ + authorize: str = REQUIRED # type: ignore - # always 0 - flags: int = REQUIRED # type: ignore + """ + The account that received the preauthorization. (The sender of the preauthorized + payments.) This field is required. + """ + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the sender's owner directory links to this object, + in case the directory consists of multiple pages. Note: The object does not contain + a direct link to the owner directory containing it, since that value can be derived + from the Account. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this object. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this object. This field is required. + """ + + flags: int = REQUIRED # type: ignore + """ + Flags is always 0 since there are no flags defined for DepositPreauth entries. + This field is required. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.DEPOSIT_PREAUTH, init=False, ) + """ + The value `0x0070`, mapped to the string `DepositPreauth`, indicates that this is a + DepositPreauth object. + """ From f6d656bd33a3bbb708474d17b374749799774837 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 13:09:29 -0500 Subject: [PATCH 20/58] update flags docstrings --- xrpl/models/ledger_objects/amendments.py | 4 ++-- xrpl/models/ledger_objects/bridge.py | 3 ++- xrpl/models/ledger_objects/check.py | 3 ++- xrpl/models/ledger_objects/deposit_preauth.py | 4 ++-- xrpl/models/ledger_objects/did.py | 14 +++++++++----- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/xrpl/models/ledger_objects/amendments.py b/xrpl/models/ledger_objects/amendments.py index 1791df567..9ebd652ce 100644 --- a/xrpl/models/ledger_objects/amendments.py +++ b/xrpl/models/ledger_objects/amendments.py @@ -25,8 +25,8 @@ class Amendments(LedgerObject): flags: int = REQUIRED # type: ignore """ - A bit-map of boolean flags enabled for this object. Currently, the protocol defines - no flags for `Amendments` objects. The value is always 0. This field is required. + A bit-map of boolean flags. Currently, the protocol defines no flags for + `Amendments` objects. The value is always 0. This field is required. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index a1bcc68f8..a1b6fb053 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -88,7 +88,8 @@ class Bridge(LedgerObject): flags: int = REQUIRED # type: ignore """ - Flags is always 0 since there are no flags defined for Chain entries. + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + Chain entries. This field is required. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index e11432edd..b1706e508 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -92,7 +92,8 @@ class Check(LedgerObject): flags: int = REQUIRED # type: ignore """ - Flags is always 0 since there are no flags defined for Check entries. + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + Check entries. This field is required. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py index 1afb730ae..172b0072e 100644 --- a/xrpl/models/ledger_objects/deposit_preauth.py +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -49,8 +49,8 @@ class DepositPreauth(LedgerObject): flags: int = REQUIRED # type: ignore """ - Flags is always 0 since there are no flags defined for DepositPreauth entries. - This field is required. + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + DepositPreauth entries. This field is required. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index b023fcb61..2d9acee85 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -51,11 +51,6 @@ class DID(LedgerObject): this object. """ - flags: int = REQUIRED # type: ignore - """ - Flags is always 0 since there are no flags defined for DID entries. - """ - uri: Optional[str] = None """ The Universal Resource Identifier that points to the corresponding DID document or @@ -64,7 +59,16 @@ class DID(LedgerObject): bytes. """ + flags: int = REQUIRED # type: ignore + """ + Flags is always 0 since there are no flags defined for DID entries. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.DID, init=False, ) + """ + The value `0x0049`, mapped to the string `DID`, indicates that this object is a DID + object. + """ From 3372896584b46cd7df4827a9ce1f31f19247bbc7 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 13:23:02 -0500 Subject: [PATCH 21/58] update DirectoryNode --- tests/unit/models/test_ledger_object.py | 1 + xrpl/models/ledger_objects/account_root.py | 2 +- xrpl/models/ledger_objects/did.py | 3 +- xrpl/models/ledger_objects/directory_node.py | 73 ++++++++++++++++++-- 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index d16b4bc7c..099bd3b27 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -674,6 +674,7 @@ def test_directory_node(self): taker_pays_issuer="5BBC0F22F61D9224A110650CFE21CC0C4BE13098", taker_gets_currency="0000000000000000000000000000000000000000", taker_gets_issuer="0000000000000000000000000000000000000000", + nftoken_id=None, ) self.assertEqual(actual, expected) self.assertEqual(directory_node_json, expected.to_dict()) diff --git a/xrpl/models/ledger_objects/account_root.py b/xrpl/models/ledger_objects/account_root.py index 1e75b554d..967005b1c 100644 --- a/xrpl/models/ledger_objects/account_root.py +++ b/xrpl/models/ledger_objects/account_root.py @@ -62,7 +62,7 @@ class AccountRoot(LedgerObject): first_nftoken_sequence: Optional[int] = None """ - The account's Sequence Number at the time it minted its first non-fungible-token. + The account's Sequence Number at the time it minted its first non-fungible token. """ message_key: Optional[str] = None diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index 2d9acee85..ce3c7d0f1 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -61,7 +61,8 @@ class DID(LedgerObject): flags: int = REQUIRED # type: ignore """ - Flags is always 0 since there are no flags defined for DID entries. + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + DID entries. This field is required. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/directory_node.py b/xrpl/models/ledger_objects/directory_node.py index ac15d879d..1bd3dffa1 100644 --- a/xrpl/models/ledger_objects/directory_node.py +++ b/xrpl/models/ledger_objects/directory_node.py @@ -16,19 +16,80 @@ class DirectoryNode(LedgerObject): """The model for the `DirectoryNode` Ledger Object""" - # always 0 - flags: int = REQUIRED # type: ignore - root_index: str = REQUIRED # type: ignore + exchange_rate: Optional[str] = None + """ + (Offer Directories only) DEPRECATED. Do not use. + """ + indexes: List[str] = REQUIRED # type: ignore + """ + The contents of this Directory: an array of IDs of other objects. + This field is required. + """ + index_next: Optional[int] = None + """ + If this Directory consists of multiple pages, this ID links to the next object in + the chain, wrapping around at the end. + """ + index_previous: Optional[int] = None + """ + If this Directory consists of multiple pages, this ID links to the previous object + in the chain, wrapping around at the beginning. This field is required. + """ + owner: Optional[str] = None - exchange_rate: Optional[str] = None - taker_pays_currency: Optional[str] = None - taker_pays_issuer: Optional[str] = None + """ + (Owner Directories only) The address of the account that owns the objects in this + directory. + """ + + root_index: str = REQUIRED # type: ignore + """ + The ID of root object for this directory. This field is required. + """ + taker_gets_currency: Optional[str] = None + """ + (Offer Directories only) The currency code of the `TakerGets` amount from the offers + in this directory. + """ + taker_gets_issuer: Optional[str] = None + """ + (Offer Directories only) The issuer of the `TakerGets` amount from the offers in + this directory. + """ + + taker_pays_currency: Optional[str] = None + """ + (Offer Directories only) The currency code of the `TakerPays` amount from the offers + in this directory. + """ + + taker_pays_issuer: Optional[str] = None + """ + (Offer Directories only) The issuer of the `TakerPays` amount from the offers in + this directory. + """ + + nftoken_id: Optional[str] = None + """ + (Non-Fungible Token Directories only) The ID of the non-fungible token. + """ + + flags: int = REQUIRED # type: ignore + """ + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + DirectoryNode entries. This field is required. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.DIRECTORY_NODE, init=False, ) + """ + The value `0x0064`, mapped to the string `DirectoryNode`, indicates that this + object is part of a Directory. + """ From 41aa83c8764406361905cf5f3d4751f856b20428 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 13:30:11 -0500 Subject: [PATCH 22/58] update Escrow --- xrpl/models/ledger_objects/escrow.py | 75 +++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/xrpl/models/ledger_objects/escrow.py b/xrpl/models/ledger_objects/escrow.py index 4f76a2dc0..eba0850e5 100644 --- a/xrpl/models/ledger_objects/escrow.py +++ b/xrpl/models/ledger_objects/escrow.py @@ -17,19 +17,90 @@ class Escrow(LedgerObject): """The model for the `Escrow` Ledger Object""" account: str = REQUIRED # type: ignore + """ + The address of the owner (sender) of this escrow. This is the account that provided + the XRP, and gets it back if the escrow is canceled. This field is required. + """ + amount: str = REQUIRED # type: ignore + """ + The amount of XRP, in drops, currently held in the escrow. This field is required. + """ + destination: str = REQUIRED # type: ignore - # always 0 - flags: int = REQUIRED # type: ignore + """ + The destination address where the XRP is paid if the escrow is successful. + This field is required. + """ + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the sender's owner directory links to this entry, + in case the directory consists of multiple pages. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this entry. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this entry. This field is required. + """ + condition: Optional[str] = None + """ + A PREIMAGE-SHA-256 crypto-condition , as hexadecimal. If present, the `EscrowFinish` + transaction must contain a fulfillment that satisfies this condition. + """ + cancel_after: Optional[int] = None + """ + The escrow can be canceled if and only if this field is present and the time it + specifies has passed. Specifically, this is specified as seconds since the Ripple + Epoch and it "has passed" if it's earlier than the close time of the previous + validated ledger. + """ + destination_node: Optional[str] = None + """ + A hint indicating which page of the destination's owner directory links to this + object, in case the directory consists of multiple pages. Omitted on escrows + created before enabling the fix1523 amendment. + """ + destination_tag: Optional[int] = None + """ + An arbitrary tag to further specify the destination for this escrow, such as a + hosted recipient at the destination address. + """ + finish_after: Optional[int] = None + """ + The time, in seconds since the Ripple Epoch, after which this escrow can be + finished. Any `EscrowFinish` transaction before this time fails. (Specifically, this + is compared with the close time of the previous validated ledger.) + """ + source_tag: Optional[int] = None + """ + An arbitrary tag to further specify the source for this escrow, such as a hosted + recipient at the owner's address. + """ + + flags: int = REQUIRED # type: ignore + """ + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + Escrow entries. This field is required. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.ESCROW, init=False ) + """ + The value `0x0075`, mapped to the string `Escrow`, indicates that this is an Escrow + entry. + """ From c213cffad918f35e6565e299ccba73c74f1c9656 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 13:44:28 -0500 Subject: [PATCH 23/58] update FeeSettings --- xrpl/models/ledger_objects/fee_settings.py | 53 ++++++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/xrpl/models/ledger_objects/fee_settings.py b/xrpl/models/ledger_objects/fee_settings.py index 891ef32f9..f85c48ba5 100644 --- a/xrpl/models/ledger_objects/fee_settings.py +++ b/xrpl/models/ledger_objects/fee_settings.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field +from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject @@ -15,12 +16,54 @@ class FeeSettings(LedgerObject): """The model for the `FeeSettings` Ledger Object""" - base_fee: str = REQUIRED # type: ignore - # always 0 + base_fee: Optional[str] = None + """ + The transaction cost of the "reference transaction" in drops of XRP as hexadecimal. + No longer used if XRPFees amendment is enabled. + """ + + reference_fee_units: Optional[int] = None + """ + The BaseFee translated into "fee units". This field is required. + """ + + reserve_base: Optional[int] = None + """ + The base reserve for an account in the XRP Ledger, as drops of XRP. + No longer used if XRPFees amendment is enabled. + """ + + reserve_increment: Optional[int] = None + """ + The incremental owner reserve for owning objects, as drops of XRP. + No longer used if XRPFees amendment is enabled. + """ + + base_fee_drops: Optional[str] = None + """ + The transaction cost of the "reference transaction" in drops of XRP. + """ + + reserve_base_drops: Optional[str] = None + """ + The base reserve for an account in the XRP Ledger, as drops of XRP. + """ + + reserve_increment_drops: Optional[str] = None + """ + The incremental owner reserve for owning objects, as drops of XRP. + """ + flags: int = REQUIRED # type: ignore - reference_fee_units: int = REQUIRED # type: ignore - reserve_base: int = REQUIRED # type: ignore - reserve_increment: int = REQUIRED # type: ignore + """ + A bit-map of boolean flags enabled for this object. Currently, the protocol defines + no flags for `FeeSettings` objects. The value is always 0. This field is required. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.FEE_SETTINGS, init=False ) + """ + The value `0x0073`, mapped to the string `FeeSettings`, indicates that this object + contains the ledger's fee settings. + """ From 0de4fca10e588abd26f59369b7559a8aeb595cb5 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 13:48:31 -0500 Subject: [PATCH 24/58] update LedgerHashes --- xrpl/models/ledger_objects/ledger_hashes.py | 33 ++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/xrpl/models/ledger_objects/ledger_hashes.py b/xrpl/models/ledger_objects/ledger_hashes.py index 4d668440e..bafb3c872 100644 --- a/xrpl/models/ledger_objects/ledger_hashes.py +++ b/xrpl/models/ledger_objects/ledger_hashes.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import List +from typing import List, Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject @@ -16,12 +16,37 @@ class LedgerHashes(LedgerObject): """The model for the `LedgerHashes` Ledger Object""" - first_ledger_sequence: int = REQUIRED # type: ignore - last_ledger_sequence: int = REQUIRED # type: ignore + first_ledger_sequence: Optional[int] = None + """ + DEPRECATED Do not use. (The "recent hashes" object on Mainnet has the value 2 in + this field as a result of an old software bug. That value gets carried forward as + the "recent hashes" object is updated. New "previous history" objects do not have + this field, nor do "recent hashes" objects in parallel networks started with more + recent versions of rippled.) + """ + + last_ledger_sequence: Optional[int] = None + """ + The Ledger Index of the last entry in this object's `Hashes` array. + """ + hashes: List[str] = REQUIRED # type: ignore - # always 0 + """ + An array of up to 256 ledger hashes. The contents depend on which sub-type of + LedgerHashes object this is. This field is required. + """ + flags: int = REQUIRED # type: ignore + """ + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + Escrow entries. This field is required. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.LEDGER_HASHES, init=False, ) + """ + The value `0x0068`, mapped to the string `LedgerHashes`, indicates that this object + is a list of ledger hashes. + """ From a5042877485580d67a05df607d8a3f2a66e8148e Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 14:13:57 -0500 Subject: [PATCH 25/58] update LedgerObject and models with flags --- tests/unit/models/test_ledger_object.py | 3 +- xrpl/models/ledger_objects/amendments.py | 2 +- xrpl/models/ledger_objects/amm.py | 2 +- xrpl/models/ledger_objects/bridge.py | 2 +- xrpl/models/ledger_objects/check.py | 2 +- xrpl/models/ledger_objects/deposit_preauth.py | 2 +- xrpl/models/ledger_objects/did.py | 2 +- xrpl/models/ledger_objects/directory_node.py | 2 +- xrpl/models/ledger_objects/escrow.py | 2 +- xrpl/models/ledger_objects/fee_settings.py | 3 +- xrpl/models/ledger_objects/ledger_hashes.py | 2 +- xrpl/models/ledger_objects/ledger_object.py | 30 +++++++++++++++++-- xrpl/models/ledger_objects/nftoken_page.py | 1 + .../ledger_objects/xchain_owned_claim_id.py | 2 +- .../xchain_owned_create_account_claim_id.py | 2 ++ 15 files changed, 43 insertions(+), 16 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 099bd3b27..ae51d4eee 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -273,6 +273,7 @@ } nftoken_page_json = { + "flags": 0, "ledger_entry_type": "NFTokenPage", "previous_token_page": "598EDFD7CF73460FB8C695d6a9397E" "907378C8A841F7204C793DCBEF5406", @@ -449,6 +450,7 @@ } xchain_owned_create_account_claim_id_json = { + "flags": 0, "ledger_entry_type": "XChainOwnedCreateAccountClaimID", "ledger_index": "5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166BB6F0C", "owner_node": "0", @@ -918,7 +920,6 @@ def test_xchain_owned_claim_id(self): actual = XChainOwnedClaimID.from_dict(xchain_owned_claim_id_json) expected = XChainOwnedClaimID( account="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - flags=0, other_chain_source="r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", owner_node="0", previous_txn_id="1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E6" diff --git a/xrpl/models/ledger_objects/amendments.py b/xrpl/models/ledger_objects/amendments.py index 9ebd652ce..72f4e56b1 100644 --- a/xrpl/models/ledger_objects/amendments.py +++ b/xrpl/models/ledger_objects/amendments.py @@ -23,7 +23,7 @@ class Amendments(LedgerObject): there are no enabled amendments. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ A bit-map of boolean flags. Currently, the protocol defines no flags for `Amendments` objects. The value is always 0. This field is required. diff --git a/xrpl/models/ledger_objects/amm.py b/xrpl/models/ledger_objects/amm.py index b9577ebfe..3d63b4bce 100644 --- a/xrpl/models/ledger_objects/amm.py +++ b/xrpl/models/ledger_objects/amm.py @@ -67,7 +67,7 @@ class AMM(LedgerObject): in case the directory consists of multiple pages. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 # type: ignore """ A bit-map of boolean flags. No flags are defined for the AMM object type, so this value is always 0. This field is required. diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index a1b6fb053..bfc9eb1a9 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -86,7 +86,7 @@ class Bridge(LedgerObject): this object. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 # type: ignore """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for Chain entries. This field is required. diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index b1706e508..bc2ec28a4 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -90,7 +90,7 @@ class Check(LedgerObject): recipient at the sender's address. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for Check entries. This field is required. diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py index 172b0072e..75729bf45 100644 --- a/xrpl/models/ledger_objects/deposit_preauth.py +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -47,7 +47,7 @@ class DepositPreauth(LedgerObject): this object. This field is required. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for DepositPreauth entries. This field is required. diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index ce3c7d0f1..4d78457ba 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -59,7 +59,7 @@ class DID(LedgerObject): bytes. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for DID entries. This field is required. diff --git a/xrpl/models/ledger_objects/directory_node.py b/xrpl/models/ledger_objects/directory_node.py index 1bd3dffa1..b506a16ad 100644 --- a/xrpl/models/ledger_objects/directory_node.py +++ b/xrpl/models/ledger_objects/directory_node.py @@ -79,7 +79,7 @@ class DirectoryNode(LedgerObject): (Non-Fungible Token Directories only) The ID of the non-fungible token. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for DirectoryNode entries. This field is required. diff --git a/xrpl/models/ledger_objects/escrow.py b/xrpl/models/ledger_objects/escrow.py index eba0850e5..2517e3a65 100644 --- a/xrpl/models/ledger_objects/escrow.py +++ b/xrpl/models/ledger_objects/escrow.py @@ -91,7 +91,7 @@ class Escrow(LedgerObject): recipient at the owner's address. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for Escrow entries. This field is required. diff --git a/xrpl/models/ledger_objects/fee_settings.py b/xrpl/models/ledger_objects/fee_settings.py index f85c48ba5..1293b62a4 100644 --- a/xrpl/models/ledger_objects/fee_settings.py +++ b/xrpl/models/ledger_objects/fee_settings.py @@ -7,7 +7,6 @@ from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject -from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @@ -54,7 +53,7 @@ class FeeSettings(LedgerObject): The incremental owner reserve for owning objects, as drops of XRP. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ A bit-map of boolean flags enabled for this object. Currently, the protocol defines no flags for `FeeSettings` objects. The value is always 0. This field is required. diff --git a/xrpl/models/ledger_objects/ledger_hashes.py b/xrpl/models/ledger_objects/ledger_hashes.py index bafb3c872..50c91c804 100644 --- a/xrpl/models/ledger_objects/ledger_hashes.py +++ b/xrpl/models/ledger_objects/ledger_hashes.py @@ -36,7 +36,7 @@ class LedgerHashes(LedgerObject): LedgerHashes object this is. This field is required. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for Escrow entries. This field is required. diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index c310a1f9f..5897e5391 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -8,6 +8,7 @@ from xrpl.models.base_model import BaseModel from xrpl.models.exceptions import XRPLModelException from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType +from xrpl.models.required import REQUIRED # TODO: REMOVE if optional is needed # from xrpl.models.required import REQUIRED @@ -21,9 +22,24 @@ class LedgerObject(BaseModel): """The base model for a Ledger Object.""" - # TODO: Try without optional - ledger_entry_type: LedgerEntryType = None index: Optional[str] = None + """ + The unique ID for this ledger entry. In JSON, this field is represented with + different names depending on the context and API method. (Note, even though this is + specified as "optional" in the code, every ledger entry should have one unless it's + legacy data from very early in the XRP Ledger's history.) + """ + + ledger_entry_type: LedgerEntryType = REQUIRED # type: ignore + """ + The type of ledger entry. Valid ledger entry types include AccountRoot, Offer, + RippleState, and others. This field is required. + """ + + flags: int = REQUIRED # type: ignore + """ + Set of bit-flags for this ledger entry. + """ @classmethod def from_dict(cls: Type[L], value: Dict[str, Any]) -> L: @@ -129,7 +145,15 @@ def get_md_ledger_object_type( ) def __getitem__(self: LedgerObject, field_name: str) -> Any: - """Enable to get the fields like from a `dict`""" + """ + Enable to get the fields like from a `dict` + + Args: + field_name: The field name to get. + + Returns: + Any: The field value. + """ if field_name == self.__class__.__name__ or self.__class__.__name__ == "".join( [word.capitalize() for word in field_name.split("_")] ): diff --git a/xrpl/models/ledger_objects/nftoken_page.py b/xrpl/models/ledger_objects/nftoken_page.py index ff8e68f46..c214b9ae1 100644 --- a/xrpl/models/ledger_objects/nftoken_page.py +++ b/xrpl/models/ledger_objects/nftoken_page.py @@ -23,6 +23,7 @@ class NFTokenPage(LedgerObject): previous_txn_id: Optional[str] = None previous_txn_lgr_seq: Optional[int] = None nftokens: Optional[List[NFToken]] = None + flags: int = 0 ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NFTOKEN_PAGE, init=False, diff --git a/xrpl/models/ledger_objects/xchain_owned_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_claim_id.py index e07f2f24c..50e0c2f48 100644 --- a/xrpl/models/ledger_objects/xchain_owned_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_claim_id.py @@ -83,7 +83,7 @@ class XChainOwnedClaimID(LedgerObject): this object. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ Flags is always 0 since there are no flags defined for Chain entries. """ diff --git a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py index bad8e11ae..cfc1be56a 100644 --- a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py @@ -69,6 +69,8 @@ class XChainOwnedCreateAccountClaimID(LedgerObject): this object. """ + flags: int = 0 + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.XCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, init=False, From ac93044b8342e948150ce14e444d1254a06ed75e Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 14:24:07 -0500 Subject: [PATCH 26/58] update NegativeUNL --- tests/unit/models/test_ledger_object.py | 13 +------ xrpl/models/ledger_objects/amendments.py | 2 +- xrpl/models/ledger_objects/amm.py | 2 +- xrpl/models/ledger_objects/bridge.py | 2 +- xrpl/models/ledger_objects/check.py | 2 +- xrpl/models/ledger_objects/deposit_preauth.py | 2 +- xrpl/models/ledger_objects/did.py | 2 +- xrpl/models/ledger_objects/directory_node.py | 2 +- xrpl/models/ledger_objects/escrow.py | 2 +- xrpl/models/ledger_objects/fee_settings.py | 2 +- xrpl/models/ledger_objects/negative_unl.py | 37 ++++++++++++++++++- 11 files changed, 45 insertions(+), 23 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index ae51d4eee..e8b8112f1 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -518,7 +518,6 @@ def test_amendments(self): actual = Amendments.from_dict(amendment_json) expected = Amendments( index="7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", - flags=0, amendments=[ "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE", "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373", @@ -560,7 +559,6 @@ def test_amm(self): ), ), owner_node="0", - flags=0, lptoken_balance=IssuedCurrencyAmount( currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", issuer="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", @@ -582,7 +580,6 @@ def test_bridge(self): actual = Bridge.from_dict(bridge_json) expected = Bridge( account="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", - flags=0, min_account_create_amount="2000000000", owner_node="0", previous_txn_id="67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE917FD1A71919EAE75" @@ -609,7 +606,6 @@ def test_check(self): index="49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", account="rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", destination="rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", - flags=0, owner_node="0000000000000000", previous_txn_id="5463C6E08862A1FAE5EDAC12D70ADB16546A" "1F674930521295BC082494B62924", @@ -632,7 +628,6 @@ def test_deposit_preauth(self): index="4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", account="rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", authorize="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", - flags=0, owner_node="0000000000000000", previous_txn_id="3E8964D5A86B3CD6B9ECB33310D4E073D64C8" "65A5B866200AD2B7E29F8326702", @@ -647,7 +642,6 @@ def test_did(self): account="rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", did_document="646F63", data="617474657374", - flags=0, owner_node="0", previous_txn_id="A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B09F" "708778E41120", @@ -662,7 +656,6 @@ def test_directory_node(self): actual = DirectoryNode.from_dict(directory_node_json) expected = DirectoryNode( index="1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", - flags=0, root_index="1BBEF97EDE88D40CEE2ADE6FEF121166A" "FE80D99EBADB01A4F069BA8FF484000", indexes=[ @@ -688,7 +681,6 @@ def test_escrow(self): account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", amount="10000", destination="ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - flags=0, owner_node="0000000000000000", previous_txn_id="C44F2EB84196B9AD820313DBEBA6316A15" "C9A2D35787579ED172B87A30131DA7", @@ -709,7 +701,6 @@ def test_fee_settings(self): expected = FeeSettings( index="4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", base_fee="000000000000000A", - flags=0, reference_fee_units=10, reserve_base=20000000, reserve_increment=5000000, @@ -730,7 +721,6 @@ def test_ledger_hashes(self): "AB4014846DF818A4B43D6B1686D0DE0644FE711577C5AB6F0B2A21CCEE280140", "3383784E82A8BA45F4DD5EF4EE90A1B2D3B4571317DBAC37B859836ADDE644C1", ], - flags=0, ) self.assertEqual(actual, expected) self.assertEqual(ledger_hashes_json, expected.to_dict()) @@ -739,7 +729,6 @@ def test_negative_unl(self): actual = NegativeUNL.from_dict(negative_unl_json) expected = NegativeUNL( index="2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", - flags=0, disabled_validators=[ DisabledValidator( first_ledger_sequence=1609728, @@ -748,7 +737,7 @@ def test_negative_unl(self): ) ], validator_to_disable=None, - validator_to_enable=None, + validator_to_re_enable=None, ) self.assertEqual(actual, expected) self.assertEqual(negative_unl_json, expected.to_dict()) diff --git a/xrpl/models/ledger_objects/amendments.py b/xrpl/models/ledger_objects/amendments.py index 72f4e56b1..657a2e5a9 100644 --- a/xrpl/models/ledger_objects/amendments.py +++ b/xrpl/models/ledger_objects/amendments.py @@ -26,7 +26,7 @@ class Amendments(LedgerObject): flags: int = 0 """ A bit-map of boolean flags. Currently, the protocol defines no flags for - `Amendments` objects. The value is always 0. This field is required. + `Amendments` objects. The value is always 0. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/amm.py b/xrpl/models/ledger_objects/amm.py index 3d63b4bce..b07cc3275 100644 --- a/xrpl/models/ledger_objects/amm.py +++ b/xrpl/models/ledger_objects/amm.py @@ -70,7 +70,7 @@ class AMM(LedgerObject): flags: int = 0 # type: ignore """ A bit-map of boolean flags. No flags are defined for the AMM object - type, so this value is always 0. This field is required. + type, so this value is always 0. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index bfc9eb1a9..c026499dc 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -89,7 +89,7 @@ class Bridge(LedgerObject): flags: int = 0 # type: ignore """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Chain entries. This field is required. + Chain entries. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index bc2ec28a4..c8999ec7e 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -93,7 +93,7 @@ class Check(LedgerObject): flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Check entries. This field is required. + Check entries. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py index 75729bf45..8a61aa344 100644 --- a/xrpl/models/ledger_objects/deposit_preauth.py +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -50,7 +50,7 @@ class DepositPreauth(LedgerObject): flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - DepositPreauth entries. This field is required. + DepositPreauth entries. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index 4d78457ba..8ab0f246d 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -62,7 +62,7 @@ class DID(LedgerObject): flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - DID entries. This field is required. + DID entries. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/directory_node.py b/xrpl/models/ledger_objects/directory_node.py index b506a16ad..95ed07103 100644 --- a/xrpl/models/ledger_objects/directory_node.py +++ b/xrpl/models/ledger_objects/directory_node.py @@ -82,7 +82,7 @@ class DirectoryNode(LedgerObject): flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - DirectoryNode entries. This field is required. + DirectoryNode entries. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/escrow.py b/xrpl/models/ledger_objects/escrow.py index 2517e3a65..06e86af7c 100644 --- a/xrpl/models/ledger_objects/escrow.py +++ b/xrpl/models/ledger_objects/escrow.py @@ -94,7 +94,7 @@ class Escrow(LedgerObject): flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Escrow entries. This field is required. + Escrow entries. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/fee_settings.py b/xrpl/models/ledger_objects/fee_settings.py index 1293b62a4..cc9d40e76 100644 --- a/xrpl/models/ledger_objects/fee_settings.py +++ b/xrpl/models/ledger_objects/fee_settings.py @@ -56,7 +56,7 @@ class FeeSettings(LedgerObject): flags: int = 0 """ A bit-map of boolean flags enabled for this object. Currently, the protocol defines - no flags for `FeeSettings` objects. The value is always 0. This field is required. + no flags for `FeeSettings` objects. The value is always 0. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/negative_unl.py b/xrpl/models/ledger_objects/negative_unl.py index 99f252394..34dab3f15 100644 --- a/xrpl/models/ledger_objects/negative_unl.py +++ b/xrpl/models/ledger_objects/negative_unl.py @@ -17,13 +17,37 @@ class NegativeUNL(LedgerObject): """The model for the `NegativeUNL` Ledger Object""" - flags: int = REQUIRED # type: ignore disabled_validators: Optional[List[DisabledValidator]] = None + """ + A list of `DisabledValidator` objects (see below), each representing a trusted + validator that is currently disabled. + """ + validator_to_disable: Optional[str] = None - validator_to_enable: Optional[str] = None + """ + The public key of a trusted validator that is scheduled to be disabled in the next + flag ledger. + """ + + validator_to_re_enable: Optional[str] = None + """ + The public key of a trusted validator in the Negative UNL that is scheduled to be + re-enabled in the next flag ledger. + """ + + flags: int = 0 + """ + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + NegativeUNL entries. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NEGATIVE_UNL, init=False ) + """ + The value `0x004E`, mapped to the string `NegativeUNL`, indicates that this entry + is the Negative UNL. + """ @require_kwargs_on_init @@ -32,4 +56,13 @@ class DisabledValidator(NestedModel): """A model for the `DisabledValidator` object""" first_ledger_sequence: int = REQUIRED # type: ignore + """ + The ledger index when the validator was added to the Negative UNL. + This field is required. + """ + public_key: str = REQUIRED # type: ignore + """ + The master public key of the validator, in hexadecimal. + This field is required. + """ From 1681bc62e66278136cf1556fd62796b4d908705f Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 14:41:44 -0500 Subject: [PATCH 27/58] update NFTokenOffer --- xrpl/models/ledger_objects/nftoken_offer.py | 63 ++++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/xrpl/models/ledger_objects/nftoken_offer.py b/xrpl/models/ledger_objects/nftoken_offer.py index 4f6c9c838..17819de45 100644 --- a/xrpl/models/ledger_objects/nftoken_offer.py +++ b/xrpl/models/ledger_objects/nftoken_offer.py @@ -19,19 +19,76 @@ class NFTokenOffer(LedgerObject): """The model for the `NFTokenOffer` Ledger Object""" amount: Union[str, NFToken] = REQUIRED # type: ignore - flags: Union[int, NFTokenOfferFlags] = REQUIRED # type: ignore + """ + Amount expected or offered for the NFToken. If the token has the `lsfOnlyXRP` flag + set, the amount must be specified in XRP. Sell offers that specify assets other + than XRP must specify a non-zero amount. Sell offers that specify XRP can be 'free' + (that is, the Amount field can be equal to `"0"`). This field is required. + """ + nftoken_id: str = REQUIRED # type: ignore + """ + The `NFTokenID` of the NFToken object referenced by this offer. This field is + required. + """ + owner: str = REQUIRED # type: ignore + """ + Owner of the account that is creating and owns the offer. Only the current Owner of + an NFToken can create an offer to sell an NFToken, but any account can create an + offer to buy an NFToken. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + Identifying hash of the transaction that most recently modified this object. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + Index of the ledger that contains the transaction that most recently modified this + object. This field is required. + """ + destination: Optional[str] = None + """ + The AccountID for which this offer is intended. If present, only that account can + accept the offer. + """ + expiration: Optional[int] = None - owner_node: Optional[str] = None - nftoken_offer_node: Optional[str] = None + """ + The time after which the offer is no longer active. The value is the number of + seconds since the Ripple Epoch. + """ + + owner_node: str = REQUIRED # type: ignore + """ + Internal bookkeeping, indicating the page inside the owner directory where this + token is being tracked. This field allows the efficient deletion of offers. + """ + + nftoken_offer_node: str = REQUIRED # type: ignore + """ + Internal bookkeeping, indicating the page inside the token buy or sell offer + directory, as appropriate, where this token is being tracked. This field allows the + efficient deletion of offers. + """ + + flags: Union[int, NFTokenOfferFlags] = REQUIRED # type: ignore + """ + A bit-map of boolean flags. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NFTOKEN_OFFER, init=False, ) + """ + The value `0x0037`, mapped to the string `NFTokenOffer`, indicates that this is an + offer to trade a `NFToken`. + """ @require_kwargs_on_init From b7fda71aa245dccab84a349835d7fda03ff1ff88 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 15:27:17 -0500 Subject: [PATCH 28/58] update NFTokenPage --- tests/unit/models/test_ledger_object.py | 8 ---- xrpl/models/ledger_objects/ledger_hashes.py | 2 +- xrpl/models/ledger_objects/nftoken_page.py | 46 ++++++++++++++++++--- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index e8b8112f1..785782cc3 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -275,10 +275,6 @@ nftoken_page_json = { "flags": 0, "ledger_entry_type": "NFTokenPage", - "previous_token_page": "598EDFD7CF73460FB8C695d6a9397E" - "907378C8A841F7204C793DCBEF5406", - "previous_token_next": "598EDFD7CF73460FB8C695d6a9397E90" - "73781BA3B78198904F659AAA252A", "previous_txn_id": "95C8761B22894E328646F7A70035E9DFBECC9" "0EDD83E43B7B973F626D21A0822", "previous_txn_lgr_seq": 42891441, @@ -766,10 +762,6 @@ def test_nftoken_page(self): index="", previous_page_min=None, next_page_min=None, - previous_token_page="598EDFD7CF73460FB8C695d6a9397E9" - "07378C8A841F7204C793DCBEF5406", - previous_token_next="598EDFD7CF73460FB8C695d6a9397E90" - "73781BA3B78198904F659AAA252A", previous_txn_id="95C8761B22894E328646F7A70035E9DFBEC" "C90EDD83E43B7B973F626D21A0822", previous_txn_lgr_seq=42891441, diff --git a/xrpl/models/ledger_objects/ledger_hashes.py b/xrpl/models/ledger_objects/ledger_hashes.py index 50c91c804..b266f5be3 100644 --- a/xrpl/models/ledger_objects/ledger_hashes.py +++ b/xrpl/models/ledger_objects/ledger_hashes.py @@ -39,7 +39,7 @@ class LedgerHashes(LedgerObject): flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Escrow entries. This field is required. + Escrow entries. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/nftoken_page.py b/xrpl/models/ledger_objects/nftoken_page.py index c214b9ae1..2b985b3ab 100644 --- a/xrpl/models/ledger_objects/nftoken_page.py +++ b/xrpl/models/ledger_objects/nftoken_page.py @@ -8,6 +8,7 @@ from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject from xrpl.models.ledger_objects.nftoken_offer import NFToken +from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @@ -16,15 +17,48 @@ class NFTokenPage(LedgerObject): """The model for the `NFTokenPage` Ledger Object""" - previous_page_min: Optional[str] = None next_page_min: Optional[str] = None - previous_token_page: Optional[str] = None - previous_token_next: Optional[str] = None - previous_txn_id: Optional[str] = None - previous_txn_lgr_seq: Optional[int] = None - nftokens: Optional[List[NFToken]] = None + """ + The locator of the next page, if any. Details about this field and how it should be + used are outlined below. + """ + + previous_page_min: Optional[str] = None + """ + The locator of the previous page, if any. Details about this field and how it + should be used are outlined below. + """ + + nftokens: List[NFToken] = REQUIRED # type: ignore + """ + The collection of NFToken objects contained in this NFTokenPage object. This + specification places an upper bound of 32 NFToken objects per page. Objects are + sorted from low to high with the NFTokenID used as the sorting parameter. + """ + + previous_txn_id: str = REQUIRED # type: ignore + """ + Identifies the transaction ID of the transaction that most recently modified this + NFTokenPage object. + """ + + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The sequence of the ledger that contains the transaction that most recently + modified this NFTokenPage object. + """ + flags: int = 0 + """ + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + NFTokenPage entries. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NFTOKEN_PAGE, init=False, ) + """ + The value `0x0050`, mapped to the string `NFTokenPage`, indicates that this is a + page containing `NFToken` objects. + """ From 1e726b33e9fe98fadf3f0ef1a9145a671e13ebd9 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 15:31:16 -0500 Subject: [PATCH 29/58] add ledger_index to LedgerObject --- xrpl/models/ledger_objects/ledger_object.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index 5897e5391..55b4a29ab 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -24,10 +24,20 @@ class LedgerObject(BaseModel): index: Optional[str] = None """ - The unique ID for this ledger entry. In JSON, this field is represented with - different names depending on the context and API method. (Note, even though this is - specified as "optional" in the code, every ledger entry should have one unless it's - legacy data from very early in the XRP Ledger's history.) + The unique ID for this ledger entry; either `index` or `LedgerIndex` is used. In + JSON, this field is represented with different names depending on the context and + API method. (Note, even though this is specified as "optional" in the code, every + ledger entry should have one unless it's legacy data from very early in the XRP + Ledger's history.) + """ + + ledger_index: Optional[str] = None + """ + The unique ID for this ledger entry; either `index` or `LedgerIndex` is used. In + JSON, this field is represented with different names depending on the context and + API method. (Note, even though this is specified as "optional" in the code, every + ledger entry should have one unless it's legacy data from very early in the XRP + Ledger's history.) """ ledger_entry_type: LedgerEntryType = REQUIRED # type: ignore From 4c82bff104d87bd8c7f85873cf3ae3e34a9b9169 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 15:41:43 -0500 Subject: [PATCH 30/58] update Offer --- xrpl/models/ledger_objects/offer.py | 66 ++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/xrpl/models/ledger_objects/offer.py b/xrpl/models/ledger_objects/offer.py index 1a7055bd7..b0770f993 100644 --- a/xrpl/models/ledger_objects/offer.py +++ b/xrpl/models/ledger_objects/offer.py @@ -19,20 +19,76 @@ class Offer(LedgerObject): """The model for the `Offer` Ledger Object""" account: str = REQUIRED # type: ignore - taker_gets: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore - taker_pays: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore - sequence: int = REQUIRED # type: ignore - flags: int = REQUIRED # type: ignore + """ + The address of the account that owns this Offer. This field is required. + """ + book_directory: str = REQUIRED # type: ignore + """ + The ID of the Offer Directory that links to this Offer. This field is required. + """ + book_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the offer directory links to this entry, in case + the directory consists of multiple pages. This field is required. + """ + + expiration: Optional[int] = None + """ + Indicates the time after which this Offer is considered unfunded. See Specifying + Time for details. + """ + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the owner directory links to this entry, in case + the directory consists of multiple pages. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this entry. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore - expiration: Optional[int] = None + """ + The index of the ledger that contains the transaction that most recently modified + this object. This field is required. + """ + + sequence: int = REQUIRED # type: ignore + """ + The `Sequence` value of the `OfferCreate` transaction that created this offer. Used + in combination with the `Account` to identify this offer. This field is required. + """ + + taker_gets: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore + """ + The remaining amount and type of currency being provided by the `Offer` creator. + This field is required. + """ + + taker_pays: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore + """ + The remaining amount and type of currency requested by the `Offer` creator. + This field is required. + """ + + flags: int = REQUIRED # type: ignore + """ + A bit-map of boolean flags. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.OFFER, init=False, ) + """ + The value 0x0050, mapped to the string NFTokenPage, indicates that this is a page + containing NFToken objects. + """ class OfferFlag(Enum): From f30d69d816dce82bdc654e1cff33efc528ed356c Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 15:53:12 -0500 Subject: [PATCH 31/58] update PayChannel --- xrpl/models/ledger_objects/pay_channel.py | 102 +++++++++++++++++++++- 1 file changed, 98 insertions(+), 4 deletions(-) diff --git a/xrpl/models/ledger_objects/pay_channel.py b/xrpl/models/ledger_objects/pay_channel.py index e0c672058..1153aaa25 100644 --- a/xrpl/models/ledger_objects/pay_channel.py +++ b/xrpl/models/ledger_objects/pay_channel.py @@ -17,22 +17,116 @@ class PayChannel(LedgerObject): """The model for the `PayChannel` Ledger Object""" account: str = REQUIRED # type: ignore + """ + The source address that owns this payment channel. This comes from the sending + address of the transaction that created the channel. This field is required. + """ + amount: str = REQUIRED # type: ignore + """ + Total XRP, in drops, that has been allocated to this channel. This includes XRP + that has been paid to the destination address. This is initially set by the + transaction that created the channel and can be increased if the source address + sends a `PaymentChannelFund` transaction. This field is required. + """ + balance: str = REQUIRED # type: ignore + """ + Total XRP, in drops, already paid out by the channel. The difference between this + value and the `Amount` field is how much XRP can still be paid to the destination + address with PaymentChannelClaim transactions. If the channel closes, the remaining + difference is returned to the source address. This field is required. + """ + destination: str = REQUIRED # type: ignore - # always 0 - flags: int = REQUIRED # type: ignore + """ + The destination address for this payment channel. While the payment channel is open, + this address is the only one that can receive XRP from the channel. This comes from + the `Destination` field of the transaction that created the channel. This field is + required. + """ + + destination_tag: Optional[int] = None + """ + An arbitrary tag to further specify the destination for this payment channel, such + as a hosted recipient at the destination address. + """ + + destination_node: Optional[str] = None + """ + A hint indicating which page of the destination's owner directory links to this + entry, in case the directory consists of multiple pages. Omitted on payment + channels created before enabling the fixPayChanRecipientOwnerDir amendment. + """ + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the source address's owner directory links to this + entry, in case the directory consists of multiple pages. This field is required. + """ + public_key: str = REQUIRED # type: ignore + """ + Public key, in hexadecimal, of the key pair that can be used to sign claims against + this channel. This can be any valid secp256k1 or Ed25519 public key. This is set by + the transaction that created the channel and must match the public key used in + claims against the channel. The channel source address can also send XRP from this + channel to the destination without signed claims. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this entry. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this entry. This field is required. + """ + settle_delay: int = REQUIRED # type: ignore - destination_node: Optional[str] = None - destination_tag: Optional[int] = None + """ + Number of seconds the source address must wait to close the channel if it still has + any XRP in it. Smaller values mean that the destination address has less time to + redeem any outstanding claims after the source address requests to close the + channel. Can be any value that fits in a 32-bit unsigned integer (0 to 2^32-1). + This is set by the transaction that creates the channel. This field is required. + """ + expiration: Optional[int] = None + """ + The mutable expiration time for this payment channel, in seconds since the Ripple + Epoch. The channel is expired if this value is present and smaller than the + previous ledger's close_time field. See Channel Expiration for more details. + """ + cancel_after: Optional[int] = None + """ + The immutable expiration time for this payment channel, in seconds since the Ripple + Epoch. This channel is expired if this value is present and smaller than the + previous ledger's close_time field. This is optionally set by the transaction that + created the channel, and cannot be changed. This field is required. + """ + source_tag: Optional[int] = None + """ + An arbitrary tag to further specify the source for this payment channel, such as a + hosted recipient at the owner's address. + """ + + flags: int = 0 + """ + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + PayChannel entries. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.PAY_CHANNEL, init=False, ) + """ + The value `0x0078`, mapped to the string `PayChannel`, indicates that this is a + payment channel entry. + """ From c231e3688b7da193b9e7577212be7777d8b75272 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 16:04:05 -0500 Subject: [PATCH 32/58] update RippleState --- xrpl/models/ledger_objects/ripple_state.py | 77 +++++++++++++++++++++- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/xrpl/models/ledger_objects/ripple_state.py b/xrpl/models/ledger_objects/ripple_state.py index bc8985b9b..5f05f3eff 100644 --- a/xrpl/models/ledger_objects/ripple_state.py +++ b/xrpl/models/ledger_objects/ripple_state.py @@ -19,21 +19,92 @@ class RippleState(LedgerObject): """The model for the `RippleState` Ledger Object""" balance: IssuedCurrencyAmount = REQUIRED # type: ignore - flags: int = REQUIRED # type: ignore - low_limit: IssuedCurrencyAmount = REQUIRED # type: ignore + """ + The balance of the trust line, from the perspective of the low account. A negative + balance indicates that the high account holds tokens issued by the low account. The + issuer in this is always set to the neutral value ACCOUNT_ONE. This field is + required. + """ + high_limit: IssuedCurrencyAmount = REQUIRED # type: ignore + """ + The limit that the high account has set on the trust line. The `issuer` is the + address of the high account that set this limit. This field is required. + """ + + low_limit: IssuedCurrencyAmount = REQUIRED # type: ignore + """ + The limit that the low account has set on the trust line. The `issuer` is the + address of the low account that set this limit. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this entry. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this entry. This field is required. + """ + high_node: Optional[str] = None - low_node: Optional[str] = None + """ + (Omitted in some historical ledgers) A hint indicating which page of the high + account's owner directory links to this entry, in case the directory consists of + multiple pages. + """ + high_quality_in: Optional[int] = None + """ + The inbound quality set by the high account, as an integer in the implied ratio + `HighQualityIn`:1,000,000,000. As a special case, the value 0 is equivalent to 1 + billion, or face value. + """ + high_quality_out: Optional[int] = None + """ + The outbound quality set by the high account, as an integer in the implied ratio + `HighQualityOut`:1,000,000,000. As a special case, the value 0 is equivalent to 1 + billion, or face value. + """ + + low_node: Optional[str] = None + """ + (Omitted in some historical ledgers) A hint indicating which page of the low + account's owner directory links to this entry, in case the directory consists of + multiple pages. + """ + low_quality_in: Optional[int] = None + """ + The inbound quality set by the low account, as an integer in the implied ratio + `LowQualityIn`:1,000,000,000. As a special case, the value 0 is equivalent to 1 + billion, or face value. + """ + low_quality_out: Optional[int] = None + """ + The outbound quality set by the low account, as an integer in the implied ratio + `LowQualityOut`:1,000,000,000. As a special case, the value 0 is equivalent to 1 + billion, or face value. + """ + + flags: int = REQUIRED # type: ignore + """ + A bit-map of boolean options enabled for this entry. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.RIPPLE_STATE, init=False, ) + """ + The value `0x0072`, mapped to the string `RippleState`, indicates that this is a + RippleState entry. + """ class RippleStateFlag(Enum): From 5857fe0d1d585e960390c45a36b27b1587257196 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 16:13:00 -0500 Subject: [PATCH 33/58] remove unnecessary flags --- xrpl/models/ledger_objects/account_root.py | 7 +------ xrpl/models/ledger_objects/amm.py | 2 +- xrpl/models/ledger_objects/nftoken_offer.py | 5 ----- xrpl/models/ledger_objects/offer.py | 5 ----- xrpl/models/ledger_objects/ripple_state.py | 5 ----- 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/xrpl/models/ledger_objects/account_root.py b/xrpl/models/ledger_objects/account_root.py index 967005b1c..691e0d864 100644 --- a/xrpl/models/ledger_objects/account_root.py +++ b/xrpl/models/ledger_objects/account_root.py @@ -4,7 +4,7 @@ from dataclasses import dataclass, field from enum import Enum -from typing import Optional, Union +from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_object import LedgerObject @@ -141,11 +141,6 @@ class AccountRoot(LedgerObject): Unused. (The code supports this field but there is no way to set it.) """ - flags: Union[int, AccountRootFlags] = REQUIRED # type: ignore - """ - A bit-map of boolean flags. This field is required. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.ACCOUNT_ROOT, init=False ) diff --git a/xrpl/models/ledger_objects/amm.py b/xrpl/models/ledger_objects/amm.py index b07cc3275..b286e3e17 100644 --- a/xrpl/models/ledger_objects/amm.py +++ b/xrpl/models/ledger_objects/amm.py @@ -67,7 +67,7 @@ class AMM(LedgerObject): in case the directory consists of multiple pages. """ - flags: int = 0 # type: ignore + flags: int = 0 """ A bit-map of boolean flags. No flags are defined for the AMM object type, so this value is always 0. diff --git a/xrpl/models/ledger_objects/nftoken_offer.py b/xrpl/models/ledger_objects/nftoken_offer.py index 17819de45..3430492b7 100644 --- a/xrpl/models/ledger_objects/nftoken_offer.py +++ b/xrpl/models/ledger_objects/nftoken_offer.py @@ -76,11 +76,6 @@ class NFTokenOffer(LedgerObject): efficient deletion of offers. """ - flags: Union[int, NFTokenOfferFlags] = REQUIRED # type: ignore - """ - A bit-map of boolean flags. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NFTOKEN_OFFER, init=False, diff --git a/xrpl/models/ledger_objects/offer.py b/xrpl/models/ledger_objects/offer.py index b0770f993..214cf848f 100644 --- a/xrpl/models/ledger_objects/offer.py +++ b/xrpl/models/ledger_objects/offer.py @@ -76,11 +76,6 @@ class Offer(LedgerObject): This field is required. """ - flags: int = REQUIRED # type: ignore - """ - A bit-map of boolean flags. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.OFFER, init=False, diff --git a/xrpl/models/ledger_objects/ripple_state.py b/xrpl/models/ledger_objects/ripple_state.py index 5f05f3eff..1add6872a 100644 --- a/xrpl/models/ledger_objects/ripple_state.py +++ b/xrpl/models/ledger_objects/ripple_state.py @@ -92,11 +92,6 @@ class RippleState(LedgerObject): billion, or face value. """ - flags: int = REQUIRED # type: ignore - """ - A bit-map of boolean options enabled for this entry. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.RIPPLE_STATE, init=False, From c5c19c1ac087fca825f01c597434bea7746673c8 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 16:14:34 -0500 Subject: [PATCH 34/58] update SignerList --- xrpl/models/ledger_objects/signer_list.py | 36 ++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/xrpl/models/ledger_objects/signer_list.py b/xrpl/models/ledger_objects/signer_list.py index ab71d631f..d33453226 100644 --- a/xrpl/models/ledger_objects/signer_list.py +++ b/xrpl/models/ledger_objects/signer_list.py @@ -18,17 +18,51 @@ class SignerList(LedgerObject): """The model for the `SignerList` Ledger Object""" - flags: int = REQUIRED # type: ignore owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the owner directory links to this object, in case + the directory consists of multiple pages. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this object. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this object. This field is required. + """ + signer_entries: List[SignerEntry] = REQUIRED # type: ignore + """ + An array of Signer Entry objects representing the parties who are part of this + signer list. This field is required. + """ + signer_list_id: int = REQUIRED # type: ignore + """ + An ID for this signer list. Currently always set to 0. If a future amendment allows + multiple signer lists for an account, this may change. This field is required. + """ + signer_quorum: int = REQUIRED # type: ignore + """ + A target number for signer weights. To produce a valid signature for the owner of + this SignerList, the signers must provide valid signatures whose weights sum to + this value or more. This field is required. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.SIGNER_LIST, init=False, ) + """ + The value `0x0053`, mapped to the string `SignerList`, indicates that this is a + SignerList ledger entry. + """ class SignerListFlag(Enum): From a2028b4d50d925b0bd2c5b1adb9f321ff0513393 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 16:17:24 -0500 Subject: [PATCH 35/58] add index to Ticket test --- tests/unit/models/test_ledger_object.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index 785782cc3..c16f4df35 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -398,7 +398,7 @@ "644F2E854D46E8D62E9C95D18E9708CBFB1", "previous_txn_lgr_seq": 4, "ticket_sequence": 3, - "index": "", # TODO: Find out if there is an unique index + "index": "A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", } xchain_owned_claim_id_json = { @@ -885,7 +885,7 @@ def test_signer_list(self): def test_ticket(self): actual = Ticket.from_dict(ticket_json) expected = Ticket( - index="", + index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", account="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", flags=0, owner_node="0000000000000000", From 5c7a0575a4b5c6859928e85ad9404fc5a8aed594 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 16:21:20 -0500 Subject: [PATCH 36/58] update Ticket --- xrpl/models/ledger_objects/ticket.py | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/xrpl/models/ledger_objects/ticket.py b/xrpl/models/ledger_objects/ticket.py index fcd000bdb..86f753b2b 100644 --- a/xrpl/models/ledger_objects/ticket.py +++ b/xrpl/models/ledger_objects/ticket.py @@ -16,13 +16,44 @@ class Ticket(LedgerObject): """The model for the `Ticket` Ledger Object""" account: str = REQUIRED # type: ignore - # always 0 - flags: int = REQUIRED # type: ignore + """ + The account that owns this Ticket. This field is required. + """ + owner_node: str = REQUIRED # type: ignore + """ + A hint indicating which page of the owner directory links to this entry, in case + the directory consists of multiple pages. This field is required. + """ + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this entry. + This field is required. + """ + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this entry. This field is required. + """ + ticket_sequence: int = REQUIRED # type: ignore + """ + The Sequence Number this Ticket sets aside. This field is required. + """ + + flags: int = 0 + """ + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + Ticket entries. + """ + ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.TICKET, init=False, ) + """ + The value `0x0054`, mapped to the string `Ticket`, indicates that this is a Ticket + entry. + """ From 1f9a418df22ad7260719ff1c4fbc6af2691f028a Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 16:27:22 -0500 Subject: [PATCH 37/58] update docstrings --- xrpl/models/ledger_objects/xchain_owned_claim_id.py | 3 ++- .../xchain_owned_create_account_claim_id.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/xrpl/models/ledger_objects/xchain_owned_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_claim_id.py index 50e0c2f48..3068d853c 100644 --- a/xrpl/models/ledger_objects/xchain_owned_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_claim_id.py @@ -85,7 +85,8 @@ class XChainOwnedClaimID(LedgerObject): flags: int = 0 """ - Flags is always 0 since there are no flags defined for Chain entries. + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + XChainOwnedClaimID entries. """ ledger_entry_type: LedgerEntryType = field( diff --git a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py index cfc1be56a..6b41a31a0 100644 --- a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py @@ -54,7 +54,7 @@ class XChainOwnedCreateAccountClaimID(LedgerObject): owner_node: str = REQUIRED # type: ignore """ A hint indicating which page of the sender's owner directory links to this entry, - in case the directory consists of multiple pages. + in case the directory consists of multiple pages. This field is required. """ previous_txn_id: str = REQUIRED # type: ignore @@ -66,10 +66,14 @@ class XChainOwnedCreateAccountClaimID(LedgerObject): previous_txn_lgr_seq: int = REQUIRED # type: ignore """ The index of the ledger that contains the transaction that most recently modified - this object. + this object. This field is required. """ flags: int = 0 + """ + A bit-map of boolean flags. Flags is always 0 since there are no flags defined for + XChainOwnedCreateAccountClaimID entries. + """ ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.XCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, From 47e97c147ae390f111e5c3fb60dd97092c1eb2a3 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 16:41:05 -0500 Subject: [PATCH 38/58] update .rst file --- docs/source/xrpl.models.ledger_objects.rst | 153 ++------------------- 1 file changed, 9 insertions(+), 144 deletions(-) diff --git a/docs/source/xrpl.models.ledger_objects.rst b/docs/source/xrpl.models.ledger_objects.rst index 3f40a2ff0..6de6d3c21 100644 --- a/docs/source/xrpl.models.ledger_objects.rst +++ b/docs/source/xrpl.models.ledger_objects.rst @@ -1,157 +1,22 @@ -xrpl.models.ledger\_objects package +XRPL Ledger Objects Models =================================== -Submodules ----------- +Use these models to process XRP Ledger Objects. -xrpl.models.ledger\_objects.account\_root module ------------------------------------------------- +Base Ledger Object Model +---------------------- -.. automodule:: xrpl.models.ledger_objects.account_root +.. autoclass:: xrpl.models.ledger_objects.ledger_object.LedgerObject :members: :undoc-members: :show-inheritance: + :inherited-members: -xrpl.models.ledger\_objects.amendments module ---------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.amendments - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.check module ----------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.check - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.deposit\_preauth module ---------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.deposit_preauth - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.directory\_node module --------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.directory_node - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.escrow module ------------------------------------------ - -.. automodule:: xrpl.models.ledger_objects.escrow - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.fee\_settings module ------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.fee_settings - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.ledger\_entry\_type module ------------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.ledger_entry_type - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.ledger\_hashes module -------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.ledger_hashes - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.ledger\_object module -------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.ledger_object - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.negative\_unl module ------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.negative_unl - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.nftoken\_offer module -------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.nftoken_offer - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.nftoken\_page module ------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.nftoken_page - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.offer module ----------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.offer - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.pay\_channel module ------------------------------------------------ - -.. automodule:: xrpl.models.ledger_objects.pay_channel - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.ripple\_state module ------------------------------------------------- - -.. automodule:: xrpl.models.ledger_objects.ripple_state - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.signer\_list module ------------------------------------------------ - -.. automodule:: xrpl.models.ledger_objects.signer_list - :members: - :undoc-members: - :show-inheritance: - -xrpl.models.ledger\_objects.ticket module ------------------------------------------ - -.. automodule:: xrpl.models.ledger_objects.ticket - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- +Specific Ledger Object Types +-------------------------- .. automodule:: xrpl.models.ledger_objects :members: :undoc-members: :show-inheritance: + :inherited-members: From 835f821c8cbfe19b163b4e568bdda1a015176704 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 25 Jan 2024 16:48:35 -0500 Subject: [PATCH 39/58] resolve mypy errors --- xrpl/models/ledger_objects/bridge.py | 2 +- .../ledger_objects/xchain_owned_create_account_claim_id.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index c026499dc..cfbffe6b8 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -86,7 +86,7 @@ class Bridge(LedgerObject): this object. """ - flags: int = 0 # type: ignore + flags: int = 0 """ A bit-map of boolean flags. Flags is always 0 since there are no flags defined for Chain entries. diff --git a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py index 6b41a31a0..5f70a2a62 100644 --- a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py @@ -42,8 +42,7 @@ class XChainOwnedCreateAccountClaimID(LedgerObject): This field is required. """ - xchain_create_account_attestations: List[XChainCreateAccountProofSig] = REQUIRED - # type: ignore + xchain_create_account_attestations: List[XChainCreateAccountProofSig] = REQUIRED # type: ignore """ Attestations collected from the witness servers. This includes the parameters needed to recreate the message that was signed, including the amount, which chain From 4fd1134937332a6bc2816cef0964dd962b6915fa Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 1 Feb 2024 14:51:59 -0500 Subject: [PATCH 40/58] remove docstring from ledger_entry_type --- xrpl/models/ledger_objects/amendments.py | 4 ---- xrpl/models/ledger_objects/check.py | 4 ---- xrpl/models/ledger_objects/deposit_preauth.py | 4 ---- xrpl/models/ledger_objects/did.py | 4 ---- xrpl/models/ledger_objects/directory_node.py | 4 ---- xrpl/models/ledger_objects/escrow.py | 4 ---- xrpl/models/ledger_objects/fee_settings.py | 4 ---- xrpl/models/ledger_objects/ledger_hashes.py | 4 ---- xrpl/models/ledger_objects/negative_unl.py | 4 ---- xrpl/models/ledger_objects/nftoken_offer.py | 4 ---- xrpl/models/ledger_objects/nftoken_page.py | 4 ---- xrpl/models/ledger_objects/offer.py | 4 ---- xrpl/models/ledger_objects/pay_channel.py | 4 ---- xrpl/models/ledger_objects/ripple_state.py | 4 ---- xrpl/models/ledger_objects/signer_list.py | 4 ---- xrpl/models/ledger_objects/ticket.py | 4 ---- .../ledger_objects/xchain_owned_create_account_claim_id.py | 4 +++- 17 files changed, 3 insertions(+), 65 deletions(-) diff --git a/xrpl/models/ledger_objects/amendments.py b/xrpl/models/ledger_objects/amendments.py index 657a2e5a9..be9adf1be 100644 --- a/xrpl/models/ledger_objects/amendments.py +++ b/xrpl/models/ledger_objects/amendments.py @@ -33,10 +33,6 @@ class Amendments(LedgerObject): default=LedgerEntryType.AMENDMENTS, init=False, ) - """ - The value `0x0066`, mapped to the string `Amendments`, indicates that this object - describes the status of amendments to the XRP Ledger. - """ majorities: Optional[List[Majority]] = None """ diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index c8999ec7e..08b25bdf8 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -100,7 +100,3 @@ class Check(LedgerObject): default=LedgerEntryType.CHECK, init=False, ) - """ - The value 0x0043, mapped to the string `Check`, indicates that this object is a - Check object. - """ diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py index 8a61aa344..dba52c18f 100644 --- a/xrpl/models/ledger_objects/deposit_preauth.py +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -57,7 +57,3 @@ class DepositPreauth(LedgerObject): default=LedgerEntryType.DEPOSIT_PREAUTH, init=False, ) - """ - The value `0x0070`, mapped to the string `DepositPreauth`, indicates that this is a - DepositPreauth object. - """ diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index 8ab0f246d..b820e666d 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -69,7 +69,3 @@ class DID(LedgerObject): default=LedgerEntryType.DID, init=False, ) - """ - The value `0x0049`, mapped to the string `DID`, indicates that this object is a DID - object. - """ diff --git a/xrpl/models/ledger_objects/directory_node.py b/xrpl/models/ledger_objects/directory_node.py index 95ed07103..1ba330009 100644 --- a/xrpl/models/ledger_objects/directory_node.py +++ b/xrpl/models/ledger_objects/directory_node.py @@ -89,7 +89,3 @@ class DirectoryNode(LedgerObject): default=LedgerEntryType.DIRECTORY_NODE, init=False, ) - """ - The value `0x0064`, mapped to the string `DirectoryNode`, indicates that this - object is part of a Directory. - """ diff --git a/xrpl/models/ledger_objects/escrow.py b/xrpl/models/ledger_objects/escrow.py index 06e86af7c..7a53b99ed 100644 --- a/xrpl/models/ledger_objects/escrow.py +++ b/xrpl/models/ledger_objects/escrow.py @@ -100,7 +100,3 @@ class Escrow(LedgerObject): ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.ESCROW, init=False ) - """ - The value `0x0075`, mapped to the string `Escrow`, indicates that this is an Escrow - entry. - """ diff --git a/xrpl/models/ledger_objects/fee_settings.py b/xrpl/models/ledger_objects/fee_settings.py index cc9d40e76..d22b6152a 100644 --- a/xrpl/models/ledger_objects/fee_settings.py +++ b/xrpl/models/ledger_objects/fee_settings.py @@ -62,7 +62,3 @@ class FeeSettings(LedgerObject): ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.FEE_SETTINGS, init=False ) - """ - The value `0x0073`, mapped to the string `FeeSettings`, indicates that this object - contains the ledger's fee settings. - """ diff --git a/xrpl/models/ledger_objects/ledger_hashes.py b/xrpl/models/ledger_objects/ledger_hashes.py index b266f5be3..d839339b0 100644 --- a/xrpl/models/ledger_objects/ledger_hashes.py +++ b/xrpl/models/ledger_objects/ledger_hashes.py @@ -46,7 +46,3 @@ class LedgerHashes(LedgerObject): default=LedgerEntryType.LEDGER_HASHES, init=False, ) - """ - The value `0x0068`, mapped to the string `LedgerHashes`, indicates that this object - is a list of ledger hashes. - """ diff --git a/xrpl/models/ledger_objects/negative_unl.py b/xrpl/models/ledger_objects/negative_unl.py index 34dab3f15..c96d45f95 100644 --- a/xrpl/models/ledger_objects/negative_unl.py +++ b/xrpl/models/ledger_objects/negative_unl.py @@ -44,10 +44,6 @@ class NegativeUNL(LedgerObject): ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NEGATIVE_UNL, init=False ) - """ - The value `0x004E`, mapped to the string `NegativeUNL`, indicates that this entry - is the Negative UNL. - """ @require_kwargs_on_init diff --git a/xrpl/models/ledger_objects/nftoken_offer.py b/xrpl/models/ledger_objects/nftoken_offer.py index 3430492b7..74fcc272c 100644 --- a/xrpl/models/ledger_objects/nftoken_offer.py +++ b/xrpl/models/ledger_objects/nftoken_offer.py @@ -80,10 +80,6 @@ class NFTokenOffer(LedgerObject): default=LedgerEntryType.NFTOKEN_OFFER, init=False, ) - """ - The value `0x0037`, mapped to the string `NFTokenOffer`, indicates that this is an - offer to trade a `NFToken`. - """ @require_kwargs_on_init diff --git a/xrpl/models/ledger_objects/nftoken_page.py b/xrpl/models/ledger_objects/nftoken_page.py index 2b985b3ab..61a93fe19 100644 --- a/xrpl/models/ledger_objects/nftoken_page.py +++ b/xrpl/models/ledger_objects/nftoken_page.py @@ -58,7 +58,3 @@ class NFTokenPage(LedgerObject): default=LedgerEntryType.NFTOKEN_PAGE, init=False, ) - """ - The value `0x0050`, mapped to the string `NFTokenPage`, indicates that this is a - page containing `NFToken` objects. - """ diff --git a/xrpl/models/ledger_objects/offer.py b/xrpl/models/ledger_objects/offer.py index 214cf848f..114ad229f 100644 --- a/xrpl/models/ledger_objects/offer.py +++ b/xrpl/models/ledger_objects/offer.py @@ -80,10 +80,6 @@ class Offer(LedgerObject): default=LedgerEntryType.OFFER, init=False, ) - """ - The value 0x0050, mapped to the string NFTokenPage, indicates that this is a page - containing NFToken objects. - """ class OfferFlag(Enum): diff --git a/xrpl/models/ledger_objects/pay_channel.py b/xrpl/models/ledger_objects/pay_channel.py index 1153aaa25..b0cf4718f 100644 --- a/xrpl/models/ledger_objects/pay_channel.py +++ b/xrpl/models/ledger_objects/pay_channel.py @@ -126,7 +126,3 @@ class PayChannel(LedgerObject): default=LedgerEntryType.PAY_CHANNEL, init=False, ) - """ - The value `0x0078`, mapped to the string `PayChannel`, indicates that this is a - payment channel entry. - """ diff --git a/xrpl/models/ledger_objects/ripple_state.py b/xrpl/models/ledger_objects/ripple_state.py index 1add6872a..45002c0e9 100644 --- a/xrpl/models/ledger_objects/ripple_state.py +++ b/xrpl/models/ledger_objects/ripple_state.py @@ -96,10 +96,6 @@ class RippleState(LedgerObject): default=LedgerEntryType.RIPPLE_STATE, init=False, ) - """ - The value `0x0072`, mapped to the string `RippleState`, indicates that this is a - RippleState entry. - """ class RippleStateFlag(Enum): diff --git a/xrpl/models/ledger_objects/signer_list.py b/xrpl/models/ledger_objects/signer_list.py index d33453226..f6ef41f67 100644 --- a/xrpl/models/ledger_objects/signer_list.py +++ b/xrpl/models/ledger_objects/signer_list.py @@ -59,10 +59,6 @@ class SignerList(LedgerObject): default=LedgerEntryType.SIGNER_LIST, init=False, ) - """ - The value `0x0053`, mapped to the string `SignerList`, indicates that this is a - SignerList ledger entry. - """ class SignerListFlag(Enum): diff --git a/xrpl/models/ledger_objects/ticket.py b/xrpl/models/ledger_objects/ticket.py index 86f753b2b..8199ab0c1 100644 --- a/xrpl/models/ledger_objects/ticket.py +++ b/xrpl/models/ledger_objects/ticket.py @@ -53,7 +53,3 @@ class Ticket(LedgerObject): default=LedgerEntryType.TICKET, init=False, ) - """ - The value `0x0054`, mapped to the string `Ticket`, indicates that this is a Ticket - entry. - """ diff --git a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py index 5f70a2a62..0bad3a9b8 100644 --- a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py @@ -42,7 +42,9 @@ class XChainOwnedCreateAccountClaimID(LedgerObject): This field is required. """ - xchain_create_account_attestations: List[XChainCreateAccountProofSig] = REQUIRED # type: ignore + xchain_create_account_attestations: List[ + XChainCreateAccountProofSig + ] = REQUIRED # type: ignore """ Attestations collected from the witness servers. This includes the parameters needed to recreate the message that was signed, including the amount, which chain From d9858db54820cd5a9adb2adeb05fb254b21f9ed6 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 1 Feb 2024 15:38:10 -0500 Subject: [PATCH 41/58] export LedgerObject --- xrpl/models/ledger_objects/__init__.py | 2 ++ xrpl/models/ledger_objects/ledger_object.py | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/xrpl/models/ledger_objects/__init__.py b/xrpl/models/ledger_objects/__init__.py index c3dd96338..214f9d0d9 100644 --- a/xrpl/models/ledger_objects/__init__.py +++ b/xrpl/models/ledger_objects/__init__.py @@ -12,6 +12,7 @@ from xrpl.models.ledger_objects.fee_settings import FeeSettings from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.ledger_objects.ledger_hashes import LedgerHashes +from xrpl.models.ledger_objects.ledger_object import LedgerObject from xrpl.models.ledger_objects.negative_unl import DisabledValidator, NegativeUNL from xrpl.models.ledger_objects.nftoken_offer import ( NFToken, @@ -48,6 +49,7 @@ "FeeSettings", "LedgerEntryType", "LedgerHashes", + "LedgerObject", "Majority", "NegativeUNL", "NFToken", diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index 55b4a29ab..59d484a90 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -9,9 +9,6 @@ from xrpl.models.exceptions import XRPLModelException from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType from xrpl.models.required import REQUIRED - -# TODO: REMOVE if optional is needed -# from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init L = TypeVar("L", bound="LedgerObject") From eb7ad2a12ca9ba45b39e1c309f3963b2b9ff4a54 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 1 Feb 2024 15:45:05 -0500 Subject: [PATCH 42/58] set flag=0 in LedgerObject --- xrpl/models/ledger_objects/amendments.py | 6 ------ xrpl/models/ledger_objects/amm.py | 6 ------ xrpl/models/ledger_objects/bridge.py | 6 ------ xrpl/models/ledger_objects/check.py | 6 ------ xrpl/models/ledger_objects/deposit_preauth.py | 6 ------ xrpl/models/ledger_objects/did.py | 6 ------ xrpl/models/ledger_objects/directory_node.py | 6 ------ xrpl/models/ledger_objects/escrow.py | 6 ------ xrpl/models/ledger_objects/fee_settings.py | 6 ------ xrpl/models/ledger_objects/ledger_hashes.py | 6 ------ xrpl/models/ledger_objects/ledger_object.py | 2 +- xrpl/models/ledger_objects/negative_unl.py | 6 ------ xrpl/models/ledger_objects/nftoken_page.py | 6 ------ xrpl/models/ledger_objects/pay_channel.py | 6 ------ xrpl/models/ledger_objects/ticket.py | 6 ------ xrpl/models/ledger_objects/xchain_owned_claim_id.py | 6 ------ .../ledger_objects/xchain_owned_create_account_claim_id.py | 6 ------ 17 files changed, 1 insertion(+), 97 deletions(-) diff --git a/xrpl/models/ledger_objects/amendments.py b/xrpl/models/ledger_objects/amendments.py index be9adf1be..265ee66e1 100644 --- a/xrpl/models/ledger_objects/amendments.py +++ b/xrpl/models/ledger_objects/amendments.py @@ -23,12 +23,6 @@ class Amendments(LedgerObject): there are no enabled amendments. """ - flags: int = 0 - """ - A bit-map of boolean flags. Currently, the protocol defines no flags for - `Amendments` objects. The value is always 0. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.AMENDMENTS, init=False, diff --git a/xrpl/models/ledger_objects/amm.py b/xrpl/models/ledger_objects/amm.py index b286e3e17..3af32db12 100644 --- a/xrpl/models/ledger_objects/amm.py +++ b/xrpl/models/ledger_objects/amm.py @@ -67,12 +67,6 @@ class AMM(LedgerObject): in case the directory consists of multiple pages. """ - flags: int = 0 - """ - A bit-map of boolean flags. No flags are defined for the AMM object - type, so this value is always 0. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.AMM, init=False, diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index cfbffe6b8..132ea8ab4 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -86,12 +86,6 @@ class Bridge(LedgerObject): this object. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Chain entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.BRIDGE, init=False, diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index 08b25bdf8..47c2f2f27 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -90,12 +90,6 @@ class Check(LedgerObject): recipient at the sender's address. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Check entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.CHECK, init=False, diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py index dba52c18f..3d7614621 100644 --- a/xrpl/models/ledger_objects/deposit_preauth.py +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -47,12 +47,6 @@ class DepositPreauth(LedgerObject): this object. This field is required. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - DepositPreauth entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.DEPOSIT_PREAUTH, init=False, diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index b820e666d..42300a577 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -59,12 +59,6 @@ class DID(LedgerObject): bytes. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - DID entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.DID, init=False, diff --git a/xrpl/models/ledger_objects/directory_node.py b/xrpl/models/ledger_objects/directory_node.py index 1ba330009..b56ca1477 100644 --- a/xrpl/models/ledger_objects/directory_node.py +++ b/xrpl/models/ledger_objects/directory_node.py @@ -79,12 +79,6 @@ class DirectoryNode(LedgerObject): (Non-Fungible Token Directories only) The ID of the non-fungible token. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - DirectoryNode entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.DIRECTORY_NODE, init=False, diff --git a/xrpl/models/ledger_objects/escrow.py b/xrpl/models/ledger_objects/escrow.py index 7a53b99ed..6612af00e 100644 --- a/xrpl/models/ledger_objects/escrow.py +++ b/xrpl/models/ledger_objects/escrow.py @@ -91,12 +91,6 @@ class Escrow(LedgerObject): recipient at the owner's address. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Escrow entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.ESCROW, init=False ) diff --git a/xrpl/models/ledger_objects/fee_settings.py b/xrpl/models/ledger_objects/fee_settings.py index d22b6152a..3fa8476d1 100644 --- a/xrpl/models/ledger_objects/fee_settings.py +++ b/xrpl/models/ledger_objects/fee_settings.py @@ -53,12 +53,6 @@ class FeeSettings(LedgerObject): The incremental owner reserve for owning objects, as drops of XRP. """ - flags: int = 0 - """ - A bit-map of boolean flags enabled for this object. Currently, the protocol defines - no flags for `FeeSettings` objects. The value is always 0. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.FEE_SETTINGS, init=False ) diff --git a/xrpl/models/ledger_objects/ledger_hashes.py b/xrpl/models/ledger_objects/ledger_hashes.py index d839339b0..66245129c 100644 --- a/xrpl/models/ledger_objects/ledger_hashes.py +++ b/xrpl/models/ledger_objects/ledger_hashes.py @@ -36,12 +36,6 @@ class LedgerHashes(LedgerObject): LedgerHashes object this is. This field is required. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Escrow entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.LEDGER_HASHES, init=False, diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index 59d484a90..09bfacf47 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -43,7 +43,7 @@ class LedgerObject(BaseModel): RippleState, and others. This field is required. """ - flags: int = REQUIRED # type: ignore + flags: int = 0 """ Set of bit-flags for this ledger entry. """ diff --git a/xrpl/models/ledger_objects/negative_unl.py b/xrpl/models/ledger_objects/negative_unl.py index c96d45f95..56b4dbf45 100644 --- a/xrpl/models/ledger_objects/negative_unl.py +++ b/xrpl/models/ledger_objects/negative_unl.py @@ -35,12 +35,6 @@ class NegativeUNL(LedgerObject): re-enabled in the next flag ledger. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - NegativeUNL entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NEGATIVE_UNL, init=False ) diff --git a/xrpl/models/ledger_objects/nftoken_page.py b/xrpl/models/ledger_objects/nftoken_page.py index 61a93fe19..f4a15796a 100644 --- a/xrpl/models/ledger_objects/nftoken_page.py +++ b/xrpl/models/ledger_objects/nftoken_page.py @@ -48,12 +48,6 @@ class NFTokenPage(LedgerObject): modified this NFTokenPage object. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - NFTokenPage entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NFTOKEN_PAGE, init=False, diff --git a/xrpl/models/ledger_objects/pay_channel.py b/xrpl/models/ledger_objects/pay_channel.py index b0cf4718f..bfbff393e 100644 --- a/xrpl/models/ledger_objects/pay_channel.py +++ b/xrpl/models/ledger_objects/pay_channel.py @@ -116,12 +116,6 @@ class PayChannel(LedgerObject): hosted recipient at the owner's address. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - PayChannel entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.PAY_CHANNEL, init=False, diff --git a/xrpl/models/ledger_objects/ticket.py b/xrpl/models/ledger_objects/ticket.py index 8199ab0c1..5729256a0 100644 --- a/xrpl/models/ledger_objects/ticket.py +++ b/xrpl/models/ledger_objects/ticket.py @@ -43,12 +43,6 @@ class Ticket(LedgerObject): The Sequence Number this Ticket sets aside. This field is required. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - Ticket entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.TICKET, init=False, diff --git a/xrpl/models/ledger_objects/xchain_owned_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_claim_id.py index 3068d853c..b301bfc1e 100644 --- a/xrpl/models/ledger_objects/xchain_owned_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_claim_id.py @@ -83,12 +83,6 @@ class XChainOwnedClaimID(LedgerObject): this object. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - XChainOwnedClaimID entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.XCHAIN_OWNED_CLAIM_ID, init=False, diff --git a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py index 0bad3a9b8..6542e3a86 100644 --- a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py @@ -70,12 +70,6 @@ class XChainOwnedCreateAccountClaimID(LedgerObject): this object. This field is required. """ - flags: int = 0 - """ - A bit-map of boolean flags. Flags is always 0 since there are no flags defined for - XChainOwnedCreateAccountClaimID entries. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.XCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, init=False, From f56a985d6eb6add84a00a53a5ed37332ce23ff5d Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 1 Feb 2024 15:53:16 -0500 Subject: [PATCH 43/58] exclude ledger objects model from code coverage --- .coveragerc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..129b75bc3 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[run] +omit = + */xrpl/models/ledger_objects/* From 8d6fea3021118cd1635a6c8b0b98bea9eb138030 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 12 Feb 2024 14:15:21 -0500 Subject: [PATCH 44/58] add ledger_objects flags to flag list --- xrpl/models/flags.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xrpl/models/flags.py b/xrpl/models/flags.py index 67662b8f0..345faf800 100644 --- a/xrpl/models/flags.py +++ b/xrpl/models/flags.py @@ -35,6 +35,7 @@ def interface_to_flag_list( A list of flags expressed as integers. """ from xrpl.models import transactions # Avoid circular dependencies + from xrpl.models import ledger_objects # Get all exported classes with names of the form `{TxType}Flag` # These are all the flag value enums for transactions/pseudo-transactions @@ -44,6 +45,7 @@ def interface_to_flag_list( pseudo_tx_flag_enums = [ f for f in transactions.pseudo_transactions.__all__ if f.endswith("Flag") ] + ledger_object_flag_enums = [f for f in ledger_objects.__all__ if f.endswith("Flag")] # Key is transaction type name, value is mapping of flag name to int value all_tx_flags: Dict[str, Dict[str, int]] = { @@ -54,6 +56,10 @@ def interface_to_flag_list( f[:-4]: _flag_enum_to_dict(getattr(transactions.pseudo_transactions, f)) for f in pseudo_tx_flag_enums }, + **{ + f[:-4]: _flag_enum_to_dict(getattr(ledger_objects, f)) + for f in ledger_object_flag_enums + }, } # if transaction types has no flags From d63f92e3c9bc6c70b10090d632812c196dfc46ae Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 12 Feb 2024 14:22:58 -0500 Subject: [PATCH 45/58] use from_xrpl in unit tests --- tests/unit/models/test_ledger_object.py | 42 ++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index c16f4df35..cd74b5c86 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -479,7 +479,7 @@ class TestFromTODict(TestCase): def test_account_root(self): - actual = AccountRoot.from_dict(account_root_json) + actual = AccountRoot.from_xrpl(account_root_json) expected = AccountRoot( index="13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", @@ -511,7 +511,7 @@ def test_account_root(self): self.assertEqual(account_root_json, expected.to_dict()) def test_amendments(self): - actual = Amendments.from_dict(amendment_json) + actual = Amendments.from_xrpl(amendment_json) expected = Amendments( index="7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", amendments=[ @@ -532,7 +532,7 @@ def test_amendments(self): self.assertEqual(amendment_json, expected.to_dict()) def test_amm(self): - actual = AMM.from_dict(amm_json) + actual = AMM.from_xrpl(amm_json) expected = AMM( account="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", asset=XRP(), @@ -573,7 +573,7 @@ def test_amm(self): self.assertEqual(amm_json, expected.to_dict()) def test_bridge(self): - actual = Bridge.from_dict(bridge_json) + actual = Bridge.from_xrpl(bridge_json) expected = Bridge( account="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", min_account_create_amount="2000000000", @@ -597,7 +597,7 @@ def test_bridge(self): self.assertEqual(bridge_json, expected.to_dict()) def test_check(self): - actual = Check.from_dict(check_json) + actual = Check.from_xrpl(check_json) expected = Check( index="49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", account="rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", @@ -619,7 +619,7 @@ def test_check(self): self.assertEqual(check_json, expected.to_dict()) def test_deposit_preauth(self): - actual = DepositPreauth.from_dict(deposit_preauth_json) + actual = DepositPreauth.from_xrpl(deposit_preauth_json) expected = DepositPreauth( index="4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", account="rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", @@ -633,7 +633,7 @@ def test_deposit_preauth(self): self.assertEqual(deposit_preauth_json, expected.to_dict()) def test_did(self): - actual = DID.from_dict(did_json) + actual = DID.from_xrpl(did_json) expected = DID( account="rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", did_document="646F63", @@ -649,7 +649,7 @@ def test_did(self): self.assertEqual(did_json, expected.to_dict()) def test_directory_node(self): - actual = DirectoryNode.from_dict(directory_node_json) + actual = DirectoryNode.from_xrpl(directory_node_json) expected = DirectoryNode( index="1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", root_index="1BBEF97EDE88D40CEE2ADE6FEF121166A" @@ -671,7 +671,7 @@ def test_directory_node(self): self.assertEqual(directory_node_json, expected.to_dict()) def test_escrow(self): - actual = Escrow.from_dict(escrow_json) + actual = Escrow.from_xrpl(escrow_json) expected = Escrow( index="DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", @@ -693,7 +693,7 @@ def test_escrow(self): self.assertEqual(escrow_json, expected.to_dict()) def test_fee_settings(self): - actual = FeeSettings.from_dict(fee_settings_json) + actual = FeeSettings.from_xrpl(fee_settings_json) expected = FeeSettings( index="4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", base_fee="000000000000000A", @@ -705,7 +705,7 @@ def test_fee_settings(self): self.assertEqual(fee_settings_json, expected.to_dict()) def test_ledger_hashes(self): - actual = LedgerHashes.from_dict(ledger_hashes_json) + actual = LedgerHashes.from_xrpl(ledger_hashes_json) expected = LedgerHashes( index="B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B", first_ledger_sequence=2, @@ -722,7 +722,7 @@ def test_ledger_hashes(self): self.assertEqual(ledger_hashes_json, expected.to_dict()) def test_negative_unl(self): - actual = NegativeUNL.from_dict(negative_unl_json) + actual = NegativeUNL.from_xrpl(negative_unl_json) expected = NegativeUNL( index="2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", disabled_validators=[ @@ -739,7 +739,7 @@ def test_negative_unl(self): self.assertEqual(negative_unl_json, expected.to_dict()) def test_nftoken_offer(self): - actual = NFTokenOffer.from_dict(nftoken_offer_json) + actual = NFTokenOffer.from_xrpl(nftoken_offer_json) expected = NFTokenOffer( index="AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", amount="1000000", @@ -757,7 +757,7 @@ def test_nftoken_offer(self): self.assertEqual(nftoken_offer_json, expected.to_dict()) def test_nftoken_page(self): - actual = NFTokenPage.from_dict(nftoken_page_json) + actual = NFTokenPage.from_xrpl(nftoken_page_json) expected = NFTokenPage( index="", previous_page_min=None, @@ -779,7 +779,7 @@ def test_nftoken_page(self): self.assertEqual(nftoken_page_json, expected.to_dict()) def test_offer(self): - actual = Offer.from_dict(offer_json) + actual = Offer.from_xrpl(offer_json) expected = Offer( index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", @@ -802,7 +802,7 @@ def test_offer(self): self.assertEqual(offer_json, expected.to_dict()) def test_pay_channel(self): - actual = PayChannel.from_dict(pay_channel_json) + actual = PayChannel.from_xrpl(pay_channel_json) expected = PayChannel( index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", @@ -827,7 +827,7 @@ def test_pay_channel(self): self.assertEqual(pay_channel_json, expected.to_dict()) def test_ripple_state(self): - actual = RippleState.from_dict(ripple_state_json) + actual = RippleState.from_xrpl(ripple_state_json) expected = RippleState( index="9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", balance=IssuedCurrencyAmount( @@ -854,7 +854,7 @@ def test_ripple_state(self): self.assertEqual(ripple_state_json, expected.to_dict()) def test_signer_list(self): - actual = SignerList.from_dict(signer_list_json) + actual = SignerList.from_xrpl(signer_list_json) expected = SignerList( index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", flags=0, @@ -883,7 +883,7 @@ def test_signer_list(self): self.assertEqual(signer_list_json, expected.to_dict()) def test_ticket(self): - actual = Ticket.from_dict(ticket_json) + actual = Ticket.from_xrpl(ticket_json) expected = Ticket( index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", account="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", @@ -898,7 +898,7 @@ def test_ticket(self): self.assertEqual(ticket_json, expected.to_dict()) def test_xchain_owned_claim_id(self): - actual = XChainOwnedClaimID.from_dict(xchain_owned_claim_id_json) + actual = XChainOwnedClaimID.from_xrpl(xchain_owned_claim_id_json) expected = XChainOwnedClaimID( account="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", other_chain_source="r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", @@ -941,7 +941,7 @@ def test_xchain_owned_claim_id(self): self.assertEqual(xchain_owned_claim_id_json, expected.to_dict()) def test_xchain_owned_create_account_claim_id(self): - actual = XChainOwnedCreateAccountClaimID.from_dict( + actual = XChainOwnedCreateAccountClaimID.from_xrpl( xchain_owned_create_account_claim_id_json ) expected = XChainOwnedCreateAccountClaimID( From 097ac0c5b4582c786d9db6e847078693bdd06993 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 12 Feb 2024 14:30:53 -0500 Subject: [PATCH 46/58] remove optional fields in unit tests --- tests/unit/models/test_ledger_object.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index cd74b5c86..e02518b26 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -483,7 +483,6 @@ def test_account_root(self): expected = AccountRoot( index="13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - amm_id=None, balance="148446663", flags=8388608, owner_count=3, @@ -493,19 +492,11 @@ def test_account_root(self): sequence=336, account_txn_id="0D5FB50FA65C9FE1538FD7E398FFFE9D1" "908DFA4576D8D7A020040686F93C77D", - burned_nftokens=None, - first_nftoken_sequence=None, domain="6D64756F31332E636F6D", email_hash="98B4375E1D753E5B91627516F6D70977", message_key="0000000000000000000000070000000300", - minted_nftokens=None, nftoken_minter="rHello", - regular_key=None, - ticket_count=None, - tick_size=None, transfer_rate=1004999999, - wallet_locator=None, - wallet_size=None, ) self.assertEqual(actual, expected) self.assertEqual(account_root_json, expected.to_dict()) @@ -613,7 +604,6 @@ def test_check(self): expiration=570113521, invoice_id="46060241FABCF692D4D934BA2A6C4427CD427" "9083E38C77CBE642243E43BE291", - source_tag=None, ) self.assertEqual(actual, expected) self.assertEqual(check_json, expected.to_dict()) @@ -657,15 +647,11 @@ def test_directory_node(self): indexes=[ "AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD" ], - index_next=None, - index_previous=None, - owner=None, exchange_rate="4F069BA8FF484000", taker_pays_currency="0000000000000000000000004A50590000000000", taker_pays_issuer="5BBC0F22F61D9224A110650CFE21CC0C4BE13098", taker_gets_currency="0000000000000000000000000000000000000000", taker_gets_issuer="0000000000000000000000000000000000000000", - nftoken_id=None, ) self.assertEqual(actual, expected) self.assertEqual(directory_node_json, expected.to_dict()) @@ -732,8 +718,6 @@ def test_negative_unl(self): "3921F309949AFCD2CA7AFEC16FE", ) ], - validator_to_disable=None, - validator_to_re_enable=None, ) self.assertEqual(actual, expected) self.assertEqual(negative_unl_json, expected.to_dict()) @@ -760,8 +744,6 @@ def test_nftoken_page(self): actual = NFTokenPage.from_xrpl(nftoken_page_json) expected = NFTokenPage( index="", - previous_page_min=None, - next_page_min=None, previous_txn_id="95C8761B22894E328646F7A70035E9DFBEC" "C90EDD83E43B7B973F626D21A0822", previous_txn_lgr_seq=42891441, @@ -796,7 +778,6 @@ def test_offer(self): previous_txn_id="F0AB71E777B2DA54B86231E19B82554EF1F821" "1F92ECA473121C655BFC5329BF", previous_txn_lgr_seq=14524914, - expiration=None, ) self.assertEqual(actual, expected) self.assertEqual(offer_json, expected.to_dict()) @@ -845,10 +826,6 @@ def test_ripple_state(self): previous_txn_lgr_seq=14090896, high_node="0000000000000000", low_node="0000000000000000", - high_quality_in=None, - high_quality_out=None, - low_quality_in=None, - low_quality_out=None, ) self.assertEqual(actual, expected) self.assertEqual(ripple_state_json, expected.to_dict()) From 2370e500eef4f9e4e7e53efe078116b7c4016297 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 12 Feb 2024 14:34:55 -0500 Subject: [PATCH 47/58] make index_next and index_previous strings --- xrpl/models/ledger_objects/directory_node.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xrpl/models/ledger_objects/directory_node.py b/xrpl/models/ledger_objects/directory_node.py index b56ca1477..bf5eeb905 100644 --- a/xrpl/models/ledger_objects/directory_node.py +++ b/xrpl/models/ledger_objects/directory_node.py @@ -27,13 +27,13 @@ class DirectoryNode(LedgerObject): This field is required. """ - index_next: Optional[int] = None + index_next: Optional[str] = None """ If this Directory consists of multiple pages, this ID links to the next object in the chain, wrapping around at the end. """ - index_previous: Optional[int] = None + index_previous: Optional[str] = None """ If this Directory consists of multiple pages, this ID links to the previous object in the chain, wrapping around at the beginning. This field is required. From 6cd3389c9081cb4796066c4aa1840ef3b1ebe180 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 12 Feb 2024 15:06:35 -0500 Subject: [PATCH 48/58] add HasPreviousTxnID class to be inherited by ledger object models --- xrpl/models/ledger_objects/account_root.py | 16 ++------------ xrpl/models/ledger_objects/bridge.py | 16 ++------------ xrpl/models/ledger_objects/check.py | 16 ++------------ xrpl/models/ledger_objects/deposit_preauth.py | 16 ++------------ xrpl/models/ledger_objects/did.py | 16 ++------------ xrpl/models/ledger_objects/escrow.py | 16 ++------------ xrpl/models/ledger_objects/ledger_object.py | 21 +++++++++++++++++++ xrpl/models/ledger_objects/nftoken_offer.py | 16 ++------------ xrpl/models/ledger_objects/nftoken_page.py | 16 ++------------ xrpl/models/ledger_objects/offer.py | 16 ++------------ xrpl/models/ledger_objects/pay_channel.py | 16 ++------------ xrpl/models/ledger_objects/ripple_state.py | 16 ++------------ xrpl/models/ledger_objects/signer_list.py | 16 ++------------ xrpl/models/ledger_objects/ticket.py | 16 ++------------ .../ledger_objects/xchain_owned_claim_id.py | 16 ++------------ .../xchain_owned_create_account_claim_id.py | 16 ++------------ 16 files changed, 51 insertions(+), 210 deletions(-) diff --git a/xrpl/models/ledger_objects/account_root.py b/xrpl/models/ledger_objects/account_root.py index 691e0d864..56fb8ab82 100644 --- a/xrpl/models/ledger_objects/account_root.py +++ b/xrpl/models/ledger_objects/account_root.py @@ -7,14 +7,14 @@ from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class AccountRoot(LedgerObject): +class AccountRoot(LedgerObject, HasPreviousTxnID): """The model for the `AccountRoot` Ledger Object""" account: str = REQUIRED # type: ignore @@ -89,18 +89,6 @@ class AccountRoot(LedgerObject): owner reserve. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. This field is required. - """ - regular_key: Optional[str] = None """ The address of a key pair that can be used to sign transactions for this account diff --git a/xrpl/models/ledger_objects/bridge.py b/xrpl/models/ledger_objects/bridge.py index 132ea8ab4..fe42e9954 100644 --- a/xrpl/models/ledger_objects/bridge.py +++ b/xrpl/models/ledger_objects/bridge.py @@ -6,7 +6,7 @@ from typing import Optional, Union from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init from xrpl.models.xchain_bridge import XChainBridge @@ -14,7 +14,7 @@ @require_kwargs_on_init @dataclass(frozen=True) -class Bridge(LedgerObject): +class Bridge(LedgerObject, HasPreviousTxnID): """The model for the `Bridge` Ledger Object""" account: str = REQUIRED # type: ignore @@ -74,18 +74,6 @@ class Bridge(LedgerObject): in case the directory consists of multiple pages. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.BRIDGE, init=False, diff --git a/xrpl/models/ledger_objects/check.py b/xrpl/models/ledger_objects/check.py index 47c2f2f27..ec0162406 100644 --- a/xrpl/models/ledger_objects/check.py +++ b/xrpl/models/ledger_objects/check.py @@ -7,14 +7,14 @@ from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class Check(LedgerObject): +class Check(LedgerObject, HasPreviousTxnID): """The model for the `Check` Ledger Object""" account: str = REQUIRED # type: ignore @@ -59,18 +59,6 @@ class Check(LedgerObject): in case the directory consists of multiple pages. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. This field is required. - """ - send_max: Union[str, IssuedCurrencyAmount] = REQUIRED # type: ignore """ The maximum amount of currency this Check can debit the sender. If the Check is diff --git a/xrpl/models/ledger_objects/deposit_preauth.py b/xrpl/models/ledger_objects/deposit_preauth.py index 3d7614621..a3dda1326 100644 --- a/xrpl/models/ledger_objects/deposit_preauth.py +++ b/xrpl/models/ledger_objects/deposit_preauth.py @@ -5,14 +5,14 @@ from dataclasses import dataclass, field from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class DepositPreauth(LedgerObject): +class DepositPreauth(LedgerObject, HasPreviousTxnID): """The model for the `DepositPreauth` Ledger Object""" account: str = REQUIRED # type: ignore @@ -35,18 +35,6 @@ class DepositPreauth(LedgerObject): from the Account. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. This field is required. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.DEPOSIT_PREAUTH, init=False, diff --git a/xrpl/models/ledger_objects/did.py b/xrpl/models/ledger_objects/did.py index 42300a577..a86146ef7 100644 --- a/xrpl/models/ledger_objects/did.py +++ b/xrpl/models/ledger_objects/did.py @@ -6,14 +6,14 @@ from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class DID(LedgerObject): +class DID(LedgerObject, HasPreviousTxnID): """The model for the `DID` Ledger Object""" account: str = REQUIRED # type: ignore @@ -39,18 +39,6 @@ class DID(LedgerObject): in case the directory consists of multiple pages. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. - """ - uri: Optional[str] = None """ The Universal Resource Identifier that points to the corresponding DID document or diff --git a/xrpl/models/ledger_objects/escrow.py b/xrpl/models/ledger_objects/escrow.py index 6612af00e..1a8af81bd 100644 --- a/xrpl/models/ledger_objects/escrow.py +++ b/xrpl/models/ledger_objects/escrow.py @@ -6,14 +6,14 @@ from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class Escrow(LedgerObject): +class Escrow(LedgerObject, HasPreviousTxnID): """The model for the `Escrow` Ledger Object""" account: str = REQUIRED # type: ignore @@ -39,18 +39,6 @@ class Escrow(LedgerObject): in case the directory consists of multiple pages. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this entry. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this entry. This field is required. - """ - condition: Optional[str] = None """ A PREIMAGE-SHA-256 crypto-condition , as hexadecimal. If present, the `EscrowFinish` diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index 09bfacf47..caddabb4f 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -166,3 +166,24 @@ def __getitem__(self: LedgerObject, field_name: str) -> Any: ): return self return self.__getattribute__(field_name) + + +@require_kwargs_on_init +@dataclass(frozen=True) +class HasPreviousTxnID: + """ + A mixin for ledger objects that have `PreviousTxnID` and `PreviousTxnLgrSeq` + fields. + """ + + previous_txn_id: str = REQUIRED # type: ignore + """ + The identifying hash of the transaction that most recently modified this entry. + This field is required. + """ + + previous_txn_lgr_seq: int = REQUIRED # type: ignore + """ + The index of the ledger that contains the transaction that most recently modified + this entry. This field is required. + """ diff --git a/xrpl/models/ledger_objects/nftoken_offer.py b/xrpl/models/ledger_objects/nftoken_offer.py index 74fcc272c..dc177227b 100644 --- a/xrpl/models/ledger_objects/nftoken_offer.py +++ b/xrpl/models/ledger_objects/nftoken_offer.py @@ -8,14 +8,14 @@ from xrpl.models.base_model import BaseModel from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class NFTokenOffer(LedgerObject): +class NFTokenOffer(LedgerObject, HasPreviousTxnID): """The model for the `NFTokenOffer` Ledger Object""" amount: Union[str, NFToken] = REQUIRED # type: ignore @@ -39,18 +39,6 @@ class NFTokenOffer(LedgerObject): offer to buy an NFToken. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - Identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - Index of the ledger that contains the transaction that most recently modified this - object. This field is required. - """ - destination: Optional[str] = None """ The AccountID for which this offer is intended. If present, only that account can diff --git a/xrpl/models/ledger_objects/nftoken_page.py b/xrpl/models/ledger_objects/nftoken_page.py index f4a15796a..d5bcfa6e6 100644 --- a/xrpl/models/ledger_objects/nftoken_page.py +++ b/xrpl/models/ledger_objects/nftoken_page.py @@ -6,7 +6,7 @@ from typing import List, Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.ledger_objects.nftoken_offer import NFToken from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @@ -14,7 +14,7 @@ @require_kwargs_on_init @dataclass(frozen=True) -class NFTokenPage(LedgerObject): +class NFTokenPage(LedgerObject, HasPreviousTxnID): """The model for the `NFTokenPage` Ledger Object""" next_page_min: Optional[str] = None @@ -36,18 +36,6 @@ class NFTokenPage(LedgerObject): sorted from low to high with the NFTokenID used as the sorting parameter. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - Identifies the transaction ID of the transaction that most recently modified this - NFTokenPage object. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The sequence of the ledger that contains the transaction that most recently - modified this NFTokenPage object. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.NFTOKEN_PAGE, init=False, diff --git a/xrpl/models/ledger_objects/offer.py b/xrpl/models/ledger_objects/offer.py index 114ad229f..0fea1778a 100644 --- a/xrpl/models/ledger_objects/offer.py +++ b/xrpl/models/ledger_objects/offer.py @@ -8,14 +8,14 @@ from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class Offer(LedgerObject): +class Offer(LedgerObject, HasPreviousTxnID): """The model for the `Offer` Ledger Object""" account: str = REQUIRED # type: ignore @@ -46,18 +46,6 @@ class Offer(LedgerObject): the directory consists of multiple pages. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this entry. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. This field is required. - """ - sequence: int = REQUIRED # type: ignore """ The `Sequence` value of the `OfferCreate` transaction that created this offer. Used diff --git a/xrpl/models/ledger_objects/pay_channel.py b/xrpl/models/ledger_objects/pay_channel.py index bfbff393e..eaa434d38 100644 --- a/xrpl/models/ledger_objects/pay_channel.py +++ b/xrpl/models/ledger_objects/pay_channel.py @@ -6,14 +6,14 @@ from typing import Optional from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class PayChannel(LedgerObject): +class PayChannel(LedgerObject, HasPreviousTxnID): """The model for the `PayChannel` Ledger Object""" account: str = REQUIRED # type: ignore @@ -74,18 +74,6 @@ class PayChannel(LedgerObject): channel to the destination without signed claims. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this entry. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this entry. This field is required. - """ - settle_delay: int = REQUIRED # type: ignore """ Number of seconds the source address must wait to close the channel if it still has diff --git a/xrpl/models/ledger_objects/ripple_state.py b/xrpl/models/ledger_objects/ripple_state.py index 45002c0e9..60b893b32 100644 --- a/xrpl/models/ledger_objects/ripple_state.py +++ b/xrpl/models/ledger_objects/ripple_state.py @@ -8,14 +8,14 @@ from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class RippleState(LedgerObject): +class RippleState(LedgerObject, HasPreviousTxnID): """The model for the `RippleState` Ledger Object""" balance: IssuedCurrencyAmount = REQUIRED # type: ignore @@ -38,18 +38,6 @@ class RippleState(LedgerObject): address of the low account that set this limit. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this entry. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this entry. This field is required. - """ - high_node: Optional[str] = None """ (Omitted in some historical ledgers) A hint indicating which page of the high diff --git a/xrpl/models/ledger_objects/signer_list.py b/xrpl/models/ledger_objects/signer_list.py index f6ef41f67..519f39b45 100644 --- a/xrpl/models/ledger_objects/signer_list.py +++ b/xrpl/models/ledger_objects/signer_list.py @@ -7,7 +7,7 @@ from typing import List from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.transactions.signer_list_set import SignerEntry from xrpl.models.utils import require_kwargs_on_init @@ -15,7 +15,7 @@ @require_kwargs_on_init @dataclass(frozen=True) -class SignerList(LedgerObject): +class SignerList(LedgerObject, HasPreviousTxnID): """The model for the `SignerList` Ledger Object""" owner_node: str = REQUIRED # type: ignore @@ -24,18 +24,6 @@ class SignerList(LedgerObject): the directory consists of multiple pages. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. This field is required. - """ - signer_entries: List[SignerEntry] = REQUIRED # type: ignore """ An array of Signer Entry objects representing the parties who are part of this diff --git a/xrpl/models/ledger_objects/ticket.py b/xrpl/models/ledger_objects/ticket.py index 5729256a0..ec455e5e1 100644 --- a/xrpl/models/ledger_objects/ticket.py +++ b/xrpl/models/ledger_objects/ticket.py @@ -5,14 +5,14 @@ from dataclasses import dataclass, field from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @require_kwargs_on_init @dataclass(frozen=True) -class Ticket(LedgerObject): +class Ticket(LedgerObject, HasPreviousTxnID): """The model for the `Ticket` Ledger Object""" account: str = REQUIRED # type: ignore @@ -26,18 +26,6 @@ class Ticket(LedgerObject): the directory consists of multiple pages. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this entry. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this entry. This field is required. - """ - ticket_sequence: int = REQUIRED # type: ignore """ The Sequence Number this Ticket sets aside. This field is required. diff --git a/xrpl/models/ledger_objects/xchain_owned_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_claim_id.py index b301bfc1e..95750ef42 100644 --- a/xrpl/models/ledger_objects/xchain_owned_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_claim_id.py @@ -6,7 +6,7 @@ from typing import List, Optional, Union from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.nested_model import NestedModel from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @@ -15,7 +15,7 @@ @require_kwargs_on_init @dataclass(frozen=True) -class XChainOwnedClaimID(LedgerObject): +class XChainOwnedClaimID(LedgerObject, HasPreviousTxnID): """The model for the `XChainOwnedClaimID` Ledger Object""" account: str = REQUIRED # type: ignore @@ -71,18 +71,6 @@ class XChainOwnedClaimID(LedgerObject): in case the directory consists of multiple pages. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.XCHAIN_OWNED_CLAIM_ID, init=False, diff --git a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py index 6542e3a86..aaff0bdcf 100644 --- a/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py +++ b/xrpl/models/ledger_objects/xchain_owned_create_account_claim_id.py @@ -6,7 +6,7 @@ from typing import List, Optional, Union from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType -from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ledger_object import HasPreviousTxnID, LedgerObject from xrpl.models.nested_model import NestedModel from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @@ -15,7 +15,7 @@ @require_kwargs_on_init @dataclass(frozen=True) -class XChainOwnedCreateAccountClaimID(LedgerObject): +class XChainOwnedCreateAccountClaimID(LedgerObject, HasPreviousTxnID): """The model for the `XChainOwnedCreateAccountClaimID` Ledger Object""" account: str = REQUIRED # type: ignore @@ -58,18 +58,6 @@ class XChainOwnedCreateAccountClaimID(LedgerObject): in case the directory consists of multiple pages. This field is required. """ - previous_txn_id: str = REQUIRED # type: ignore - """ - The identifying hash of the transaction that most recently modified this object. - This field is required. - """ - - previous_txn_lgr_seq: int = REQUIRED # type: ignore - """ - The index of the ledger that contains the transaction that most recently modified - this object. This field is required. - """ - ledger_entry_type: LedgerEntryType = field( default=LedgerEntryType.XCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, init=False, From 3d4ef7e1bdfd949aad250e3bb2707af9c60ce305 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Tue, 13 Feb 2024 14:13:26 -0500 Subject: [PATCH 49/58] add TODO to .coveragerc --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index 129b75bc3..905ea2273 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,4 @@ [run] omit = + # TODO: Remove the following line once the models are incorporated into the rest of the code. */xrpl/models/ledger_objects/* From 376590b0a1d2d35b7354a11c028f29f1f43d0604 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Tue, 13 Feb 2024 14:15:40 -0500 Subject: [PATCH 50/58] update TODO in .coveragerc --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 905ea2273..bd6db6799 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,4 @@ +# TODO: Delete this .coveragerc file once the ledger objects models are incorporated into the rest of the code. [run] omit = - # TODO: Remove the following line once the models are incorporated into the rest of the code. */xrpl/models/ledger_objects/* From 901ed122fc15846d0cc62dd150dcaf9292b43de5 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Fri, 16 Feb 2024 11:57:23 -0500 Subject: [PATCH 51/58] update test JSONs to match XRPL formatting --- tests/unit/models/test_ledger_object.py | 574 ++++++++++++------------ xrpl/models/ledger_objects/amm.py | 2 +- 2 files changed, 277 insertions(+), 299 deletions(-) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py index e02518b26..324e87936 100644 --- a/tests/unit/models/test_ledger_object.py +++ b/tests/unit/models/test_ledger_object.py @@ -30,6 +30,7 @@ ) from xrpl.models.ledger_objects.amm import AuctionSlot, VoteEntry from xrpl.models.ledger_objects.bridge import Bridge +from xrpl.models.ledger_objects.ledger_object import LedgerObject from xrpl.models.ledger_objects.xchain_owned_claim_id import ( XChainClaimProofSig, XChainOwnedClaimID, @@ -41,199 +42,199 @@ from xrpl.models.xchain_bridge import XChainBridge account_root_json = { - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "account_txn_id": "0D5FB50FA65C9FE1538FD7E398FFFE9D190" + "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "AccountTxnID": "0D5FB50FA65C9FE1538FD7E398FFFE9D190" "8DFA4576D8D7A020040686F93C77D", - "balance": "148446663", - "domain": "6D64756F31332E636F6D", - "email_hash": "98B4375E1D753E5B91627516F6D70977", - "flags": 8388608, - "ledger_entry_type": "AccountRoot", - "message_key": "0000000000000000000000070000000300", - "owner_count": 3, - "nftoken_minter": "rHello", - "previous_txn_id": "0D5FB50FA65C9FE1538FD7E398FFFE9D1908DFA4576D8D7A0200" + "Balance": "148446663", + "Domain": "6D64756F31332E636F6D", + "EmailHash": "98B4375E1D753E5B91627516F6D70977", + "Flags": 8388608, + "LedgerEntryType": "AccountRoot", + "MessageKey": "0000000000000000000000070000000300", + "OwnerCount": 3, + "NFTokenMinter": "rHello", + "PreviousTxnID": "0D5FB50FA65C9FE1538FD7E398FFFE9D1908DFA4576D8D7A0200" "40686F93C77D", - "previous_txn_lgr_seq": 14091160, - "sequence": 336, - "transfer_rate": 1004999999, + "PreviousTxnLgrSeq": 14091160, + "Sequence": 336, + "TransferRate": 1004999999, "index": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", } amendment_json = { - "majorities": [ + "Majorities": [ { - "majority": { - "amendment": "1562511F573A19AE9BD103B5D6B9E01B3B46805AEC5D3C4805C902B51" + "Majority": { + "Amendment": "1562511F573A19AE9BD103B5D6B9E01B3B46805AEC5D3C4805C902B51" "4399146", - "close_time": 535589001, + "CloseTime": 535589001, } } ], - "amendments": [ + "Amendments": [ "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE", "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373", "6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC", "740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D628A06927F11", ], - "flags": 0, - "ledger_entry_type": "Amendments", + "Flags": 0, + "LedgerEntryType": "Amendments", "index": "7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", } amm_json = { - "account": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", - "asset": {"currency": "XRP"}, - "asset2": {"currency": "TST", "issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"}, - "auction_slot": { - "account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", - "auth_accounts": [ - {"auth_account": {"account": "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"}}, - {"auth_account": {"account": "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"}}, + "Account": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "TST", "issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"}, + "AuctionSlot": { + "Account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + "AuthAccounts": [ + {"AuthAccount": {"Account": "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"}}, + {"AuthAccount": {"Account": "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"}}, ], - "discounted_fee": 0, - "expiration": 721870180, - "price": { + "DiscountedFee": 0, + "Expiration": 721870180, + "Price": { "currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2", "issuer": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", "value": "0.8696263565463045", }, }, - "lptoken_balance": { + "LPTokenBalance": { "currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2", "issuer": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", "value": "71150.53584131501", }, - "trading_fee": 600, - "vote_slots": [ + "TradingFee": 600, + "VoteSlots": [ { - "vote_entry": { - "account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", - "trading_fee": 600, - "vote_weight": 100000, + "VoteEntry": { + "Account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + "TradingFee": 600, + "VoteWeight": 100000, } } ], - "owner_node": "0", - "flags": 0, - "ledger_entry_type": "AMM", + "OwnerNode": "0", + "Flags": 0, + "LedgerEntryType": "AMM", } bridge_json = { - "account": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", - "flags": 0, - "ledger_entry_type": "Bridge", - "min_account_create_amount": "2000000000", - "owner_node": "0", - "previous_txn_id": "67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE917FD1A71919EAE7548E56" + "Account": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + "Flags": 0, + "LedgerEntryType": "Bridge", + "MinAccountCreateAmount": "2000000000", + "OwnerNode": "0", + "PreviousTxnID": "67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE917FD1A71919EAE7548E56" "36", - "previous_txn_lgr_seq": 102, - "signature_reward": "204", - "xchain_account_claim_count": "0", - "xchain_account_create_count": "0", - "xchain_bridge": { - "issuing_chain_door": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "issuing_chain_issue": {"currency": "XRP"}, - "locking_chain_door": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", - "locking_chain_issue": {"currency": "XRP"}, + "PreviousTxnLgrSeq": 102, + "SignatureReward": "204", + "XChainAccountClaimCount": "0", + "XChainAccountCreateCount": "0", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": {"currency": "XRP"}, + "LockingChainDoor": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + "LockingChainIssue": {"currency": "XRP"}, }, - "xchain_claim_id": "1", + "XChainClaimID": "1", "index": "9F2C9E23343852036AFD323025A8506018ABF9D4DBAA746D61BF1CFB5C297D10", } check_json = { - "account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", - "destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", - "destination_node": "0000000000000000", - "destination_tag": 1, - "expiration": 570113521, - "flags": 0, - "invoice_id": "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291", - "ledger_entry_type": "Check", - "owner_node": "0000000000000000", - "previous_txn_id": "5463C6E08862A1FAE5EDAC12D70ADB16546A1F67" + "Account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + "Destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + "DestinationNode": "0000000000000000", + "DestinationTag": 1, + "Expiration": 570113521, + "Flags": 0, + "InvoiceID": "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291", + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "5463C6E08862A1FAE5EDAC12D70ADB16546A1F67" "4930521295BC082494B62924", - "previous_txn_lgr_seq": 6, - "send_max": "100000000", - "sequence": 2, + "PreviousTxnLgrSeq": 6, + "SendMax": "100000000", + "Sequence": 2, "index": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", } deposit_preauth_json = { - "ledger_entry_type": "DepositPreauth", - "account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", - "authorize": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", - "flags": 0, - "owner_node": "0000000000000000", - "previous_txn_id": "3E8964D5A86B3CD6B9ECB33310D4E073D64C865A5B866200" + "LedgerEntryType": "DepositPreauth", + "Account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", + "Authorize": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + "Flags": 0, + "OwnerNode": "0000000000000000", + "PreviousTxnID": "3E8964D5A86B3CD6B9ECB33310D4E073D64C865A5B866200" "AD2B7E29F8326702", - "previous_txn_lgr_seq": 7, + "PreviousTxnLgrSeq": 7, "index": "4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", } did_json = { - "account": "rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", - "did_document": "646F63", - "data": "617474657374", - "flags": 0, - "ledger_entry_type": "DID", - "owner_node": "0", - "previous_txn_id": "A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B0" + "Account": "rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", + "DIDDocument": "646F63", + "Data": "617474657374", + "Flags": 0, + "LedgerEntryType": "DID", + "OwnerNode": "0", + "PreviousTxnID": "A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B0" "9F708778E41120", - "previous_txn_lgr_seq": 4, - "uri": "6469645F6578616D706C65", + "PreviousTxnLgrSeq": 4, + "URI": "6469645F6578616D706C65", "index": "46813BE38B798B3752CA590D44E7FEADB17485649074403AD1761A2835CE91FF", } directory_node_json = { - "exchange_rate": "4F069BA8FF484000", - "flags": 0, - "indexes": ["AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD"], - "ledger_entry_type": "DirectoryNode", - "root_index": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", - "taker_gets_currency": "0000000000000000000000000000000000000000", - "taker_gets_issuer": "0000000000000000000000000000000000000000", - "taker_pays_currency": "0000000000000000000000004A50590000000000", - "taker_pays_issuer": "5BBC0F22F61D9224A110650CFE21CC0C4BE13098", + "ExchangeRate": "4F069BA8FF484000", + "Flags": 0, + "Indexes": ["AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD"], + "LedgerEntryType": "DirectoryNode", + "RootIndex": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", + "TakerGetsCurrency": "0000000000000000000000000000000000000000", + "TakerGetsIssuer": "0000000000000000000000000000000000000000", + "TakerPaysCurrency": "0000000000000000000000004A50590000000000", + "TakerPaysIssuer": "5BBC0F22F61D9224A110650CFE21CC0C4BE13098", "index": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", } escrow_json = { - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "amount": "10000", - "cancel_after": 545440232, - "condition": "A0258020A82A88B2DF843A54F58772E4A3861866ECDB4157645DD9AE528C1D3AEEDAB" + "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "Amount": "10000", + "CancelAfter": 545440232, + "Condition": "A0258020A82A88B2DF843A54F58772E4A3861866ECDB4157645DD9AE528C1D3AEEDAB" "AB6810120", - "destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - "destination_tag": 23480, - "finish_after": 545354132, - "flags": 0, - "ledger_entry_type": "Escrow", - "owner_node": "0000000000000000", - "destination_node": "0000000000000000", - "previous_txn_id": "C44F2EB84196B9AD820313DBEBA6316A15C9A2" + "Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + "DestinationTag": 23480, + "FinishAfter": 545354132, + "Flags": 0, + "LedgerEntryType": "Escrow", + "OwnerNode": "0000000000000000", + "DestinationNode": "0000000000000000", + "PreviousTxnID": "C44F2EB84196B9AD820313DBEBA6316A15C9A2" "D35787579ED172B87A30131DA7", - "previous_txn_lgr_seq": 28991004, - "source_tag": 11747, + "PreviousTxnLgrSeq": 28991004, + "SourceTag": 11747, "index": "DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", } fee_settings_json = { - "base_fee": "000000000000000A", - "flags": 0, - "ledger_entry_type": "FeeSettings", - "reference_fee_units": 10, - "reserve_base": 20000000, - "reserve_increment": 5000000, + "BaseFee": "000000000000000A", + "Flags": 0, + "LedgerEntryType": "FeeSettings", + "ReferenceFeeUnits": 10, + "ReserveBase": 20000000, + "ReserveIncrement": 5000000, "index": "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", } ledger_hashes_json = { - "ledger_entry_type": "LedgerHashes", - "flags": 0, - "first_ledger_sequence": 2, - "last_ledger_sequence": 33872029, - "hashes": [ + "LedgerEntryType": "LedgerHashes", + "Flags": 0, + "FirstLedgerSequence": 2, + "LastLedgerSequence": 33872029, + "Hashes": [ "D638208ADBD04CBB10DE7B645D3AB4BA31489379411A3A347151702B6401AA78", "254D690864E418DDD9BCAC93F41B1F53B1AE693FC5FE667CE40205C322D1BE3B", "A2B31D28905E2DEF926362822BC412B12ABF6942B73B72A32D46ED2ABB7ACCFA", @@ -244,41 +245,41 @@ } negative_unl_json = { - "disabled_validators": [ + "DisabledValidators": [ { - "disabled_validator": { - "first_ledger_sequence": 1609728, - "public_key": "ED6629D456285AE3613B285F65BBFF168D695BA" + "DisabledValidator": { + "FirstLedgerSequence": 1609728, + "PublicKey": "ED6629D456285AE3613B285F65BBFF168D695BA" "3921F309949AFCD2CA7AFEC16FE", } } ], - "flags": 0, - "ledger_entry_type": "NegativeUNL", + "Flags": 0, + "LedgerEntryType": "NegativeUNL", "index": "2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", } nftoken_offer_json = { - "ledger_entry_type": "NFTokenOffer", + "LedgerEntryType": "NFTokenOffer", "index": "AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", - "amount": "1000000", - "flags": 1, - "nftoken_id": "00081B5825A08C22787716FA031B432EBBC1B101BB54875F0002D2A400000000", - "owner": "rhRxL3MNvuKEjWjL7TBbZSDacb8PmzAd7m", - "previous_txn_id": "BFA9BE27383FA315651E26FDE1FA30815C5A5D0544EE10EC33D3E92532993" + "Amount": "1000000", + "Flags": 1, + "NFTokenID": "00081B5825A08C22787716FA031B432EBBC1B101BB54875F0002D2A400000000", + "Owner": "rhRxL3MNvuKEjWjL7TBbZSDacb8PmzAd7m", + "PreviousTxnID": "BFA9BE27383FA315651E26FDE1FA30815C5A5D0544EE10EC33D3E92532993" "769", - "previous_txn_lgr_seq": 75443565, - "owner_node": "17", - "nftoken_offer_node": "0", + "PreviousTxnLgrSeq": 75443565, + "OwnerNode": "17", + "NFTokenOfferNode": "0", } nftoken_page_json = { - "flags": 0, - "ledger_entry_type": "NFTokenPage", - "previous_txn_id": "95C8761B22894E328646F7A70035E9DFBECC9" + "Flags": 0, + "LedgerEntryType": "NFTokenPage", + "PreviousTxnID": "95C8761B22894E328646F7A70035E9DFBECC9" "0EDD83E43B7B973F626D21A0822", - "previous_txn_lgr_seq": 42891441, - "nftokens": [ + "PreviousTxnLgrSeq": 42891441, + "NFTokens": [ { "nftoken_id": "000B013A95F14B0044F78A264E41713" "C64B5F89242540EE208C3098E00000D65", @@ -290,187 +291,187 @@ } offer_json = { - "account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", - "book_directory": "ACC27DE91DBA86FC509069EAF4BC511D7" + "Account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + "BookDirectory": "ACC27DE91DBA86FC509069EAF4BC511D7" "3128B780F2E54BF5E07A369E2446000", - "book_node": "0000000000000000", - "flags": 131072, - "ledger_entry_type": "Offer", - "owner_node": "0000000000000000", - "previous_txn_id": "F0AB71E777B2DA54B86231E19B82554EF1" + "BookNode": "0000000000000000", + "Flags": 131072, + "LedgerEntryType": "Offer", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "F0AB71E777B2DA54B86231E19B82554EF1" "F8211F92ECA473121C655BFC5329BF", - "previous_txn_lgr_seq": 14524914, - "sequence": 866, - "taker_gets": { + "PreviousTxnLgrSeq": 14524914, + "Sequence": 866, + "TakerGets": { "currency": "XAG", "issuer": "r9Dr5xwkeLegBeXq6ujinjSBLQzQ1zQGjH", "value": "37", }, - "taker_pays": "79550000000", + "TakerPays": "79550000000", "index": "96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", } pay_channel_json = { - "account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", - "destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "amount": "4325800", - "balance": "2323423", - "public_key": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A", - "settle_delay": 3600, - "expiration": 536027313, - "cancel_after": 536891313, - "source_tag": 0, - "destination_tag": 1002341, - "destination_node": "0000000000000000", - "flags": 0, - "ledger_entry_type": "PayChannel", - "owner_node": "0000000000000000", - "previous_txn_id": "F0AB71E777B2DA54B86231E19B82554E" + "Account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + "Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "Amount": "4325800", + "Balance": "2323423", + "PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A", + "SettleDelay": 3600, + "Expiration": 536027313, + "CancelAfter": 536891313, + "SourceTag": 0, + "DestinationTag": 1002341, + "DestinationNode": "0000000000000000", + "Flags": 0, + "LedgerEntryType": "PayChannel", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "F0AB71E777B2DA54B86231E19B82554E" "F1F8211F92ECA473121C655BFC5329BF", - "previous_txn_lgr_seq": 14524914, + "PreviousTxnLgrSeq": 14524914, "index": "96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", } ripple_state_json = { - "balance": { + "Balance": { "currency": "USD", "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", "value": "-10", }, - "flags": 393216, - "high_limit": { + "Flags": 393216, + "HighLimit": { "currency": "USD", "issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "value": "110", }, - "high_node": "0000000000000000", - "ledger_entry_type": "RippleState", - "low_limit": { + "HighNode": "0000000000000000", + "LedgerEntryType": "RippleState", + "LowLimit": { "currency": "USD", "issuer": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", "value": "0", }, - "low_node": "0000000000000000", - "previous_txn_id": "E3FE6EA3D48F0C2B639448020EA4F03D" + "LowNode": "0000000000000000", + "PreviousTxnID": "E3FE6EA3D48F0C2B639448020EA4F03D" "4F4F8FFDB243A852A0F59177921B4879", - "previous_txn_lgr_seq": 14090896, + "PreviousTxnLgrSeq": 14090896, "index": "9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", } signer_list_json = { - "flags": 0, - "ledger_entry_type": "SignerList", - "owner_node": "0000000000000000", - "previous_txn_id": "5904C0DC72C58A83AEFED2FFC5386356" + "Flags": 0, + "LedgerEntryType": "SignerList", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "5904C0DC72C58A83AEFED2FFC5386356" "AA83FCA6A88C89D00646E51E687CDBE4", - "previous_txn_lgr_seq": 16061435, - "signer_entries": [ + "PreviousTxnLgrSeq": 16061435, + "SignerEntries": [ { - "signer_entry": { - "account": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", - "signer_weight": 2, + "SignerEntry": { + "Account": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", + "SignerWeight": 2, } }, { - "signer_entry": { - "account": "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n", - "signer_weight": 1, + "SignerEntry": { + "Account": "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n", + "SignerWeight": 1, } }, { - "signer_entry": { - "account": "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v", - "signer_weight": 1, + "SignerEntry": { + "Account": "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v", + "SignerWeight": 1, } }, ], - "signer_list_id": 0, - "signer_quorum": 3, + "SignerListID": 0, + "SignerQuorum": 3, "index": "A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", } ticket_json = { - "account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", - "flags": 0, - "ledger_entry_type": "Ticket", - "owner_node": "0000000000000000", - "previous_txn_id": "F19AD4577212D3BEACA0F75FE1BA1" + "Account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + "Flags": 0, + "LedgerEntryType": "Ticket", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "F19AD4577212D3BEACA0F75FE1BA1" "644F2E854D46E8D62E9C95D18E9708CBFB1", - "previous_txn_lgr_seq": 4, - "ticket_sequence": 3, + "PreviousTxnLgrSeq": 4, + "TicketSequence": 3, "index": "A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", } xchain_owned_claim_id_json = { - "account": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - "flags": 0, - "other_chain_source": "r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", - "owner_node": "0", - "previous_txn_id": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E660" + "Account": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "Flags": 0, + "OtherChainSource": "r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", + "OwnerNode": "0", + "PreviousTxnID": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E660" "70A6", - "previous_txn_lgr_seq": 58673, - "signature_reward": "100", - "xchain_bridge": { - "issuing_chain_door": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "issuing_chain_issue": {"currency": "XRP"}, - "locking_chain_door": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", - "locking_chain_issue": {"currency": "XRP"}, + "PreviousTxnLgrSeq": 58673, + "SignatureReward": "100", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": {"currency": "XRP"}, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": {"currency": "XRP"}, }, - "xchain_claim_attestations": [ + "XChainClaimAttestations": [ { - "xchain_claim_proof_sig": { - "amount": "1000000", - "attestation_reward_account": "rfgjrgEJGDxfUY2U8VEDs7BnB1jiH3ofu6", - "attestation_signer_account": "rfsxNxZ6xB1nTPhTMwQajNnkCxWG8B714n", - "destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - "public_key": "025CA526EF20567A50FEC504589F949E0E3401C13EF76DD5FD1CC285" + "XChainClaimProofSig": { + "Amount": "1000000", + "AttestationRewardAccount": "rfgjrgEJGDxfUY2U8VEDs7BnB1jiH3ofu6", + "AttestationSignerAccount": "rfsxNxZ6xB1nTPhTMwQajNnkCxWG8B714n", + "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "PublicKey": "025CA526EF20567A50FEC504589F949E0E3401C13EF76DD5FD1CC285" "0FA485BD7B", - "was_locking_chain_send": 1, + "WasLockingChainSend": 1, } }, { - "xchain_claim_proof_sig": { - "amount": "1000000", - "attestation_reward_account": "rUUL1tP523M8KimERqVS7sxb1tLLmpndyv", - "attestation_signer_account": "rEg5sHxZVTNwRL3BAdMwJatkmWDzHMmzDF", - "destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - "public_key": "03D40434A6843638681E2F215310EBC4131AFB12EA85985DA073183B" + "XChainClaimProofSig": { + "Amount": "1000000", + "AttestationRewardAccount": "rUUL1tP523M8KimERqVS7sxb1tLLmpndyv", + "AttestationSignerAccount": "rEg5sHxZVTNwRL3BAdMwJatkmWDzHMmzDF", + "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "PublicKey": "03D40434A6843638681E2F215310EBC4131AFB12EA85985DA073183B" "732525F7C9", - "was_locking_chain_send": 1, + "WasLockingChainSend": 1, }, }, ], - "xchain_claim_id": "b5", - "ledger_entry_type": "XChainOwnedClaimID", - "ledger_index": "20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BACB1388F5", + "XChainClaimID": "b5", + "LedgerEntryType": "XChainOwnedClaimID", + "LedgerIndex": "20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BACB1388F5", } xchain_owned_create_account_claim_id_json = { - "flags": 0, - "ledger_entry_type": "XChainOwnedCreateAccountClaimID", - "ledger_index": "5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166BB6F0C", - "owner_node": "0", - "previous_txn_id": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E660", - "previous_txn_lgr_seq": 58673, - "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "xchain_account_create_count": "66", - "xchain_bridge": { - "issuing_chain_door": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "issuing_chain_issue": {"currency": "XRP"}, - "locking_chain_door": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", - "locking_chain_issue": {"currency": "XRP"}, + "Flags": 0, + "LedgerEntryType": "XChainOwnedCreateAccountClaimID", + "LedgerIndex": "5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166BB6F0C", + "OwnerNode": "0", + "PreviousTxnID": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E660", + "PreviousTxnLgrSeq": 58673, + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "XChainAccountCreateCount": "66", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": {"currency": "XRP"}, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": {"currency": "XRP"}, }, - "xchain_create_account_attestations": [ + "XChainCreateAccountAttestations": [ { - "xchain_create_account_proof_sig": { - "amount": "20000000", - "attestation_reward_account": "rMtYb1vNdeMDpD9tA5qSFm8WXEBdEoKKVw", - "attestation_signer_account": "rL8qTrAvZ8Q1o1H9H9Ahpj3xjgmRvFLvJ3", - "destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - "public_key": "021F7CC4033EFBE5E8214B04D1BAAEC14808DC6C02F4ACE930A8" + "XChainCreateAccountProofSig": { + "Amount": "20000000", + "AttestationRewardAccount": "rMtYb1vNdeMDpD9tA5qSFm8WXEBdEoKKVw", + "AttestationSignerAccount": "rL8qTrAvZ8Q1o1H9H9Ahpj3xjgmRvFLvJ3", + "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "PublicKey": "021F7CC4033EFBE5E8214B04D1BAAEC14808DC6C02F4ACE930A8" "EF0F5909B0C438", - "signature_reward": "100", - "was_locking_chain_send": 1, + "SignatureReward": "100", + "WasLockingChainSend": 1, } } ], @@ -479,7 +480,7 @@ class TestFromTODict(TestCase): def test_account_root(self): - actual = AccountRoot.from_xrpl(account_root_json) + actual = LedgerObject.from_xrpl(account_root_json) expected = AccountRoot( index="13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", @@ -499,10 +500,9 @@ def test_account_root(self): transfer_rate=1004999999, ) self.assertEqual(actual, expected) - self.assertEqual(account_root_json, expected.to_dict()) def test_amendments(self): - actual = Amendments.from_xrpl(amendment_json) + actual = LedgerObject.from_xrpl(amendment_json) expected = Amendments( index="7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", amendments=[ @@ -520,10 +520,9 @@ def test_amendments(self): ], ) self.assertEqual(actual, expected) - self.assertEqual(amendment_json, expected.to_dict()) def test_amm(self): - actual = AMM.from_xrpl(amm_json) + actual = LedgerObject.from_xrpl(amm_json) expected = AMM( account="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", asset=XRP(), @@ -546,7 +545,7 @@ def test_amm(self): ), ), owner_node="0", - lptoken_balance=IssuedCurrencyAmount( + lp_token_balance=IssuedCurrencyAmount( currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", issuer="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", value="71150.53584131501", @@ -561,10 +560,9 @@ def test_amm(self): ], ) self.assertEqual(actual, expected) - self.assertEqual(amm_json, expected.to_dict()) def test_bridge(self): - actual = Bridge.from_xrpl(bridge_json) + actual = LedgerObject.from_xrpl(bridge_json) expected = Bridge( account="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", min_account_create_amount="2000000000", @@ -585,10 +583,9 @@ def test_bridge(self): index="9F2C9E23343852036AFD323025A8506018ABF9D4DBAA746D61BF1CFB5C297D10", ) self.assertEqual(actual, expected) - self.assertEqual(bridge_json, expected.to_dict()) def test_check(self): - actual = Check.from_xrpl(check_json) + actual = LedgerObject.from_xrpl(check_json) expected = Check( index="49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", account="rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", @@ -606,10 +603,9 @@ def test_check(self): "9083E38C77CBE642243E43BE291", ) self.assertEqual(actual, expected) - self.assertEqual(check_json, expected.to_dict()) def test_deposit_preauth(self): - actual = DepositPreauth.from_xrpl(deposit_preauth_json) + actual = LedgerObject.from_xrpl(deposit_preauth_json) expected = DepositPreauth( index="4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", account="rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", @@ -620,10 +616,9 @@ def test_deposit_preauth(self): previous_txn_lgr_seq=7, ) self.assertEqual(actual, expected) - self.assertEqual(deposit_preauth_json, expected.to_dict()) def test_did(self): - actual = DID.from_xrpl(did_json) + actual = LedgerObject.from_xrpl(did_json) expected = DID( account="rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", did_document="646F63", @@ -636,10 +631,9 @@ def test_did(self): index="46813BE38B798B3752CA590D44E7FEADB17485649074403AD1761A2835CE91FF", ) self.assertEqual(actual, expected) - self.assertEqual(did_json, expected.to_dict()) def test_directory_node(self): - actual = DirectoryNode.from_xrpl(directory_node_json) + actual = LedgerObject.from_xrpl(directory_node_json) expected = DirectoryNode( index="1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", root_index="1BBEF97EDE88D40CEE2ADE6FEF121166A" @@ -654,10 +648,9 @@ def test_directory_node(self): taker_gets_issuer="0000000000000000000000000000000000000000", ) self.assertEqual(actual, expected) - self.assertEqual(directory_node_json, expected.to_dict()) def test_escrow(self): - actual = Escrow.from_xrpl(escrow_json) + actual = LedgerObject.from_xrpl(escrow_json) expected = Escrow( index="DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", @@ -676,10 +669,9 @@ def test_escrow(self): source_tag=11747, ) self.assertEqual(actual, expected) - self.assertEqual(escrow_json, expected.to_dict()) def test_fee_settings(self): - actual = FeeSettings.from_xrpl(fee_settings_json) + actual = LedgerObject.from_xrpl(fee_settings_json) expected = FeeSettings( index="4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", base_fee="000000000000000A", @@ -688,10 +680,9 @@ def test_fee_settings(self): reserve_increment=5000000, ) self.assertEqual(actual, expected) - self.assertEqual(fee_settings_json, expected.to_dict()) def test_ledger_hashes(self): - actual = LedgerHashes.from_xrpl(ledger_hashes_json) + actual = LedgerObject.from_xrpl(ledger_hashes_json) expected = LedgerHashes( index="B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B", first_ledger_sequence=2, @@ -705,10 +696,9 @@ def test_ledger_hashes(self): ], ) self.assertEqual(actual, expected) - self.assertEqual(ledger_hashes_json, expected.to_dict()) def test_negative_unl(self): - actual = NegativeUNL.from_xrpl(negative_unl_json) + actual = LedgerObject.from_xrpl(negative_unl_json) expected = NegativeUNL( index="2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", disabled_validators=[ @@ -720,10 +710,9 @@ def test_negative_unl(self): ], ) self.assertEqual(actual, expected) - self.assertEqual(negative_unl_json, expected.to_dict()) def test_nftoken_offer(self): - actual = NFTokenOffer.from_xrpl(nftoken_offer_json) + actual = LedgerObject.from_xrpl(nftoken_offer_json) expected = NFTokenOffer( index="AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", amount="1000000", @@ -738,10 +727,9 @@ def test_nftoken_offer(self): nftoken_offer_node="0", ) self.assertEqual(actual, expected) - self.assertEqual(nftoken_offer_json, expected.to_dict()) def test_nftoken_page(self): - actual = NFTokenPage.from_xrpl(nftoken_page_json) + actual = LedgerObject.from_xrpl(nftoken_page_json) expected = NFTokenPage( index="", previous_txn_id="95C8761B22894E328646F7A70035E9DFBEC" @@ -758,10 +746,9 @@ def test_nftoken_page(self): ], ) self.assertEqual(actual, expected) - self.assertEqual(nftoken_page_json, expected.to_dict()) def test_offer(self): - actual = Offer.from_xrpl(offer_json) + actual = LedgerObject.from_xrpl(offer_json) expected = Offer( index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", @@ -780,10 +767,9 @@ def test_offer(self): previous_txn_lgr_seq=14524914, ) self.assertEqual(actual, expected) - self.assertEqual(offer_json, expected.to_dict()) def test_pay_channel(self): - actual = PayChannel.from_xrpl(pay_channel_json) + actual = LedgerObject.from_xrpl(pay_channel_json) expected = PayChannel( index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", @@ -805,10 +791,9 @@ def test_pay_channel(self): source_tag=0, ) self.assertEqual(actual, expected) - self.assertEqual(pay_channel_json, expected.to_dict()) def test_ripple_state(self): - actual = RippleState.from_xrpl(ripple_state_json) + actual = LedgerObject.from_xrpl(ripple_state_json) expected = RippleState( index="9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", balance=IssuedCurrencyAmount( @@ -828,10 +813,9 @@ def test_ripple_state(self): low_node="0000000000000000", ) self.assertEqual(actual, expected) - self.assertEqual(ripple_state_json, expected.to_dict()) def test_signer_list(self): - actual = SignerList.from_xrpl(signer_list_json) + actual = LedgerObject.from_xrpl(signer_list_json) expected = SignerList( index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", flags=0, @@ -857,10 +841,9 @@ def test_signer_list(self): signer_quorum=3, ) self.assertEqual(actual, expected) - self.assertEqual(signer_list_json, expected.to_dict()) def test_ticket(self): - actual = Ticket.from_xrpl(ticket_json) + actual = LedgerObject.from_xrpl(ticket_json) expected = Ticket( index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", account="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", @@ -872,10 +855,9 @@ def test_ticket(self): ticket_sequence=3, ) self.assertEqual(actual, expected) - self.assertEqual(ticket_json, expected.to_dict()) def test_xchain_owned_claim_id(self): - actual = XChainOwnedClaimID.from_xrpl(xchain_owned_claim_id_json) + actual = LedgerObject.from_xrpl(xchain_owned_claim_id_json) expected = XChainOwnedClaimID( account="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", other_chain_source="r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", @@ -915,12 +897,9 @@ def test_xchain_owned_claim_id(self): "88F5", ) self.assertEqual(actual, expected) - self.assertEqual(xchain_owned_claim_id_json, expected.to_dict()) def test_xchain_owned_create_account_claim_id(self): - actual = XChainOwnedCreateAccountClaimID.from_xrpl( - xchain_owned_create_account_claim_id_json - ) + actual = LedgerObject.from_xrpl(xchain_owned_create_account_claim_id_json) expected = XChainOwnedCreateAccountClaimID( account="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", owner_node="0", @@ -950,4 +929,3 @@ def test_xchain_owned_create_account_claim_id(self): ], ) self.assertEqual(actual, expected) - self.assertEqual(xchain_owned_create_account_claim_id_json, expected.to_dict()) diff --git a/xrpl/models/ledger_objects/amm.py b/xrpl/models/ledger_objects/amm.py index 3af32db12..bd4bf0844 100644 --- a/xrpl/models/ledger_objects/amm.py +++ b/xrpl/models/ledger_objects/amm.py @@ -42,7 +42,7 @@ class AMM(LedgerObject): Details of the current owner of the auction slot, as an Auction Slot object. """ - lptoken_balance: IssuedCurrencyAmount = REQUIRED # type: ignore + lp_token_balance: IssuedCurrencyAmount = REQUIRED # type: ignore """ The total outstanding balance of liquidity provider tokens from this AMM instance. The holders of these tokens can vote on the AMM's trading fee in proportion to From a7f0f545ed13a5f5bea607668f43a56c4eedd129 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Fri, 16 Feb 2024 15:52:38 -0500 Subject: [PATCH 52/58] move unit tests into their own files --- tests/unit/models/ledger_objects/__init__.py | 0 .../ledger_objects/test_account_root.py | 47 + .../models/ledger_objects/test_amendments.py | 47 + tests/unit/models/ledger_objects/test_amm.py | 90 ++ .../unit/models/ledger_objects/test_bridge.py | 53 + .../unit/models/ledger_objects/test_check.py | 44 + .../ledger_objects/test_deposit_preauth.py | 30 + tests/unit/models/ledger_objects/test_did.py | 34 + .../ledger_objects/test_directory_node.py | 38 + .../unit/models/ledger_objects/test_escrow.py | 47 + .../ledger_objects/test_fee_settings.py | 26 + .../ledger_objects/test_ledger_hashes.py | 36 + .../ledger_objects/test_negative_unl.py | 34 + .../ledger_objects/test_nftoken_offer.py | 38 + .../ledger_objects/test_nftoken_page.py | 44 + .../unit/models/ledger_objects/test_offer.py | 48 + .../models/ledger_objects/test_pay_channel.py | 51 + .../ledger_objects/test_ripple_state.py | 54 + .../models/ledger_objects/test_signer_list.py | 66 ++ .../unit/models/ledger_objects/test_ticket.py | 31 + .../test_xchain_owned_claim_id.py | 104 ++ ...st_xchain_owned_create_account_claim_id.py | 78 ++ tests/unit/models/test_ledger_object.py | 931 ------------------ 23 files changed, 1040 insertions(+), 931 deletions(-) create mode 100644 tests/unit/models/ledger_objects/__init__.py create mode 100644 tests/unit/models/ledger_objects/test_account_root.py create mode 100644 tests/unit/models/ledger_objects/test_amendments.py create mode 100644 tests/unit/models/ledger_objects/test_amm.py create mode 100644 tests/unit/models/ledger_objects/test_bridge.py create mode 100644 tests/unit/models/ledger_objects/test_check.py create mode 100644 tests/unit/models/ledger_objects/test_deposit_preauth.py create mode 100644 tests/unit/models/ledger_objects/test_did.py create mode 100644 tests/unit/models/ledger_objects/test_directory_node.py create mode 100644 tests/unit/models/ledger_objects/test_escrow.py create mode 100644 tests/unit/models/ledger_objects/test_fee_settings.py create mode 100644 tests/unit/models/ledger_objects/test_ledger_hashes.py create mode 100644 tests/unit/models/ledger_objects/test_negative_unl.py create mode 100644 tests/unit/models/ledger_objects/test_nftoken_offer.py create mode 100644 tests/unit/models/ledger_objects/test_nftoken_page.py create mode 100644 tests/unit/models/ledger_objects/test_offer.py create mode 100644 tests/unit/models/ledger_objects/test_pay_channel.py create mode 100644 tests/unit/models/ledger_objects/test_ripple_state.py create mode 100644 tests/unit/models/ledger_objects/test_signer_list.py create mode 100644 tests/unit/models/ledger_objects/test_ticket.py create mode 100644 tests/unit/models/ledger_objects/test_xchain_owned_claim_id.py create mode 100644 tests/unit/models/ledger_objects/test_xchain_owned_create_account_claim_id.py delete mode 100644 tests/unit/models/test_ledger_object.py diff --git a/tests/unit/models/ledger_objects/__init__.py b/tests/unit/models/ledger_objects/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/unit/models/ledger_objects/test_account_root.py b/tests/unit/models/ledger_objects/test_account_root.py new file mode 100644 index 000000000..6cab8b736 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_account_root.py @@ -0,0 +1,47 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.account_root import AccountRoot +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestAccountRoot(TestCase): + def test_account_root(self): + account_root_json = { + "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "AccountTxnID": "0D5FB50FA65C9FE1538FD7E398FFFE9D190" + "8DFA4576D8D7A020040686F93C77D", + "Balance": "148446663", + "Domain": "6D64756F31332E636F6D", + "EmailHash": "98B4375E1D753E5B91627516F6D70977", + "Flags": 8388608, + "LedgerEntryType": "AccountRoot", + "MessageKey": "0000000000000000000000070000000300", + "OwnerCount": 3, + "NFTokenMinter": "rHello", + "PreviousTxnID": "0D5FB50FA65C9FE1538FD7E398FFFE9D1908DFA4576D8D7A0200" + "40686F93C77D", + "PreviousTxnLgrSeq": 14091160, + "Sequence": 336, + "TransferRate": 1004999999, + "index": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", + } + actual = LedgerObject.from_xrpl(account_root_json) + expected = AccountRoot( + index="13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", + account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + balance="148446663", + flags=8388608, + owner_count=3, + previous_txn_id="0D5FB50FA65C9FE1538FD7E398FFFE9D" + "1908DFA4576D8D7A020040686F93C77D", + previous_txn_lgr_seq=14091160, + sequence=336, + account_txn_id="0D5FB50FA65C9FE1538FD7E398FFFE9D1" + "908DFA4576D8D7A020040686F93C77D", + domain="6D64756F31332E636F6D", + email_hash="98B4375E1D753E5B91627516F6D70977", + message_key="0000000000000000000000070000000300", + nftoken_minter="rHello", + transfer_rate=1004999999, + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_amendments.py b/tests/unit/models/ledger_objects/test_amendments.py new file mode 100644 index 000000000..84c14da72 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_amendments.py @@ -0,0 +1,47 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.amendments import Amendments, Majority +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestAmendments(TestCase): + def test_amendments(self): + amendment_json = { + "Majorities": [ + { + "Majority": { + "Amendment": "1562511F573A19AE9BD103B5D6B9E01B3B46805AEC" + "5D3C4805C902B51" + "4399146", + "CloseTime": 535589001, + } + } + ], + "Amendments": [ + "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE", + "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373", + "6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC", + "740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D628A06927F11", + ], + "Flags": 0, + "LedgerEntryType": "Amendments", + "index": "7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", + } + actual = LedgerObject.from_xrpl(amendment_json) + expected = Amendments( + index="7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", + amendments=[ + "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE", + "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373", + "6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC", + "740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D628A06927F11", + ], + majorities=[ + Majority( + amendment="1562511F573A19AE9BD103B5D6B9E01B3B46805AEC5D3C" + "4805C902B514399146", + close_time=535589001, + ) + ], + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_amm.py b/tests/unit/models/ledger_objects/test_amm.py new file mode 100644 index 000000000..d5158c94b --- /dev/null +++ b/tests/unit/models/ledger_objects/test_amm.py @@ -0,0 +1,90 @@ +from unittest import TestCase + +from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount +from xrpl.models.auth_account import AuthAccount +from xrpl.models.currencies.issued_currency import IssuedCurrency +from xrpl.models.currencies.xrp import XRP +from xrpl.models.ledger_objects.amm import AMM, AuctionSlot, VoteEntry +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestAMM(TestCase): + def test_amm(self): + amm_json = { + "Account": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + "Asset": {"currency": "XRP"}, + "Asset2": { + "currency": "TST", + "issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd", + }, + "AuctionSlot": { + "Account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + "AuthAccounts": [ + {"AuthAccount": {"Account": "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"}}, + {"AuthAccount": {"Account": "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"}}, + ], + "DiscountedFee": 0, + "Expiration": 721870180, + "Price": { + "currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2", + "issuer": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + "value": "0.8696263565463045", + }, + }, + "LPTokenBalance": { + "currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2", + "issuer": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + "value": "71150.53584131501", + }, + "TradingFee": 600, + "VoteSlots": [ + { + "VoteEntry": { + "Account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + "TradingFee": 600, + "VoteWeight": 100000, + } + } + ], + "OwnerNode": "0", + "Flags": 0, + "LedgerEntryType": "AMM", + } + actual = LedgerObject.from_xrpl(amm_json) + expected = AMM( + account="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + asset=XRP(), + asset2=IssuedCurrency( + currency="TST", + issuer="rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd", + ), + auction_slot=AuctionSlot( + account="rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + auth_accounts=[ + AuthAccount(account="rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"), + AuthAccount(account="rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"), + ], + discounted_fee=0, + expiration=721870180, + price=IssuedCurrencyAmount( + currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", + issuer="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + value="0.8696263565463045", + ), + ), + owner_node="0", + lp_token_balance=IssuedCurrencyAmount( + currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", + issuer="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", + value="71150.53584131501", + ), + trading_fee=600, + vote_slots=[ + VoteEntry( + account="rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", + trading_fee=600, + vote_weight=100000, + ), + ], + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_bridge.py b/tests/unit/models/ledger_objects/test_bridge.py new file mode 100644 index 000000000..cdd7f61cc --- /dev/null +++ b/tests/unit/models/ledger_objects/test_bridge.py @@ -0,0 +1,53 @@ +from unittest import TestCase + +from xrpl.models.currencies.xrp import XRP +from xrpl.models.ledger_objects.bridge import Bridge +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.xchain_bridge import XChainBridge + + +class TestBridge(TestCase): + def test_bridge(self): + bridge_json = { + "Account": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + "Flags": 0, + "LedgerEntryType": "Bridge", + "MinAccountCreateAmount": "2000000000", + "OwnerNode": "0", + "PreviousTxnID": "67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE" + "917FD1A71919EAE7548E56" + "36", + "PreviousTxnLgrSeq": 102, + "SignatureReward": "204", + "XChainAccountClaimCount": "0", + "XChainAccountCreateCount": "0", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": {"currency": "XRP"}, + "LockingChainDoor": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + "LockingChainIssue": {"currency": "XRP"}, + }, + "XChainClaimID": "1", + "index": "9F2C9E23343852036AFD323025A8506018ABF9D4DBAA746D61BF1CFB5C297D10", + } + actual = LedgerObject.from_xrpl(bridge_json) + expected = Bridge( + account="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + min_account_create_amount="2000000000", + owner_node="0", + previous_txn_id="67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE917FD1A71919EAE75" + "48E5636", + previous_txn_lgr_seq=102, + signature_reward="204", + xchain_account_claim_count="0", + xchain_account_create_count="0", + xchain_bridge=XChainBridge( + issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + issuing_chain_issue=XRP(), + locking_chain_door="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", + locking_chain_issue=XRP(), + ), + xchain_claim_id="1", + index="9F2C9E23343852036AFD323025A8506018ABF9D4DBAA746D61BF1CFB5C297D10", + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_check.py b/tests/unit/models/ledger_objects/test_check.py new file mode 100644 index 000000000..5a38fd0d8 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_check.py @@ -0,0 +1,44 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.check import Check +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestCheck(TestCase): + def test_check(self): + check_json = { + "Account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + "Destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + "DestinationNode": "0000000000000000", + "DestinationTag": 1, + "Expiration": 570113521, + "Flags": 0, + "InvoiceID": "46060241FABCF692D4D934BA2A6C4427CD4279083E3" + "8C77CBE642243E43BE291", + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "5463C6E08862A1FAE5EDAC12D70ADB16546A1F67" + "4930521295BC082494B62924", + "PreviousTxnLgrSeq": 6, + "SendMax": "100000000", + "Sequence": 2, + "index": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", + } + actual = LedgerObject.from_xrpl(check_json) + expected = Check( + index="49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", + account="rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + destination="rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + owner_node="0000000000000000", + previous_txn_id="5463C6E08862A1FAE5EDAC12D70ADB16546A" + "1F674930521295BC082494B62924", + previous_txn_lgr_seq=6, + send_max="100000000", + sequence=2, + destination_node="0000000000000000", + destination_tag=1, + expiration=570113521, + invoice_id="46060241FABCF692D4D934BA2A6C4427CD427" + "9083E38C77CBE642243E43BE291", + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_deposit_preauth.py b/tests/unit/models/ledger_objects/test_deposit_preauth.py new file mode 100644 index 000000000..57bf8dbdc --- /dev/null +++ b/tests/unit/models/ledger_objects/test_deposit_preauth.py @@ -0,0 +1,30 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.deposit_preauth import DepositPreauth +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestDepositPreauth(TestCase): + def test_deposit_preauth(self): + deposit_preauth_json = { + "LedgerEntryType": "DepositPreauth", + "Account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", + "Authorize": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + "Flags": 0, + "OwnerNode": "0000000000000000", + "PreviousTxnID": "3E8964D5A86B3CD6B9ECB33310D4E073D64C865A5B866200" + "AD2B7E29F8326702", + "PreviousTxnLgrSeq": 7, + "index": "4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", + } + actual = LedgerObject.from_xrpl(deposit_preauth_json) + expected = DepositPreauth( + index="4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", + account="rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", + authorize="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + owner_node="0000000000000000", + previous_txn_id="3E8964D5A86B3CD6B9ECB33310D4E073D64C8" + "65A5B866200AD2B7E29F8326702", + previous_txn_lgr_seq=7, + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_did.py b/tests/unit/models/ledger_objects/test_did.py new file mode 100644 index 000000000..6396f463a --- /dev/null +++ b/tests/unit/models/ledger_objects/test_did.py @@ -0,0 +1,34 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.did import DID +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestDID(TestCase): + def test_did(self): + did_json = { + "Account": "rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", + "DIDDocument": "646F63", + "Data": "617474657374", + "Flags": 0, + "LedgerEntryType": "DID", + "OwnerNode": "0", + "PreviousTxnID": "A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B0" + "9F708778E41120", + "PreviousTxnLgrSeq": 4, + "URI": "6469645F6578616D706C65", + "index": "46813BE38B798B3752CA590D44E7FEADB17485649074403AD1761A2835CE91FF", + } + actual = LedgerObject.from_xrpl(did_json) + expected = DID( + account="rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", + did_document="646F63", + data="617474657374", + owner_node="0", + previous_txn_id="A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B09F" + "708778E41120", + previous_txn_lgr_seq=4, + uri="6469645F6578616D706C65", + index="46813BE38B798B3752CA590D44E7FEADB17485649074403AD1761A2835CE91FF", + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_directory_node.py b/tests/unit/models/ledger_objects/test_directory_node.py new file mode 100644 index 000000000..f4c9b579d --- /dev/null +++ b/tests/unit/models/ledger_objects/test_directory_node.py @@ -0,0 +1,38 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.directory_node import DirectoryNode +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestDirectoryNode(TestCase): + def test_directory_node(self): + directory_node_json = { + "ExchangeRate": "4F069BA8FF484000", + "Flags": 0, + "Indexes": [ + "AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD" + ], + "LedgerEntryType": "DirectoryNode", + "RootIndex": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A" + "4F069BA8FF484000", + "TakerGetsCurrency": "0000000000000000000000000000000000000000", + "TakerGetsIssuer": "0000000000000000000000000000000000000000", + "TakerPaysCurrency": "0000000000000000000000004A50590000000000", + "TakerPaysIssuer": "5BBC0F22F61D9224A110650CFE21CC0C4BE13098", + "index": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", + } + actual = LedgerObject.from_xrpl(directory_node_json) + expected = DirectoryNode( + index="1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", + root_index="1BBEF97EDE88D40CEE2ADE6FEF121166A" + "FE80D99EBADB01A4F069BA8FF484000", + indexes=[ + "AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD" + ], + exchange_rate="4F069BA8FF484000", + taker_pays_currency="0000000000000000000000004A50590000000000", + taker_pays_issuer="5BBC0F22F61D9224A110650CFE21CC0C4BE13098", + taker_gets_currency="0000000000000000000000000000000000000000", + taker_gets_issuer="0000000000000000000000000000000000000000", + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_escrow.py b/tests/unit/models/ledger_objects/test_escrow.py new file mode 100644 index 000000000..fc2360606 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_escrow.py @@ -0,0 +1,47 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.escrow import Escrow +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestEscrow(TestCase): + def test_escrow(self): + escrow_json = { + "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "Amount": "10000", + "CancelAfter": 545440232, + "Condition": "A0258020A82A88B2DF843A54F58772E4A386" + "1866ECDB4157645DD9AE528C1D3AEEDAB" + "AB6810120", + "Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + "DestinationTag": 23480, + "FinishAfter": 545354132, + "Flags": 0, + "LedgerEntryType": "Escrow", + "OwnerNode": "0000000000000000", + "DestinationNode": "0000000000000000", + "PreviousTxnID": "C44F2EB84196B9AD820313DBEBA6316A15C9A2" + "D35787579ED172B87A30131DA7", + "PreviousTxnLgrSeq": 28991004, + "SourceTag": 11747, + "index": "DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", + } + actual = LedgerObject.from_xrpl(escrow_json) + expected = Escrow( + index="DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", + account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + amount="10000", + destination="ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + owner_node="0000000000000000", + previous_txn_id="C44F2EB84196B9AD820313DBEBA6316A15" + "C9A2D35787579ED172B87A30131DA7", + previous_txn_lgr_seq=28991004, + condition="A0258020A82A88B2DF843A54F58772E4A3861866EC" + "DB4157645DD9AE528C1D3AEEDABAB6810120", + cancel_after=545440232, + destination_node="0000000000000000", + destination_tag=23480, + finish_after=545354132, + source_tag=11747, + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_fee_settings.py b/tests/unit/models/ledger_objects/test_fee_settings.py new file mode 100644 index 000000000..90a8f6c21 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_fee_settings.py @@ -0,0 +1,26 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.fee_settings import FeeSettings +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestFeeSettings(TestCase): + def test_fee_settings(self): + fee_settings_json = { + "BaseFee": "000000000000000A", + "Flags": 0, + "LedgerEntryType": "FeeSettings", + "ReferenceFeeUnits": 10, + "ReserveBase": 20000000, + "ReserveIncrement": 5000000, + "index": "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", + } + actual = LedgerObject.from_xrpl(fee_settings_json) + expected = FeeSettings( + index="4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", + base_fee="000000000000000A", + reference_fee_units=10, + reserve_base=20000000, + reserve_increment=5000000, + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_ledger_hashes.py b/tests/unit/models/ledger_objects/test_ledger_hashes.py new file mode 100644 index 000000000..fb3e2fc1d --- /dev/null +++ b/tests/unit/models/ledger_objects/test_ledger_hashes.py @@ -0,0 +1,36 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.ledger_hashes import LedgerHashes +from xrpl.models.ledger_objects.ledger_object import LedgerObject + + +class TestLedgerHashes(TestCase): + def test_ledger_hashes(self): + ledger_hashes_json = { + "LedgerEntryType": "LedgerHashes", + "Flags": 0, + "FirstLedgerSequence": 2, + "LastLedgerSequence": 33872029, + "Hashes": [ + "D638208ADBD04CBB10DE7B645D3AB4BA31489379411A3A347151702B6401AA78", + "254D690864E418DDD9BCAC93F41B1F53B1AE693FC5FE667CE40205C322D1BE3B", + "A2B31D28905E2DEF926362822BC412B12ABF6942B73B72A32D46ED2ABB7ACCFA", + "AB4014846DF818A4B43D6B1686D0DE0644FE711577C5AB6F0B2A21CCEE280140", + "3383784E82A8BA45F4DD5EF4EE90A1B2D3B4571317DBAC37B859836ADDE644C1", + ], + "index": "B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B", + } + actual = LedgerObject.from_xrpl(ledger_hashes_json) + expected = LedgerHashes( + index="B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B", + first_ledger_sequence=2, + last_ledger_sequence=33872029, + hashes=[ + "D638208ADBD04CBB10DE7B645D3AB4BA31489379411A3A347151702B6401AA78", + "254D690864E418DDD9BCAC93F41B1F53B1AE693FC5FE667CE40205C322D1BE3B", + "A2B31D28905E2DEF926362822BC412B12ABF6942B73B72A32D46ED2ABB7ACCFA", + "AB4014846DF818A4B43D6B1686D0DE0644FE711577C5AB6F0B2A21CCEE280140", + "3383784E82A8BA45F4DD5EF4EE90A1B2D3B4571317DBAC37B859836ADDE644C1", + ], + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_negative_unl.py b/tests/unit/models/ledger_objects/test_negative_unl.py new file mode 100644 index 000000000..e2e36bc72 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_negative_unl.py @@ -0,0 +1,34 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.negative_unl import DisabledValidator, NegativeUNL + + +class TestNegativeUNL(TestCase): + def test_negative_unl(self): + negative_unl_json = { + "DisabledValidators": [ + { + "DisabledValidator": { + "FirstLedgerSequence": 1609728, + "PublicKey": "ED6629D456285AE3613B285F65BBFF168D695BA" + "3921F309949AFCD2CA7AFEC16FE", + } + } + ], + "Flags": 0, + "LedgerEntryType": "NegativeUNL", + "index": "2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", + } + actual = LedgerObject.from_xrpl(negative_unl_json) + expected = NegativeUNL( + index="2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", + disabled_validators=[ + DisabledValidator( + first_ledger_sequence=1609728, + public_key="ED6629D456285AE3613B285F65BBFF168D695BA" + "3921F309949AFCD2CA7AFEC16FE", + ) + ], + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_nftoken_offer.py b/tests/unit/models/ledger_objects/test_nftoken_offer.py new file mode 100644 index 000000000..4cac83ab8 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_nftoken_offer.py @@ -0,0 +1,38 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.nftoken_offer import NFTokenOffer + + +class TestNFTokenOffer(TestCase): + def test_nftoken_offer(self): + nftoken_offer_json = { + "LedgerEntryType": "NFTokenOffer", + "index": "AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", + "Amount": "1000000", + "Flags": 1, + "NFTokenID": "00081B5825A08C22787716FA031B432EBBC1B101BB54875F0002D2A40000" + "0000", + "Owner": "rhRxL3MNvuKEjWjL7TBbZSDacb8PmzAd7m", + "PreviousTxnID": "BFA9BE27383FA315651E26FDE1FA30815C5A5D0544EE10EC33D3E925" + "32993" + "769", + "PreviousTxnLgrSeq": 75443565, + "OwnerNode": "17", + "NFTokenOfferNode": "0", + } + actual = LedgerObject.from_xrpl(nftoken_offer_json) + expected = NFTokenOffer( + index="AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", + amount="1000000", + flags=1, + nftoken_id="00081B5825A08C22787716FA031B432EBBC1B101BB54875F0002D2A400000" + "000", + owner="rhRxL3MNvuKEjWjL7TBbZSDacb8PmzAd7m", + previous_txn_id="BFA9BE27383FA315651E26FDE1FA30815C5A5D0544EE10EC33D3E925" + "32993769", + previous_txn_lgr_seq=75443565, + owner_node="17", + nftoken_offer_node="0", + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_nftoken_page.py b/tests/unit/models/ledger_objects/test_nftoken_page.py new file mode 100644 index 000000000..cd709d566 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_nftoken_page.py @@ -0,0 +1,44 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.nftoken_offer import NFToken +from xrpl.models.ledger_objects.nftoken_page import NFTokenPage + + +class TestNFTokenPage(TestCase): + def test_nftoken_page(self): + nftoken_page_json = { + "Flags": 0, + "LedgerEntryType": "NFTokenPage", + "PreviousTxnID": "95C8761B22894E328646F7A70035E9DFBECC9" + "0EDD83E43B7B973F626D21A0822", + "PreviousTxnLgrSeq": 42891441, + "NFTokens": [ + { + "nftoken_id": "000B013A95F14B0044F78A264E41713" + "C64B5F89242540EE208C3098E00000D65", + "uri": "697066733A2F2F62616679626569676479727A74357366703775646D376" + "8753736" + "7568377932366E6634646675796C71616266336F636C67747179353566627A64" + "69", + }, + ], + "index": "", + } + actual = LedgerObject.from_xrpl(nftoken_page_json) + expected = NFTokenPage( + index="", + previous_txn_id="95C8761B22894E328646F7A70035E9DFBEC" + "C90EDD83E43B7B973F626D21A0822", + previous_txn_lgr_seq=42891441, + nftokens=[ + NFToken( + nftoken_id="000B013A95F14B0044F78A264E41713" + "C64B5F89242540EE208C3098E00000D65", + uri="697066733A2F2F62616679626569676479727A" + "74357366703775646D37687537367568377932366E" + "6634646675796C71616266336F636C67747179353566627A6469", + ) + ], + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_offer.py b/tests/unit/models/ledger_objects/test_offer.py new file mode 100644 index 000000000..e8b992980 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_offer.py @@ -0,0 +1,48 @@ +from unittest import TestCase + +from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.offer import Offer + + +class TestOffer(TestCase): + def test_offer(self): + offer_json = { + "Account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + "BookDirectory": "ACC27DE91DBA86FC509069EAF4BC511D7" + "3128B780F2E54BF5E07A369E2446000", + "BookNode": "0000000000000000", + "Flags": 131072, + "LedgerEntryType": "Offer", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "F0AB71E777B2DA54B86231E19B82554EF1" + "F8211F92ECA473121C655BFC5329BF", + "PreviousTxnLgrSeq": 14524914, + "Sequence": 866, + "TakerGets": { + "currency": "XAG", + "issuer": "r9Dr5xwkeLegBeXq6ujinjSBLQzQ1zQGjH", + "value": "37", + }, + "TakerPays": "79550000000", + "index": "96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", + } + actual = LedgerObject.from_xrpl(offer_json) + expected = Offer( + index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", + account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + taker_gets=IssuedCurrencyAmount( + currency="XAG", issuer="r9Dr5xwkeLegBeXq6ujinjSBLQzQ1zQGjH", value="37" + ), + taker_pays="79550000000", + sequence=866, + flags=131072, + book_directory="ACC27DE91DBA86FC509069EAF4BC511D7" + "3128B780F2E54BF5E07A369E2446000", + book_node="0000000000000000", + owner_node="0000000000000000", + previous_txn_id="F0AB71E777B2DA54B86231E19B82554EF1F821" + "1F92ECA473121C655BFC5329BF", + previous_txn_lgr_seq=14524914, + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_pay_channel.py b/tests/unit/models/ledger_objects/test_pay_channel.py new file mode 100644 index 000000000..c7b4ee8cc --- /dev/null +++ b/tests/unit/models/ledger_objects/test_pay_channel.py @@ -0,0 +1,51 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.pay_channel import PayChannel + + +class TestPayChannel(TestCase): + def test_pay_channel(self): + pay_channel_json = { + "Account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + "Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "Amount": "4325800", + "Balance": "2323423", + "PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612D" + "A0F0A", + "SettleDelay": 3600, + "Expiration": 536027313, + "CancelAfter": 536891313, + "SourceTag": 0, + "DestinationTag": 1002341, + "DestinationNode": "0000000000000000", + "Flags": 0, + "LedgerEntryType": "PayChannel", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "F0AB71E777B2DA54B86231E19B82554E" + "F1F8211F92ECA473121C655BFC5329BF", + "PreviousTxnLgrSeq": 14524914, + "index": "96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", + } + actual = LedgerObject.from_xrpl(pay_channel_json) + expected = PayChannel( + index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", + account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", + amount="4325800", + balance="2323423", + destination="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + flags=0, + owner_node="0000000000000000", + public_key="32D2471DB72B27E3310F355BB33E339BF26F83" + "92D5A93D3BC0FC3B566612DA0F0A", + previous_txn_id="F0AB71E777B2DA54B86231E19B82554EF1" + "F8211F92ECA473121C655BFC5329BF", + previous_txn_lgr_seq=14524914, + settle_delay=3600, + destination_node="0000000000000000", + destination_tag=1002341, + expiration=536027313, + cancel_after=536891313, + source_tag=0, + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_ripple_state.py b/tests/unit/models/ledger_objects/test_ripple_state.py new file mode 100644 index 000000000..bd17c8682 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_ripple_state.py @@ -0,0 +1,54 @@ +from unittest import TestCase + +from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ripple_state import RippleState + + +class TestRippleState(TestCase): + def test_ripple_state(self): + ripple_state_json = { + "Balance": { + "currency": "USD", + "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value": "-10", + }, + "Flags": 393216, + "HighLimit": { + "currency": "USD", + "issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "value": "110", + }, + "HighNode": "0000000000000000", + "LedgerEntryType": "RippleState", + "LowLimit": { + "currency": "USD", + "issuer": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", + "value": "0", + }, + "LowNode": "0000000000000000", + "PreviousTxnID": "E3FE6EA3D48F0C2B639448020EA4F03D" + "4F4F8FFDB243A852A0F59177921B4879", + "PreviousTxnLgrSeq": 14090896, + "index": "9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", + } + actual = LedgerObject.from_xrpl(ripple_state_json) + expected = RippleState( + index="9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", + balance=IssuedCurrencyAmount( + currency="USD", issuer="rrrrrrrrrrrrrrrrrrrrBZbvji", value="-10" + ), + flags=393216, + low_limit=IssuedCurrencyAmount( + currency="USD", issuer="rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", value="0" + ), + high_limit=IssuedCurrencyAmount( + currency="USD", issuer="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", value="110" + ), + previous_txn_id="E3FE6EA3D48F0C2B639448020EA4F03D4F4" + "F8FFDB243A852A0F59177921B4879", + previous_txn_lgr_seq=14090896, + high_node="0000000000000000", + low_node="0000000000000000", + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_signer_list.py b/tests/unit/models/ledger_objects/test_signer_list.py new file mode 100644 index 000000000..3b5153d97 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_signer_list.py @@ -0,0 +1,66 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.signer_list import SignerList +from xrpl.models.transactions.signer_list_set import SignerEntry + + +class TestSignerList(TestCase): + def test_signer_list(self): + signer_list_json = { + "Flags": 0, + "LedgerEntryType": "SignerList", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "5904C0DC72C58A83AEFED2FFC5386356" + "AA83FCA6A88C89D00646E51E687CDBE4", + "PreviousTxnLgrSeq": 16061435, + "SignerEntries": [ + { + "SignerEntry": { + "Account": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", + "SignerWeight": 2, + } + }, + { + "SignerEntry": { + "Account": "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n", + "SignerWeight": 1, + } + }, + { + "SignerEntry": { + "Account": "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v", + "SignerWeight": 1, + } + }, + ], + "SignerListID": 0, + "SignerQuorum": 3, + "index": "A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", + } + actual = LedgerObject.from_xrpl(signer_list_json) + expected = SignerList( + index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", + flags=0, + owner_node="0000000000000000", + previous_txn_id="5904C0DC72C58A83AEFED2FFC5386356" + "AA83FCA6A88C89D00646E51E687CDBE4", + previous_txn_lgr_seq=16061435, + signer_entries=[ + SignerEntry( + account="rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", + signer_weight=2, + ), + SignerEntry( + account="raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n", + signer_weight=1, + ), + SignerEntry( + account="rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v", + signer_weight=1, + ), + ], + signer_list_id=0, + signer_quorum=3, + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_ticket.py b/tests/unit/models/ledger_objects/test_ticket.py new file mode 100644 index 000000000..07ee31c63 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_ticket.py @@ -0,0 +1,31 @@ +from unittest import TestCase + +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.ticket import Ticket + + +class TestTicket(TestCase): + def test_ticket(self): + ticket_json = { + "Account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + "Flags": 0, + "LedgerEntryType": "Ticket", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "F19AD4577212D3BEACA0F75FE1BA1" + "644F2E854D46E8D62E9C95D18E9708CBFB1", + "PreviousTxnLgrSeq": 4, + "TicketSequence": 3, + "index": "A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", + } + actual = LedgerObject.from_xrpl(ticket_json) + expected = Ticket( + index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", + account="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", + flags=0, + owner_node="0000000000000000", + previous_txn_id="F19AD4577212D3BEACA0F75FE1BA1644F2E85" + "4D46E8D62E9C95D18E9708CBFB1", + previous_txn_lgr_seq=4, + ticket_sequence=3, + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_xchain_owned_claim_id.py b/tests/unit/models/ledger_objects/test_xchain_owned_claim_id.py new file mode 100644 index 000000000..d4bceca2b --- /dev/null +++ b/tests/unit/models/ledger_objects/test_xchain_owned_claim_id.py @@ -0,0 +1,104 @@ +from unittest import TestCase + +from xrpl.models.currencies.xrp import XRP +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.xchain_owned_claim_id import ( + XChainClaimProofSig, + XChainOwnedClaimID, +) +from xrpl.models.xchain_bridge import XChainBridge + + +class TestXChainOwnedClaimID(TestCase): + def test_xchain_owned_claim_id(self): + xchain_owned_claim_id_json = { + "Account": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "Flags": 0, + "OtherChainSource": "r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", + "OwnerNode": "0", + "PreviousTxnID": "1CFD80E9CF232B8EED62A52857DE97438D12230C0" + "6496932A81DEFA6E660" + "70A6", + "PreviousTxnLgrSeq": 58673, + "SignatureReward": "100", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": {"currency": "XRP"}, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": {"currency": "XRP"}, + }, + "XChainClaimAttestations": [ + { + "XChainClaimProofSig": { + "Amount": "1000000", + "AttestationRewardAccount": "rfgjrgEJGDxfUY2U8VEDs7BnB1jiH3of" + "u6", + "AttestationSignerAccount": "rfsxNxZ6xB1nTPhTMwQajNnkCxWG8B71" + "4n", + "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "PublicKey": "025CA526EF20567A50FEC504589F949E0E3401C13EF76DD" + "5FD1CC285" + "0FA485BD7B", + "WasLockingChainSend": 1, + } + }, + { + "XChainClaimProofSig": { + "Amount": "1000000", + "AttestationRewardAccount": "rUUL1tP523M8KimERqVS7sxb1tLLmpnd" + "yv", + "AttestationSignerAccount": "rEg5sHxZVTNwRL3BAdMwJatkmWDzHMmz" + "DF", + "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "PublicKey": "03D40434A6843638681E2F215310EBC4131AFB12EA85985" + "DA073183B" + "732525F7C9", + "WasLockingChainSend": 1, + }, + }, + ], + "XChainClaimID": "b5", + "LedgerEntryType": "XChainOwnedClaimID", + "LedgerIndex": "20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BAC" + "B1388F5", + } + actual = LedgerObject.from_xrpl(xchain_owned_claim_id_json) + expected = XChainOwnedClaimID( + account="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + other_chain_source="r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", + owner_node="0", + previous_txn_id="1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E6" + "6070A6", + previous_txn_lgr_seq=58673, + signature_reward="100", + xchain_bridge=XChainBridge( + issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + issuing_chain_issue=XRP(), + locking_chain_door="rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + locking_chain_issue=XRP(), + ), + xchain_claim_attestations=[ + XChainClaimProofSig( + amount="1000000", + attestation_reward_account="rfgjrgEJGDxfUY2U8VEDs7BnB1jiH3ofu6", + attestation_signer_account="rfsxNxZ6xB1nTPhTMwQajNnkCxWG8B714n", + destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + public_key="025CA526EF20567A50FEC504589F949E0E3401C13EF76DD5FD1CC2" + "850FA485BD7B", + was_locking_chain_send=1, + ), + XChainClaimProofSig( + amount="1000000", + attestation_reward_account="rUUL1tP523M8KimERqVS7sxb1tLLmpndyv", + attestation_signer_account="rEg5sHxZVTNwRL3BAdMwJatkmWDzHMmzDF", + destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + public_key="03D40434A6843638681E2F215310EBC4131AFB12EA85985DA07318" + "3B732525F7C9", + was_locking_chain_send=1, + ), + ], + xchain_claim_id="b5", + ledger_index="20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BACB13" + "88F5", + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/ledger_objects/test_xchain_owned_create_account_claim_id.py b/tests/unit/models/ledger_objects/test_xchain_owned_create_account_claim_id.py new file mode 100644 index 000000000..5aea225d4 --- /dev/null +++ b/tests/unit/models/ledger_objects/test_xchain_owned_create_account_claim_id.py @@ -0,0 +1,78 @@ +from unittest import TestCase + +from xrpl.models.currencies.xrp import XRP +from xrpl.models.ledger_objects.ledger_object import LedgerObject +from xrpl.models.ledger_objects.xchain_owned_create_account_claim_id import ( + XChainCreateAccountProofSig, + XChainOwnedCreateAccountClaimID, +) +from xrpl.models.xchain_bridge import XChainBridge + + +class TestXChainOwnedCreateAccountClaimID(TestCase): + def test_xchain_owned_create_account_claim_id(self): + xchain_owned_create_account_claim_id_json = { + "Flags": 0, + "LedgerEntryType": "XChainOwnedCreateAccountClaimID", + "LedgerIndex": "5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166B" + "B6F0C", + "OwnerNode": "0", + "PreviousTxnID": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6" + "E660", + "PreviousTxnLgrSeq": 58673, + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "XChainAccountCreateCount": "66", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": {"currency": "XRP"}, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": {"currency": "XRP"}, + }, + "XChainCreateAccountAttestations": [ + { + "XChainCreateAccountProofSig": { + "Amount": "20000000", + "AttestationRewardAccount": "rMtYb1vNdeMDpD9tA5qSFm8WXEBdEo" + "KKVw", + "AttestationSignerAccount": "rL8qTrAvZ8Q1o1H9H9Ahpj3xjgmRvF" + "LvJ3", + "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + "PublicKey": "021F7CC4033EFBE5E8214B04D1BAAEC14808DC6C02F4A" + "CE930A8" + "EF0F5909B0C438", + "SignatureReward": "100", + "WasLockingChainSend": 1, + } + } + ], + } + actual = LedgerObject.from_xrpl(xchain_owned_create_account_claim_id_json) + expected = XChainOwnedCreateAccountClaimID( + account="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + owner_node="0", + previous_txn_id="1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81D" + "EFA6E660", + previous_txn_lgr_seq=58673, + ledger_index="5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166B" + "B6F0C", + xchain_account_create_count="66", + xchain_bridge=XChainBridge( + issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + issuing_chain_issue=XRP(), + locking_chain_door="rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + locking_chain_issue=XRP(), + ), + xchain_create_account_attestations=[ + XChainCreateAccountProofSig( + amount="20000000", + attestation_reward_account="rMtYb1vNdeMDpD9tA5qSFm8WXEBdEoKKVw", + attestation_signer_account="rL8qTrAvZ8Q1o1H9H9Ahpj3xjgmRvFLvJ3", + destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", + public_key="021F7CC4033EFBE5E8214B04D1BAAEC14808DC6C02F4ACE930A8E" + "F0F5909B0C438", + signature_reward="100", + was_locking_chain_send=1, + ) + ], + ) + self.assertEqual(actual, expected) diff --git a/tests/unit/models/test_ledger_object.py b/tests/unit/models/test_ledger_object.py deleted file mode 100644 index 324e87936..000000000 --- a/tests/unit/models/test_ledger_object.py +++ /dev/null @@ -1,931 +0,0 @@ -from unittest import TestCase - -from xrpl.models import IssuedCurrencyAmount -from xrpl.models.auth_account import AuthAccount -from xrpl.models.currencies.issued_currency import IssuedCurrency -from xrpl.models.currencies.xrp import XRP -from xrpl.models.ledger_objects import ( - AMM, - DID, - AccountRoot, - Amendments, - Check, - DepositPreauth, - DirectoryNode, - DisabledValidator, - Escrow, - FeeSettings, - LedgerHashes, - Majority, - NegativeUNL, - NFToken, - NFTokenOffer, - NFTokenPage, - Offer, - PayChannel, - RippleState, - SignerEntry, - SignerList, - Ticket, -) -from xrpl.models.ledger_objects.amm import AuctionSlot, VoteEntry -from xrpl.models.ledger_objects.bridge import Bridge -from xrpl.models.ledger_objects.ledger_object import LedgerObject -from xrpl.models.ledger_objects.xchain_owned_claim_id import ( - XChainClaimProofSig, - XChainOwnedClaimID, -) -from xrpl.models.ledger_objects.xchain_owned_create_account_claim_id import ( - XChainCreateAccountProofSig, - XChainOwnedCreateAccountClaimID, -) -from xrpl.models.xchain_bridge import XChainBridge - -account_root_json = { - "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "AccountTxnID": "0D5FB50FA65C9FE1538FD7E398FFFE9D190" - "8DFA4576D8D7A020040686F93C77D", - "Balance": "148446663", - "Domain": "6D64756F31332E636F6D", - "EmailHash": "98B4375E1D753E5B91627516F6D70977", - "Flags": 8388608, - "LedgerEntryType": "AccountRoot", - "MessageKey": "0000000000000000000000070000000300", - "OwnerCount": 3, - "NFTokenMinter": "rHello", - "PreviousTxnID": "0D5FB50FA65C9FE1538FD7E398FFFE9D1908DFA4576D8D7A0200" - "40686F93C77D", - "PreviousTxnLgrSeq": 14091160, - "Sequence": 336, - "TransferRate": 1004999999, - "index": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", -} - -amendment_json = { - "Majorities": [ - { - "Majority": { - "Amendment": "1562511F573A19AE9BD103B5D6B9E01B3B46805AEC5D3C4805C902B51" - "4399146", - "CloseTime": 535589001, - } - } - ], - "Amendments": [ - "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE", - "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373", - "6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC", - "740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D628A06927F11", - ], - "Flags": 0, - "LedgerEntryType": "Amendments", - "index": "7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", -} - -amm_json = { - "Account": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", - "Asset": {"currency": "XRP"}, - "Asset2": {"currency": "TST", "issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"}, - "AuctionSlot": { - "Account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", - "AuthAccounts": [ - {"AuthAccount": {"Account": "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"}}, - {"AuthAccount": {"Account": "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"}}, - ], - "DiscountedFee": 0, - "Expiration": 721870180, - "Price": { - "currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2", - "issuer": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", - "value": "0.8696263565463045", - }, - }, - "LPTokenBalance": { - "currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2", - "issuer": "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", - "value": "71150.53584131501", - }, - "TradingFee": 600, - "VoteSlots": [ - { - "VoteEntry": { - "Account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", - "TradingFee": 600, - "VoteWeight": 100000, - } - } - ], - "OwnerNode": "0", - "Flags": 0, - "LedgerEntryType": "AMM", -} - -bridge_json = { - "Account": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", - "Flags": 0, - "LedgerEntryType": "Bridge", - "MinAccountCreateAmount": "2000000000", - "OwnerNode": "0", - "PreviousTxnID": "67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE917FD1A71919EAE7548E56" - "36", - "PreviousTxnLgrSeq": 102, - "SignatureReward": "204", - "XChainAccountClaimCount": "0", - "XChainAccountCreateCount": "0", - "XChainBridge": { - "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "IssuingChainIssue": {"currency": "XRP"}, - "LockingChainDoor": "r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", - "LockingChainIssue": {"currency": "XRP"}, - }, - "XChainClaimID": "1", - "index": "9F2C9E23343852036AFD323025A8506018ABF9D4DBAA746D61BF1CFB5C297D10", -} - -check_json = { - "Account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", - "Destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", - "DestinationNode": "0000000000000000", - "DestinationTag": 1, - "Expiration": 570113521, - "Flags": 0, - "InvoiceID": "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291", - "LedgerEntryType": "Check", - "OwnerNode": "0000000000000000", - "PreviousTxnID": "5463C6E08862A1FAE5EDAC12D70ADB16546A1F67" - "4930521295BC082494B62924", - "PreviousTxnLgrSeq": 6, - "SendMax": "100000000", - "Sequence": 2, - "index": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", -} - -deposit_preauth_json = { - "LedgerEntryType": "DepositPreauth", - "Account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", - "Authorize": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", - "Flags": 0, - "OwnerNode": "0000000000000000", - "PreviousTxnID": "3E8964D5A86B3CD6B9ECB33310D4E073D64C865A5B866200" - "AD2B7E29F8326702", - "PreviousTxnLgrSeq": 7, - "index": "4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", -} - -did_json = { - "Account": "rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", - "DIDDocument": "646F63", - "Data": "617474657374", - "Flags": 0, - "LedgerEntryType": "DID", - "OwnerNode": "0", - "PreviousTxnID": "A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B0" - "9F708778E41120", - "PreviousTxnLgrSeq": 4, - "URI": "6469645F6578616D706C65", - "index": "46813BE38B798B3752CA590D44E7FEADB17485649074403AD1761A2835CE91FF", -} - -directory_node_json = { - "ExchangeRate": "4F069BA8FF484000", - "Flags": 0, - "Indexes": ["AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD"], - "LedgerEntryType": "DirectoryNode", - "RootIndex": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", - "TakerGetsCurrency": "0000000000000000000000000000000000000000", - "TakerGetsIssuer": "0000000000000000000000000000000000000000", - "TakerPaysCurrency": "0000000000000000000000004A50590000000000", - "TakerPaysIssuer": "5BBC0F22F61D9224A110650CFE21CC0C4BE13098", - "index": "1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", -} - -escrow_json = { - "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "Amount": "10000", - "CancelAfter": 545440232, - "Condition": "A0258020A82A88B2DF843A54F58772E4A3861866ECDB4157645DD9AE528C1D3AEEDAB" - "AB6810120", - "Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - "DestinationTag": 23480, - "FinishAfter": 545354132, - "Flags": 0, - "LedgerEntryType": "Escrow", - "OwnerNode": "0000000000000000", - "DestinationNode": "0000000000000000", - "PreviousTxnID": "C44F2EB84196B9AD820313DBEBA6316A15C9A2" - "D35787579ED172B87A30131DA7", - "PreviousTxnLgrSeq": 28991004, - "SourceTag": 11747, - "index": "DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", -} - -fee_settings_json = { - "BaseFee": "000000000000000A", - "Flags": 0, - "LedgerEntryType": "FeeSettings", - "ReferenceFeeUnits": 10, - "ReserveBase": 20000000, - "ReserveIncrement": 5000000, - "index": "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", -} - -ledger_hashes_json = { - "LedgerEntryType": "LedgerHashes", - "Flags": 0, - "FirstLedgerSequence": 2, - "LastLedgerSequence": 33872029, - "Hashes": [ - "D638208ADBD04CBB10DE7B645D3AB4BA31489379411A3A347151702B6401AA78", - "254D690864E418DDD9BCAC93F41B1F53B1AE693FC5FE667CE40205C322D1BE3B", - "A2B31D28905E2DEF926362822BC412B12ABF6942B73B72A32D46ED2ABB7ACCFA", - "AB4014846DF818A4B43D6B1686D0DE0644FE711577C5AB6F0B2A21CCEE280140", - "3383784E82A8BA45F4DD5EF4EE90A1B2D3B4571317DBAC37B859836ADDE644C1", - ], - "index": "B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B", -} - -negative_unl_json = { - "DisabledValidators": [ - { - "DisabledValidator": { - "FirstLedgerSequence": 1609728, - "PublicKey": "ED6629D456285AE3613B285F65BBFF168D695BA" - "3921F309949AFCD2CA7AFEC16FE", - } - } - ], - "Flags": 0, - "LedgerEntryType": "NegativeUNL", - "index": "2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", -} - -nftoken_offer_json = { - "LedgerEntryType": "NFTokenOffer", - "index": "AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", - "Amount": "1000000", - "Flags": 1, - "NFTokenID": "00081B5825A08C22787716FA031B432EBBC1B101BB54875F0002D2A400000000", - "Owner": "rhRxL3MNvuKEjWjL7TBbZSDacb8PmzAd7m", - "PreviousTxnID": "BFA9BE27383FA315651E26FDE1FA30815C5A5D0544EE10EC33D3E92532993" - "769", - "PreviousTxnLgrSeq": 75443565, - "OwnerNode": "17", - "NFTokenOfferNode": "0", -} - -nftoken_page_json = { - "Flags": 0, - "LedgerEntryType": "NFTokenPage", - "PreviousTxnID": "95C8761B22894E328646F7A70035E9DFBECC9" - "0EDD83E43B7B973F626D21A0822", - "PreviousTxnLgrSeq": 42891441, - "NFTokens": [ - { - "nftoken_id": "000B013A95F14B0044F78A264E41713" - "C64B5F89242540EE208C3098E00000D65", - "uri": "697066733A2F2F62616679626569676479727A74357366703775646D3768753736" - "7568377932366E6634646675796C71616266336F636C67747179353566627A6469", - }, - ], - "index": "", -} - -offer_json = { - "Account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", - "BookDirectory": "ACC27DE91DBA86FC509069EAF4BC511D7" - "3128B780F2E54BF5E07A369E2446000", - "BookNode": "0000000000000000", - "Flags": 131072, - "LedgerEntryType": "Offer", - "OwnerNode": "0000000000000000", - "PreviousTxnID": "F0AB71E777B2DA54B86231E19B82554EF1" - "F8211F92ECA473121C655BFC5329BF", - "PreviousTxnLgrSeq": 14524914, - "Sequence": 866, - "TakerGets": { - "currency": "XAG", - "issuer": "r9Dr5xwkeLegBeXq6ujinjSBLQzQ1zQGjH", - "value": "37", - }, - "TakerPays": "79550000000", - "index": "96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", -} - -pay_channel_json = { - "Account": "rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", - "Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "Amount": "4325800", - "Balance": "2323423", - "PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A", - "SettleDelay": 3600, - "Expiration": 536027313, - "CancelAfter": 536891313, - "SourceTag": 0, - "DestinationTag": 1002341, - "DestinationNode": "0000000000000000", - "Flags": 0, - "LedgerEntryType": "PayChannel", - "OwnerNode": "0000000000000000", - "PreviousTxnID": "F0AB71E777B2DA54B86231E19B82554E" - "F1F8211F92ECA473121C655BFC5329BF", - "PreviousTxnLgrSeq": 14524914, - "index": "96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", -} - -ripple_state_json = { - "Balance": { - "currency": "USD", - "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", - "value": "-10", - }, - "Flags": 393216, - "HighLimit": { - "currency": "USD", - "issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "value": "110", - }, - "HighNode": "0000000000000000", - "LedgerEntryType": "RippleState", - "LowLimit": { - "currency": "USD", - "issuer": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", - "value": "0", - }, - "LowNode": "0000000000000000", - "PreviousTxnID": "E3FE6EA3D48F0C2B639448020EA4F03D" - "4F4F8FFDB243A852A0F59177921B4879", - "PreviousTxnLgrSeq": 14090896, - "index": "9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", -} - -signer_list_json = { - "Flags": 0, - "LedgerEntryType": "SignerList", - "OwnerNode": "0000000000000000", - "PreviousTxnID": "5904C0DC72C58A83AEFED2FFC5386356" - "AA83FCA6A88C89D00646E51E687CDBE4", - "PreviousTxnLgrSeq": 16061435, - "SignerEntries": [ - { - "SignerEntry": { - "Account": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", - "SignerWeight": 2, - } - }, - { - "SignerEntry": { - "Account": "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n", - "SignerWeight": 1, - } - }, - { - "SignerEntry": { - "Account": "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v", - "SignerWeight": 1, - } - }, - ], - "SignerListID": 0, - "SignerQuorum": 3, - "index": "A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", -} - -ticket_json = { - "Account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", - "Flags": 0, - "LedgerEntryType": "Ticket", - "OwnerNode": "0000000000000000", - "PreviousTxnID": "F19AD4577212D3BEACA0F75FE1BA1" - "644F2E854D46E8D62E9C95D18E9708CBFB1", - "PreviousTxnLgrSeq": 4, - "TicketSequence": 3, - "index": "A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", -} - -xchain_owned_claim_id_json = { - "Account": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - "Flags": 0, - "OtherChainSource": "r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", - "OwnerNode": "0", - "PreviousTxnID": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E660" - "70A6", - "PreviousTxnLgrSeq": 58673, - "SignatureReward": "100", - "XChainBridge": { - "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "IssuingChainIssue": {"currency": "XRP"}, - "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", - "LockingChainIssue": {"currency": "XRP"}, - }, - "XChainClaimAttestations": [ - { - "XChainClaimProofSig": { - "Amount": "1000000", - "AttestationRewardAccount": "rfgjrgEJGDxfUY2U8VEDs7BnB1jiH3ofu6", - "AttestationSignerAccount": "rfsxNxZ6xB1nTPhTMwQajNnkCxWG8B714n", - "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - "PublicKey": "025CA526EF20567A50FEC504589F949E0E3401C13EF76DD5FD1CC285" - "0FA485BD7B", - "WasLockingChainSend": 1, - } - }, - { - "XChainClaimProofSig": { - "Amount": "1000000", - "AttestationRewardAccount": "rUUL1tP523M8KimERqVS7sxb1tLLmpndyv", - "AttestationSignerAccount": "rEg5sHxZVTNwRL3BAdMwJatkmWDzHMmzDF", - "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - "PublicKey": "03D40434A6843638681E2F215310EBC4131AFB12EA85985DA073183B" - "732525F7C9", - "WasLockingChainSend": 1, - }, - }, - ], - "XChainClaimID": "b5", - "LedgerEntryType": "XChainOwnedClaimID", - "LedgerIndex": "20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BACB1388F5", -} - -xchain_owned_create_account_claim_id_json = { - "Flags": 0, - "LedgerEntryType": "XChainOwnedCreateAccountClaimID", - "LedgerIndex": "5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166BB6F0C", - "OwnerNode": "0", - "PreviousTxnID": "1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E660", - "PreviousTxnLgrSeq": 58673, - "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "XChainAccountCreateCount": "66", - "XChainBridge": { - "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "IssuingChainIssue": {"currency": "XRP"}, - "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", - "LockingChainIssue": {"currency": "XRP"}, - }, - "XChainCreateAccountAttestations": [ - { - "XChainCreateAccountProofSig": { - "Amount": "20000000", - "AttestationRewardAccount": "rMtYb1vNdeMDpD9tA5qSFm8WXEBdEoKKVw", - "AttestationSignerAccount": "rL8qTrAvZ8Q1o1H9H9Ahpj3xjgmRvFLvJ3", - "Destination": "rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - "PublicKey": "021F7CC4033EFBE5E8214B04D1BAAEC14808DC6C02F4ACE930A8" - "EF0F5909B0C438", - "SignatureReward": "100", - "WasLockingChainSend": 1, - } - } - ], -} - - -class TestFromTODict(TestCase): - def test_account_root(self): - actual = LedgerObject.from_xrpl(account_root_json) - expected = AccountRoot( - index="13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8", - account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - balance="148446663", - flags=8388608, - owner_count=3, - previous_txn_id="0D5FB50FA65C9FE1538FD7E398FFFE9D" - "1908DFA4576D8D7A020040686F93C77D", - previous_txn_lgr_seq=14091160, - sequence=336, - account_txn_id="0D5FB50FA65C9FE1538FD7E398FFFE9D1" - "908DFA4576D8D7A020040686F93C77D", - domain="6D64756F31332E636F6D", - email_hash="98B4375E1D753E5B91627516F6D70977", - message_key="0000000000000000000000070000000300", - nftoken_minter="rHello", - transfer_rate=1004999999, - ) - self.assertEqual(actual, expected) - - def test_amendments(self): - actual = LedgerObject.from_xrpl(amendment_json) - expected = Amendments( - index="7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4", - amendments=[ - "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE", - "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373", - "6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC", - "740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D628A06927F11", - ], - majorities=[ - Majority( - amendment="1562511F573A19AE9BD103B5D6B9E01B3B46805AEC5D3C" - "4805C902B514399146", - close_time=535589001, - ) - ], - ) - self.assertEqual(actual, expected) - - def test_amm(self): - actual = LedgerObject.from_xrpl(amm_json) - expected = AMM( - account="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", - asset=XRP(), - asset2=IssuedCurrency( - currency="TST", - issuer="rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd", - ), - auction_slot=AuctionSlot( - account="rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", - auth_accounts=[ - AuthAccount(account="rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"), - AuthAccount(account="rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"), - ], - discounted_fee=0, - expiration=721870180, - price=IssuedCurrencyAmount( - currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", - issuer="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", - value="0.8696263565463045", - ), - ), - owner_node="0", - lp_token_balance=IssuedCurrencyAmount( - currency="039C99CD9AB0B70B32ECDA51EAAE471625608EA2", - issuer="rE54zDvgnghAoPopCgvtiqWNq3dU5y836S", - value="71150.53584131501", - ), - trading_fee=600, - vote_slots=[ - VoteEntry( - account="rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", - trading_fee=600, - vote_weight=100000, - ), - ], - ) - self.assertEqual(actual, expected) - - def test_bridge(self): - actual = LedgerObject.from_xrpl(bridge_json) - expected = Bridge( - account="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", - min_account_create_amount="2000000000", - owner_node="0", - previous_txn_id="67A8A1B36C1B97BE3AAB6B19CB3A3069034877DE917FD1A71919EAE75" - "48E5636", - previous_txn_lgr_seq=102, - signature_reward="204", - xchain_account_claim_count="0", - xchain_account_create_count="0", - xchain_bridge=XChainBridge( - issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - issuing_chain_issue=XRP(), - locking_chain_door="r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC", - locking_chain_issue=XRP(), - ), - xchain_claim_id="1", - index="9F2C9E23343852036AFD323025A8506018ABF9D4DBAA746D61BF1CFB5C297D10", - ) - self.assertEqual(actual, expected) - - def test_check(self): - actual = LedgerObject.from_xrpl(check_json) - expected = Check( - index="49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", - account="rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", - destination="rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", - owner_node="0000000000000000", - previous_txn_id="5463C6E08862A1FAE5EDAC12D70ADB16546A" - "1F674930521295BC082494B62924", - previous_txn_lgr_seq=6, - send_max="100000000", - sequence=2, - destination_node="0000000000000000", - destination_tag=1, - expiration=570113521, - invoice_id="46060241FABCF692D4D934BA2A6C4427CD427" - "9083E38C77CBE642243E43BE291", - ) - self.assertEqual(actual, expected) - - def test_deposit_preauth(self): - actual = LedgerObject.from_xrpl(deposit_preauth_json) - expected = DepositPreauth( - index="4A255038CC3ADCC1A9C91509279B59908251728D0DAADB248FFE297D0F7E068C", - account="rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8", - authorize="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", - owner_node="0000000000000000", - previous_txn_id="3E8964D5A86B3CD6B9ECB33310D4E073D64C8" - "65A5B866200AD2B7E29F8326702", - previous_txn_lgr_seq=7, - ) - self.assertEqual(actual, expected) - - def test_did(self): - actual = LedgerObject.from_xrpl(did_json) - expected = DID( - account="rpfqJrXg5uidNo2ZsRhRY6TiF1cvYmV9Fg", - did_document="646F63", - data="617474657374", - owner_node="0", - previous_txn_id="A4C15DA185E6092DF5954FF62A1446220C61A5F60F0D93B4B09F" - "708778E41120", - previous_txn_lgr_seq=4, - uri="6469645F6578616D706C65", - index="46813BE38B798B3752CA590D44E7FEADB17485649074403AD1761A2835CE91FF", - ) - self.assertEqual(actual, expected) - - def test_directory_node(self): - actual = LedgerObject.from_xrpl(directory_node_json) - expected = DirectoryNode( - index="1BBEF97EDE88D40CEE2ADE6FEF121166AFE80D99EBADB01A4F069BA8FF484000", - root_index="1BBEF97EDE88D40CEE2ADE6FEF121166A" - "FE80D99EBADB01A4F069BA8FF484000", - indexes=[ - "AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD" - ], - exchange_rate="4F069BA8FF484000", - taker_pays_currency="0000000000000000000000004A50590000000000", - taker_pays_issuer="5BBC0F22F61D9224A110650CFE21CC0C4BE13098", - taker_gets_currency="0000000000000000000000000000000000000000", - taker_gets_issuer="0000000000000000000000000000000000000000", - ) - self.assertEqual(actual, expected) - - def test_escrow(self): - actual = LedgerObject.from_xrpl(escrow_json) - expected = Escrow( - index="DC5F3851D8A1AB622F957761E5963BC5BD439D5C24AC6AD7AC4523F0640244AC", - account="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - amount="10000", - destination="ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - owner_node="0000000000000000", - previous_txn_id="C44F2EB84196B9AD820313DBEBA6316A15" - "C9A2D35787579ED172B87A30131DA7", - previous_txn_lgr_seq=28991004, - condition="A0258020A82A88B2DF843A54F58772E4A3861866EC" - "DB4157645DD9AE528C1D3AEEDABAB6810120", - cancel_after=545440232, - destination_node="0000000000000000", - destination_tag=23480, - finish_after=545354132, - source_tag=11747, - ) - self.assertEqual(actual, expected) - - def test_fee_settings(self): - actual = LedgerObject.from_xrpl(fee_settings_json) - expected = FeeSettings( - index="4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", - base_fee="000000000000000A", - reference_fee_units=10, - reserve_base=20000000, - reserve_increment=5000000, - ) - self.assertEqual(actual, expected) - - def test_ledger_hashes(self): - actual = LedgerObject.from_xrpl(ledger_hashes_json) - expected = LedgerHashes( - index="B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B", - first_ledger_sequence=2, - last_ledger_sequence=33872029, - hashes=[ - "D638208ADBD04CBB10DE7B645D3AB4BA31489379411A3A347151702B6401AA78", - "254D690864E418DDD9BCAC93F41B1F53B1AE693FC5FE667CE40205C322D1BE3B", - "A2B31D28905E2DEF926362822BC412B12ABF6942B73B72A32D46ED2ABB7ACCFA", - "AB4014846DF818A4B43D6B1686D0DE0644FE711577C5AB6F0B2A21CCEE280140", - "3383784E82A8BA45F4DD5EF4EE90A1B2D3B4571317DBAC37B859836ADDE644C1", - ], - ) - self.assertEqual(actual, expected) - - def test_negative_unl(self): - actual = LedgerObject.from_xrpl(negative_unl_json) - expected = NegativeUNL( - index="2E8A59AA9D3B5B186B0B9E0F62E6C02587CA74A4D778938E957B6357D364B244", - disabled_validators=[ - DisabledValidator( - first_ledger_sequence=1609728, - public_key="ED6629D456285AE3613B285F65BBFF168D695BA" - "3921F309949AFCD2CA7AFEC16FE", - ) - ], - ) - self.assertEqual(actual, expected) - - def test_nftoken_offer(self): - actual = LedgerObject.from_xrpl(nftoken_offer_json) - expected = NFTokenOffer( - index="AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3", - amount="1000000", - flags=1, - nftoken_id="00081B5825A08C22787716FA031B432EBBC1B101BB54875F0002D2A400000" - "000", - owner="rhRxL3MNvuKEjWjL7TBbZSDacb8PmzAd7m", - previous_txn_id="BFA9BE27383FA315651E26FDE1FA30815C5A5D0544EE10EC33D3E925" - "32993769", - previous_txn_lgr_seq=75443565, - owner_node="17", - nftoken_offer_node="0", - ) - self.assertEqual(actual, expected) - - def test_nftoken_page(self): - actual = LedgerObject.from_xrpl(nftoken_page_json) - expected = NFTokenPage( - index="", - previous_txn_id="95C8761B22894E328646F7A70035E9DFBEC" - "C90EDD83E43B7B973F626D21A0822", - previous_txn_lgr_seq=42891441, - nftokens=[ - NFToken( - nftoken_id="000B013A95F14B0044F78A264E41713" - "C64B5F89242540EE208C3098E00000D65", - uri="697066733A2F2F62616679626569676479727A" - "74357366703775646D37687537367568377932366E" - "6634646675796C71616266336F636C67747179353566627A6469", - ) - ], - ) - self.assertEqual(actual, expected) - - def test_offer(self): - actual = LedgerObject.from_xrpl(offer_json) - expected = Offer( - index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", - account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", - taker_gets=IssuedCurrencyAmount( - currency="XAG", issuer="r9Dr5xwkeLegBeXq6ujinjSBLQzQ1zQGjH", value="37" - ), - taker_pays="79550000000", - sequence=866, - flags=131072, - book_directory="ACC27DE91DBA86FC509069EAF4BC511D7" - "3128B780F2E54BF5E07A369E2446000", - book_node="0000000000000000", - owner_node="0000000000000000", - previous_txn_id="F0AB71E777B2DA54B86231E19B82554EF1F821" - "1F92ECA473121C655BFC5329BF", - previous_txn_lgr_seq=14524914, - ) - self.assertEqual(actual, expected) - - def test_pay_channel(self): - actual = LedgerObject.from_xrpl(pay_channel_json) - expected = PayChannel( - index="96F76F27D8A327FC48753167EC04A46AA0E382E6F57F32FD12274144D00F1797", - account="rBqb89MRQJnMPq8wTwEbtz4kvxrEDfcYvt", - amount="4325800", - balance="2323423", - destination="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - flags=0, - owner_node="0000000000000000", - public_key="32D2471DB72B27E3310F355BB33E339BF26F83" - "92D5A93D3BC0FC3B566612DA0F0A", - previous_txn_id="F0AB71E777B2DA54B86231E19B82554EF1" - "F8211F92ECA473121C655BFC5329BF", - previous_txn_lgr_seq=14524914, - settle_delay=3600, - destination_node="0000000000000000", - destination_tag=1002341, - expiration=536027313, - cancel_after=536891313, - source_tag=0, - ) - self.assertEqual(actual, expected) - - def test_ripple_state(self): - actual = LedgerObject.from_xrpl(ripple_state_json) - expected = RippleState( - index="9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B", - balance=IssuedCurrencyAmount( - currency="USD", issuer="rrrrrrrrrrrrrrrrrrrrBZbvji", value="-10" - ), - flags=393216, - low_limit=IssuedCurrencyAmount( - currency="USD", issuer="rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", value="0" - ), - high_limit=IssuedCurrencyAmount( - currency="USD", issuer="rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", value="110" - ), - previous_txn_id="E3FE6EA3D48F0C2B639448020EA4F03D4F4" - "F8FFDB243A852A0F59177921B4879", - previous_txn_lgr_seq=14090896, - high_node="0000000000000000", - low_node="0000000000000000", - ) - self.assertEqual(actual, expected) - - def test_signer_list(self): - actual = LedgerObject.from_xrpl(signer_list_json) - expected = SignerList( - index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", - flags=0, - owner_node="0000000000000000", - previous_txn_id="5904C0DC72C58A83AEFED2FFC5386356" - "AA83FCA6A88C89D00646E51E687CDBE4", - previous_txn_lgr_seq=16061435, - signer_entries=[ - SignerEntry( - account="rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", - signer_weight=2, - ), - SignerEntry( - account="raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n", - signer_weight=1, - ), - SignerEntry( - account="rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v", - signer_weight=1, - ), - ], - signer_list_id=0, - signer_quorum=3, - ) - self.assertEqual(actual, expected) - - def test_ticket(self): - actual = LedgerObject.from_xrpl(ticket_json) - expected = Ticket( - index="A9C28A28B85CD533217F5C0A0C7767666B093FA58A0F2D80026FCC4CD932DDC7", - account="rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de", - flags=0, - owner_node="0000000000000000", - previous_txn_id="F19AD4577212D3BEACA0F75FE1BA1644F2E85" - "4D46E8D62E9C95D18E9708CBFB1", - previous_txn_lgr_seq=4, - ticket_sequence=3, - ) - self.assertEqual(actual, expected) - - def test_xchain_owned_claim_id(self): - actual = LedgerObject.from_xrpl(xchain_owned_claim_id_json) - expected = XChainOwnedClaimID( - account="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - other_chain_source="r9oXrvBX5aDoyMGkoYvzazxDhYoWFUjz8p", - owner_node="0", - previous_txn_id="1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81DEFA6E6" - "6070A6", - previous_txn_lgr_seq=58673, - signature_reward="100", - xchain_bridge=XChainBridge( - issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - issuing_chain_issue=XRP(), - locking_chain_door="rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", - locking_chain_issue=XRP(), - ), - xchain_claim_attestations=[ - XChainClaimProofSig( - amount="1000000", - attestation_reward_account="rfgjrgEJGDxfUY2U8VEDs7BnB1jiH3ofu6", - attestation_signer_account="rfsxNxZ6xB1nTPhTMwQajNnkCxWG8B714n", - destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - public_key="025CA526EF20567A50FEC504589F949E0E3401C13EF76DD5FD1CC2" - "850FA485BD7B", - was_locking_chain_send=1, - ), - XChainClaimProofSig( - amount="1000000", - attestation_reward_account="rUUL1tP523M8KimERqVS7sxb1tLLmpndyv", - attestation_signer_account="rEg5sHxZVTNwRL3BAdMwJatkmWDzHMmzDF", - destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - public_key="03D40434A6843638681E2F215310EBC4131AFB12EA85985DA07318" - "3B732525F7C9", - was_locking_chain_send=1, - ), - ], - xchain_claim_id="b5", - ledger_index="20B136D7BF6D2E3D610E28E3E6BE09F5C8F4F0241BBF6E2D072AE1BACB13" - "88F5", - ) - self.assertEqual(actual, expected) - - def test_xchain_owned_create_account_claim_id(self): - actual = LedgerObject.from_xrpl(xchain_owned_create_account_claim_id_json) - expected = XChainOwnedCreateAccountClaimID( - account="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - owner_node="0", - previous_txn_id="1CFD80E9CF232B8EED62A52857DE97438D12230C06496932A81D" - "EFA6E660", - previous_txn_lgr_seq=58673, - ledger_index="5A92F6ED33FDA68FB4B9FD140EA38C056CD2BA9673ECA5B4CEF40F2166B" - "B6F0C", - xchain_account_create_count="66", - xchain_bridge=XChainBridge( - issuing_chain_door="rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - issuing_chain_issue=XRP(), - locking_chain_door="rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", - locking_chain_issue=XRP(), - ), - xchain_create_account_attestations=[ - XChainCreateAccountProofSig( - amount="20000000", - attestation_reward_account="rMtYb1vNdeMDpD9tA5qSFm8WXEBdEoKKVw", - attestation_signer_account="rL8qTrAvZ8Q1o1H9H9Ahpj3xjgmRvFLvJ3", - destination="rBW1U7J9mEhEdk6dMHEFUjqQ7HW7WpaEMi", - public_key="021F7CC4033EFBE5E8214B04D1BAAEC14808DC6C02F4ACE930A8E" - "F0F5909B0C438", - signature_reward="100", - was_locking_chain_send=1, - ) - ], - ) - self.assertEqual(actual, expected) From 93e8222f55ee97fe6ab72eb88d0516f4d10a956c Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Fri, 16 Feb 2024 16:41:07 -0500 Subject: [PATCH 53/58] fix docstring --- xrpl/models/ledger_objects/ledger_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index caddabb4f..63f9ed131 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -104,7 +104,7 @@ def get_ledger_object_type( ledger_object_type: The ledger object type willing to get. Returns: - Type[AffectedNode]: The correct ledger object type. + Type[LedgerObject]: The correct ledger object type. Raises: XRPLModelException: If the Ledger Object type does not exist. From 2fac6757ddd449eacc766840c4be624642806488 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Wed, 21 Feb 2024 14:46:23 -0500 Subject: [PATCH 54/58] fix NFTokenOffer.amount type --- xrpl/models/ledger_objects/nftoken_offer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xrpl/models/ledger_objects/nftoken_offer.py b/xrpl/models/ledger_objects/nftoken_offer.py index dc177227b..c66a3a43d 100644 --- a/xrpl/models/ledger_objects/nftoken_offer.py +++ b/xrpl/models/ledger_objects/nftoken_offer.py @@ -4,7 +4,7 @@ from dataclasses import dataclass, field from enum import Enum -from typing import Optional, Union +from typing import Optional from xrpl.models.base_model import BaseModel from xrpl.models.ledger_objects.ledger_entry_type import LedgerEntryType @@ -18,7 +18,7 @@ class NFTokenOffer(LedgerObject, HasPreviousTxnID): """The model for the `NFTokenOffer` Ledger Object""" - amount: Union[str, NFToken] = REQUIRED # type: ignore + amount: str = REQUIRED # type: ignore """ Amount expected or offered for the NFToken. If the token has the `lsfOnlyXRP` flag set, the amount must be specified in XRP. Sell offers that specify assets other From 207a3430fd08a3496534c1a2356fab70ee83afc7 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Wed, 21 Feb 2024 15:04:52 -0500 Subject: [PATCH 55/58] update docstrings --- xrpl/models/ledger_objects/ledger_object.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index 63f9ed131..676b3526f 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -98,7 +98,8 @@ def from_dict(cls: Type[L], value: Dict[str, Any]) -> L: def get_ledger_object_type( cls: Type[LedgerObject], ledger_object_type: str ) -> Type[LedgerObject]: - """Get the correct model + """ + Gets the correct ledger object type. Args: ledger_object_type: The ledger object type willing to get. @@ -127,7 +128,8 @@ def get_md_ledger_object_type( cls: Type[LedgerObject], ledger_object_type: str ) -> Type[LedgerObject]: """ - Get the correct model + Gets the ledger object type within fields prefixed with "MD and suffixed with + "Fields". Args: ledger_object_type: The object type willing to get. From ada14f682ed63ecfdf98d616eeab23ff99f0e22f Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Wed, 21 Feb 2024 15:32:54 -0500 Subject: [PATCH 56/58] add lsfAMMNode to RippleState --- xrpl/models/ledger_objects/ripple_state.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xrpl/models/ledger_objects/ripple_state.py b/xrpl/models/ledger_objects/ripple_state.py index 60b893b32..059013ae2 100644 --- a/xrpl/models/ledger_objects/ripple_state.py +++ b/xrpl/models/ledger_objects/ripple_state.py @@ -97,3 +97,4 @@ class RippleStateFlag(Enum): LSF_HIGH_NO_RIPPLE = 0x00200000 LSF_LOW_FREEZE = 0x00400000 LSF_HIGH_FREEZE = 0x00800000 + LSF_AMM_NODE = 0x01000000 From ac8e7379e6492755a052fafc8fa2efd4ddbfaafc Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 22 Feb 2024 20:15:02 -0500 Subject: [PATCH 57/58] add missing del --- xrpl/models/ledger_objects/ledger_object.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index 676b3526f..c99c8e07f 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -48,6 +48,18 @@ class LedgerObject(BaseModel): Set of bit-flags for this ledger entry. """ + def to_dict(self: LedgerObject) -> Dict[str, Any]: + """ + Returns the dictionary representation of a LedgerObject. + + Returns: + The dictionary representation of a LedgerObject. + """ + return { + **super().to_dict(), + "flags": self._flags_to_int(), + } + @classmethod def from_dict(cls: Type[L], value: Dict[str, Any]) -> L: """Derive the model from a dict. @@ -68,6 +80,7 @@ def from_dict(cls: Type[L], value: Dict[str, Any]) -> L: "Ledger Object does not include ledger_entry_type." ) correct_type = cls.get_ledger_object_type(value["ledger_entry_type"]) + del value["ledger_entry_type"] return correct_type.from_dict(value) # type: ignore elif cls.__name__ in ["FinalFields", "PreviousFields", "NewFields"]: if "ledger_entry_type" not in value: From ca02097d7b3f89c216ab775af473dfbba0de04c3 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 22 Feb 2024 20:21:23 -0500 Subject: [PATCH 58/58] remove accidental change --- xrpl/models/ledger_objects/ledger_object.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/xrpl/models/ledger_objects/ledger_object.py b/xrpl/models/ledger_objects/ledger_object.py index c99c8e07f..a512af701 100644 --- a/xrpl/models/ledger_objects/ledger_object.py +++ b/xrpl/models/ledger_objects/ledger_object.py @@ -48,18 +48,6 @@ class LedgerObject(BaseModel): Set of bit-flags for this ledger entry. """ - def to_dict(self: LedgerObject) -> Dict[str, Any]: - """ - Returns the dictionary representation of a LedgerObject. - - Returns: - The dictionary representation of a LedgerObject. - """ - return { - **super().to_dict(), - "flags": self._flags_to_int(), - } - @classmethod def from_dict(cls: Type[L], value: Dict[str, Any]) -> L: """Derive the model from a dict.